1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.index.context; 20 21 import java.io.IOException; 22 import java.util.Collection; 23 import java.util.List; 24 25 import org.apache.lucene.document.Document; 26 import org.apache.maven.index.ArtifactContext; 27 import org.apache.maven.index.ArtifactInfo; 28 import org.apache.maven.index.IndexerField; 29 30 /** 31 * An index creator is responsible for storing and reading data to and from Lucene index. 32 * 33 * @author Jason van Zyl 34 * @see org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator 35 * @see org.apache.maven.index.creator.JarFileContentsIndexCreator 36 */ 37 public interface IndexCreator { 38 /** 39 * Returns IndexCreator ID, that has to be unique across all existing creators. 40 * 41 * @return 42 */ 43 String getId(); 44 45 /** 46 * Returns list of IndexCreator IDs that this creator depends on. Needed to perform a topological sort on 47 * IndexCreators to guarantee proper ordering of them, as some IndexCreators might rely on informations already 48 * extracted by some other IndexCreator. 49 * 50 * @return 51 */ 52 List<String> getCreatorDependencies(); 53 54 /** 55 * Returns the indexer fields that this IndexCreator introduces to index. 56 * 57 * @return 58 */ 59 Collection<IndexerField> getIndexerFields(); 60 61 /** 62 * Populate an <code>ArtifactContext</code> with information about corresponding artifact. 63 */ 64 void populateArtifactInfo(ArtifactContext artifactContext) throws IOException; 65 66 /** 67 * Update Lucene <code>Document</code> from a given <code>ArtifactInfo</code>. 68 */ 69 void updateDocument(ArtifactInfo artifactInfo, Document document); 70 71 /** 72 * Update an <code>ArtifactInfo</code> from given Lucene <code>Document</code>. 73 * 74 * @return true is artifact info has been updated 75 */ 76 boolean updateArtifactInfo(Document document, ArtifactInfo artifactInfo); 77 }