Package org.jibx.runtime.impl

Examples of org.jibx.runtime.impl.UnmarshallingContext


        }
    }

    public Object read(QName elementQName, XMLStreamReader input, Class<?> type) {
        try {
            UnmarshallingContext ctx = getUnmarshallingContext(input, type);
            return ctx.unmarshalElement(type);
        } catch (JiBXException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here


        if (JibxSimpleTypes.isSimpleType(jtype)) {
            factory = JibxNullBindingFactory.getFactory();
        } else {
            factory = BindingDirectory.getFactory(jtype);
        }
        UnmarshallingContext ctx = (UnmarshallingContext)factory.createUnmarshallingContext();
        StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element", true);
        ctx.setDocument(wrapper);
        ctx.toTag();
        return ctx;
    }
View Full Code Here

    }

    public Object read(MessagePartInfo part, XMLStreamReader input) {
        Class<?> type = part.getTypeClass();
        try {
            UnmarshallingContext ctx = getUnmarshallingContext(input, type);
            if (JibxSimpleTypes.isSimpleType(type)) {
                QName stype = part.getTypeQName();
                QName ctype = part.getConcreteName();
                if (ctx.isAt(ctype.getNamespaceURI(), ctype.getLocalPart())) {
                    String text = ctx.parseElementText(ctype.getNamespaceURI(), ctype.getLocalPart());
                    return JibxSimpleTypes.toObject(text, stype);
                } else {
                    throw new RuntimeException("Missing required element [" + ctype + "]");
                }
            } else {
                return ctx.unmarshalElement(part.getTypeClass());  
            }
        } catch (JiBXException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

  }

  @Override
  protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) {
    try {
      UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext();
      IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true);
      unmarshallingContext.setDocument(xmlReader);
      return unmarshallingContext.unmarshalElement();
    }
    catch (JiBXException ex) {
      throw convertJibxException(ex, false);
    }
  }
View Full Code Here

    public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException {
        return ctx.isAt(marshalURI, marshallName);
    }

    public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException {
        UnmarshallingContext ctx = (UnmarshallingContext) ictx;
        if (!ctx.isAt(marshalURI, marshallName))
            ctx.throwStartTagNameError(marshalURI, marshallName);

        int size = ctx.attributeInt(marshalURI, SIZE_ATTRIBUTE_NAME, DEFAULT_SIZE);
        Properties map = (Properties) obj;
        if (map == null)
            map = new Properties(size);

        ctx.parsePastStartTag(marshalURI, marshallName);
        while (ctx.isAt(marshalURI, ENTRY_ELEMENT_NAME)) {
            Object key = ctx.attributeText(marshalURI, KEY_ATTRIBUTE_NAME, null);
            ctx.next();
            Object value = ctx.getText();
            map.put(key.toString(), value.toString());
            ctx.parsePastEndTag(marshalURI, ENTRY_ELEMENT_NAME);
        }
        ctx.parsePastEndTag(marshalURI, marshallName);
        return map;
    }
View Full Code Here

        return new MarshallingContext(EMPTY_STRINGS, EMPTY_STRINGS, EMPTY_STRINGS, this);
    }

    public IUnmarshallingContext createUnmarshallingContext()
            throws JiBXException {
        return new UnmarshallingContext(0, EMPTY_STRINGS, EMPTY_STRINGS, EMPTY_STRINGS,
                                        EMPTY_STRINGS, this);
    }
View Full Code Here

TOP

Related Classes of org.jibx.runtime.impl.UnmarshallingContext

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.