com.calitha.resource
Class BinaryResource
java.lang.Object
com.calitha.resource.Resource
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
BinaryResource
public BinaryResource(Locale locale,
String namespace,
String id,
String mimetype)
- Creates a new binary resource.
- Parameters:
locale - localenamespace - namespaceid - idmimetype - mimetype
- Throws:
IllegalArgumentException - if an argument is null
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.