Package de.odysseus.staxon.json.jaxb

Examples of de.odysseus.staxon.json.jaxb.JsonXML


@JsonXML
public class JsonXMLTest {
  @Test
  public void testDefaults() {
    JsonXML config = getClass().getAnnotation(JsonXML.class);
    Assert.assertFalse(config.autoArray());
    Assert.assertTrue(config.namespaceDeclarations());
    Assert.assertEquals(':', config.namespaceSeparator());
    Assert.assertEquals(0, config.multiplePaths().length);
    Assert.assertFalse(config.prettyPrint());
    Assert.assertFalse(config.virtualRoot());
  }
View Full Code Here


    Assert.assertEquals("ASCII", new TestProvider().getCharset(customMediaType));
  }
 
  @Test
  public void testGetJsonXML() {
    JsonXML typeAnnotation = SampleRootElement.class.getAnnotation(JsonXML.class);
    Assert.assertEquals(typeAnnotation, new TestProvider().getJsonXML(SampleRootElement.class, new Annotation[0]));

    Annotation[] resourceAnnotations = new Annotation[]{JsonXMLDefault.class.getAnnotation(JsonXML.class)};
    Assert.assertEquals(resourceAnnotations[0], new TestProvider().getJsonXML(SampleType.class, resourceAnnotations));
View Full Code Here

      Type genericType,
      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders,
      Reader stream) throws IOException, WebApplicationException {
    JsonXML config = getJsonXML(type, annotations);
    try {
      return readObject(type, config, getContext(type, mediaType), stream);
    } catch (XMLStreamException e) {
      throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
    } catch (JAXBException e) {
View Full Code Here

      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      Writer stream,
      Object value) throws IOException, WebApplicationException {
    JsonXML config = getJsonXML(type, annotations);
    try {
      writeObject(type, config, getContext(type, mediaType), stream, value);
    } catch (XMLStreamException e) {
      throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
    } catch (JAXBException e) {
View Full Code Here

      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders,
      Reader stream) throws IOException, WebApplicationException {
    Class<?> componentType = getComponentType(type, genericType);
    JsonXML config = getJsonXML(componentType, annotations)
    List<?> list;
    try {
      list = readArray(componentType, config, getContext(componentType, mediaType), stream);
    } catch (XMLStreamException e) {
      throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
View Full Code Here

      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      Writer stream,
      Object entry) throws IOException, WebApplicationException {
    Class<?> componentType = getComponentType(type, genericType);
    JsonXML config = getJsonXML(componentType, annotations);
    Collection<?> collection;
    if (entry == null) {
      collection = null;
    } else if (type.isArray()) {
      collection = Arrays.asList((Object[]) entry);
View Full Code Here

    super(true);
    this.store = new JsonXMLContextStore(providers);
  }

  protected JsonXML getJsonXML(Class<?> type, Annotation[] resourceAnnotations) {
    JsonXML result = getAnnotation(resourceAnnotations, JsonXML.class);
    if (result == null) {
      result = type.getAnnotation(JsonXML.class);
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of de.odysseus.staxon.json.jaxb.JsonXML

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.