org.red5.io.amf

## Class Output

- java.lang.Object
- - org.red5.io.object.BaseOutput
  - - org.red5.io.amf.Output

All Implemented Interfaces:
  Output

Direct Known Subclasses:
  Output

    public class Output
    extends BaseOutput
    implements Output

Author:
  The Red5 Project (red5@osflash.org), Luke Hubbard, Codegent Ltd (luke@codegent.com), Paul Gregoire (mondain@gmail.com), Harald Radi (harald.radi@nme.at)

### Field Summary

Fields
`protected IoBuffer` `buf` Output buffer
`protected static org.slf4j.Logger` `log`

### Fields inherited from class org.red5.io.object.BaseOutput

`refId, refMap`

### Constructor Summary

Constructors
Constructor and Description
`Output(IoBuffer buf)` Creates output with given byte buffer

### Method Summary

Methods
`IoBuffer` `buf()` Return buffer of this Output object
`protected boolean` `checkWriteReference(Object obj)`
`static void` `destroyCache()`
`protected static byte[]` `encodeString(String string)` Encode string.
`protected Field` `getField(Class<?> objectClass, String keyName)`
`protected static net.sf.ehcache.Cache` `getFieldCache()`
`protected Method` `getGetter(Class<?> objectClass, org.apache.commons.beanutils.BeanMap beanMap, String keyName)`
`protected static net.sf.ehcache.Cache` `getGetterCache()`
`protected static net.sf.ehcache.Cache` `getSerializeCache()`
`protected static net.sf.ehcache.Cache` `getStringCache()`
`boolean` `isCustom(Object custom)` Whether object is custom
`static void` `putString(IoBuffer buf, String string)` Write out string
`void` `putString(String string)`
`void` `reset()`
`protected boolean` `serializeField(Serializer serializer, Class<?> objectClass, String keyName, Field field, Method getter)`
`boolean` `supportsDataType(byte type)`
`protected void` `writeArbitraryObject(Object object, Serializer serializer)` Writes an arbitrary object to the output.
`void` `writeArray(Collection<?> array, Serializer serializer)` Write array.
`void` `writeArray(Object[] array, Serializer serializer)` Write array.
`void` `writeArray(Object array, Serializer serializer)` Write primitive array.
`void` `writeBoolean(Boolean bol)` Write boolean
`void` `writeByteArray(ByteArray array)` Write ByteArray object (AMF3 only).
`void` `writeCustom(Object custom)` Write custom (user) object
`void` `writeDate(Date date)` Write date
`void` `writeMap(Collection<?> array, Serializer serializer)` Write array as map.
`void` `writeMap(Map<Object,Object> map, Serializer serializer)` Write map.
`void` `writeNull()`
`void` `writeNumber(Number num)` Write number
`void` `writeObject(Map<Object,Object> map, Serializer serializer)` Write map as object.
`void` `writeObject(Object object, Serializer serializer)` Write object.
`void` `writeRecordSet(RecordSet recordset, Serializer serializer)` Write recordset.
`void` `writeReference(Object obj)` Write reference to complex data type
`void` `writeString(String string)` Write string
`void` `writeVectorInt(Vector<Integer> vector)` Write a Vector<int>.
`void` `writeVectorNumber(Vector<Double> vector)` Write a Vector<Number>.
`void` `writeVectorObject(Vector<Object> vector)` Write a Vector
`void` `writeVectorUInt(Vector<Long> vector)` Write a Vector<uint>.
`void` `writeXML(Document xml)` Write XML object
`void` `writeXML(String xml)` Convenience method to allow XML text to be used, instead of requiring an XML Document.

### Methods inherited from class org.red5.io.object.BaseOutput

`clearReferences, getReferenceId, hasReference, storeReference`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.red5.io.object.Output

`clearReferences`

### Field Detail

#### log

    protected static org.slf4j.Logger log

#### buf

    protected IoBuffer buf

Output buffer

### Constructor Detail

#### Output

    public Output(IoBuffer buf)

Creates output with given byte buffer

Parameters:
  `buf` - Bute buffer

### Method Detail

#### isCustom

    public boolean isCustom(Object custom)

Whether object is custom

Specified by:
  `isCustom` in interface `Output`
Parameters:
  `custom` - Object
Returns:
  true if object is of user type, false otherwise

#### checkWriteReference

    protected boolean checkWriteReference(Object obj)

#### writeArray

    public void writeArray(Collection<?> array,
                  Serializer serializer)

Write array.

Specified by:
  `writeArray` in interface `Output`
Parameters:
  `array` - Array to write.
  `serializer` - Serializer to use for subobjects.

#### writeArray

    public void writeArray(Object[] array,
                  Serializer serializer)

Write array.

Specified by:
  `writeArray` in interface `Output`
Parameters:
  `array` - Array to write.
  `serializer` - Serializer to use for subobjects.

#### writeArray

    public void writeArray(Object array,
                  Serializer serializer)

Write primitive array.

Specified by:
  `writeArray` in interface `Output`
Parameters:
  `array` - Array to write.
  `serializer` - Serializer to use for subobjects.

#### writeMap

    public void writeMap(Map<Object,Object> map,
                Serializer serializer)

