org.alfresco.repo.content.selector
Class XPathContentWorkerSelector

java.lang.Object
  extended by org.alfresco.repo.content.selector.XPathContentWorkerSelector
All Implemented Interfaces:
ContentWorkerSelector

public class XPathContentWorkerSelector
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

Constructor Summary
XPathContentWorkerSelector()
           
 
Method Summary
 ContentWorker getWorker(org.alfresco.service.cmr.repository.ContentReader reader)
          Execute the XPath statements, in order, against the document.
 void init()
          Checks the configuration.
 void setSupportedMimetypes(java.util.Set supportedMimetypes)
          Optionally set the mimetypes supported.
 void setWorkers(java.util.Map workers)
          Set the workers to use.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPathContentWorkerSelector

public XPathContentWorkerSelector()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setSupportedMimetypes

public void setSupportedMimetypes(java.util.Set 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 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 ContentWorker 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:
getWorker in interface ContentWorkerSelector
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.


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.