jp.develop.common.util.amf
Class AmfEncoder

java.lang.Object
  extended by jp.develop.common.util.amf.AmfEncoder
All Implemented Interfaces:
DataOutput, ObjectOutput

public class AmfEncoder
extends Object
implements ObjectOutput

Main class of AMF encoder. This class implements ObjectOutput for the encode of externalizable object.

Author:
Waki Takeya
See Also:
AmfUtil

Constructor Summary
AmfEncoder(OutputStream out)
          Constructs a instance with specified output stream.
AmfEncoder(OutputStream out, AmfEncoderOption option)
          Constructs a instance with specified output stream and configuration option.
 
Method Summary
 void close()
          
 void flush()
          
 void write(byte[] b)
          
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
<T> void
writeAmfArray(IEncoder.IArrayEncoder<T> encoder, T array)
          Write array by AMF manner.
<T> void
writeAmfArray(IEncoder.IArrayEncoder<T> encoder, T array, boolean useReference)
          Write array by AMF manner with reference control.
 void writeAmfBoolean(boolean value)
          Write boolean by AMF manner.
 void writeAmfByteArray(byte[] bytes)
          Write byte array by AMF manner.
 void writeAmfDate(Date date)
          Write date by AMF manner.
<T> void
writeAmfDictionary(IEncoder.IDictionaryEncoder<T> encoder, T object)
          Write dictionary by AMF manner.
 void writeAmfDouble(double value)
          Write double by AMF manner.
 void writeAmfInteger(int value)
          Write integer by AMF manner.
 void writeAmfNull()
          Write null by AMF manner.
<T> void
writeAmfObject(IEncoder.IObjectEncoder<T> encoder, T object)
          Write object by AMF manner.
 void writeAmfString(String string)
          Write string by AMF manner.
 void writeAmfUndefined()
          Write undefined by AMF manner.
 void writeAmfXml(String xml)
          Write XML by AMF manner(Not implemented) UnsupportedOperationException is just thrown.
 void writeAmfXmlDocument(String xml)
          Write XML document by AMF manner.
 void writeBoolean(boolean v)
          
 void writeByte(int v)
          
 void writeBytes(String s)
          
 void writeChar(int v)
          
 void writeChars(String s)
          
 void writeDouble(double v)
          
 void writeFloat(float v)
          
 void writeInt(int v)
          
 void writeLong(long v)
          
 void writeObject(Object obj)
          Write object encoded by AMF.
 void writeShort(int v)
          
 void writeStringOrReference(String string)
          Write string by AMF manner(without marker).
 void writeU29(int value)
          Write unsigned integer(29bit) by AMF manner.
 void writeUTF(String s)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmfEncoder

public AmfEncoder(OutputStream out)
Constructs a instance with specified output stream.

Parameters:
out - Output stream.

AmfEncoder

public AmfEncoder(OutputStream out,
                  AmfEncoderOption option)
Constructs a instance with specified output stream and configuration option.

Parameters:
out - Output stream.
option - Configuration option.
Method Detail

writeObject

public void writeObject(Object obj)
                 throws IOException
Write object encoded by AMF.

Specified by:
writeObject in interface ObjectOutput
Parameters:
obj - The object to be encoded.
Throws:
IOException - I/O Exception.

writeAmfUndefined

public final void writeAmfUndefined()
                             throws IOException
Write undefined by AMF manner. This method is not used for default configuration.

Throws:
IOException - I/O Exception.

writeAmfNull

public final void writeAmfNull()
                        throws IOException
Write null by AMF manner.

Throws:
IOException - I/O Exception.

writeAmfBoolean

public final void writeAmfBoolean(boolean value)
                           throws IOException
Write boolean by AMF manner.

Parameters:
value - The value to be encoded.
Throws:
IOException - I/O Exception.

writeAmfInteger

public final void writeAmfInteger(int value)
                           throws IOException
Write integer by AMF manner.

Parameters:
value - The value to be encoded.
Throws:
IOException - I/O Exception.

writeAmfDouble

public final void writeAmfDouble(double value)
                          throws IOException
Write double by AMF manner.

Parameters:
value - The value to be encoded.
Throws:
IOException - I/O Exception.

writeAmfString

public final void writeAmfString(String string)
                          throws IOException
