com.calitha.resource
Class BinaryResource

java.lang.Object
  extended by com.calitha.resource.Resource
      extended by com.calitha.resource.BinaryResource
All Implemented Interfaces:
IResource
Direct Known Subclasses:
Base64Resource, JavaResource, WWWResource

public abstract class BinaryResource
extends Resource

A BinaryResource object represents a binary resource such as a www resource or base64 encoded resource.

This class must be extended to create a concrete implementation.

Author:
Robert van Loenhout

Constructor Summary
BinaryResource(Locale locale, String namespace, String id, String mimetype)
          Creates a new binary resource.
 
Method Summary
 String getText()
          Gets the contents of the resource as a string.
 String getText(Charset encoding)
          Gets the contents of the resource as a string.
 
Methods inherited from class com.calitha.resource.Resource
createKey, equals, getId, getKey, getLocale, getMimetype, getNamespace, hashCode, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.calitha.resource.IResource
getBytes
 

Constructor Detail

BinaryResource

public BinaryResource(Locale locale,
                      String namespace,
                      String id,
                      String mimetype)
Creates a new binary resource.

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

getText

public String getText()
Gets the contents of the resource as a string. The bytes of the binary resource are used to convert them into a string.

Returns:
text

getText

public String getText(Charset encoding)
               throws UnsupportedEncodingException
Gets the contents of the resource as a string. The bytes of the binary resource are used to convert them into a string using the specified encoding.

Parameters:
encoding - encoding that was used to encode the text into bytes
Returns:
text
Throws:
UnsupportedEncodingException - if the specified encoding is not supported.