/* (non-Javadoc)
@see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext)
183413
public void marshal(Object obj, HierarchicalStreamWriter writer,
			MarshallingContext context) {
		XExtension extension = (XExtension)obj;
		writer.addAttribute("uri", extension.getUri().toString());
	}
347912
public void marshalling(Xdr xdr) {
        super.marshalling(xdr);
        xdr.putLong(_offsetToCommit);
        xdr.putUnsignedInt(_dataSizeToCommit);
    }
711530
public void marshal(Object obj, HierarchicalStreamWriter writer,
			MarshallingContext context) {
		XAttribute attribute = (XAttribute) obj;
		writer.addAttribute("key", attribute.getKey());
		writer.addAttribute("type", XAttributeUtils.getTypeString(attribute));
		String value = attribute.toString();
		if (value == null) {
			throw new AssertionError("Attribute value must not be null");
		}
		writer.addAttribute("value", value);
		if (attribute.getExtension() != null) {
			writer.addAttribute("extension", attribute.getExtension().getUri()
					.toString());
		}
		// marshal meta-attributes
		if (attribute.getAttributes().size() > 0) {
			writer.startNode("XAttributeMap");
			XAttribute oldParent = (XAttribute) context.get(PARENT);
			context.put(PARENT, attribute); 
			context.convertAnother(attribute.getAttributes(),
					XesXStreamPersistency.attributeMapConverter);
			context.put(PARENT, oldParent);
			writer.endNode();
		}
	}
515543
public void marshalling(Xdr xdr) {
        if ( !isBareTime() ) {
            xdr.putInt(_timeSettingType);
        }
        if ( captureTime() ) {
            xdr.putUnsignedInt(seconds);
            xdr.putUnsignedInt(nanoseconds);
        }
    }
1309669
protected static Map<Class<?>, FieldMarshaller> createMarshallers ()
    {
        Map<Class<?>, FieldMarshaller> marshallers = Maps.newHashMap();

        // create a generic marshaller for streamable instances
        FieldMarshaller gmarsh = new FieldMarshaller("Generic") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.set(target, in.readObject());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeObject(field.get(source));
            }
        };
        marshallers.put(Streamable.class, gmarsh);

        // use the same generic marshaller for fields declared as Object with the expectation that
        // they will contain only primitive types or Streamables; the runtime will fail
        // informatively if we attempt to store non-Streamable objects in that field
        marshallers.put(Object.class, gmarsh);

        // create marshallers for the primitive types
        marshallers.put(Boolean.TYPE, new FieldMarshaller("boolean") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setBoolean(target, in.readBoolean());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeBoolean(field.getBoolean(source));
            }
        });
        marshallers.put(Byte.TYPE, new FieldMarshaller("byte") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setByte(target, in.readByte());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeByte(field.getByte(source));
            }
        });
        marshallers.put(Character.TYPE, new FieldMarshaller("char") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setChar(target, in.readChar());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeChar(field.getChar(source));
            }
        });
        marshallers.put(Short.TYPE, new FieldMarshaller("short") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setShort(target, in.readShort());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeShort(field.getShort(source));
            }
        });
        marshallers.put(Integer.TYPE, new FieldMarshaller("int") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setInt(target, in.readInt());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeInt(field.getInt(source));
            }
        });
        marshallers.put(Long.TYPE, new FieldMarshaller("long") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setLong(target, in.readLong());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeLong(field.getLong(source));
            }
        });
        marshallers.put(Float.TYPE, new FieldMarshaller("float") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setFloat(target, in.readFloat());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeFloat(field.getFloat(source));
            }
        });
        marshallers.put(Double.TYPE, new FieldMarshaller("double") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.setDouble(target, in.readDouble());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeDouble(field.getDouble(source));
            }
        });
        marshallers.put(Date.class, new FieldMarshaller("Date") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.set(target, new Date(in.readLong()));
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeLong(((Date)field.get(source)).getTime());
            }
        });

        // create field marshallers for all of the basic types
        for (Map.Entry<Class<?>,Streamer> entry : BasicStreamers.BSTREAMERS.entrySet()) {
            marshallers.put(entry.getKey(), new StreamerMarshaller(entry.getValue()));
        }

        // create the field marshaller for pooled strings
        _internMarshaller = new FieldMarshaller("intern") {
            @Override
            public void readField (Field field, Object target, ObjectInputStream in)
                throws Exception {
                field.set(target, in.readIntern());
            }
            @Override
            public void writeField (Field field, Object source, ObjectOutputStream out)
                throws Exception {
                out.writeIntern((String)field.get(source));
            }
        };

        return marshallers;
    }
644436
private <J, T extends Proxy<J>> T marshalConstructor(final int opcode,
                                                         final J implementation,
                                                         final int version,
                                                         final Class<T> newProxyCls,
                                                         final long argsPointer) {
        try {
            final long wlProxy = WaylandClientCore.INSTANCE()
                                                  .wl_proxy_marshal_array_constructor(this.pointer,
                                                                                      opcode,
                                                                                      argsPointer,
                                                                                      InterfaceMeta.get(newProxyCls).pointer.address);
            return marshalProxy(wlProxy,
                                implementation,
                                version,
                                newProxyCls);
        }
        catch (final NoSuchMethodException |
                IllegalAccessException |
                InstantiationException |
                InvocationTargetException e) {
            throw new RuntimeException("Uh oh, this is a bug!",
                                       e);
        }
    }
183546
public Object marshalRootElement() {
        if (justRoutes) {
            RoutesDefinition routes = new RoutesDefinition();
            routes.setRoutes(contextElement.getRoutes());
            return routes;
        } else {
            return contextElement;
        }
    }
1295648
ModuleMarshal marshal(Class<?> sourceType)
  {
    ModuleMarshal marshal = _marshalSourceMap.get(sourceType);
    
    if (marshal == null) {
      marshal = marshalImpl(sourceType);
      _marshalSourceMap.put(sourceType, marshal);
    }
    
    return marshal;
  }
133344
public Object unmarshal(HierarchicalStreamReader reader,
			UnmarshallingContext context) {
		URI uri = URI.create(reader.getAttribute("uri"));
		return XExtensionManager.instance().getByUri(uri);
	}
574682
public Object unmarshal(HierarchicalStreamReader reader,
			UnmarshallingContext context) {
		String key = reader.getAttribute("key");
		String type = reader.getAttribute("type");
		String value = reader.getAttribute("value");
		XExtension extension = null;
		String extensionString = reader.getAttribute("extension");
		if (extensionString != null && extensionString.length() > 0) {
			URI uri = URI.create(extensionString);
			extension = XExtensionManager.instance().getByUri(uri);
		}
		XFactory factory = XFactoryRegistry.instance().currentDefault();
		XAttribute attribute = XAttributeUtils.composeAttribute(factory, key,
				value, type, extension);
		XAttribute parent = (XAttribute) context.get(PARENT);
		if (parent != null && parent instanceof XAttributeCollection) {
			((XAttributeCollection) parent).addToCollection(attribute);
		}
		System.err.println("8");
		if (reader.hasMoreChildren()) {
			System.err.println("9");
			reader.moveDown();
			Object oldParent = context.get(PARENT);
			context.put(PARENT, attribute);
			XAttributeMap metaAttributes = (XAttributeMap) context
					.convertAnother(attribute, XAttributeMap.class,
							XesXStreamPersistency.attributeMapConverter);
			context.put(PARENT, oldParent);
			reader.moveUp();
			attribute.setAttributes(metaAttributes);
		}
		System.err.println("done");
		return attribute;
	}
187941
public static XContentBuilder marshall(RoleMembershipBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("organizationId", bean.getOrganizationId())
                    .field("roleId", bean.getRoleId())
                    .field("userId", bean.getUserId())
                    .field("createdOn", bean.getCreatedOn().getTime())
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
1348893
private static void autoMarshalEligible(Object o,
                                            HierarchicalStreamWriter writer) {
        try {
            Class c = o.getClass();
            Field[] fields = c.getDeclaredFields();
            Annotation annotation = null;
            for (Field f : fields) {
                annotation = f.getAnnotation(Auto.class);
                if (annotation != null) {
                    f.setAccessible(true);
                    if (f.get(o) != null) {
                        writer.startNode(f.getName());
                        writer.setValue(String.valueOf(f.get(o)));
                        writer.endNode();
                    }

                }
            }
        } catch (Throwable th) {
            logger.error("Error in marshalling the object", th);
        }
    }
588239
@Deprecated
    public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException {
        marshallAsElement(attribute, resourceModel, true, writer);
    }
42691
private void marshalFields() {
    Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
        .getPropertyMetadataCollection();
    for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
      marshalField(propertyMetadata, entity);
    }
  }
1266556
public void marshall(MarshallLocation marshallLocation, Object val) {
        marshallerRegistry().getMarshaller(marshallLocation, val).marshall(val, this, null);
    }
287475
private void marshallPrimitive(Object value, PrimitiveType primitiveType) throws XMLStreamException {

        LOG.trace("Primitive value: {} of type: {}", value, primitiveType);
        if (value != null) {
            xmlWriter.writeCharacters(value.toString());
        }
    }
674156
public String marshal(ContextItems contextItems) {
        SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyyMMddHHmmssz");
        contextItems.setItem(PROPNAME_TIME, timestampFormat.format(new Date()));
        contextItems.setItem(PROPNAME_KEY, signer.getKeyName());
        return contextItems.toString();
    }