in core/src/main/java/flex/messaging/io/amf/Amf0Output.java [130:206]
public void writeObject(Object o) throws IOException {
if (o == null) {
writeAMFNull();
return;
}
if (o instanceof String) {
writeAMFString((String) o);
} else if (o instanceof Number) {
if (!context.legacyBigNumbers &&
(o instanceof BigInteger || o instanceof BigDecimal)) {
// Using double to write big numbers such as BigInteger or
// BigDecimal can result in information loss so we write
// them as String by default...
writeAMFString((o).toString());
} else {
writeAMFDouble(((Number) o).doubleValue());
}
} else if (o instanceof Boolean) {
writeAMFBoolean(((Boolean) o).booleanValue());
} else if (o instanceof Character) {
String s = o.toString();
writeAMFString(s);
} else if (o instanceof Date) {
// Note that dates are not considered complex types in AMF 0
writeAMFDate((Date) o);
} else if (o instanceof Calendar) {
writeAMFDate(((Calendar) o).getTime());
}
// If there is a proxy for this,write it as a custom object so the default
// behavior can be overriden.
else if (o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null) {
Enum<?> enumValue = (Enum<?>) o;
writeAMFString(enumValue.name());
} else {
// We have a complex object.
// If we're using AMF 3, delegate to AVM+ encoding format
if (avmPlus) {
if (avmPlusOutput == null) {
createAMF3Output();
}
out.writeByte(kAvmPlusObjectType);
avmPlusOutput.writeObject(o);
} else {
Class cls = o.getClass();
if (cls.isArray()) {
writeAMFArray(o, cls.getComponentType());
} else if (o instanceof Map && context.legacyMap && !(o instanceof ASObject)) {
writeMapAsECMAArray((Map) o);
} else if (o instanceof Collection) {
if (context.legacyCollection)
writeCollection((Collection) o, null);
else
writeArrayCollection((Collection) o, null);
} else if (o instanceof org.w3c.dom.Document) {
out.write(kXMLObjectType);
String xml = documentToString(o);
if (isDebug)
trace.write(xml);
writeUTF(xml, true, false);
} else {
// Special Case: wrap RowSet in PageableRowSet for Serialization
if (o instanceof RowSet) {
o = new PagedRowSet((RowSet) o, Integer.MAX_VALUE, false);
} else if (o instanceof Throwable && context.legacyThrowable) {
o = new StatusInfoProxy((Throwable) o);
}
writeCustomObject(o);
}
}
}
}