org.carrot2.source.xml
Class XmlDocumentSourceDescriptor.AttributeBuilder

java.lang.Object
  extended by org.carrot2.source.xml.XmlDocumentSourceDescriptor.AttributeBuilder
Enclosing class:
XmlDocumentSourceDescriptor

public static class XmlDocumentSourceDescriptor.AttributeBuilder
extends Object

Attribute map builder for the XmlDocumentSource component. You can use this builder as a type-safe alternative to populating the attribute map using attribute keys.


Field Summary
 Map<String,Object> map
          The attribute map populated by this builder.
 
Constructor Summary
protected XmlDocumentSourceDescriptor.AttributeBuilder(Map<String,Object> map)
          Creates a builder backed by the provided map.
 
Method Summary
 List<Document> documents()
          Documents read from the XML data.
 String query()
          After processing this field may hold the query read from the XML data, if any.
 XmlDocumentSourceDescriptor.AttributeBuilder query(String value)
          After processing this field may hold the query read from the XML data, if any.
 XmlDocumentSourceDescriptor.AttributeBuilder readAll(boolean value)
          If true, all documents are read from the input XML stream, regardless of the limit set by XmlDocumentSource.results.
 XmlDocumentSourceDescriptor.AttributeBuilder results(int value)
          The maximum number of documents to read from the XML data if XmlDocumentSource.readAll is false.
 String title()
          The title (file name or query attribute, if present) for the search result fetched from the resource.
 XmlDocumentSourceDescriptor.AttributeBuilder xml(Class<? extends IResource> clazz)
          The resource to load XML data from.
 XmlDocumentSourceDescriptor.AttributeBuilder xml(IResource value)
          The resource to load XML data from.
 XmlDocumentSourceHelperDescriptor.AttributeBuilder xmlDocumentSourceHelper()
          Returns an attribute builder for the nested XmlDocumentSourceHelper component, backed by the same attribute map as the current builder.
 XmlDocumentSourceDescriptor.AttributeBuilder xmlParameters(Map<String,String> value)
          Values for custom placeholders in the XML URL.
 XmlDocumentSourceDescriptor.AttributeBuilder xslt(Class<? extends IResource> clazz)
          The resource to load XSLT stylesheet from.
 XmlDocumentSourceDescriptor.AttributeBuilder xslt(IResource value)
          The resource to load XSLT stylesheet from.
 XmlDocumentSourceDescriptor.AttributeBuilder xsltParameters(Map<String,String> value)
          Parameters to be passed to the XSLT transformer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

public final Map<String,Object> map
The attribute map populated by this builder.

Constructor Detail

XmlDocumentSourceDescriptor.AttributeBuilder

protected XmlDocumentSourceDescriptor.AttributeBuilder(Map<String,Object> map)
Creates a builder backed by the provided map.

Method Detail

xml

public XmlDocumentSourceDescriptor.AttributeBuilder xml(IResource value)
The resource to load XML data from. You can either create instances of IResource implementations directly or use ResourceLookup to look up IResource instances from a variety of locations.

One special IResource implementation you can use is URLResourceWithParams. It allows you to specify attribute placeholders in the URL that will be replaced with actual values at runtime. The placeholder format is ${attribute}. The following common attributes will be substituted:

Additionally, custom placeholders can be used. Values for the custom placeholders should be provided in the XmlDocumentSource.xmlParameters attribute.

See Also:
XmlDocumentSource.xml

xml

public XmlDocumentSourceDescriptor.AttributeBuilder xml(Class<? extends IResource> clazz)
The resource to load XML data from. You can either create instances of IResource implementations directly or use ResourceLookup to look up IResource instances from a variety of locations.

One special IResource implementation you can use is URLResourceWithParams. It allows you to specify attribute placeholders in the URL that will be replaced with actual values at runtime. The placeholder format is ${attribute}. The following common attributes will be substituted:

Additionally, custom placeholders can be used. Values for the custom placeholders should be provided in the XmlDocumentSource.xmlParameters attribute.

See Also:
XmlDocumentSource.xml

xslt

public XmlDocumentSourceDescriptor.AttributeBuilder xslt(IResource value)
The resource to load XSLT stylesheet from. The XSLT stylesheet is optional and is useful when the source XML stream does not follow the Carrot2 format. The XSLT transformation will be applied to the source XML stream, the transformed XML stream will be deserialized into Documents.

The XSLT IResource can be provided both on initialization and processing time. The stylesheet provided on initialization will be cached for the life time of the component, while processing-time style sheets will be compiled every time processing is requested and will override the initialization-time stylesheet.

To pass additional parameters to the XSLT transformer, use the XmlDocumentSource.xsltParameters attribute.

See Also:
XmlDocumentSource.xslt

xslt

public XmlDocumentSourceDescriptor.AttributeBuilder xslt(Class<? extends IResource> clazz)
The resource to load XSLT stylesheet from. The XSLT stylesheet is optional and is useful when the source XML stream does not follow the Carrot2 format. The XSLT transformation will be applied to the source XML stream, the transformed XML stream will be deserialized into Documents.

The XSLT IResource can be provided both on initialization and processing time. The stylesheet provided on initialization will be cached for the life time of the component, while processing-time style sheets will be compiled every time processing is requested and will override the initialization-time stylesheet.

To pass additional parameters to the XSLT transformer, use the XmlDocumentSource.xsltParameters attribute.

See Also:
XmlDocumentSource.xslt

xmlParameters

public XmlDocumentSourceDescriptor.AttributeBuilder xmlParameters(Map<String,String> value)
Values for custom placeholders in the XML URL. If the type of resource provided in the XmlDocumentSource.xml attribute is URLResourceWithParams, this map provides values for custom placeholders found in the XML URL. Keys of the map correspond to placeholder names, values of the map will be used to replace the placeholders. Please see XmlDocumentSource.xml for the placeholder syntax.

See Also:
XmlDocumentSource.xmlParameters

xsltParameters

public XmlDocumentSourceDescriptor.AttributeBuilder xsltParameters(Map<String,String> value)
Parameters to be passed to the XSLT transformer. Keys of the map will be used as parameter names, values of the map as parameter values.

See Also:
XmlDocumentSource.xsltParameters

query

public XmlDocumentSourceDescriptor.AttributeBuilder query(String value)
After processing this field may hold the query read from the XML data, if any. For the semantics of this field on input, see XmlDocumentSource.xml.

See Also:
XmlDocumentSource.query

query

public String query()
After processing this field may hold the query read from the XML data, if any. For the semantics of this field on input, see XmlDocumentSource.xml.

See Also:
XmlDocumentSource.query

results

public XmlDocumentSourceDescriptor.AttributeBuilder results(int value)
The maximum number of documents to read from the XML data if XmlDocumentSource.readAll is false.

See Also:
XmlDocumentSource.results

readAll

public XmlDocumentSourceDescriptor.AttributeBuilder readAll(boolean value)
If true, all documents are read from the input XML stream, regardless of the limit set by XmlDocumentSource.results.

See Also:
XmlDocumentSource.readAll

title

public String title()
The title (file name or query attribute, if present) for the search result fetched from the resource.

See Also:
XmlDocumentSource.title

documents

public List<Document> documents()
Documents read from the XML data.

See Also:
XmlDocumentSource.documents

xmlDocumentSourceHelper

public XmlDocumentSourceHelperDescriptor.AttributeBuilder xmlDocumentSourceHelper()
Returns an attribute builder for the nested XmlDocumentSourceHelper component, backed by the same attribute map as the current builder.



Copyright (c) Dawid Weiss, Stanislaw Osinski