Search in sources :

Example 1 with RIElement

use of com.sun.xml.bind.RIElement in project OpenAM by OpenRock.

the class MSVValidator method childAsElementBody.

private void childAsElementBody(Object o, ValidatableObject vo) throws SAXException {
    String intfName = vo.getPrimaryInterface().getName();
    intfName = intfName.replace('$', '.');
    // if the object implements the RIElement interface,
    // add a marker attribute to the dummy element.
    //
    // For example, if the object is org.acme.impl.FooImpl,
    // the dummy element will look like
    // <{DUMMY_ELEMENT_NS}org.acme.Foo
    //          {<URI of this element>}:<local name of this element>="" />
    // 
    // This extra attribute is used to validate wildcards.
    //        AttributesImpl atts;
    //        if(o instanceof RIElement) {
    //            RIElement rie = (RIElement)o;
    //            atts = new AttributesImpl();
    //            atts.addAttribute(
    //                rie.____jaxb_ri____getNamespaceURI(),
    //                rie.____jaxb_ri____getLocalName(),
    //                rie.____jaxb_ri____getLocalName(),  // use local name as qname
    //                "CDATA",
    //                "");    // we don't care about the attribute value
    //        } else
    //            atts = emptyAttributes;
    // feed a dummy element to the acceptor.
    StartTagInfo sti = new StartTagInfo(DUMMY_ELEMENT_NS, intfName, intfName, /*just pass the local name as QName.*/
    emptyAttributes, this);
    Acceptor child = acceptor.createChildAcceptor(sti, null);
    if (child == null) {
        // some required elements were missing. report errors
        StringRef ref = new StringRef();
        child = acceptor.createChildAcceptor(sti, ref);
        context.reportEvent(target, ref.str);
    }
    if (o instanceof RIElement) {
        RIElement rie = (RIElement) o;
        if (!child.onAttribute2(rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName(), rie.____jaxb_ri____getLocalName(), "", null, null, null))
            // this object is not a valid member of the wildcard
            context.reportEvent(target, Messages.format(Messages.INCORRECT_CHILD_FOR_WILDCARD, rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName()));
    }
    child.onEndAttributes(sti, null);
    if (!acceptor.stepForward(child, null)) {
        // generated by XJC.
        throw new JAXBAssertionError();
    }
    // we need a separate validator instance to validate a child object
    context.validate(vo);
}
Also used : Acceptor(com.sun.msv.verifier.Acceptor) JAXBAssertionError(com.sun.xml.bind.JAXBAssertionError) RIElement(com.sun.xml.bind.RIElement) StartTagInfo(com.sun.msv.util.StartTagInfo) StringRef(com.sun.msv.util.StringRef)

Example 2 with RIElement

use of com.sun.xml.bind.RIElement in project OpenAM by OpenRock.

the class MSVValidator method childAsElementBody.

private void childAsElementBody(Object o, ValidatableObject vo) throws SAXException {
    String intfName = vo.getPrimaryInterface().getName();
    intfName = intfName.replace('$', '.');
    // if the object implements the RIElement interface,
    // add a marker attribute to the dummy element.
    //
    // For example, if the object is org.acme.impl.FooImpl,
    // the dummy element will look like
    // <{DUMMY_ELEMENT_NS}org.acme.Foo
    //          {<URI of this element>}:<local name of this element>="" />
    // 
    // This extra attribute is used to validate wildcards.
    //        AttributesImpl atts;
    //        if(o instanceof RIElement) {
    //            RIElement rie = (RIElement)o;
    //            atts = new AttributesImpl();
    //            atts.addAttribute(
    //                rie.____jaxb_ri____getNamespaceURI(),
    //                rie.____jaxb_ri____getLocalName(),
    //                rie.____jaxb_ri____getLocalName(),  // use local name as qname
    //                "CDATA",
    //                "");    // we don't care about the attribute value
    //        } else
    //            atts = emptyAttributes;
    // feed a dummy element to the acceptor.
    StartTagInfo sti = new StartTagInfo(DUMMY_ELEMENT_NS, intfName, intfName, /*just pass the local name as QName.*/
    emptyAttributes, this);
    Acceptor child = acceptor.createChildAcceptor(sti, null);
    if (child == null) {
        // some required elements were missing. report errors
        StringRef ref = new StringRef();
        child = acceptor.createChildAcceptor(sti, ref);
        context.reportEvent(target, ref.str);
    }
    if (o instanceof RIElement) {
        RIElement rie = (RIElement) o;
        if (!child.onAttribute2(rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName(), rie.____jaxb_ri____getLocalName(), "", null, null, null))
            // this object is not a valid member of the wildcard
            context.reportEvent(target, Messages.format(Messages.INCORRECT_CHILD_FOR_WILDCARD, rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName()));
    }
    child.onEndAttributes(sti, null);
    if (!acceptor.stepForward(child, null)) {
        // generated by XJC.
        throw new JAXBAssertionError();
    }
    // we need a separate validator instance to validate a child object
    context.validate(vo);
}
Also used : Acceptor(com.sun.msv.verifier.Acceptor) JAXBAssertionError(com.sun.xml.bind.JAXBAssertionError) RIElement(com.sun.xml.bind.RIElement) StartTagInfo(com.sun.msv.util.StartTagInfo) StringRef(com.sun.msv.util.StringRef)

Example 3 with RIElement

use of com.sun.xml.bind.RIElement in project OpenAM by OpenRock.

the class MSVValidator method childAsElementBody.

