Class MCRTextResolver.Term

java.lang.Object
org.mycore.common.MCRTextResolver.Term
Direct Known Subclasses:
MCRTextResolver.Condition, MCRTextResolver.EscapeCharacter, MCRTextResolver.Text, MCRTextResolver.Variable
Enclosing class:
MCRTextResolver

protected abstract static class MCRTextResolver.Term extends Object
A term is a defined part in a text. In general, a term is defined by brackets, but this is not required. Here are some example terms:
  • Variable: {term1}
  • Condition: [term2]
  • EscapeChar: \[
You can write your own terms and add them to the text resolver. A sample is shown in the MCRTextResolverTest class.
Author:
Matthias Eichner
  • Field Details

    • termBuffer

      protected StringBuffer termBuffer
      The string buffer within the term. For example: {var}.
    • resolved

      protected boolean resolved
      If the term is successfully resolved. By default this is true.
    • position

      protected int position
      The current character position in the term.
    • textResolver

      protected MCRTextResolver textResolver
  • Constructor Details

  • Method Details

    • resolve

      public String resolve(String text, int startPosition)
      Resolves the text from the startPosition to the end of the text or if a term specific end character is found.
      Parameters:
      text - the term to resolve
      startPosition - the current character position
      Returns:
      the value of the term after resolving
    • resolveInternal

      protected abstract boolean resolveInternal(String text, int pos)
      Does term specific resolving for the current character.
      Returns:
      true if the end string is reached, otherwise false
    • getValue

      public String getValue()
      Returns the value of the term. Overwrite this if you don't want to get the default termBuffer content as value.
      Returns:
      the value of the term
    • getStartEnclosingString

      public abstract String getStartEnclosingString()
      Implement this to define the start enclosing string for your term. The resolver searches in the text for this string, if found, the text is processed by your term.
      Returns:
      the start enclosing string
    • getEndEnclosingString

      public abstract String getEndEnclosingString()
      Implement this to define the end enclosing string for your term. You have to check manual in the resolveInternal method if the end of your term is reached.
      Returns:
      the end enclosing string
    • getTextResolver

      public MCRTextResolver getTextResolver()