org.apache.jackrabbit.core.query.lucene
Class NodeIndexer

java.lang.Object
  extended byorg.apache.jackrabbit.core.query.lucene.NodeIndexer

public class NodeIndexer
extends Object

Creates a lucene Document object from a Node.


Field Summary
protected  NamespaceMappings mappings
          Namespace mappings to use for indexing.
protected  NodeState node
          The NodeState of the node to index
protected  ItemStateManager stateProvider
          The persistent item state provider
protected  List textFilters
          List of text filters in use.
 
Constructor Summary
protected NodeIndexer(NodeState node, ItemStateManager stateProvider, NamespaceMappings mappings, List textFilters)
          Creates a new node indexer.
 
Method Summary
protected  void addBinaryValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the binary value to the document as the named field.
protected  void addBooleanValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the string representation of the boolean value to the document as the named field.
protected  void addCalendarValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the calendar value to the document as the named field.
protected  void addDoubleValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the double value to the document as the named field.
protected  void addLongValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the long value to the document as the named field.
protected  void addNameValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the name value to the document as the named field.
protected  void addPathValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the path value to the document as the named field.
protected  void addReferenceValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the reference value to the document as the named field.
protected  void addStringValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
          Adds the string value to the document both as the named field and for full text indexing.
protected  org.apache.lucene.document.Document createDoc()
          Creates a lucene Document.
static org.apache.lucene.document.Document createDocument(NodeState node, ItemStateManager stateProvider, NamespaceMappings mappings, List textFilters)
          Creates a lucene Document from a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected final NodeState node
The NodeState of the node to index


stateProvider

protected final ItemStateManager stateProvider
The persistent item state provider


mappings

protected final NamespaceMappings mappings
Namespace mappings to use for indexing. This is the internal namespace mapping.


textFilters

protected final List textFilters
List of text filters in use.

Constructor Detail

NodeIndexer

protected NodeIndexer(NodeState node,
                      ItemStateManager stateProvider,
                      NamespaceMappings mappings,
                      List textFilters)
Creates a new node indexer.

Parameters:
node - the node state to index.
stateProvider - the persistent item state manager to retrieve properties.
mappings - internal namespace mappings.
textFilters - List of TextFilters.
Method Detail

createDocument

public static org.apache.lucene.document.Document createDocument(NodeState node,
                                                                 ItemStateManager stateProvider,
                                                                 NamespaceMappings mappings,
                                                                 List textFilters)
                                                          throws RepositoryException
Creates a lucene Document from a node.

Parameters:
node - the node state to index.
stateProvider - the state provider to retrieve property values.
mappings - internal namespace mappings.
textFilters - list of text filters to use for indexing binary properties.
Returns:
the lucene Document.
Throws:
RepositoryException - if an error occurs while reading property values from the ItemStateProvider.

createDoc

protected org.apache.lucene.document.Document createDoc()
                                                 throws RepositoryException
Creates a lucene Document.

Returns:
the lucene Document with the index layout.
Throws:
RepositoryException - if an error occurs while reading property values from the ItemStateProvider.

addBinaryValue

protected void addBinaryValue(org.apache.lucene.document.Document doc,
                              String fieldName,
                              Object internalValue)
Adds the binary value to the document as the named field.

This implementation checks if this node is of type nt:resource and if that is the case, tries to extract text from the data atom using the textFilters.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addBooleanValue

protected void addBooleanValue(org.apache.lucene.document.Document doc,
                               String fieldName,
                               Object internalValue)
Adds the string representation of the boolean value to the document as the named field.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addCalendarValue

protected void addCalendarValue(org.apache.lucene.document.Document doc,
                                String fieldName,
                                Object internalValue)
Adds the calendar value to the document as the named field. The calendar value is converted to an indexable string value using the DateField class.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addDoubleValue

protected void addDoubleValue(org.apache.lucene.document.Document doc,
                              String fieldName,
                              Object internalValue)
Adds the double value to the document as the named field. The double value is converted to an indexable string value using the DoubleField class.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addLongValue

protected void addLongValue(org.apache.lucene.document.Document doc,
                            String fieldName,
                            Object internalValue)
Adds the long value to the document as the named field. The long value is converted to an indexable string value using the LongField class.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addReferenceValue

protected void addReferenceValue(org.apache.lucene.document.Document doc,
                                 String fieldName,
                                 Object internalValue)
Adds the reference value to the document as the named field. The value's string representation is added as the reference data. Additionally the reference data is stored in the index.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addPathValue

protected void addPathValue(org.apache.lucene.document.Document doc,
                            String fieldName,
                            Object internalValue)
Adds the path value to the document as the named field. The path value is converted to an indexable string value using the name space mappings with which this class has been created.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addStringValue

protected void addStringValue(org.apache.lucene.document.Document doc,
                              String fieldName,
                              Object internalValue)
Adds the string value to the document both as the named field and for full text indexing.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.

addNameValue

protected void addNameValue(org.apache.lucene.document.Document doc,
                            String fieldName,
                            Object internalValue)
Adds the name value to the document as the named field. The name value is converted to an indexable string treating the internal value as a qualified name and mapping the name space using the name space mappings with which this class has been created.

Parameters:
doc - The document to which to add the field
fieldName - The name of the field to add
internalValue - The value for the field to add to the document.


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.