Write map.

Specified by:
  `writeMap` in interface `Output`
Parameters:
  `map` - Map to write
  `serializer` - Serializer to use for subobjects.

#### writeMap

    public void writeMap(Collection<?> array,
                Serializer serializer)

Write array as map.

Specified by:
  `writeMap` in interface `Output`
Parameters:
  `array` - Array to write
  `serializer` - Serializer to use for subobjects.

#### writeRecordSet

    public void writeRecordSet(RecordSet recordset,
                      Serializer serializer)

Write recordset.

Specified by:
  `writeRecordSet` in interface `Output`
Parameters:
  `recordset` - Recordset to write.
  `serializer` - Serializer to use for subobjects.

#### supportsDataType

    public boolean supportsDataType(byte type)

Specified by:
  `supportsDataType` in interface `Output`

#### writeBoolean

    public void writeBoolean(Boolean bol)

Write boolean

Specified by:
  `writeBoolean` in interface `Output`
Parameters:
  `bol` - Boolean

#### writeCustom

    public void writeCustom(Object custom)

Write custom (user) object

Specified by:
  `writeCustom` in interface `Output`
Parameters:
  `custom` - Custom data type object

#### writeDate

    public void writeDate(Date date)

Write date

Specified by:
  `writeDate` in interface `Output`
Parameters:
  `date` - Date

#### writeNull

    public void writeNull()

Specified by:
  `writeNull` in interface `Output`

#### writeNumber

    public void writeNumber(Number num)

Write number

Specified by:
  `writeNumber` in interface `Output`
Parameters:
  `num` - Number

#### writeReference

    public void writeReference(Object obj)

Write reference to complex data type

Specified by:
  `writeReference` in interface `Output`
Parameters:
  `obj` - Referenced object

#### writeObject

    public void writeObject(Object object,
                   Serializer serializer)

Write object.

Specified by:
  `writeObject` in interface `Output`
Parameters:
  `object` - Object to write
  `serializer` - Serializer to use for subobjects.

#### serializeField

    protected boolean serializeField(Serializer serializer,
                         Class<?> objectClass,
                         String keyName,
                         Field field,
                         Method getter)

#### getField

    protected Field getField(Class<?> objectClass,
                 String keyName)

#### getGetter

    protected Method getGetter(Class<?> objectClass,
                   org.apache.commons.beanutils.BeanMap beanMap,
                   String keyName)

#### writeObject

    public void writeObject(Map<Object,Object> map,
                   Serializer serializer)

Write map as object.

Specified by:
  `writeObject` in interface `Output`
Parameters:
  `map` - Map to write
  `serializer` - Serializer to use for subobjects.

#### writeArbitraryObject

    protected void writeArbitraryObject(Object object,
                            Serializer serializer)

Writes an arbitrary object to the output.

Parameters:
  `serializer` - Output writer
  `object` - Object to write

#### writeString

    public void writeString(String string)

Write string

Specified by:
  `writeString` in interface `Output`
Parameters:
  `string` - String

#### writeByteArray

    public void writeByteArray(ByteArray array)

Write ByteArray object (AMF3 only).

Specified by:
  `writeByteArray` in interface `Output`
Parameters:
  `array` - object to write

#### writeVectorInt

    public void writeVectorInt(Vector<Integer> vector)

Write a Vector<int>.

Specified by:
  `writeVectorInt` in interface `Output`

#### writeVectorUInt

    public void writeVectorUInt(Vector<Long> vector)

Write a Vector<uint>.

Specified by:
  `writeVectorUInt` in interface `Output`

#### writeVectorNumber

    public void writeVectorNumber(Vector<Double> vector)

Write a Vector<Number>.

Specified by:
  `writeVectorNumber` in interface `Output`

#### writeVectorObject

    public void writeVectorObject(Vector<Object> vector)

Write a Vector

Specified by:
  `writeVectorObject` in interface `Output`

#### encodeString

    protected static byte[] encodeString(String string)

Encode string.

Parameters:
  `string` -
Returns:
  encoded string

#### putString

    public static void putString(IoBuffer buf,
                 String string)

Write out string

Parameters:
  `buf` - Byte buffer to write to
  `string` - String to write

#### putString

    public void putString(String string)

Specified by:
  `putString` in interface `Output`

#### writeXML

    public void writeXML(Document xml)

Write XML object

Specified by:
  `writeXML` in interface `Output`
Parameters:
  `xml` - XML document

#### writeXML

    public void writeXML(String xml)

Convenience method to allow XML text to be used, instead of requiring an XML Document.

Parameters:
  `xml` - xml to write

#### buf

    public IoBuffer buf()

Return buffer of this Output object

Returns:
  Byte buffer of this Output object

#### reset

    public void reset()

#### getStringCache

    protected static net.sf.ehcache.Cache getStringCache()

#### getSerializeCache

    protected static net.sf.ehcache.Cache getSerializeCache()

#### getFieldCache

    protected static net.sf.ehcache.Cache getFieldCache()

#### getGetterCache

    protected static net.sf.ehcache.Cache getGetterCache()

#### destroyCache

    public static void destroyCache()