Version: 1.1.1

org.biomoby.shared.data
Class MobyDataBytes

java.lang.Object
  extended by org.biomoby.shared.MobyData
      extended by org.biomoby.shared.MobyPrimaryData
          extended by org.biomoby.shared.MobyPrimaryDataSimple
              extended by org.biomoby.shared.data.MobyDataObject
                  extended by org.biomoby.shared.data.MobyDataComposite
                      extended by org.biomoby.shared.data.MobyDataBytes
All Implemented Interfaces:
Cloneable, Comparable, ConcurrentMap<String,MobyDataObject>, Map<String,MobyDataObject>, MobyDataInstance

public class MobyDataBytes
extends MobyDataComposite

A convenience class generally intended for the transmission of binary data that will be Base64 encoded to fit in the MOBY XML envelope. It will also decode Base64 and UUEncoded strings. All members of the object can be accessed as they normally would be in a MobyDataComposite (including the Base64 representation of the bytes in the "contents" member), but the getBytes() and getObject() method, for convenience, return the bytes encoded by the "contents" member of the class. Note: changing the "contents" member's underlying StringBuffer changes the byte output! This class could be used to handle a JPEG's raw data for example.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static String BASE64_DATATYPE
           
static int BYTE_READ_SIZE
          How much is read from a input stream (e.g. file) at once
static String ENCODED_MEMBER_NAME
           
 
Fields inherited from interface org.biomoby.shared.data.MobyDataInstance
CENTRAL_XML_MODE, SERVICE_XML_MODE
 
Constructor Summary
MobyDataBytes(Element element)
          Construct the object using a DOM fragment.
MobyDataBytes(Element element, Registry registry)
           
MobyDataBytes(String name, byte[] data)
          C-tor to use when you have binary data to encode
MobyDataBytes(String name, byte[] data, MobyDataType inputDataType)
          C-tor to use when you have binary data to encode
MobyDataBytes(String name, byte[] data, Registry registry)
           
MobyDataBytes(String name, CharSequence data)
          C-tor to use when you have received text-encoded binary.
MobyDataBytes(String name, CharSequence data, MobyDataType inputDataType)
          C-tor to use when you have received text-encoded binary.
MobyDataBytes(String name, CharSequence data, Registry registry)
           
MobyDataBytes(String name, URL resourceURL)
          C-tor to use when you want to encode a resource, such as an image file.
MobyDataBytes(String name, URL resourceURL, MobyDataType inputDataType)
          C-tor to use when you want to encode a resource, such as an image file.
MobyDataBytes(String name, URL resourceURL, Registry registry)
           
 
Method Summary
 byte[] getBytes()
          The same as getObject, but doesn't require a cast of the result
 InputStream getInputStream()
          Convenience method that returns an InputStream for use in image loaders, file savers, etc.
 Object getObject()
          Gives access to the Java object instance underlying the MobyData instance.
 
Methods inherited from class org.biomoby.shared.data.MobyDataComposite
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, isObjectValid, keySet, put, putAll, putIfAbsent, remove, remove, replace, replace, size, toXML, values
 
Methods inherited from class org.biomoby.shared.data.MobyDataObject
addCrossReference, addCrossReferences, addCrossReferences, addProvisionInfo, compareTo, createInstanceFromDOM, createInstanceFromDOM, createInstanceFromString, createInstanceFromString, createInstanceFromXML, getCrossReferences, getId, getName, getPrimaryNamespace, getProvisionInfo, getTextContents, getValue, getXmlMode, hasCrossReferences, setId, setName, setPrimaryNamespace, setProvisionInfo, setXmlMode, toString
 
Methods inherited from class org.biomoby.shared.MobyPrimaryDataSimple
addNamespace, format, getDataType, getNamespaces, removeNamespace, removeNamespace, setDataType, setNamespaces
 
Methods inherited from class org.biomoby.shared.MobyPrimaryData
isPrimary
 
