|
Qizx fe-4.4p2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.qizx.xdm.XMLPullStreamBase
com.qizx.api.util.fulltext.FullTextHighlighter
public class FullTextHighlighter
An implementation of FullTextPullStream
that can be used to
highlight terms of a full-text query (more generally to distinguish these terms
from the rest of the XML source).
The source can be a node of the Data Model, or any stream of XML events
provided by a XMLPullStream
.
The full-text query can be specified in diverse manners: see the constructors.
Field Summary |
---|
Fields inherited from interface com.qizx.api.fulltext.FullTextPullStream |
---|
FT_TERM |
Fields inherited from interface com.qizx.api.XMLPullStream |
---|
COMMENT, DOCUMENT_END, DOCUMENT_START, ELEMENT_END, ELEMENT_START, END, PROCESSING_INSTRUCTION, START, TEXT |
Constructor Summary | |
---|---|
FullTextHighlighter(Expression query)
Creates a FullTextHighlighter from a compiled XQuery Expression. |
|
FullTextHighlighter(com.qizx.queries.FullText.Selection query,
FullTextFactory fulltextFactory)
For internal use. |
|
FullTextHighlighter(String[] words,
FullTextFactory fulltextFactory,
String language)
Creates a FullTextHighlighter from a list of words. |
|
FullTextHighlighter(String simpleSyntaxQuery,
FullTextFactory fulltextFactory,
String language)
Creates a FullTextHighlighter from a query string using the simple full-text syntax. |
Method Summary | |
---|---|
String |
extractFirstWords(String text,
int count)
Internal use. |
String |
extractLastWords(String text,
int count)
Internal use. |
Node |
getCurrentNode()
Returns the current node, if the implementation of this object is able to. |
QName |
getName()
Returns the name of the current element node, or if the node is not an element, returns the name of the parent element. |
int |
getQueryTermCount()
Returns the number of terms in the query. |
String[] |
getQueryTerms()
Returns the terms of the query as a String array. |
String |
getTarget()
Returns the target name for a PROCESSING_INSTRUCTION. |
int |
getTermPosition()
On a FT_TERM event, returns the rank of the term (word, wildcard) in the full-text query. |
String |
getText()
Returns the textual contents of an atomic node. |
int |
getTextLength()
Returns the size of the textual contents of an atomic node. |
int |
getWordCount()
On a TEXT or FT_TERM event, returns the number of words in the text chunk. |
int |
moveToNextEvent()
Moves the event stream one step forward. |
void |
start(Node node)
Starts iteration on a Node tree. |
void |
start(XMLPullStream source)
Starts iteration using another XML Stream as source. |
Methods inherited from class com.qizx.xdm.XMLPullStreamBase |
---|
getAttributeCount, getAttributeName, getAttributeValue, getCurrentEvent, getDTDName, getDTDPublicId, getDTDSystemId, getEncoding, getInternalSubset, getNamespaceCount, getNamespacePrefix, getNamespaceURI |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.qizx.api.XMLPullStream |
---|
getAttributeCount, getAttributeName, getAttributeValue, getCurrentEvent, getDTDName, getDTDPublicId, getDTDSystemId, getEncoding, getInternalSubset, getNamespaceCount, getNamespacePrefix, getNamespaceURI |
Constructor Detail |
---|
public FullTextHighlighter(Expression query) throws EvaluationException
The expression must be either of:
Expression e = session.compileExpression( ". ftcontains 'Romeo Juliet' all words case sensitive"); FullTextHighlighter hiliter = new FullTextHighlighter(e);
context
argument is ignored. Full-text options are taken
into account. Example:
Expression e = session.compileExpression("ft:contains('+Romeo +Juliet', <options case='sensitive'/>)"); FullTextHighlighter hiliter = new FullTextHighlighter(e);
Expression e = session.compileExpression("'+Romeo +Juliet'"); FullTextHighlighter hiliter = new FullTextHighlighter(e);
query
- a compiled full-text predicate, or a string using the simple
full-text syntax.
EvaluationException
public FullTextHighlighter(String simpleSyntaxQuery, FullTextFactory fulltextFactory, String language) throws DataModelException
FullTextHighlighter hiliter = new FullTextHighlighter("+Romeo +Juliet", ftfactory, "en");
simpleSyntaxQuery
- a query using the simple full-text syntax.fulltextFactory
- a FullTextFactory used with the language parameter
to get a tokenizer (both at compile-time and run-time).language
- language used for the options of the full-text query
DataModelException
- if the query is incorrectpublic FullTextHighlighter(String[] words, FullTextFactory fulltextFactory, String language)
words
- an array of words, used as is (no tokenization applied).fulltextFactory
- a FullTextFactory used to get a tokenizerlanguage
- language used for the options of the full-text querypublic FullTextHighlighter(com.qizx.queries.FullText.Selection query, FullTextFactory fulltextFactory)
Method Detail |
---|
public void start(Node node) throws DataModelException
node
-
DataModelException
public void start(XMLPullStream source)
source
- a pull stream. Text nodes (events of type TEXT) can be
split into several sections corresponding to recognized full-text terms
and plain text (resp. events FT_TERM and TEXT).public int getQueryTermCount()
FullTextPullStream
getQueryTermCount
in interface FullTextPullStream
public String[] getQueryTerms()
FullTextPullStream
getQueryTerms
in interface FullTextPullStream
public int moveToNextEvent() throws DataModelException
XMLPullStream
moveToNextEvent
in interface XMLPullStream
XMLPullStream.END
.
DataModelException
- may be thrown by the stream implementation in
case access to data is impossible (deleted document, closed Library).public int getTermPosition()
FullTextPullStream
Example: in the following query, terms 'romeo' has position 0, and term 'juliet' has position 1.
. ftcontains "romeo juliet" all words
Note that excluded terms (following ftnot
or not
in
) are ignored.
getTermPosition
in interface FullTextPullStream
public int getWordCount()
FullTextPullStream
getWordCount
in interface FullTextPullStream
public QName getName()
XMLPullStream
getName
in interface XMLPullStream
public String getText()
XMLPullStream
getText
in interface XMLPullStream
getText
in class com.qizx.xdm.XMLPullStreamBase
public int getTextLength()
XMLPullStream
getTextLength
in interface XMLPullStream
getTextLength
in class com.qizx.xdm.XMLPullStreamBase
XMLPullStream.getText()
public String getTarget()
XMLPullStream
getTarget
in interface XMLPullStream
getTarget
in class com.qizx.xdm.XMLPullStreamBase
public String extractFirstWords(String text, int count)
public String extractLastWords(String text, int count)
public Node getCurrentNode()
XMLPullStream
getCurrentNode
in interface XMLPullStream
|
© 2010 Axyana Software | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |