Adapt {@code parser} to a {@link Marshaller}.

@since 1.0.0
436234
public static <T extends MessageNano> Marshaller<T> marshaller(MessageNanoFactory<T> factory) {
    return new MessageMarshaller<>(factory);
  }
1224992
public void parse(Reader xmlReader) throws XMLStreamException {
    if (isoControlCharsAwareParser) {
      throw new XMLStreamException("Method call not supported when isoControlCharsAwareParser=true");
    }
    parse(inf.rootElementCursor(xmlReader));
  }
889058
public final Parser<T> followedBy(Parser<?> parser) {
    return Parsers.sequence(this, parser, InternalFunctors.<T, Object>firstOfTwo());
  }
893162
@Override
    public void marshal(
                    final Object obj,
                    final Result result
                    )
    {
        try {
            _marshaller.marshal( obj, result );
                        //@throws IOException
                        //@throws XmlMappingException
        } catch (Exception ex) {
            throw new XmlException( ex );
        }
    }
472567
private synchronized static void initParser() throws IOException
    {
        if (__parser != null) return;

        __parser = new XmlParser();
        URL config13URL = XmlConfiguration.class.getClassLoader().getResource(
                "org/browsermob/proxy/jetty/xml/configure_1_3.dtd");
        __parser.redirectEntity("configure.dtd", config13URL);
        __parser.redirectEntity("configure_1_3.dtd", config13URL);
        __parser.redirectEntity("http://jetty.jetty.org/configure_1_3.dtd", config13URL);
        __parser.redirectEntity("http://jetty.jetty.org/configure.dtd", config13URL);
        __parser.redirectEntity("-//Mort Bay Consulting//DTD Configure 1.3//EN", config13URL);
        __parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN", config13URL);

        URL config12URL = XmlConfiguration.class.getClassLoader().getResource(
                "org/browsermob/proxy/jetty/xml/configure_1_2.dtd");
        __parser.redirectEntity("configure_1_2.dtd", config12URL);
        __parser.redirectEntity("http://jetty.jetty.org/configure_1_2.dtd", config12URL);
        __parser.redirectEntity("-//Mort Bay Consulting//DTD Configure 1.2//EN", config12URL);

        URL config11URL = XmlConfiguration.class.getClassLoader().getResource(
                "org/browsermob/proxy/jetty/xml/configure_1_1.dtd");
        __parser.redirectEntity("configure_1_1.dtd", config11URL);
        __parser.redirectEntity("http://jetty.jetty.org/configure_1_1.dtd", config11URL);
        __parser.redirectEntity("-//Mort Bay Consulting//DTD Configure 1.1//EN", config11URL);

        URL config10URL = XmlConfiguration.class.getClassLoader().getResource(
                "org/browsermob/proxy/jetty/xml/configure_1_0.dtd");
        __parser.redirectEntity("configure_1_0.dtd", config10URL);
        __parser.redirectEntity("http://jetty.jetty.org/configure_1_0.dtd", config10URL);
        __parser.redirectEntity("-//Mort Bay Consulting//DTD Configure 1.0//EN", config10URL);
    }
1287066
public Object parse(InputSource is) throws ParserConfigurationException, SAXException, IOException{
        SAXUtil.newSAXParser(true, false, false).parse(is, this);
        return reset();
    }
286930
@Nonnull
  @OverrideOnDemand
  protected Marshaller createMarshaller () throws JAXBException
  {
    final JAXBContext aJAXBContext = getJAXBContext ();

    // create a Marshaller
    final Marshaller aMarshaller = aJAXBContext.createMarshaller ();

    // Validating (if possible)
    final Schema aSchema = getSchema ();
    if (aSchema != null)
      aMarshaller.setSchema (aSchema);

    return aMarshaller;
  }
316365
public static Marshaller createMarshaller(Class clazz, String encoding) {
		try {
			JAXBContext jaxbContext = getJaxbContext(clazz);

			Marshaller marshaller = jaxbContext.createMarshaller();

			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

			if (StringUtils.isNotBlank(encoding)) {
				marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding);
			}

			return marshaller;
		} catch (JAXBException e) {
			throw ExceptionUtil.unchecked(e);
		}
	}
1074129
public static FieldMarshaller getFieldMarshaller (Field field)
    {
        if (_marshallers == null) {
            // multiple threads may attempt to create the stock marshallers, but they'll just do
            // extra work and _marshallers will only ever contain a fully populated table
            _marshallers = createMarshallers();
        }

        // if necessary (we're running in a sandbox), look for custom field accessors
        if (useFieldAccessors()) {
            Method reader = null, writer = null;
            try {
                reader = field.getDeclaringClass().getMethod(
                    getReaderMethodName(field.getName()), READER_ARGS);
            } catch (NoSuchMethodException nsme) {
                // no problem
            }
            try {
                writer = field.getDeclaringClass().getMethod(
                    getWriterMethodName(field.getName()), WRITER_ARGS);
            } catch (NoSuchMethodException nsme) {
                // no problem
            }
            if (reader != null && writer != null) {
                return new MethodFieldMarshaller(reader, writer);
            }
            if ((reader == null && writer != null) || (writer == null && reader != null)) {
                log.warning("Class contains one but not both custom field reader and writer",
                            "class", field.getDeclaringClass().getName(), "field", field.getName(),
                            "reader", reader, "writer", writer);
                // fall through to using reflection on the fields...
            }
        }

        Class<?> ftype = field.getType();

        // use the intern marshaller for pooled strings
        if (ftype == String.class && field.isAnnotationPresent(Intern.class)) {
            return _internMarshaller;
        }

        // if we have an exact match, use that
        FieldMarshaller fm = _marshallers.get(ftype);
        if (fm == null) {
            Class<?> collClass = Streamer.getCollectionClass(ftype);
            if (collClass != null && !collClass.equals(ftype)) {
                log.warning("Specific field types are discouraged " +
                    "for Iterables/Collections and Maps. The implementation type may not be " +
                    "recreated on the other side.",
                    "class", field.getDeclaringClass(), "field", field.getName(),
                    "type", ftype, "shouldBe", collClass);
                fm = _marshallers.get(collClass);
            }

            // otherwise if the class is a pure interface or streamable,
            // use the streamable marshaller
            if (fm == null && (ftype.isInterface() || Streamer.isStreamable(ftype))) {
                fm = _marshallers.get(Streamable.class);
            }
        }

        return fm;
    }
86579
@SuppressWarnings("unchecked")
  <T> T parse(Class<T> clazz) throws JsonParserException {
    advanceToken();
    Object parsed = currentValue();
    if (advanceToken() != Token.EOF)
      throw createParseException(null, "Expected end of input, got " + token, true);
    if (clazz != Object.class && (parsed == null || clazz != parsed.getClass()))
      throw createParseException(null, "JSON did not contain the correct type, expected " + clazz.getName()
          + ".", true);
    return (T)(parsed);
  }
1074394
private void process(JsonParser jsonParser) throws IOException, ODataUnmarshallingException {
        if (jsonParser.getCurrentToken() == JsonToken.FIELD_NAME) {
            LOG.info("Starting to parse {} token", jsonParser.getCurrentName());
            String key = jsonParser.getCurrentName();
            jsonParser.nextToken();

            JsonToken token = jsonParser.getCurrentToken();
            if (token == JsonToken.START_ARRAY) {
                if (JsonConstants.VALUE.equals(key)) {
                    throw new ODataUnmarshallingException("Feed is not supported");
                }
                values.put(key, getCollectionValue(jsonParser));
            } else if (token == JsonToken.START_OBJECT) {
                values.put(key, getEmbeddedObject(jsonParser));
            } else {
                if (token.equals(JsonToken.VALUE_NULL)) {
                    values.put(key, null);
                } else {
                    values.put(key, jsonParser.getText());
                }
            }
        }
    }