private void childAsElementBody(Object o, ValidatableObject vo) throws SAXException {
    String intfName = vo.getPrimaryInterface().getName();
    intfName = intfName.replace('$', '.');
    // if the object implements the RIElement interface,
    // add a marker attribute to the dummy element.
    //
    // For example, if the object is org.acme.impl.FooImpl,
    // the dummy element will look like
    // <{DUMMY_ELEMENT_NS}org.acme.Foo
    //          {<URI of this element>}:<local name of this element>="" />
    // 
    // This extra attribute is used to validate wildcards.
    //        AttributesImpl atts;
    //        if(o instanceof RIElement) {
    //            RIElement rie = (RIElement)o;
    //            atts = new AttributesImpl();
    //            atts.addAttribute(
    //                rie.____jaxb_ri____getNamespaceURI(),
    //                rie.____jaxb_ri____getLocalName(),
    //                rie.____jaxb_ri____getLocalName(),  // use local name as qname
    //                "CDATA",
    //                "");    // we don't care about the attribute value
    //        } else
    //            atts = emptyAttributes;
    // feed a dummy element to the acceptor.
    StartTagInfo sti = new StartTagInfo(DUMMY_ELEMENT_NS, intfName, intfName, /*just pass the local name as QName.*/
    emptyAttributes, this);
    Acceptor child = acceptor.createChildAcceptor(sti, null);
    if (child == null) {
        // some required elements were missing. report errors
        StringRef ref = new StringRef();
        child = acceptor.createChildAcceptor(sti, ref);
        context.reportEvent(target, ref.str);
    }
    if (o instanceof RIElement) {
        RIElement rie = (RIElement) o;
        if (!child.onAttribute2(rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName(), rie.____jaxb_ri____getLocalName(), "", null, null, null))
            // this object is not a valid member of the wildcard
            context.reportEvent(target, Messages.format(Messages.INCORRECT_CHILD_FOR_WILDCARD, rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName()));
    }
    child.onEndAttributes(sti, null);
    if (!acceptor.stepForward(child, null)) {
        // generated by XJC.
        throw new JAXBAssertionError();
    }
    // we need a separate validator instance to validate a child object
    context.validate(vo);
}
Also used : Acceptor(com.sun.msv.verifier.Acceptor) JAXBAssertionError(com.sun.xml.bind.JAXBAssertionError) RIElement(com.sun.xml.bind.RIElement) StartTagInfo(com.sun.msv.util.StartTagInfo) StringRef(com.sun.msv.util.StringRef)

Example 4 with RIElement

use of com.sun.xml.bind.RIElement in project OpenAM by OpenRock.

the class MSVValidator method childAsElementBody.

private void childAsElementBody(Object o, ValidatableObject vo) throws SAXException {
    String intfName = vo.getPrimaryInterface().getName();
    intfName = intfName.replace('$', '.');
    // if the object implements the RIElement interface,
    // add a marker attribute to the dummy element.
    //
    // For example, if the object is org.acme.impl.FooImpl,
    // the dummy element will look like
    // <{DUMMY_ELEMENT_NS}org.acme.Foo
    //          {<URI of this element>}:<local name of this element>="" />
    // 
    // This extra attribute is used to validate wildcards.
    //        AttributesImpl atts;
    //        if(o instanceof RIElement) {
    //            RIElement rie = (RIElement)o;
    //            atts = new AttributesImpl();
    //            atts.addAttribute(
    //                rie.____jaxb_ri____getNamespaceURI(),
    //                rie.____jaxb_ri____getLocalName(),
    //                rie.____jaxb_ri____getLocalName(),  // use local name as qname
    //                "CDATA",
    //                "");    // we don't care about the attribute value
    //        } else
    //            atts = emptyAttributes;
    // feed a dummy element to the acceptor.
    StartTagInfo sti = new StartTagInfo(DUMMY_ELEMENT_NS, intfName, intfName, /*just pass the local name as QName.*/
    emptyAttributes, this);
    Acceptor child = acceptor.createChildAcceptor(sti, null);
    if (child == null) {
        // some required elements were missing. report errors
        StringRef ref = new StringRef();
        child = acceptor.createChildAcceptor(sti, ref);
        context.reportEvent(target, ref.str);
    }
    if (o instanceof RIElement) {
        RIElement rie = (RIElement) o;
        if (!child.onAttribute2(rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName(), rie.____jaxb_ri____getLocalName(), "", null, null, null))
            // this object is not a valid member of the wildcard
            context.reportEvent(target, Messages.format(Messages.INCORRECT_CHILD_FOR_WILDCARD, rie.____jaxb_ri____getNamespaceURI(), rie.____jaxb_ri____getLocalName()));
    }
    child.onEndAttributes(sti, null);
    if (!acceptor.stepForward(child, null)) {
        // generated by XJC.
        throw new JAXBAssertionError();
    }
    // we need a separate validator instance to validate a child object
    context.validate(vo);
}
Also used : Acceptor(com.sun.msv.verifier.Acceptor) JAXBAssertionError(com.sun.xml.bind.JAXBAssertionError) RIElement(com.sun.xml.bind.RIElement) StartTagInfo(com.sun.msv.util.StartTagInfo) StringRef(com.sun.msv.util.StringRef)

Aggregations

StartTagInfo (com.sun.msv.util.StartTagInfo)4 StringRef (com.sun.msv.util.StringRef)4 Acceptor (com.sun.msv.verifier.Acceptor)4 JAXBAssertionError (com.sun.xml.bind.JAXBAssertionError)4 RIElement (com.sun.xml.bind.RIElement)4