com.calitha.resource
Class TextResource

java.lang.Object
  extended by com.calitha.resource.Resource
      extended by com.calitha.resource.TextResource
All Implemented Interfaces:
IResource

public final class TextResource
extends Resource

A TextResource object respresents a text resource.

Text resources can be use to make an application support multi-language text messages.

Author:
Robert van Loenhout

Constructor Summary
TextResource(Locale locale, String namespace, String id, String text)
          Creates a new TextResource object.
 
Method Summary
 byte[] getBytes()
          Gets the content of the resource as a byte array.
 String getText()
          Gets the content of the resource as a text string.
 String getText(Charset encoding)
          Gets the content of the resource as a text string.
 String toString()
           
 void toString(StringBuffer buffer)
           
 
Methods inherited from class com.calitha.resource.Resource
createKey, equals, getId, getKey, getLocale, getMimetype, getNamespace, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextResource

public TextResource(Locale locale,
                    String namespace,
                    String id,
                    String text)
Creates a new TextResource object.

Parameters:
locale - locale
namespace - namespace
id - id
text - text
Throws:
IllegalArgumentException - if an argument is null
Method Detail

getText

public String getText()
Description copied from interface: IResource
Gets the content of the resource as a text string.

Returns:
text

getText

public String getText(Charset encoding)
Description copied from interface: IResource
Gets the content of the resource as a text string.

Useful if the encoding is not part of the resource. For example a file that contains a text string.

Parameters:
encoding - character set such as UTF-8 or ISO-8859-1
Returns:
text

getBytes

public byte[] getBytes()
Description copied from interface: IResource
Gets the content of the resource as a byte array.

Returns:
bytes

toString

public void toString(StringBuffer buffer)
Overrides:
toString in class Resource

toString

public String toString()
Overrides:
toString in class Resource