org.mycore.services.fieldquery
Class MCRData2Fields

java.lang.Object
  extended by org.mycore.services.fieldquery.MCRData2Fields

public class MCRData2Fields
extends Object

Provides methods to automatically extract field values for indexing from MCRObject, MCRFile or any XML document using the definition in searchfields.xml. The buildFields method returns a list of MCRFieldValue objects with values extracted from the object for the given search index. This class supports extracting values from MCRObject metadata, MCRFile metadata, MCRFile xml content. MCRFile additional data, MCRFile text content using the text filter plug-ins, and any plain XML document.

Author:
Frank L�tzenkirchen
See Also:
MCRSearcher#addToIndex(String, List)

Constructor Summary
MCRData2Fields()
           
 
Method Summary
static List<MCRFieldValue> buildFields(byte[] xml, String index, String source, String objectType)
          Extracts field values for indexing from the given JDOM xml document.
static List<MCRFieldValue> buildFields(Document doc, String index)
          Extracts field values for indexing from the given JDOM xml document.
static List<MCRFieldValue> buildFields(MCRFile file, String index)
          Extracts field values for indexing from the given MCRFile's metadata, xml content or text content.
static List<MCRFieldValue> buildFields(MCRObject obj, String index)
          Extracts field values for indexing from the given MCRObject's metadata.
static String normalizeDate(String sDate)
          Xalan XSL extension to convert MyCoRe date values to standard format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRData2Fields

public MCRData2Fields()
Method Detail

buildFields

public static List<MCRFieldValue> buildFields(MCRObject obj,
                                              String index)
Extracts field values for indexing from the given MCRObject's metadata.

Parameters:
obj - the MCRObject thats metadata should be indexed
index - the ID of the index as defined in searchfields.xml
Returns:
a List of MCRFieldValue objects that contain field and value

buildFields

public static List<MCRFieldValue> buildFields(MCRFile file,
                                              String index)
Extracts field values for indexing from the given MCRFile's metadata, xml content or text content.

Parameters:
file - the MCRFile thats data should be indexed
index - the ID of the index as defined in searchfields.xml
Returns:
a List of MCRFieldValue objects that contain field and value

buildFields

public static List<MCRFieldValue> buildFields(Document doc,
                                              String index)
Extracts field values for indexing from the given JDOM xml document.

Parameters:
doc - the JDOM xml document thats data should be indexed
index - the ID of the index as defined in searchfields.xml
Returns:
a List of MCRFieldValue objects that contain name, type and value

buildFields

public static List<MCRFieldValue> buildFields(byte[] xml,
                                              String index,
                                              String source,
                                              String objectType)
Extracts field values for indexing from the given JDOM xml document.

Parameters:
xml - the xml document thats data should be indexed as byte array
index - the ID of the index as defined in searchfields.xml
Returns:
a List of MCRFieldValue objects that contain name, type and value

normalizeDate

public static String normalizeDate(String sDate)
Xalan XSL extension to convert MyCoRe date values to standard format. To be used in a stylesheet or searchfields.xml configuration. Usage example: <field name="date" type="date" xpath="/mycoreobject/metadata/dates/date" value="ext:normalizeDate(string(text()))" >

Parameters:
date - the date string in a locale-dependent format