if (str == null)
state.object = new byte[0];
else {
//-- Base64 decoding
char[] chars = str.toCharArray();
MimeBase64Decoder decoder = new MimeBase64Decoder();
decoder.translate(chars, 0, chars.length);
state.object = decoder.getByteArray();
}
}
else if (state.args != null) {
state.object = createInstance(state.type, state.args);
}
else state.object = toPrimitiveObject(type,str,state.fieldDesc);
}
else if (ArrayHandler.class.isAssignableFrom(state.type)) {
state.object = ((ArrayHandler)state.object).getObject();
state.type = state.object.getClass();
}
//-- check for character content
if ((state.buffer != null) &&
(state.buffer.length() > 0) &&
(state.classDesc != null)) {
XMLFieldDescriptor cdesc = state.classDesc.getContentDescriptor();
if (cdesc != null) {
Object value = state.buffer.toString();
if (isPrimitive(cdesc.getFieldType()))
value = toPrimitiveObject(cdesc.getFieldType(), (String)value, state.fieldDesc);
else {
Class valueType = cdesc.getFieldType();
//-- handle base64
if (valueType.isArray() &&
(valueType.getComponentType() == Byte.TYPE))
{
char[] chars = ((String)value).toCharArray();
MimeBase64Decoder decoder = new MimeBase64Decoder();
decoder.translate(chars, 0, chars.length);
value = decoder.getByteArray();
}
}
try {