Class XPathContentWorkerSelector<W extends ContentWorker>
- java.lang.Object
-
- org.alfresco.repo.content.selector.XPathContentWorkerSelector<W>
-
- All Implemented Interfaces:
ContentWorkerSelector
public class XPathContentWorkerSelector<W extends ContentWorker> extends java.lang.Object implements ContentWorkerSelector
A selector that executes a set of XPath statements against the XML document to determine which content worker to provide. The XPath rules are simple, i.e. if an XML node is found by the XPath statement, then it is considered to be a hit and the corresponding worker is returned.Currently, the only namespaces supported are those contained in the XML documents being tested.
- Since:
- 2.1
- Author:
- Derek Hulley
-
-
Constructor Summary
Constructors Constructor Description XPathContentWorkerSelector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WgetWorker(org.alfresco.service.cmr.repository.ContentReader reader)Execute the XPath statements, in order, against the document.voidinit()Checks the configuration.voidsetSupportedMimetypes(java.util.Set<java.lang.String> supportedMimetypes)Optionally set the mimetypes supported.voidsetWorkers(java.util.Map<java.lang.String,W> workers)Set the workers to use.java.lang.StringtoString()
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setSupportedMimetypes
public void setSupportedMimetypes(java.util.Set<java.lang.String> supportedMimetypes)
Optionally set the mimetypes supported. They must be XML formats that the chosen parser will be able to handle.- Parameters:
supportedMimetypes- the list of mimetypes. The default is text/xml.
-
setWorkers
public void setWorkers(java.util.Map<java.lang.String,W> workers)
Set the workers to use. All the XPath statements provided must be compatible with a return value of type NODE.- Parameters:
workers- a map of ContentWorker instances keyed by XPath statements
-
init
public void init()
Checks the configuration.
-
getWorker
public W getWorker(org.alfresco.service.cmr.repository.ContentReader reader)
Execute the XPath statements, in order, against the document. Any statements that fail to run will be ignored.- Specified by:
getWorkerin interfaceContentWorkerSelector<W extends ContentWorker>- Parameters:
reader- the content reader, providing the actual stream metadata and even the stream, if required.- Returns:
- Return a worker that can operate on the content, or null if this identifier doesn't support the content.
-
-