jp.develop.common.util.amf.encoder
Class CollectionEncoder

java.lang.Object
  extended by jp.develop.common.util.amf.encoder.CollectionEncoder
All Implemented Interfaces:
IEncoder<Collection<Object>>, IEncoder.IArrayEncoder<Collection<Object>>
Direct Known Subclasses:
ArrayCollectionEncoder

public class CollectionEncoder
extends Object
implements IEncoder<Collection<Object>>, IEncoder.IArrayEncoder<Collection<Object>>

Implementation of IEncoder.IArrayEncoder for Collection.

Author:
Waki Takeya
See Also:
IEncoder, IEncoder.IArrayEncoder, ArrayEncoder

Nested Class Summary
 
Nested classes/interfaces inherited from interface jp.develop.common.util.amf.encoder.IEncoder
IEncoder.IArrayEncoder<T>, IEncoder.IDictionaryEncoder<T>, IEncoder.IObjectEncoder<T>
 
Constructor Summary
CollectionEncoder()
           
 
Method Summary
 void encode(AmfEncoder encoder, Collection<Object> collection)
          Encode to Action Message Format(AMF).
 int getArraySize(Collection<Object> collection)
          Get the size of array.
 Iterator<Object> getIterator(Collection<Object> collection)
          Get the iterator of specified array.
 Map<String,Object> getProperties(Collection<Object> collection)
          Get the properties of specified array.
 Object getValue(Collection<Object> collection, int index)
          Get the value of specified index.
 boolean isRandomAccess(Collection<Object> collection)
          Is this random access array?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionEncoder

public CollectionEncoder()
Method Detail

encode

public void encode(AmfEncoder encoder,
                   Collection<Object> collection)
            throws IOException
Encode to Action Message Format(AMF).

Specified by:
encode in interface IEncoder<Collection<Object>>
Parameters:
encoder - AMF encoder.
collection - Object to be encoded.
Throws:
IOException - I/O Exception.

getArraySize

public int getArraySize(Collection<Object> collection)
Get the size of array.

Specified by:
getArraySize in interface IEncoder.IArrayEncoder<Collection<Object>>
Parameters:
collection - Array to be encoded.
Returns:
The size of array.

isRandomAccess

public boolean isRandomAccess(Collection<Object> collection)
Is this random access array?

Specified by:
isRandomAccess in interface IEncoder.IArrayEncoder<Collection<Object>>
Returns:
true, if random access is available.

getIterator

public Iterator<Object> getIterator(Collection<Object> collection)
Get the iterator of specified array. If it is random access array, this method is not required to be implemented.

Specified by:
getIterator in interface IEncoder.IArrayEncoder<Collection<Object>>
Parameters:
collection - Array to be encoded.
Returns:
Iterator of specified array.

getValue

public Object getValue(Collection<Object> collection,
                       int index)
Get the value of specified index. If it is not random access array, this method is not required to be implemented.

Specified by:
getValue in interface IEncoder.IArrayEncoder<Collection<Object>>
Parameters:
collection - Array to be encoded.
index - Target index.
Returns:
The value of specified index.

getProperties

public Map<String,Object> getProperties(Collection<Object> collection)
Get the properties of specified array. This is for associative portion.

Specified by:
getProperties in interface IEncoder.IArrayEncoder<Collection<Object>>
Returns:
Properties of specified array. Null means that there is no property.