Package org.appng.search.indexer
Class SimpleDocument
- java.lang.Object
-
- org.appng.search.indexer.SimpleDocument
-
- All Implemented Interfaces:
Comparable<Document>
,Observable<Document>
,Document
public class SimpleDocument extends Object implements Document
A basicDocument
-implementation, suitable for most cases. Uses anObservableDelegate
to manage itsObserver
s.- Author:
- Matthias Müller
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.appng.api.observe.Observable
Observable.Event
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.commons.lang3.time.FastDateFormat
DATEFORMAT
-
Fields inherited from interface org.appng.api.search.Document
CREATE, DELETE, FIELD_CONTENT, FIELD_DATE, FIELD_ID, FIELD_IMAGE, FIELD_LANGUAGE, FIELD_PATH, FIELD_TEASER, FIELD_TITLE, FIELD_TYPE, UPDATE, YYYY_MM_DD_HH_MM_SS
-
-
Constructor Summary
Constructors Constructor Description SimpleDocument()
SimpleDocument(float score)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addField(org.apache.lucene.index.IndexableField field)
boolean
addObserver(Observer<? super Document> observer)
Adds anObserver
.int
compareTo(Document other)
static SimpleDocument
extract(org.apache.lucene.document.Document doc, int docId, float score)
Iterable<org.apache.lucene.index.IndexableField>
getAdditionalFields()
Returns some additionallyIndexableField
s (if any) to be added to theDocument
which is being created from thisDocument
.String
getContent()
Returns the content to be indexed.Date
getDate()
String
getDescription()
Returns the description of thisDocument
.int
getDocId()
org.apache.lucene.index.IndexableField
getField(String name)
String
getFragment()
String
getId()
String
getImage()
String
getLanguage()
Returns the language of thisDocument
.String
getName()
Returns the name of thisDocument
.protected static Number
getNumberFromField(org.apache.lucene.document.Document doc, String name, List<org.apache.lucene.index.IndexableField> fieldsList)
Observable<Document>
getObservable()
String
getPath()
float
getScore()
String
getType()
void
notifyObservers(Observable.Event event)
Notifies theObserver
s.boolean
removeObserver(Observer<? super Document> observer)
Removes anObserver
.void
setContent(String content)
void
setDate(Date date)
void
setDescription(String description)
void
setDocId(int docId)
void
setFragment(String fragment)
void
setFragment(String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)
static void
setFragment(SimpleDocument doc, String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)
void
setId(String id)
void
setImage(String image)
void
setLanguage(String language)
void
setName(String name)
void
setObservable(Observable<Document> observable)
void
setPath(String path)
void
setScore(float score)
void
setType(String type)
-
-
-
Method Detail
-
addObserver
public boolean addObserver(Observer<? super Document> observer)
Description copied from interface:Observable
Adds anObserver
.- Specified by:
addObserver
in interfaceObservable<Document>
- Parameters:
observer
- theObserver
to be added- Returns:
true
if adding theObserver
was successful,false
otherwise
-
removeObserver
public boolean removeObserver(Observer<? super Document> observer)
Description copied from interface:Observable
Removes anObserver
.- Specified by:
removeObserver
in interfaceObservable<Document>
- Parameters:
observer
- theObserver
to be removed- Returns:
true
if removing theObserver
was successful,false
otherwise
-
notifyObservers
public void notifyObservers(Observable.Event event)
Description copied from interface:Observable
Notifies theObserver
s.- Specified by:
notifyObservers
in interfaceObservable<Document>
- Parameters:
event
- anObservable.Event
-
getAdditionalFields
public Iterable<org.apache.lucene.index.IndexableField> getAdditionalFields()
Description copied from interface:Document
Returns some additionallyIndexableField
s (if any) to be added to theDocument
which is being created from thisDocument
.- Specified by:
getAdditionalFields
in interfaceDocument
- Returns:
- some
IndexableField
s
-
addField
public void addField(org.apache.lucene.index.IndexableField field)
-
getField
public org.apache.lucene.index.IndexableField getField(String name)
-
getObservable
public Observable<Document> getObservable()
-
setObservable
public void setObservable(Observable<Document> observable)
-
getLanguage
public String getLanguage()
Description copied from interface:Document
Returns the language of thisDocument
.- Specified by:
getLanguage
in interfaceDocument
- Returns:
- the language
-
setLanguage
public void setLanguage(String language)
-
setType
public void setType(String type)
-
getContent
public String getContent()
Description copied from interface:Document
Returns the content to be indexed.- Specified by:
getContent
in interfaceDocument
- Returns:
- the content to be indexed
-
setContent
public void setContent(String content)
-
setPath
public void setPath(String path)
-
setImage
public void setImage(String image)
-
getDescription
public String getDescription()
Description copied from interface:Document
Returns the description of thisDocument
.- Specified by:
getDescription
in interfaceDocument
- Returns:
- the description of this
Document
-
setDescription
public void setDescription(String description)
-
setDate
public void setDate(Date date)
-
getName
public String getName()
Description copied from interface:Document
Returns the name of thisDocument
.
-
setName
public void setName(String name)
-
setId
public void setId(String id)
-
setDocId
public void setDocId(int docId)
-
setScore
public void setScore(float score)
-
getFragment
public String getFragment()
- Specified by:
getFragment
in interfaceDocument
-
setFragment
public void setFragment(String fragment)
- Specified by:
setFragment
in interfaceDocument
-
compareTo
public int compareTo(Document other)
- Specified by:
compareTo
in interfaceComparable<Document>
-
extract
public static SimpleDocument extract(org.apache.lucene.document.Document doc, int docId, float score)
-
getNumberFromField
protected static Number getNumberFromField(org.apache.lucene.document.Document doc, String name, List<org.apache.lucene.index.IndexableField> fieldsList)
-
setFragment
public void setFragment(String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)
-
setFragment
public static void setFragment(SimpleDocument doc, String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)
-
-