protected void writeAMF3IntegerData(int i) throws IOException { if (debugMore) logMore.debug("writeAMF3IntegerData(i=%d)", i); if (i < AMF3_INTEGER_MIN || i > AMF3_INTEGER_MAX) throw new IllegalArgumentException("Integer out of range: " + i); if (i < 0 || i >= 0x200000) { write(((i >> 22) & 0x7F) | 0x80); write(((i >> 15) & 0x7F) | 0x80); write(((i >> 8) & 0x7F) | 0x80); write(i & 0xFF); } else { if (i >= 0x4000) write(((i >> 14) & 0x7F) | 0x80); if (i >= 0x80) write(((i >> 7) & 0x7F) | 0x80); write(i & 0x7F); } }
protected void writeAMF3String(String s) throws IOException { if (debugMore) logMore.debug("writeAMF3String(s=%s)", s); write(AMF3_STRING); writeAMF3StringData(s); }
protected void writeAMF3Number(double d) throws IOException { if (debugMore) logMore.debug("writeAMF3Number(d=%f)", d); write(AMF3_NUMBER); writeDouble(d); }
write(AMF3_NULL); else if (!(o instanceof Externalizable)) { write(AMF3_NULL); else if (o instanceof String || o instanceof Character) writeAMF3String(o.toString()); else if (o instanceof Boolean) write(((Boolean)o).booleanValue() ? AMF3_BOOLEAN_TRUE : AMF3_BOOLEAN_FALSE); else if (o instanceof Number) { if (o instanceof Integer || o instanceof Short || o instanceof Byte)
protected void writeAMF3Object(Object o) throws IOException { if (debug) log.debug("writeAMF3Object(o=%s)...", o); write(AMF3_OBJECT);
protected void writeAMF3Array(Object array) throws IOException { if (debugMore) logMore.debug("writeAMF3Array(array=%s)", array); write(AMF3_ARRAY); int index = indexOfStoredObjects(array); if (index >= 0) writeAMF3IntegerData(index << 1); else { addToStoredObjects(array); int length = Array.getLength(array); writeAMF3IntegerData(length << 1 | 0x01); write(0x01); for (int i = 0; i < length; i++) writeObject(Array.get(array, i)); } }
protected void writeAMF3Integer(int i) throws IOException { if (debugMore) logMore.debug("writeAMF3Integer(i=%d)", i); if (i < AMF3_INTEGER_MIN || i > AMF3_INTEGER_MAX) { if (debugMore) logMore.debug("writeAMF3Integer() - %d is out of AMF3 int range, writing it as a Number", i); writeAMF3Number(i); } else { write(AMF3_INTEGER); writeAMF3IntegerData(i); } }
protected void writeAMF3Date(Date date) throws IOException { if (debugMore) logMore.debug("writeAMF3Date(date=%s)", date); write(AMF3_DATE); int index = indexOfStoredObjects(date); if (index >= 0) writeAMF3IntegerData(index << 1); else { addToStoredObjects(date); writeAMF3IntegerData(0x01); writeDouble(date.getTime()); } }
protected void writeAMF3ByteArray(byte[] bytes) throws IOException { if (debugMore) logMore.debug("writeAMF3ByteArray(bytes=%s)", bytes); write(AMF3_BYTEARRAY); int index = indexOfStoredObjects(bytes); if (index >= 0) writeAMF3IntegerData(index << 1); else { addToStoredObjects(bytes); writeAMF3IntegerData(bytes.length << 1 | 0x01); //write(bytes); for (int i = 0; i < bytes.length; i++) out.write(bytes[i]); } }
protected void writeAMF3Xml(Document doc) throws IOException { if (debugMore) logMore.debug("writeAMF3Xml(doc=%s)", doc); byte xmlType = AMF3_XMLSTRING; Channel channel = getChannel(); if (channel != null && channel.isLegacyXmlSerialization()) xmlType = AMF3_XML; write(xmlType); int index = indexOfStoredObjects(doc); if (index >= 0) writeAMF3IntegerData(index << 1); else { addToStoredObjects(doc); byte[] bytes = xmlUtil.toString(doc).getBytes("UTF-8"); writeAMF3IntegerData((bytes.length << 1) | 0x01); write(bytes); } }