NASA World Wind

gov.nasa.worldwind.util
Class BasicTextDecoder

java.lang.Object
  extended by gov.nasa.worldwind.util.BasicTextDecoder
All Implemented Interfaces:
TextDecoder
Direct Known Subclasses:
KMLBalloonTextDecoder

public class BasicTextDecoder
extends 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
protected  String decodedText
           
protected  long lastUpdateTime
           
protected  String text
           
 
Constructor Summary
BasicTextDecoder()
           
 
Method Summary
protected  String decode(String textToDecode)
          Decode the text.
 String getDecodedText()
          Get the decoded text.
 long getLastUpdateTime()
          Get the time at which the decoded text last changed.
 void setText(String input)
          Set the input text which the decoder will process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decodedText

protected String decodedText

lastUpdateTime

protected long lastUpdateTime

text

protected String text
Constructor Detail

BasicTextDecoder

public BasicTextDecoder()
Method Detail

decode

protected String decode(String textToDecode)
Decode the text. Subclasses may override this method to change the decoding.

Parameters:
textToDecode - The text to decode.
Returns:
Decoded text.

getDecodedText

public 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.

setText

public void setText(String input)
Set the input text which the decoder will process.

Specified by:
setText in interface TextDecoder
Parameters:
input - Text to decode.

NASA World Wind