⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msvvalidator.java

📁 这是一个基于计算网格的web service。它用java编写。一旦安装完成
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        public void endElement() throws SAXException {        writePendingText();                if(!acceptor.isAcceptState(null)) {            // some required elements are missing            // report error            StringRef ref = new StringRef();            acceptor.isAcceptState(ref);            context.reportEvent(target,ref.str);        }                // pop the acceptor        Acceptor child = acceptor;        acceptor = (Acceptor)stack.pop();        if(!acceptor.stepForward( child, null )) {            // some required elements are missing.            // report an error            StringRef ref = new StringRef();            acceptor.stepForward( child, ref );  // force recovery and obtain an error message.                        context.reportEvent(target,ref.str);        }                context.getNamespaceContext().endElement();    }            public void childAsAttributes( JAXBObject o, String fieldName ) throws SAXException {        // do nothing                // either the onMarshallableObjectInElement method        // or the onMarshallableObjectInAttributeBody method will be         // called for every content tree objects.        //        // so we don't need to validate an object within this method.    }    public void childAsURIs( JAXBObject o, String fieldName ) throws SAXException {        // ditto.    }        /** An empty <code>Attributes</code> object. */    private static final AttributesImpl emptyAttributes = new AttributesImpl();        /** namespace URI of dummy elements. TODO: allocate one namespace URI for this. */    public static final String DUMMY_ELEMENT_NS =        "http://java.sun.com/jaxb/xjc/dummy-elements";    public void childAsBody( JAXBObject o, String fieldName ) throws SAXException {        //final ValidatableObject vo = Util.toValidatableObject(o);        final ValidatableObject vo =  jaxbContext.getGrammarInfo().castToValidatableObject(o);        if(vo==null) {            reportMissingObjectError(fieldName);            return;        }                if( insideAttribute )   childAsAttributeBody(vo,fieldName);        else                    childAsElementBody(o,vo);    }        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)) {            // this can't be possible, as the dummy element was             // generated by XJC.            throw new JAXBAssertionError();        }                // we need a separate validator instance to validate a child object        context.validate(vo);            }        private void childAsAttributeBody( ValidatableObject vo, String fieldName ) throws SAXException {        /*        Dirty quick hack. When we split a schema into fragments, basically        every chlid object needs a place holder in the fragment        (so that the parent schema fragment can correctly validate that the        child objects are at their supposed places.)                For example, cconsider the following schema:                imagine:        <class>          <attribute>            <list>              <oneOrMore>                <ref name="bar"/>              </oneOrMore>            </list>          </attribute>        </class>                In our algorithm, the corresponding schema fragment will be:                <class>          <attribute>            <list>              <oneOrMore>                <value>\u0000full.class.name.of.BarImpl</value>              </oneOrMore>            </list>          </attribute>        </class>                If we find a child object inside an attribute        (that's why we are in this method BTW),        we generate a class name (with a special marker \u0000).        */                // put a class name with a special marker \u0000. This char is an invalid        // XML char, so sensible datatypes should reject this (although many        // datatype implementations will accept it in actuality)        text("\u0000"+vo.getPrimaryInterface().getName(),fieldName);        // validate a child object        context.validate(vo);    }    public void reportError( ValidationEvent e ) throws AbortSerializationException {        context.reportEvent(target,e);    }////// ID/IDREF validation////    public String onID( IdentifiableObject owner, String value ) throws SAXException {        return context.onID(target,value);    }    public String onIDREF( IdentifiableObject value ) throws SAXException {        return context.onIDREF(target,value.____jaxb____getId());    }////  // ValidationContext implementation. Used by MSV to obtain// contextual information related to validation.////    public String getBaseUri() { return null; }    public boolean isUnparsedEntity( String entityName ) {        // abandon the validation of ENTITY type.        return true;    }    public boolean isNotation( String notation ) {        // abandon the validation of NOTATION type.        return true;    }    public void onID( Datatype dt, StringToken s ) {        // ID/IDREF validation will be done by ourselves.        // so we will not rely on the validator to perform this check.        // because we will use multiple instances of validators, so         // they cannot check global consistency.                // see onID/onIDREF of the ValidationContext.    }    public String resolveNamespacePrefix( String prefix ) {        return context.getNamespaceContext().getNamespaceURI(prefix);    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -