Class KMLBalloonTextDecoder

  • All Implemented Interfaces:
    TextDecoder

    public class KMLBalloonTextDecoder
    extends BasicTextDecoder
    Text decoder that performs entity substitution for KML description balloons. This class is thread safe.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.String> entityCache
      Keep a cache of entities that have been resolved so that we don't have to re-resolve them every time the decoded text is requested.
      protected KMLAbstractFeature feature
      Feature to use as context for entity replacements.
      protected boolean isUnresolved
      True if there are entities in the balloon text which may refer to unresolved schema.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String decode​(java.lang.String textToDecode)
      Perform entity substitution.
      java.lang.String getDecodedText()
      Get the balloon text after entity substitutions (for example, $[name], $[description], etc) have been made.
      KMLAbstractFeature getFeature()
      Get the feature used as context for resolving entity references.
      protected java.lang.String getGeDirectionsText()
      Get the text used to replace the $[geDirections] entity.
      protected java.lang.String resolveEntityReference​(java.lang.String pattern)
      Resolve an entity reference.
      void setText​(java.lang.String input)
      Set the input text which the decoder will process.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • isUnresolved

        protected boolean isUnresolved
        True if there are entities in the balloon text which may refer to unresolved schema. False if all entities have been resolved, or are known to be unresolvable (because the data they refer to does not exist).
      • entityCache

        protected java.util.Map<java.lang.String,​java.lang.String> entityCache
        Keep a cache of entities that have been resolved so that we don't have to re-resolve them every time the decoded text is requested.
      • feature

        protected KMLAbstractFeature feature
        Feature to use as context for entity replacements.
    • Constructor Detail

      • KMLBalloonTextDecoder

        public KMLBalloonTextDecoder​(KMLAbstractFeature feature)
        Create a decoder to generate balloon text for a feature. The feature becomes the context of the entity replacements (for example "$[name]" will be replaced with the feature's name.
        Parameters:
        feature - Feature that is the context of entity replacements.
    • Method Detail

      • getDecodedText

        public java.lang.String getDecodedText()
        Get the balloon text after entity substitutions (for example, $[name], $[description], etc) have been made. See the KML specification for details on entity replacement. If some entities could not be resolved because they refer to unresolved schema, the decoder will try to decode the string again the next time this method is called.
        Specified by:
        getDecodedText in interface TextDecoder
        Overrides:
        getDecodedText in class BasicTextDecoder
        Returns:
        String after replacements have been made. Returns null if the input text is null.
      • decode

        protected java.lang.String decode​(java.lang.String textToDecode)
        Perform entity substitution.
        Overrides:
        decode in class BasicTextDecoder
        Parameters:
        textToDecode - The text to decode.
        Returns:
        Decoded text.
      • setText

        public void setText​(java.lang.String input)
        Set the input text which the decoder will process.
        Specified by:
        setText in interface TextDecoder
        Overrides:
        setText in class BasicTextDecoder
        Parameters:
        input - Text to decode.
      • resolveEntityReference

        protected java.lang.String resolveEntityReference​(java.lang.String pattern)
        Resolve an entity reference. The pattern can be in one of these forms:
          FeatureField
          DataField
          DataField/displayName
          SchemaName/SchemaField
          SchemaName/SchemaField/displayName
          
        See the KML spec for details.
        Parameters:
        pattern - Pattern of entity to resolve.
        Returns:
        Return the replacement string for the entity, or null if no replacement can be found.
      • getFeature

        public KMLAbstractFeature getFeature()
        Get the feature used as context for resolving entity references.
        Returns:
        The context feature.
      • getGeDirectionsText

        protected java.lang.String getGeDirectionsText()
        Get the text used to replace the $[geDirections] entity. This implementation returns an empty string. Subclasses can override this method to provide directions text.
        Returns:
        Text to replace the $[geDirections] entity.