150015
ArgumentMarshaller getArgumentMarshaller(final Method getter) {

        synchronized (argumentMarshallerCache) {
            if ( !argumentMarshallerCache.containsKey(getter) ) {
                ArgumentMarshaller marshaller = null;

                if ( isCustomMarshaller(getter) ) {
                    marshaller = new ArgumentMarshaller() {

                        @Override
                        public AttributeValue marshall(Object obj) {
                            return getCustomerMarshallerAttributeValue(getter, obj);
                        }
                    };
                } else {

                    Class<?> returnType = getter.getReturnType();
                    if ( Set.class.isAssignableFrom(returnType) ) {
                        Type genericType = getter.getGenericReturnType();
                        if ( genericType instanceof ParameterizedType ) {
                            if ( ((ParameterizedType) genericType).getActualTypeArguments()[0].toString().equals("byte[]") ) {
                                returnType = byte[].class;
                            } else {
                                returnType = (Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0];
                            }
                        }

                        if ( Date.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    List<String> timestamps = new LinkedList<String>();
                                    for ( Object o : (Set<?>) obj ) {
                                        timestamps.add(DateUtils.formatISO8601Date((Date) o));
                                    }
                                    return new AttributeValue().withSS(timestamps);
                                }
                            };
                        } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    List<String> timestamps = new LinkedList<String>();
                                    for ( Object o : (Set<?>) obj ) {
                                        timestamps.add(DateUtils.formatISO8601Date(((Calendar) o).getTime()));
                                    }
                                    return new AttributeValue().withSS(timestamps);
                                }
                            };
                        } else if ( boolean.class.isAssignableFrom(returnType)
                                || Boolean.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    List<String> booleanAttributes = new ArrayList<String>();
                                    for ( Object b : (Set<?>) obj ) {
                                        if ( b == null || !(Boolean) b ) {
                                            booleanAttributes.add("0");
                                        } else {
                                            booleanAttributes.add("1");
                                        }
                                    }
                                    return new AttributeValue().withNS(booleanAttributes);
                                }
                            };
                        } else if ( returnType.isPrimitive() || Number.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    List<String> attributes = new ArrayList<String>();
                                    for ( Object o : (Set<?>) obj ) {
                                        attributes.add(String.valueOf(o));
                                    }
                                    return new AttributeValue().withNS(attributes);
                                }
                            };
                        } else if (ByteBuffer.class.isAssignableFrom(returnType)) {
                        	 marshaller = new ArgumentMarshaller() {

                                 @Override
                                 public AttributeValue marshall(Object obj) {
                                     List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                                     for ( Object o : (Set<?>) obj ) {
                                         attributes.add((ByteBuffer) o);
                                     }
                                     return new AttributeValue().withBS(attributes);
                                 }
                             };
                        } else if (byte[].class.isAssignableFrom(returnType)) { 
                        	 marshaller = new ArgumentMarshaller() {

                                 @Override
                                 public AttributeValue marshall(Object obj) {
                                     List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                                     for ( Object o : (Set<?>) obj ) {
                                         attributes.add(ByteBuffer.wrap((byte[])o));
                                     }
                                     return new AttributeValue().withBS(attributes);
                                 }
                             };
                        } else {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    List<String> attributes = new ArrayList<String>();
                                    for ( Object o : (Set<?>) obj ) {
                                        attributes.add(String.valueOf(o));
                                    }
                                    return new AttributeValue().withSS(attributes);
                                }
                            };
                        }
                    } else if ( Collection.class.isAssignableFrom(returnType) ) {
                        throw new DynamoDBMappingException("Non-set collections aren't supported: "
                                + (getter.getDeclaringClass() + "." + getter.getName()));
                    } else {
                        if ( Date.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    return new AttributeValue().withS(DateUtils.formatISO8601Date((Date) obj));
                                }
                            };
                        } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    return new AttributeValue().withS(DateUtils
                                            .formatISO8601Date(((Calendar) obj).getTime()));
                                }
                            };
                        } else if ( boolean.class.isAssignableFrom(returnType)
                                || Boolean.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    if ( obj == null || !(Boolean) obj ) {
                                        return new AttributeValue().withN("0");
                                    } else {
                                        return new AttributeValue().withN("1");
                                    }
                                }
                            };
                        } else if ( returnType.isPrimitive() || Number.class.isAssignableFrom(returnType) ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    return new AttributeValue().withN(String.valueOf(obj));
                                }
                            };
                        } else if ( returnType == String.class ) {
                            marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    if ( ((String) obj).length() == 0 )
                                        return null;
                                    return new AttributeValue().withS(String.valueOf(obj));
                                }
                            };
                        } else if ( returnType == ByteBuffer.class ) {
                        	marshaller = new ArgumentMarshaller() {

                                @Override
                                public AttributeValue marshall(Object obj) {
                                    return new AttributeValue().withB((ByteBuffer)obj);
                                }
                            };
                        } else if ( returnType == byte[].class) {
                        	 marshaller = new ArgumentMarshaller() {

                                 @Override
                                 public AttributeValue marshall(Object obj) {
                                     return new AttributeValue().withB(ByteBuffer.wrap((byte[])obj));
                                 }
                             };
                        } else {
                            throw new DynamoDBMappingException("Unsupported type: " + returnType + " for " + getter);
                        }
                    }
                }
                argumentMarshallerCache.put(getter, marshaller);
            }
        }

        return argumentMarshallerCache.get(getter);
    }
1280120
function Marshal(type)
{
    var parsedType = parseTypeString(type);

    if (parsedType.isCollection)
    {
        this.type = parsedType.type;
        parsedType = parsedType.name;
        this.isComposite = false;
    }
    else
    {
        this.type = parsedType;
        this.isComposite = Array.isArray(parsedType);
    }

    this.serialize = getSerializer(parsedType, this.type);
    this.deserialize = getDeserializer(parsedType, this.type);
}
354802
@SuppressWarnings({"unchecked", "rawtypes"})
  @Private static <T> Parser<T>[] toArray(Iterable<? extends Parser<? extends T>> parsers) {
    if (parsers instanceof Collection<?>) {
      return toArray((Collection) parsers);
    }
    return toArrayWithIteration(parsers);
  }
1095855
public void addFieldParser(char type, SdpParser<? extends SdpField> parser) {
		synchronized (this.fieldParsers) {
			this.fieldParsers.put(type, parser);
		}
	}
218082
public Marshaller createMarshaller(Class<?> clazz) throws JAXBException {
    Marshaller marshaller = getContext(clazz).createMarshaller();
    setMarshallerProperties(marshaller);
    return marshaller;
  }
1345147
public static Marshaller createMarshaller() throws JAXBException {
		Marshaller marshaller = MessageUtilsHelper.getContext().createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		return marshaller;
	}