kr.co.hit.live.web.flex.io.amf
Class Amf3OutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.DataOutputStream
              extended by kr.co.hit.live.web.flex.io.amf.AmfOutputStream
                  extended by kr.co.hit.live.web.flex.io.amf.Amf3OutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput

public class Amf3OutputStream
extends AmfOutputStream

AMF3 방식으로 객체를 OutputStream으로 직렬화한다.

Author:
김형도

Field Summary
protected  Map<Object,Integer> objectRefTable
          한번 사용된 객체들을 담아둔다.
protected  Map<String,Integer> stringRefTable
          한번 사용된 문자열을 그 인덱스와 함께 담아둔다.
protected  Map<ObjectTraits,Integer> traitsRefTable
          한번 사용된 ObjectTraits 객체를 그 인덱스와 함께 담아둔다.
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
Amf3OutputStream(OutputStream out)
           
 
Method Summary
protected  String getASName(Object obj)
          return ActionScript object classname
protected  List<String> getPropertyNames(Object obj)
           
protected  Object getValue(Object obj, String name)
           
 void reset()
           
protected  void writeArray(Object[] obj)
           
protected  void writeASObject(Object obj)
           
protected  void writeBoolean(Boolean b)
           
protected  void writeBooleanArray(boolean[] a)
           
protected  void writeBooleanArray(Boolean[] a)
           
protected  void writeByteArray(byte[] ba)
           
protected  void writeByteArray(Byte[] ba)
           
protected  void writeCharArray(char[] ca)
          String 형태로 전송한다.
protected  void writeCharArray(Character[] ca)
          String 형태로 전송한다.
protected  void writeCollection(Collection<?> c)
           
protected  void writeDate(Date d)
           
protected  void writeDouble(double d, boolean mark)
           
protected  void writeDoubleArray(double[] a)
           
protected  void writeDoubleArray(Number[] a)
           
protected  void writeFloatArray(float[] a)
           
protected  void writeInt(int i, boolean mark)
           
protected  void writeIntArray(int[] a)
           
protected  void writeIntArray(Number[] a)
           
protected  void writeLongArray(long[] a)
           
protected  void writeNumber(Number num)
           
 void writeObject(Object obj)
           
protected  void writeObjectArray(Object[] oa)
           
protected  boolean writeObjectReference(Object obj)
          객체가 이미 사용된 경우에는 객체의 reference를 전송하고 true를 반환한다.
protected  void writeShortArray(short[] a)
           
protected  void writeString(String s, boolean marker)
          AMF3 Spec의 string-type으로 전송한다.
protected  boolean writeStringReference(String s)
          해당 문자열의 reference를 전송하고 true를 반환한다.
protected  boolean writeTraitsReference(ObjectTraits traits)
          객체의 Traits 정보에 대한 reference를 전송하고 true를 반환한다.
protected  void writeUTF8(String s)
          AMF3 Spec의 U29S-value *(UTF8-char) 타입 또는 U29X-value *(UTF8-char) 타입으로 전송한다.
protected  void writeXML(Document doc)
           
 
Methods inherited from class kr.co.hit.live.web.flex.io.amf.AmfOutputStream
encodeUTF, getBuffer, writeS16, writeU16, writeU29, writeU32
 
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.ObjectOutput
close, flush, write, write, write
 
Methods inherited from interface java.io.DataOutput
writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 

Field Detail

stringRefTable

protected Map<String,Integer> stringRefTable
한번 사용된 문자열을 그 인덱스와 함께 담아둔다.


objectRefTable

protected Map<Object,Integer> objectRefTable
한번 사용된 객체들을 담아둔다. 객체의 주소값을 사용하여 비교하도록 IdentityHashMap을 사용한다.


traitsRefTable

protected Map<ObjectTraits,Integer> traitsRefTable
한번 사용된 ObjectTraits 객체를 그 인덱스와 함께 담아둔다.

Constructor Detail

Amf3OutputStream

public Amf3OutputStream(OutputStream out)
Method Detail

reset

public void reset()
Specified by:
reset in class AmfOutputStream

writeObject

public void writeObject(Object obj)
                 throws IOException
Specified by:
writeObject in interface ObjectOutput
Specified by:
writeObject in class AmfOutputStream
Throws:
IOException

