本文整理汇总了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;
}
示例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;
}
示例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);
}