/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(length != null) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(length != null) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
@SuppressWarnings("rawtypes") @Override public boolean write(Type type, Object value, NodeMap node, Map map){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual != expect) { node.put("class", real.getName()); } return false; } }
/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(length != null) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(!containsKey(value)) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(!containsKey(value)) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
/** * This is used to add a length attribute to the element due to * the fact that the serialized value is an array. The length * of the array is acquired and inserted in to the attributes. * * @param field this is the field type for the array to set * @param value this is the actual value for the array to set * @param node this is the map of attributes for the element * * @return returns the array component type that is set */ private Class writeArray(Class field, Object value, NodeMap node){ int size = Array.getLength(value); if(!containsKey(value)) { node.put(length, String.valueOf(size)); } return field.getComponentType(); } }
/** * This is used to attach a attribute to the provided element * that is used to identify the class. The attribute name is * "class" and has the value of the fully qualified class * name for the object provided. This will only be invoked * if the object class is different from the field class. * * @param type this is the declared class for the field used * @param value this is the instance variable being serialized * @param node this is the element used to represent the value * @param map this is used to maintain contextual information * * @return this returns true if serialization is complete */ public boolean write(Type type, Object value, NodeMap node, Map map){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(expect, value, node); } if(actual != expect) { node.put(label, real.getName()); } return false; }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ private boolean writeReference(Object value, NodeMap node) { String name = get(value); int size = size(); if(name != null) { node.put(refer, name); return true; } String unique = String.valueOf(size); node.put(mark, unique); put(value, unique); return false; }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ private boolean writeReference(Object value, NodeMap node) { String name = get(value); int size = size(); if(name != null) { node.put(refer, name); return true; } String unique = String.valueOf(size); node.put(mark, unique); put(value, unique); return false; }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ private boolean writeReference(Object value, NodeMap node) { String name = get(value); int size = size(); if(name != null) { node.put(refer, name); return true; } String unique = String.valueOf(size); node.put(mark, unique); put(value, unique); return false; }
/** * This is used to attach a attribute to the provided element * that is used to identify the class. The attribute name is * "class" and has the value of the fully qualified class * name for the object provided. This will only be invoked * if the object class is different from the field class. * * @param type this is the declared class for the field used * @param value this is the instance variable being serialized * @param node this is the element used to represent the value * @param map this is used to maintain contextual information * * @return this returns true if serialization is complete */ public boolean write(Type type, Object value, NodeMap node, Map map){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(expect, value, node); } if(actual != expect) { node.put(label, real.getName()); } return false; }
/** * This is used to attach a attribute to the provided element * that is used to identify the class. The attribute name is * "class" and has the value of the fully qualified class * name for the object provided. This will only be invoked * if the object class is different from the field class. * * @param type this is the declared class for the field used * @param value this is the instance variable being serialized * @param node this is the element used to represent the value * @param map this is used to maintain contextual information * * @return this returns true if serialization is complete */ public boolean write(Type type, Object value, NodeMap node, Map map){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(expect, value, node); } if(actual != expect) { node.put(label, real.getName()); } return false; }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param type this is the type of the object to be serialized * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ public boolean write(Type type, Object value, NodeMap node){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(actual, value, node); } if(actual != expect) { node.put(label, real.getName()); } return writeReference(value, node); }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param type this is the type of the object to be serialized * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ public boolean write(Type type, Object value, NodeMap node){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(actual, value, node); } if(actual != expect) { node.put(label, real.getName()); } return writeReference(value, node); }
/** * This is used to write the XML element attributes representing * the serialized object instance. If the object has already been * serialized to the XML document then a reference attribute is * inserted and this returns true, if not, then this will write * a unique identity marker attribute and return false. * * @param type this is the type of the object to be serialized * @param value this is the instance that is to be serialized * @param node this is the node that contains the attributes * * @return returns true if the element has been fully written */ public boolean write(Type type, Object value, NodeMap node){ Class actual = value.getClass(); Class expect = type.getType(); Class real = actual; if(actual.isArray()) { real = writeArray(actual, value, node); } if(actual != expect) { node.put(label, real.getName()); } return writeReference(value, node); }
@Override public OutputNode writeAttribute(OutputNode output, String namespace, String attribute, Object source) { OutputNode node = null; if (!skip(null, source)) { NodeMap<OutputNode> attributes = output.getAttributes(); node = attributes.get(attribute); if (node == null) { node = attributes.put(attribute, EMPTY); } node.setReference(namespace == null ? EMPTY : namespace); write(node, source); } return node; }