Package gov.nasa.worldwind.util
Class BasicTextDecoder
- java.lang.Object
-
- gov.nasa.worldwind.util.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.StringdecodedTextprotected longlastUpdateTimeprotected java.lang.Stringtext
-
Constructor Summary
Constructors Constructor Description BasicTextDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Stringdecode(java.lang.String textToDecode)Decode the text.java.lang.StringgetDecodedText()Get the decoded text.longgetLastUpdateTime()Get the time at which the decoded text last changed.voidsetText(java.lang.String input)Set the input text which the decoder will process.
-
-
-
Method Detail
-
setText
public void setText(java.lang.String input)
Set the input text which the decoder will process.- Specified by:
setTextin interfaceTextDecoder- 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:
getDecodedTextin interfaceTextDecoder- 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 callTextDecoder.getDecodedText(), and then call this method to compare the timestamp with some previous timestamp to determine if the decoded text has changed sinceTextDecoder.getDecodedText()was last called.- Specified by:
getLastUpdateTimein interfaceTextDecoder- 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.
-
-