Class BasicTextDecoder

  • All Implemented Interfaces:
    TextDecoder
    Direct Known Subclasses:
    KMLBalloonTextDecoder

    public class BasicTextDecoder
    extends java.lang.Object
    implements TextDecoder
    Base class for text decoders. This decoder handles caching the decoded text, but does not provide any actual decoding logic. This class is thread safe.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String decodedText  
      protected long lastUpdateTime  
      protected java.lang.String text  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String decode​(java.lang.String textToDecode)
      Decode the text.
      java.lang.String getDecodedText()
      Get the decoded text.
      long getLastUpdateTime()
      Get the time at which the decoded text last changed.
      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

      • text

        protected java.lang.String text
      • decodedText

        protected java.lang.String decodedText
      • lastUpdateTime

        protected long lastUpdateTime
    • Constructor Detail

      • BasicTextDecoder

        public BasicTextDecoder()
    • Method Detail

      • setText

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

        public java.lang.String getDecodedText()
        Get the decoded text. This method may be called many times. Implementations should cache decoding results that do not need to be recomputed.
        Specified by:
        getDecodedText in interface TextDecoder
        Returns:
        Text after decoding.
      • getLastUpdateTime

        public long getLastUpdateTime()
        Get the time at which the decoded text last changed. The text can change because new source text is set, or because an external resource required for decoding has been resolved.

        The update time does not change until TextDecoder.getDecodedText() is called. An application should call TextDecoder.getDecodedText(), and then call this method to compare the timestamp with some previous timestamp to determine if the decoded text has changed since TextDecoder.getDecodedText() was last called.

        Specified by:
        getLastUpdateTime in interface TextDecoder
        Returns:
        The time (as returned by System.currentTimeMillis()) at which the decoded text last changed. Returns zero if called before the text is decoded.
      • decode

        protected java.lang.String decode​(java.lang.String textToDecode)
        Decode the text. Subclasses may override this method to change the decoding.
        Parameters:
        textToDecode - The text to decode.
        Returns:
        Decoded text.