Examples of UnmarshallingContext


Examples of org.jibx.runtime.impl.UnmarshallingContext

     */
    public Object unmarshal(Object obj, IUnmarshallingContext ictx)
        throws JiBXException {
       
        // make sure we're at the appropriate start tag
        UnmarshallingContext ctx = (UnmarshallingContext)ictx;
        if (!ctx.isAt(m_uri, m_name)) {
            ctx.throwStartTagNameError(m_uri, m_name);
        }
       
        // create new hashmap if needed
        int size = ctx.attributeInt(m_uri,
            getSizeAttributeName(), DEFAULT_SIZE);
        Map map = (Map)obj;
        if (map == null) {
            map = new HashMap(size);
        }
       
        // process all entries present in document
        ctx.parsePastStartTag(m_uri, m_name);
        while (ctx.isAt(m_uri, getEntryElementName())) {
            Object key = ctx.attributeText(m_uri, getKeyAttributeName(), null);
            ctx.parsePastStartTag(m_uri, getEntryElementName());
            Object value = ctx.unmarshalElement();
            map.put(key, value);
            ctx.parsePastEndTag(m_uri, getEntryElementName());
        }
        ctx.parsePastEndTag(m_uri, m_name);
        return map;
    }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

     * @see #preset(IUnmarshallingContext)
     */
    protected static void validateAttributes(IUnmarshallingContext ictx, boolean extra, StringArray attrs) {
       
        // loop through all attributes of current element
        UnmarshallingContext uctx = (UnmarshallingContext)ictx;
        for (int i = 0; i < uctx.getAttributeCount(); i++) {
            String name = uctx.getAttributeName(i);
            String ns = uctx.getAttributeNamespace(i);
            if (ns == null || ns.length() == 0) {
               
                // check if schema attribute in allowed set
                if (attrs.indexOf(name) < 0) {
                    ValidationContext vctx = (ValidationContext)ictx.getUserContext();
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

     * pre-set method processing when a subclass instance is being created.
     *
     * @param ictx unmarshalling context
     */
    protected void readNamespaces(IUnmarshallingContext ictx) {
        UnmarshallingContext ctx = (UnmarshallingContext)ictx;
        int count = ctx.getNamespaceCount();
        if (count > 0) {
            m_namespaces = new ArrayList();
            for (int i = 0; i < count; i++) {
                String pref = ctx.getNamespacePrefix(i);
                if (pref == null) {
                    pref = "";
                }
                if (pref.equals("xs")) {
                    if (SCHEMA_NAMESPACE.equals(ctx.getNamespaceUri(i))) {
                        continue;
                    } else {
                        throw new RuntimeException("Cannot handle 'xs' prefix associated with non-schema namespace");
                    }
                }
                m_namespaces.add(pref);
                m_namespaces.add(ctx.getNamespaceUri(i));
            }
        } else {
            m_namespaces = null;
        }
    }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

    /* (non-Javadoc)
     * @see org.jibx.runtime.IUnmarshaller#unmarshal(java.lang.Object, org.jibx.runtime.IUnmarshallingContext)
     */
    public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException {
        UnmarshallingContext ctx = (UnmarshallingContext)ictx;
        Name name = (Name)obj;
        if (name == null) {
            name = new Name();
        }
        ctx.parsePastStartTag(null, "name");
        name.firstName = ctx.parseElementText(null, "first-name");
        name.lastName = ctx.parseElementText(null, "last-name");
        ctx.parsePastEndTag(null, "name");
        return name;
    }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

    /* (non-Javadoc)
     * @see org.jibx.runtime.IUnmarshaller#unmarshal(java.lang.Object, org.jibx.runtime.IUnmarshallingContext)
     */
    public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException {
        UnmarshallingContext ctx = (UnmarshallingContext)ictx;
        Name name = (Name)obj;
        if (name == null) {
            name = new Name();
        }
        ctx.parsePastStartTag(m_uri, m_name);
        name.firstName = ctx.parseElementText(m_uri, "first-name");
        name.lastName = ctx.parseElementText(m_uri, "last-name");
        ctx.parsePastEndTag(m_uri, m_name);
        return name;
    }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

     */
    public Object unmarshal(Object obj, IUnmarshallingContext ictx)
        throws JiBXException {
       
        // make sure we're at the appropriate start tag
        UnmarshallingContext ctx = (UnmarshallingContext)ictx;
        if (m_name != null) {
            if (ctx.isAt(m_uri, m_name)) {
                ctx.parsePastStartTag(m_uri, m_name);
            } else {
                return null;
            }
        }
       
        // create new array if needed
        if (m_holder == null) {
            m_holder = new ArrayList();
        }
       
        // process all items present in document
        while (!ctx.isEnd()) {
            Object item = ctx.unmarshalElement();
            m_holder.add(item);
        }
       
        // discard close tag if used
        if (m_name != null) {
            ctx.parsePastEndTag(m_uri, m_name);
        }
       
        // return array containing all items
        Object[] result = m_holder.toArray();
        m_holder.clear();
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

        // setup for attribute access
        int count = ictx.getStackDepth();
        BindingElement.UnmarshalWrapper wrapper =
            (BindingElement.UnmarshalWrapper)ictx.getStackObject(count-1);
        ValidationContext vctx = wrapper.getValidation();
        UnmarshallingContext uctx = (UnmarshallingContext)ictx;
       
        // loop through all attributes of current element
        for (int i = 0; i < uctx.getAttributeCount(); i++) {
           
            // check if nonamespace attribute is in the allowed set
            String name = uctx.getAttributeName(i);
            if (uctx.getAttributeNamespace(i).length() == 0) {
                if (attrs.indexOf(name) < 0) {
                    vctx.addWarning("Undefined attribute " + name, this);
                }
            }
        }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

        String[] bindings) {
        m_attributeUri = uri;
        m_attributeName = name;
        m_versionTexts = versions;
        m_versionBindings = bindings;
        m_context = new UnmarshallingContext();
        m_outputIndent = -1;
    }
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

            if (version.equals(m_versionTexts[i])) {
               
                // version found, create unmarshaller for the associated binding
                IBindingFactory fact = BindingDirectory.
                    getFactory(m_versionBindings[i], clas);
                UnmarshallingContext context =
                    (UnmarshallingContext)fact.createUnmarshallingContext();
               
                // return object unmarshalled using binding for document version
                context.setFromContext(m_context);
                return context.unmarshalElement();
               
            }
        }
       
        // error if unknown version in document
View Full Code Here

Examples of org.jibx.runtime.impl.UnmarshallingContext

            StAXReaderWrapper wrapper = new StAXReaderWrapper(
                    fsr,
                    getSchemaType().getLocalPart(),
                    true);

            UnmarshallingContext ctx = (UnmarshallingContext) mctx;
            ctx.setDocument(wrapper);
            Object obj = mctx.unmarshalElement();
            return obj;
        }
        catch (JiBXException e)
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.