Class XPathContentWorkerSelector<W extends ContentWorker>

  • 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      W 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<java.lang.String> supportedMimetypes)
      Optionally set the mimetypes supported.
      void setWorkers​(java.util.Map<java.lang.String,​W> 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<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:
        getWorker in interface ContentWorkerSelector<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.