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

java.lang.Object
  extended by jp.develop.common.util.amf.encoder.ArrayEncoder
All Implemented Interfaces:
IEncoder<Object>, IEncoder.IArrayEncoder<Object>

public class ArrayEncoder
extends Object
implements IEncoder<Object>, IEncoder.IArrayEncoder<Object>

Implementation of IEncoder.IArrayEncoder for Array.

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

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
ArrayEncoder()
           
 
Method Summary
 void encode(AmfEncoder encoder, Object object)
          Encode to Action Message Format(AMF).
 int getArraySize(Object object)
          Get the size of array.
 Iterator<Object> getIterator(Object object)
          Get the iterator of specified array.
 Map<String,Object> getProperties(Object object)
          Get the properties of specified array.
 Object getValue(Object object, int index)
          Get the value of specified index.
 boolean isRandomAccess(Object object)
          Is this random access array?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayEncoder

public ArrayEncoder()
Method Detail

encode

public void encode(AmfEncoder encoder,
                   Object object)
            throws IOException
Encode to Action Message Format(AMF).

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

getArraySize

public int getArraySize(Object object)
Get the size of array.

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

isRandomAccess

public boolean isRandomAccess(Object object)
Is this random access array?

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

getIterator

public Iterator<Object> getIterator(Object object)
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<Object>
Parameters:
object - Array to be encoded.
Returns:
Iterator of specified array.

getValue

public Object getValue(Object object,
                       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<Object>
Parameters:
object - Array to be encoded.
index - Target index.
Returns:
The value of specified index.

getProperties

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

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