Class MCRDynamicURIResolver

java.lang.Object
org.mycore.common.xml.MCRDynamicURIResolver
All Implemented Interfaces:
URIResolver

public abstract class MCRDynamicURIResolver extends Object implements URIResolver

Extend this class to include dynamic jdom content. The content is loaded from a xml file, which have to be set by the setXmlFile method.

The dynamic comes into play by the variables that can be defined for the uri. In general they are set directly behind the uri prefix. For example:

 uriprefix:value1:value2:value3... or
 uriprefix:varname1=varvalue1:varname2=varvalue2:varname3=varname3...
 
In the xml file you can use these variables with curly brackets '{}'. For more informations about the syntax see MCRTextResolver. Heres only a short example what is possible:

myURIResolver:classId=class_000_1:levels=-1:axis=children

 <dynIncl>
   <panel>
     <hidden var="@classid" default="{classId}"/>
     <include uri="dynClassification:editor:{levels}:{axis}:{classId}[:{categId}]"/>
   <panel/>
 </dynIncl>
 
Author:
Matthias Eichner
See Also:
  • Field Details

    • cachedElement

      protected Element cachedElement
    • xmlFile

      protected File xmlFile
    • lastModified

      protected long lastModified
  • Constructor Details

    • MCRDynamicURIResolver

      public MCRDynamicURIResolver()
  • Method Details

    • setXmlFile

      public void setXmlFile(File xmlFile)
      Sets the xml file. From this file the jdom content will be created.
      Parameters:
      xmlFile - xml file object
    • resolveElement

      public Element resolveElement(String uri) throws Exception
      Throws:
      Exception
    • getRootElement

      protected Element getRootElement()
    • createVariablesMap

      protected Hashtable<String,String> createVariablesMap(String uri)
      This method creates a hashtable that contains variables. There are two possibilities for getting the name of a variable from the uri:
      1. uriprefix:value1:value2:value3
      2. uriprefix:varname1=varvalue1:varname2=varvalue2:varname3=varname3
      Both options can be mixed, but this is not recommended.
      For the first option the name of the variables is 'x', where 'x' is a number for the position in the uri. To get the first value use {1}, to get the second one use {2} and so on.
      Parameters:
      uri - the whole uri
      Returns:
      a hashtable with all variables from the uri
    • resolveVariablesFromElement

      protected void resolveVariablesFromElement(Element startElement, Hashtable<String,String> variablesMap)
      This method runs through the whole content of the startElement and tries to resolve all variables in texts and attributes.
      Parameters:
      startElement - where to start to resolve the variables
      variablesMap - a map of all variables