Write string by AMF manner.

Parameters:
string - The string to be encoded.
Throws:
IOException - I/O Exception.

writeAmfXmlDocument

public final void writeAmfXmlDocument(String xml)
                               throws IOException
Write XML document by AMF manner.

Parameters:
xml - The XML string to be encoded.
Throws:
IOException - I/O Exception.

writeAmfDate

public final void writeAmfDate(Date date)
                        throws IOException
Write date by AMF manner.

Parameters:
date - The date to be encoded.
Throws:
IOException - I/O Exception.

writeAmfArray

public final <T> void writeAmfArray(IEncoder.IArrayEncoder<T> encoder,
                                    T array)
                         throws IOException
Write array by AMF manner.

Type Parameters:
T - The type of array to be encoded.
Parameters:
encoder - The encoder for specified array.
array - The array to be encoded.
Throws:
IOException - I/O Exception.

writeAmfArray

public final <T> void writeAmfArray(IEncoder.IArrayEncoder<T> encoder,
                                    T array,
                                    boolean useReference)
                         throws IOException
Write array by AMF manner with reference control. Usually this method should not be used.

Type Parameters:
T - The type of array to be encoded.
Parameters:
encoder - The encoder for specified array.
array - The array to be encoded.
useReference - true for using reference.
Throws:
IOException - I/O Exception.

writeAmfObject

public final <T> void writeAmfObject(IEncoder.IObjectEncoder<T> encoder,
                                     T object)
                          throws IOException
Write object by AMF manner.

Type Parameters:
T - The type of object to be encoded.
Parameters:
encoder - The encoder for specified object.
object - The object to be encoded.
Throws:
IOException - I/O Exception.

writeAmfDictionary

public final <T> void writeAmfDictionary(IEncoder.IDictionaryEncoder<T> encoder,
                                         T object)
                              throws IOException
Write dictionary by AMF manner.

Type Parameters:
T - The type of dictionary to be encoded.
Parameters:
encoder - The encoder for specified array.
object - The dictionary to be encoded.
Throws:
IOException - I/O Exception.

writeAmfXml

public final void writeAmfXml(String xml)
                       throws IOException
Write XML by AMF manner(Not implemented) UnsupportedOperationException is just thrown.

Parameters:
xml - The XML to be encoded.
Throws:
IOException - I/O Exception.

writeAmfByteArray

public final void writeAmfByteArray(byte[] bytes)
                             throws IOException
Write byte array by AMF manner.

Parameters:
bytes - The byte array to be encoded.
Throws:
IOException - I/O Exception.

writeU29

public final void writeU29(int value)
                    throws IOException
Write unsigned integer(29bit) by AMF manner.

Parameters:
value - The value to be encoded.
Throws:
IOException - I/O Exception.

writeStringOrReference

public final void writeStringOrReference(String string)
                                  throws IOException
Write string by AMF manner(without marker).

Parameters:
string - The string to be encoded.
Throws:
IOException - I/O Exception.

writeBoolean

public void writeBoolean(boolean v)
                  throws IOException

Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte

public void writeByte(int v)
               throws IOException

Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeBytes

public void writeBytes(String s)
                throws IOException

Specified by:
writeBytes in interface DataOutput
Throws:
IOException

writeChar

public void writeChar(int v)
               throws IOException

Specified by:
writeChar in interface DataOutput
Throws:
IOException

writeChars

public void writeChars(String s)
                throws IOException

Specified by:
writeChars in interface DataOutput
Throws:
IOException

writeDouble

public void writeDouble(double v)
                 throws IOException

Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeFloat

public void writeFloat(float v)
                throws IOException

Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeInt

public void writeInt(int v)
              throws IOException

Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong

public void writeLong(long v)
               throws IOException

Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeShort

public void writeShort(int v)
                throws IOException

Specified by:
writeShort in interface DataOutput
Throws:
IOException

writeUTF

public void writeUTF(String s)
              throws IOException

Specified by:
writeUTF in interface DataOutput
Throws:
IOException

write

public void write(int b)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

write

public void write(byte[] b)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

flush

public void flush()
           throws IOException

Specified by:
flush in interface ObjectOutput
Throws:
IOException

close

public void close()
           throws IOException

Specified by:
close in interface ObjectOutput
Throws:
IOException