currentBody.setData(value);
}
else
{
throw new MessageException("Unexpected value: " + value);
}
return;
}
// ActionScript Data
Object obj = objectStack.peek();
// <object type="..."> <traits externalizable="true">
if (obj instanceof Externalizable)
{
if (value != null && value.getClass().isArray() && Byte.TYPE.equals(value.getClass().getComponentType()))
{
Externalizable extern = (Externalizable)obj;
Amf3Input objIn = new Amf3Input(context);
byte[] ba = (byte[])value;
ByteArrayInputStream baIn = new ByteArrayInputStream(ba);
try
{
//objIn.setDebugTrace(trace);
objIn.setInputStream(baIn);
extern.readExternal(objIn);
}
catch (ClassNotFoundException ex)
{
throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
}
catch (IOException ex)
{
throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
}
finally
{
try
{
objIn.close();
}
catch (IOException ex)
{
}
}
}
else
{
throw new MessageException("Error while reading Externalizable class. Value must be a byte array.");
}
}
// <object>
else if (obj instanceof ASObject)
{
String prop;
TraitsContext traitsContext = (TraitsContext)traitsStack.peek();
try
{
prop = traitsContext.next();
}
catch (IndexOutOfBoundsException ex)
{
throw new MessageException("Object has no trait info for value: " + value);
}
ASObject aso = (ASObject)obj;
aso.put(prop, value);
if (isDebug)
trace.namedElement(prop);
}
// <array ecma="false"> in ArrayList form
else if (obj instanceof ArrayList && !(obj instanceof ArrayCollection))
{
ArrayList list = (ArrayList)obj;
list.add(value);
if (isDebug)
trace.arrayElement(list.size() - 1);
}
// <array ecma="false"> in Object[] form
else if (obj.getClass().isArray())
{
if (!strictArrayIndexStack.empty())
{
int[] indexObj = (int[])strictArrayIndexStack.peek();
int index = indexObj[0];
if (Array.getLength(obj) > index)
{
Array.set(obj, index, value);
}
else
{
throw new MessageException("Index out of bounds at: " + index + " cannot set array value: " + value + "");
}
indexObj[0]++;
}
}
// <array ecma="true">
else if (obj instanceof Map)
{
Map map = (Map)obj;
// <item name="prop">
if (!arrayPropertyStack.empty())
{
String prop = (String)arrayPropertyStack.peek();
map.put(prop, value);
if (isDebug)
trace.namedElement(prop);
return;
}
// Mixed content, auto-generate string for ECMA Array index
if (!ecmaArrayIndexStack.empty())
{
int[] index = (int[])ecmaArrayIndexStack.peek();
String prop = String.valueOf(index[0]);
index[0]++;
map.put(prop, value);
if (isDebug)
trace.namedElement(prop);
}
}
// <object type="...">
else
{
String prop;
TraitsContext traitsContext = (TraitsContext)traitsStack.peek();
try
{
prop = traitsContext.next();
}
catch (IndexOutOfBoundsException ex)
{
throw new MessageException("Object has no trait info for value: " + value, ex);
}
try
{
// Then check if there's a more suitable proxy now that we have an instance
PropertyProxy proxy = (PropertyProxy) proxyStack.peek();
if (proxy == null)
proxy = beanproxy;
proxy.setValue(obj, prop, value);
}
catch (Exception ex)
{
throw new MessageException("Failed to set property '" + prop + "' with value: " + value, ex);
}
if (isDebug)
trace.namedElement(prop);