Commit 337e7fee authored by mohamad.alturky's avatar mohamad.alturky

edit representers resolver

parent a4ec0586
package com.search.lucene.documents.representers.resolver; package com.search.lucene.documents.representers.resolver;
import com.search.lucene.documents.representers.abstractions.IDocumentRepresenter; import com.search.lucene.documents.representers.abstractions.IDocumentRepresenter;
import com.search.lucene.documents.representers.implementations.CSVDocumentStringRepresenter;
import com.search.lucene.documents.representers.implementations.PDFDocumentStringRepresenter;
import com.search.lucene.documents.representers.implementations.TextDocumentStringRepresenter;
import com.search.lucene.settings.RepresentationSchema; import com.search.lucene.settings.RepresentationSchema;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import java.util.HashMap; import java.util.HashMap;
public class DocumentRepresenterResolver<T> { public class DocumentToStringRepresenterResolver implements IDocumentRepresenterResolver<String>{
private final HashMap<String,IDocumentRepresenter<T>> hashMap; private final HashMap<String,IDocumentRepresenter<String>> hashMap;
public DocumentToStringRepresenterResolver() {
hashMap = new HashMap<>();
hashMap.put(RepresentationSchema.CSV,new CSVDocumentStringRepresenter());
hashMap.put(RepresentationSchema.TEXT,new TextDocumentStringRepresenter());
hashMap.put(RepresentationSchema.PDF,new PDFDocumentStringRepresenter());
public DocumentRepresenterResolver(HashMap<String,IDocumentRepresenter<T>> hashMap) {
this.hashMap = hashMap;
} }
public T resolveRepresentation(Document document) { public String resolveRepresentation(Document document) {
return hashMap.get(document.get(RepresentationSchema.TYPE)).Represent(document); return hashMap.get(document.get(RepresentationSchema.TYPE)).Represent(document);
} }
} }
package com.search.lucene.documents.representers.resolver;
import org.apache.lucene.document.Document;
public interface IDocumentRepresenterResolver<T> {
T resolveRepresentation(Document document);
}
package com.search.lucene.engine.builder.implementations; package com.search.lucene.engine.builder.implementations;
import com.search.lucene.documents.representers.resolver.DocumentRepresenterResolver;
import com.search.lucene.engine.abstractions.ISearchEngine; import com.search.lucene.engine.abstractions.ISearchEngine;
import com.search.lucene.engine.builder.abstractions.IEngineBuilder; import com.search.lucene.engine.builder.abstractions.IEngineBuilder;
import com.search.lucene.engine.implementations.LuceneEngine; import com.search.lucene.engine.implementations.LuceneEngine;
...@@ -16,7 +15,6 @@ import com.search.lucene.settings.IndexPaths; ...@@ -16,7 +15,6 @@ import com.search.lucene.settings.IndexPaths;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
public class LuceneEngineBuilder implements IEngineBuilder { public class LuceneEngineBuilder implements IEngineBuilder {
@Override @Override
......
package com.search.lucene.engine.implementations; package com.search.lucene.engine.implementations;
import com.search.lucene.documents.representers.resolver.DocumentRepresenterResolver;
import com.search.lucene.engine.abstractions.ISearchEngine; import com.search.lucene.engine.abstractions.ISearchEngine;
import com.search.lucene.indexers.abstractions.IFileIndexer; import com.search.lucene.indexers.abstractions.IFileIndexer;
import com.search.lucene.searchers.abstractions.ISearcher; import com.search.lucene.searchers.abstractions.ISearcher;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment