當前位置: 首頁>>代碼示例>>Java>>正文


Java Acceptor類代碼示例

本文整理匯總了Java中com.sun.msv.verifier.Acceptor的典型用法代碼示例。如果您正苦於以下問題:Java Acceptor類的具體用法?Java Acceptor怎麽用?Java Acceptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Acceptor類屬於com.sun.msv.verifier包,在下文中一共展示了Acceptor類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateElementAndAttributes

import com.sun.msv.verifier.Acceptor; //導入依賴的package包/類
@Override
public int validateElementAndAttributes()
    throws XMLStreamException
{
    // Not handling any attributes
    mCurrAttrLocalName = mCurrAttrPrefix = "";
    if (mCurrAcceptor != null) {
        /* start tag info is still intact here (only attributes sent
         * since child acceptor was created)
         */
        if (!mCurrAcceptor.onEndAttributes(mStartTag, mErrorRef)
            || mErrorRef.str != null) {
            reportError(mErrorRef);
        }

        int stringChecks = mCurrAcceptor.getStringCareLevel();
        switch (stringChecks) {
        case Acceptor.STRING_PROHIBITED: // only WS
            return XMLValidator.CONTENT_ALLOW_WS;
        case Acceptor.STRING_IGNORE: // anything (mixed content models)
            return XMLValidator.CONTENT_ALLOW_ANY_TEXT;
        case Acceptor.STRING_STRICT: // validatable (data-oriented)
            return XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT;
        default:
            throw new IllegalArgumentException("Internal error: unexpected string care level value return by MSV: "+stringChecks);
        }
    }

    // If no acceptor, we are recovering, no need or use to validate text
    return CONTENT_ALLOW_ANY_TEXT;
}
 
開發者ID:FasterXML,項目名稱:woodstox,代碼行數:32,代碼來源:GenericMsvValidator.java

示例2: startElement

import com.sun.msv.verifier.Acceptor; //導入依賴的package包/類
public void startElement( String uri, String local ) throws SAXException {
    writePendingText();
    
    context.getNamespaceContext().startElement();
    
    stack.push(acceptor);
    
    StartTagInfo sti = new StartTagInfo(uri,local,local,emptyAttributes,this);
    
    // we pass in an empty attributes, as there is just no way for us to
    // properly re-construct attributes. Fortunately, I know MSV is not using
    // attribute values, so this would work, but nevertheless this code is
    // ugly. This is one of the problems of the "middle" approach.
    Acceptor child = acceptor.createChildAcceptor( sti, null );
    if( child==null ) {
        // this element is invalid. probably, so this object is invalid
        // report an error
        StringRef ref = new StringRef();
        child = acceptor.createChildAcceptor( sti, ref );
        context.reportEvent(target,ref.str);
    }
    
    this.currentElementUri = uri;
    this.currentElementLocalName = local;
    
    acceptor = child;
}
 
開發者ID:nhrdl,項目名稱:javacash,代碼行數:28,代碼來源:MSVValidator.java

示例3: childAsElementBody

import com.sun.msv.verifier.Acceptor; //導入依賴的package包/類
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);
        
    }
 
開發者ID:nhrdl,項目名稱:javacash,代碼行數:75,代碼來源:MSVValidator.java


注:本文中的com.sun.msv.verifier.Acceptor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。