writeXML

protected void writeXML(Document doc)
                 throws IOException
Throws:
IOException

writeNumber

protected void writeNumber(Number num)
                    throws IOException
Throws:
IOException

writeArray

protected void writeArray(Object[] obj)
                   throws IOException
Throws:
IOException

writeIntArray

protected void writeIntArray(int[] a)
                      throws IOException
Throws:
IOException

writeIntArray

protected void writeIntArray(Number[] a)
                      throws IOException
Throws:
IOException

writeShortArray

protected void writeShortArray(short[] a)
                        throws IOException
Throws:
IOException

writeLongArray

protected void writeLongArray(long[] a)
                       throws IOException
Throws:
IOException

writeFloatArray

protected void writeFloatArray(float[] a)
                        throws IOException
Throws:
IOException

writeDoubleArray

protected void writeDoubleArray(double[] a)
                         throws IOException
Throws:
IOException

writeDoubleArray

protected void writeDoubleArray(Number[] a)
                         throws IOException
Throws:
IOException

writeBooleanArray

protected void writeBooleanArray(boolean[] a)
                          throws IOException
Throws:
IOException

writeBooleanArray

protected void writeBooleanArray(Boolean[] a)
                          throws IOException
Throws:
IOException

writeByteArray

protected void writeByteArray(byte[] ba)
                       throws IOException
Throws:
IOException

writeByteArray

protected void writeByteArray(Byte[] ba)
                       throws IOException
Throws:
IOException

writeCharArray

protected void writeCharArray(char[] ca)
                       throws IOException
String 형태로 전송한다.

Parameters:
ca -
Throws:
IOException

writeCharArray

protected void writeCharArray(Character[] ca)
                       throws IOException
String 형태로 전송한다.

Parameters:
ca -
Throws:
IOException

writeObjectArray

protected void writeObjectArray(Object[] oa)
                         throws IOException
Throws:
IOException

writeCollection

protected void writeCollection(Collection<?> c)
                        throws IOException
Throws:
IOException

writeString

protected void writeString(String s,
                           boolean marker)
                    throws IOException
AMF3 Spec의 string-type으로 전송한다.

Parameters:
s -
Throws:
IOException

writeUTF8

protected void writeUTF8(String s)
                  throws IOException
AMF3 Spec의 U29S-value *(UTF8-char) 타입 또는 U29X-value *(UTF8-char) 타입으로 전송한다.

Parameters:
s -
Throws:
IOException

writeBoolean

protected void writeBoolean(Boolean b)
                     throws IOException
Throws:
IOException

writeDate

protected void writeDate(Date d)
                  throws IOException
Throws:
IOException

writeDouble

protected void writeDouble(double d,
                           boolean mark)
                    throws IOException
Throws:
IOException

writeInt

protected void writeInt(int i,
                        boolean mark)
                 throws IOException
Throws:
IOException

writeASObject

protected void writeASObject(Object obj)
                      throws IOException
Throws:
IOException

writeStringReference

protected boolean writeStringReference(String s)
                                throws IOException
해당 문자열의 reference를 전송하고 true를 반환한다. 해당 문자열이 없으면 stringRefTable에 저장하고 false를 반환한다.

Parameters:
s -
Returns:
Throws:
IOException

writeTraitsReference

protected boolean writeTraitsReference(ObjectTraits traits)
                                throws IOException
객체의 Traits 정보에 대한 reference를 전송하고 true를 반환한다. 해당 traits가 없으면 traitsRefTable에 저장하고 false를 반환한다.

Parameters:
traits -
Returns:
Throws:
IOException

writeObjectReference

protected boolean writeObjectReference(Object obj)
                                throws IOException
객체가 이미 사용된 경우에는 객체의 reference를 전송하고 true를 반환한다. 그렇지 않은 경우엔 objectRefTable에 저장하고 false를 반환한다.

Parameters:
obj -
Returns:
Throws:
IOException

getPropertyNames

protected List<String> getPropertyNames(Object obj)

getASName

protected String getASName(Object obj)
return ActionScript object classname

Parameters:
obj -
Returns:

getValue

protected Object getValue(Object obj,
                          String name)


Copyright © 2014. All Rights Reserved.