com.calitha.resource
Interface IResource

All Known Implementing Classes:
Base64Resource, BinaryResource, JavaResource, Resource, TextResource, WWWResource

public interface IResource

An IResource object represents a resource such as text or a www resource that can be used in your application.

Author:
Robert van Loenhout

Method Summary
 byte[] getBytes()
          Gets the content of the resource as a byte array.
 String getId()
          Gets the id of the resource.
 String getKey()
          Gets the key of the resource.
 Locale getLocale()
          Gets the locale that this resource is associated with.
 String getMimetype()
          Gets the mimetype of the resource.
 String getNamespace()
          Gets the namespace that the resource is part of.
 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.
 

Method Detail

getNamespace

String getNamespace()
Gets the namespace that the resource is part of. This is used to keep resources with the same id seperate like java packages do, or XML namespaces.

Returns:
namespace

getId

String getId()
Gets the id of the resource.

Returns:
resource name

getKey

String getKey()
Gets the key of the resource.

This is a combination of namespace and id. For example: namespace=com.caltiha, id=msg, key=com.calitha.msg If the namespace is null, then the key is the same as the id.

Returns:
resource key

getLocale

Locale getLocale()
Gets the locale that this resource is associated with.

Each resource is associated with a particular locale. However both the language and country can be empty mean it can be used for all languages and countries.

Returns:
locale

getMimetype

String getMimetype()
Gets the mimetype of the resource.

Returns:
mimetype

getBytes

byte[] getBytes()
Gets the content of the resource as a byte array.

Returns:
bytes

getText

String getText()
Gets the content of the resource as a text string.

Returns:
text

getText

String getText(Charset encoding)
               throws UnsupportedEncodingException
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
Throws:
UnsupportedEncodingException - thrown if the Character Encoding is not supported.