Refine search
@Override protected void writeItem( Object item, MarshallingContext context, HierarchicalStreamWriter writer) { ExtendedHierarchicalStreamWriterHelper.startNode(writer, "string", Keyword.class); context.convertAnother(item); writer.endNode(); } }
public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Map map = (Map) source; for (Object o : map.entrySet()) { Map.Entry e = (Map.Entry) o; if (e.getKey() == null) { continue; } writer.startNode(name); if (map.get(null) == e.getValue()) { writer.addAttribute("default", "true"); } context.convertAnother(e.getValue()); writer.endNode(); } }
public void writeToStream(final Object object) { if (object == null) { writer.startNode("null"); writer.endNode(); } else { ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedClass(object.getClass()), object.getClass()); context.convertAnother(object); writer.endNode(); } }
public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context) { MultiHashMap map = (MultiHashMap) source; for (Object v : map.values()) { if (v instanceof DataStoreInfo) { writer.startNode("dataStore"); context.convertAnother(v); writer.endNode(); } if (v instanceof CoverageStoreInfo) { writer.startNode("coverageStore"); context.convertAnother(v); writer.endNode(); } } }
public void writeToStream(Object object) { if (object == null) { writer.startNode(ELEMENT_NULL); writer.endNode(); } else { ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedClass(object.getClass()), object.getClass()); context.convertAnother(object); writer.endNode(); } }
@Override public void marshal( Object original, HierarchicalStreamWriter writer, MarshallingContext context) { NumberRange range = (NumberRange) original; writer.startNode("min"); if (Double.isInfinite(((Number) range.getMinValue()).doubleValue())) { context.convertAnother("-inf"); } else { context.convertAnother(range.getMinValue()); } writer.endNode(); writer.startNode("max"); if (Double.isInfinite(((Number) range.getMaxValue()).doubleValue())) { context.convertAnother("inf"); } else { context.convertAnother(range.getMaxValue()); } writer.endNode(); }
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Application app = (Application) source; writer.startNode(ELEM_NAME); writer.setValue(app.getName()); writer.endNode(); for (InstanceInfo instanceInfo : app.getInstances()) { writer.startNode(NODE_INSTANCE); context.convertAnother(instanceInfo); writer.endNode(); } }
@Override public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Clock clock = (Clock)source; ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(Clock.class, "zone"), null); context.convertAnother(clock.getZone()); writer.endNode(); }
private void writeField(String propertyName, Class fieldType, Object newObj) { Class actualType = newObj.getClass(); Class defaultType = mapper.defaultImplementationOf(fieldType); String serializedMember = mapper.serializedMember(source.getClass(), propertyName); ExtendedHierarchicalStreamWriterHelper.startNode(writer, serializedMember, actualType); if (!actualType.equals(defaultType) && classAttributeName != null) { writer.addAttribute(classAttributeName, mapper.serializedClass(actualType)); } context.convertAnother(newObj); writer.endNode(); }
public void writeItem(Object item) { if (item == null) { String name = mapper.serializedClass(null); ExtendedHierarchicalStreamWriterHelper.startNode( writer, name, Mapper.Null.class); writer.endNode(); } else { String name = mapper.serializedClass(item.getClass()); ExtendedHierarchicalStreamWriterHelper.startNode( writer, name, item.getClass()); context.convertAnother(item); writer.endNode(); } } };
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final int length = Array.getLength(source); for (int i = 0; i < length; ++i) { final Object item = Array.get(source, i); final Class itemType = item == null ? Mapper.Null.class : arrayType.getComponentType().isPrimitive() ? Primitives.unbox(item.getClass()) : item.getClass(); ExtendedHierarchicalStreamWriterHelper.startNode(writer, itemName, itemType); if (!itemType.equals(arrayType.getComponentType())) { final String attributeName = mapper.aliasForSystemAttribute("class"); if (attributeName != null) { writer.addAttribute(attributeName, mapper.serializedClass(itemType)); } } if (item != null) { context.convertAnother(item); } writer.endNode(); } }
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { InvocationHandler invocationHandler = Proxy.getInvocationHandler(source); addInterfacesToXml(source, writer); writer.startNode("handler"); String attributeName = mapper.aliasForSystemAttribute("class"); if (attributeName != null) { writer.addAttribute(attributeName, mapper.serializedClass(invocationHandler.getClass())); } context.convertAnother(invocationHandler); writer.endNode(); }
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Font font = (Font)source; Map attributes = font.getAttributes(); if (mapper != null) { String classAlias = mapper.aliasForSystemAttribute("class"); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry)iter.next(); String name = textAttributeConverter.toString(entry.getKey()); Object value = entry.getValue(); Class type = value != null ? value.getClass() : Mapper.Null.class; ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, type); writer.addAttribute(classAlias, mapper.serializedClass(type)); if (value != null) { context.convertAnother(value); } writer.endNode(); } } else { writer.startNode("attributes"); // <attributes> context.convertAnother(attributes); writer.endNode(); // </attributes> } }
protected static void marshalComparator( Mapper mapper, Comparator comparator, HierarchicalStreamWriter writer, MarshallingContext context) { if (comparator != null) { writer.startNode("comparator"); writer.addAttribute( mapper.aliasForSystemAttribute("class"), mapper.serializedClass(comparator.getClass())); context.convertAnother(comparator); writer.endNode(); } }
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Applications apps = (Applications) source; writer.startNode(VERSIONS_DELTA); writer.setValue(apps.getVersion().toString()); writer.endNode(); writer.startNode(APPS_HASHCODE); writer.setValue(apps.getAppsHashCode()); writer.endNode(); for (Application app : apps.getRegisteredApplications()) { writer.startNode(NODE_APP); context.convertAnother(app); writer.endNode(); } }
@Override public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final WeekFields weekFields = (WeekFields)source; ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(WeekFields.class, "minimalDays"), int.class); writer.setValue(String.valueOf(weekFields.getMinimalDaysInFirstWeek())); writer.endNode(); ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(WeekFields.class, "firstDayOfWeek"), DayOfWeek.class); context.convertAnother(weekFields.getFirstDayOfWeek()); writer.endNode(); }
protected void writeItem(String name, Class type, Object item, MarshallingContext context, HierarchicalStreamWriter writer) { Class itemType = item == null ? Mapper.Null.class : item.getClass(); ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, itemType); if (!itemType.equals(type)) { String attributeName = mapper().aliasForSystemAttribute("class"); if (attributeName != null) { writer.addAttribute(attributeName, mapper().serializedClass(itemType)); } } if (item != null) { context.convertAnother(item); } writer.endNode(); }
protected void marshalComparator(Comparator comparator, HierarchicalStreamWriter writer, MarshallingContext context) { if (comparator != null) { writer.startNode("comparator"); writer.addAttribute(mapper().aliasForSystemAttribute("class"), mapper().serializedClass(comparator.getClass())); context.convertAnother(comparator); writer.endNode(); } }
} else { writer.startNode(complexTypeId); context.convertAnother(value); writer.endNode(); writer.endNode();
public void writeFieldsToStream(Map fields) { ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType[0]); writer.startNode(ELEMENT_DEFAULT); for (Iterator iterator = fields.keySet().iterator(); iterator.hasNext();) { String name = (String) iterator.next(); if (!mapper.shouldSerializeMember(currentType[0], name)) { continue; } ObjectStreamField field = objectStreamClass.getField(name); Object value = fields.get(name); if (field == null) { throw new MissingFieldException(value.getClass().getName(), name); } if (value != null) { ExtendedHierarchicalStreamWriterHelper.startNode( writer, mapper.serializedMember(source.getClass(), name), value.getClass()); if (field.getType() != value.getClass() && !field.getType().isPrimitive()) { String attributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS); if (attributeName != null) { writer.addAttribute(attributeName, mapper.serializedClass(value.getClass())); } } context.convertAnother(value); writer.endNode(); } } writer.endNode(); }