Methods inherited from class org.biomoby.shared.MobyData
getId, getName, getUserData, setUserData
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biomoby.shared.data.MobyDataInstance
getName, getUserData, setUserData
 

Field Detail

BASE64_DATATYPE

public static final String BASE64_DATATYPE
See Also:
Constant Field Values

ENCODED_MEMBER_NAME

public static final String ENCODED_MEMBER_NAME
See Also:
Constant Field Values

BYTE_READ_SIZE

public static final int BYTE_READ_SIZE
How much is read from a input stream (e.g. file) at once

See Also:
Constant Field Values
Constructor Detail

MobyDataBytes

public MobyDataBytes(Element element)
              throws MobyException
Construct the object using a DOM fragment.

Throws:
IllegalArgumentException - if the element is not a text-base64 tag, or doesn't inherit from it
MobyException

MobyDataBytes

public MobyDataBytes(Element element,
                     Registry registry)
              throws MobyException
Throws:
MobyException

MobyDataBytes

public MobyDataBytes(String name,
                     byte[] data)
              throws MobyException
C-tor to use when you have binary data to encode

Throws:
MobyException - if the data provided is null, or could not be encoded(?!)

MobyDataBytes

public MobyDataBytes(String name,
                     byte[] data,
                     Registry registry)
              throws MobyException
Throws:
MobyException

MobyDataBytes

public MobyDataBytes(String name,
                     byte[] data,
                     MobyDataType inputDataType)
              throws MobyException
C-tor to use when you have binary data to encode

Throws:
MobyException

MobyDataBytes

public MobyDataBytes(String name,
                     CharSequence data)
C-tor to use when you have received text-encoded binary. Currently Base64 encoding is acceptable, UU Decoding has yet to be implemented..


MobyDataBytes

public MobyDataBytes(String name,
                     CharSequence data,
                     Registry registry)

MobyDataBytes

public MobyDataBytes(String name,
                     CharSequence data,
                     MobyDataType inputDataType)
              throws MobyException
C-tor to use when you have received text-encoded binary. Currently Base64 encoding is acceptable, UU Decoding has yet to be implemented..

Throws:
MobyException

MobyDataBytes

public MobyDataBytes(String name,
                     URL resourceURL)
              throws MobyException,
                     IOException
C-tor to use when you want to encode a resource, such as an image file.

Parameters:
resourceURL - the URL of the resource to encode, such as "file:..." or "http:..."
Throws:
MobyException
IOException

MobyDataBytes

public MobyDataBytes(String name,
                     URL resourceURL,
                     Registry registry)
              throws MobyException,
                     IOException
Throws:
MobyException
IOException

MobyDataBytes

public MobyDataBytes(String name,
                     URL resourceURL,
                     MobyDataType inputDataType)
              throws IOException,
                     MobyException
C-tor to use when you want to encode a resource, such as an image file.

Parameters:
resourceURL - the URL of the resource to encode, such as "file:..." or "http:..."
Throws:
IOException
MobyException
Method Detail

getInputStream

public InputStream getInputStream()
Convenience method that returns an InputStream for use in image loaders, file savers, etc.


getObject

public Object getObject()
Description copied from class: MobyDataObject
Gives access to the Java object instance underlying the MobyData instance. For example, to change a MOBY String object, call ((StringBuffer) (data.getObject()).append("extra text to add to the end") In the case of a base Moby Object, there really is no underlying Java equivalent to return, so a java.lang.Object is returned for completeness's sake. possibly useful for notification events and pointer equivalency testing in derived classes such as MobyDataServiceAssocInstance?

Specified by:
getObject in interface MobyDataInstance
Overrides:
getObject in class MobyDataComposite
Returns:
byte[] representing the (mutable) underlying data in this object

getBytes

public byte[] getBytes()
The same as getObject, but doesn't require a cast of the result


Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010