Package org.jibx.runtime.impl

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


    /* (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

     */
    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

        // 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

        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

            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

            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

   * @see org.jibx.runtime.IUnmarshaller#unmarshal(java.lang.Object, org.jibx.runtime.IUnmarshallingContext)
   */
  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(uri, name)) {
      ctx.throwStartTagNameError(uri, name);
    }

    // create new hashmap if needed
    OverlapBehaviorInfo overlapBehaviorInfo = (OverlapBehaviorInfo) obj;
    if (overlapBehaviorInfo == null) {
      overlapBehaviorInfo = new OverlapBehaviorInfo();
    }

    // process all entries present in document
    ctx.parsePastStartTag(uri, name);
    boolean found = false;
    for (OverlapBehaviorInfoInner inner : OverlapBehaviorInfoInner.values()) {
      if (ctx.parseIfStartTag(uri, inner.name())) {
        found = true;
        overlapBehaviorInfo.setOverlapBehavior(inner);
        ctx.parsePastEndTag(uri, inner.name());
        break;
      }
    }
    if (!found) {
      ctx.throwStartTagException("Unrecognized inner element");
    }
    ctx.parsePastEndTag(uri, name);
    return overlapBehaviorInfo;
  }
View Full Code Here

    public Container getSharedLayout() throws Exception {
        String path = "war:/conf/portal/portal/sharedlayout.xml";
        String out = IOUtil.getStreamContentAsString(confManager_.getInputStream(path));
        ByteArrayInputStream is = new ByteArrayInputStream(out.getBytes("UTF-8"));
        IBindingFactory bfact = BindingDirectory.getFactory(Container.class);
        UnmarshallingContext uctx = (UnmarshallingContext) bfact.createUnmarshallingContext();
        uctx.setDocument(is, null, "UTF-8", false);
        Container container = (Container) uctx.unmarshalElement();
        generateStorageName(container);
        return container;
    }
View Full Code Here

   {
      String path = "war:/conf/portal/portal/sharedlayout.xml";
      String out = IOUtil.getStreamContentAsString(confManager_.getInputStream(path));
      ByteArrayInputStream is = new ByteArrayInputStream(out.getBytes("UTF-8"));
      IBindingFactory bfact = BindingDirectory.getFactory(Container.class);
      UnmarshallingContext uctx = (UnmarshallingContext)bfact.createUnmarshallingContext();
      uctx.setDocument(is, null, "UTF-8", false);
      Container container = (Container)uctx.unmarshalElement();
      generateStorageName(container);
      return container;
   }
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.