本文整理汇总了Java中com.sun.tools.internal.xjc.reader.Const类的典型用法代码示例。如果您正苦于以下问题:Java Const类的具体用法?Java Const怎么用?Java Const使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Const类属于com.sun.tools.internal.xjc.reader包,在下文中一共展示了Const类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startElement
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
super.startElement(namespaceURI, localName, qName, atts);
Element e = getCurrentElement();
locatorTable.storeStartLocation( e, locator );
// check if this element is an outer-most <jaxb:bindings>
if( Const.JAXB_NSURI.equals(e.getNamespaceURI())
&& "bindings".equals(e.getLocalName()) ) {
// if this is the root node (meaning that this file is an
// external binding file) or if the parent is XML Schema element
// (meaning that this is an "inlined" external binding)
Node p = e.getParentNode();
if( p instanceof Document
||( p instanceof Element && !e.getNamespaceURI().equals(p.getNamespaceURI()))) {
outerMostBindings.add(e); // remember this value
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DOMBuilder.java
示例2: declareExtensionNamespace
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
* attribute of the target document.
*/
private void declareExtensionNamespace( Element target, String nsUri ) {
// look for the attribute
Element root = target.getOwnerDocument().getDocumentElement();
Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
if( att==null ) {
String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
// no such attribute. Create one.
att = target.getOwnerDocument().createAttributeNS(
Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
root.setAttributeNodeNS(att);
}
String prefix = allocatePrefix(root,nsUri);
if( att.getValue().indexOf(prefix)==-1 )
// avoid redeclaring the same namespace twice.
att.setValue( att.getValue()+' '+prefix);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Internalizer.java
示例3: allocatePrefix
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Declares a new prefix on the given element and associates it
* with the specified namespace URI.
* <p>
* Note that this method doesn't use the default namespace
* even if it can.
*/
private String allocatePrefix( Element e, String nsUri ) {
// look for existing namespaces.
NamedNodeMap atts = e.getAttributes();
for( int i=0; i<atts.getLength(); i++ ) {
Attr a = (Attr)atts.item(i);
if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
if( a.getName().indexOf(':')==-1 ) continue;
if( a.getValue().equals(nsUri) )
return a.getLocalName(); // found one
}
}
// none found. allocate new.
while(true) {
String prefix = "p"+(int)(Math.random()*1000000)+'_';
if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
continue; // this prefix is already allocated.
e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
return prefix;
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:Internalizer.java
示例4: createXSOM
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Parses a {@link DOMForest} into a {@link XSSchemaSet}.
*
* @return
* null if the parsing failed.
*/
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
// set up other parameters to XSOMParser
XSOMParser reader = createXSOMParser(forest);
// re-parse the transformed schemas
for (String systemId : forest.getRootDocuments()) {
errorReceiver.pollAbort();
Document dom = forest.get(systemId);
if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
reader.parse(systemId);
}
}
XSSchemaSet result = reader.getResult();
if(result!=null)
scdBasedBindingSet.apply(result,errorReceiver);
return result;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:ModelLoader.java
示例5: startElement
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
QName newElement = new QName(namespaceURI,localName);
if( newElement.getNamespaceURI().equals(Const.JAXB_NSURI)
&& top().getNamespaceURI().equals(WellKnownNamespace.XML_SCHEMA) ) {
// we hit a JAXB customization. the stack top should be
// <xs:appinfo>
if( elementNames.size()>=3 ) {
// the above statement checks if the following statement doesn't
// cause an exception.
QName schemaElement = elementNames.get( elementNames.size()-3 );
if( prohibitedSchemaElementNames.contains(schemaElement.getLocalPart()) ) {
// the owner schema element is in the wanted list.
errorHandler.error( new SAXParseException(
Messages.format(
Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION,
localName ),
locator ) );
}
}
}
elementNames.push(newElement);
super.startElement(namespaceURI, localName, qName, atts );
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:CustomizationContextChecker.java
示例6: endDocument
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
@Override
public void endDocument() throws SAXException {
if( isJAXBPrefixUsed && !isCustomizationUsed ) {
SAXParseException e = new SAXParseException(
Messages.format(Messages.WARN_INCORRECT_URI, Const.JAXB_NSURI),
locator );
errorHandler.warning(e);
}
super.endDocument();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:IncorrectNamespaceURIChecker.java
示例7: startPrefixMapping
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; //xml prefix shall not be declared based on jdk api javadoc
if( prefix.equals("jaxb") )
isJAXBPrefixUsed = true;
if( uri.equals(Const.JAXB_NSURI) )
isCustomizationUsed = true;
super.startPrefixMapping(prefix, uri);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:IncorrectNamespaceURIChecker.java
示例8: startElement
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
super.startElement(namespaceURI, localName, qName, atts);
// I'm not sure if this is necessary (SAX might report the change of the default prefix
// through the startPrefixMapping method, and I think it does indeed.)
//
// but better safe than sorry.
if( namespaceURI.equals(Const.JAXB_NSURI) )
isCustomizationUsed = true;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:IncorrectNamespaceURIChecker.java
示例9: checkExpectedContentTypes
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
private void checkExpectedContentTypes(XSComponent c) {
if(c.getForeignAttribute(WellKnownNamespace.XML_MIME_URI, Const.EXPECTED_CONTENT_TYPES)==null)
return; // no such attribute
if(c instanceof XSParticle)
return; // particles get the same foreign attributes as local element decls,
// so we need to skip them
if(!stb.isAcknowledgedXmimeContentTypes(c)) {
// this is not used
getErrorReporter().warning(c.getLocator(),Messages.WARN_UNUSED_EXPECTED_CONTENT_TYPES);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:UnusedCustomizationChecker.java
示例10: needsToBePruned
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Returns true if the elements with the given namespace URI
* should be blocked by this filter.
*/
private boolean needsToBePruned( String uri ) {
if( uri.equals(schemaLanguage) )
return false;
if( uri.equals(Const.JAXB_NSURI) )
return false;
if( uri.equals(Const.XJC_EXTENSION_URI) )
return false;
// we don't want validator to see extensions that we understand ,
// because they will complain.
// OTOH, if this is an extension that we didn't understand,
// we want the validator to report an error
return enabledExtensions.contains(uri);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:DTDExtensionBindingChecker.java
示例11: getOneDocument
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Picks one document at random and returns it.
*/
public Document getOneDocument() {
for (Document dom : core.values()) {
if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI))
return dom;
}
// we should have caught this error very early on
throw new AssertionError();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:DOMForest.java
示例12: declExtensionNamespace
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Recursively visits sub-elements and declare all used namespaces.
* TODO: the fact that we recognize all namespaces in the extension
* is a bad design.
*/
private void declExtensionNamespace(Element decl, Element target) {
// if this comes from external namespaces, add the namespace to
// @extensionBindingPrefixes.
if( !Const.JAXB_NSURI.equals(decl.getNamespaceURI()) )
declareExtensionNamespace( target, decl.getNamespaceURI() );
NodeList lst = decl.getChildNodes();
for( int i=0; i<lst.getLength(); i++ ) {
Node n = lst.item(i);
if( n instanceof Element )
declExtensionNamespace( (Element)n, target );
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Internalizer.java
示例13: startElement
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
super.startElement(namespaceURI, localName, qName, atts);
if(!seenRoot) {
// if this is the root element
seenRoot = true;
rootTagStart = new LocatorImpl(locator);
version = atts.getValue(Const.JAXB_NSURI,"version");
if( namespaceURI.equals(Const.JAXB_NSURI) ) {
String version2 = atts.getValue("","version");
if( version!=null && version2!=null ) {
// we have both @version and @jaxb:version. error.
SAXParseException e = new SAXParseException(
Messages.format( Messages.TWO_VERSION_ATTRIBUTES ), locator );
getErrorHandler().error(e);
}
if( version==null )
version = version2;
}
}
if( Const.JAXB_NSURI.equals(namespaceURI) )
seenBindings = true;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:VersionChecker.java
示例14: findExternalResource
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
protected String findExternalResource( String nsURI, String localName, Attributes atts) {
if( Const.RELAXNG_URI.equals(nsURI)
&& ("include".equals(localName) || "externalRef".equals(localName) ) )
return atts.getValue("href");
else
return null;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:RELAXNGInternalizationLogic.java
示例15: loadRELAXNG
import com.sun.tools.internal.xjc.reader.Const; //导入依赖的package包/类
/**
* Parses a RELAX NG grammar into an annotated grammar.
*/
private Model loadRELAXNG() throws SAXException {
// build DOM forest
final DOMForest forest = buildDOMForest( new RELAXNGInternalizationLogic() );
// use JAXP masquerading to validate the input document.
// DOMForest -> ExtensionBindingChecker -> RNGOM
XMLReaderCreator xrc = new XMLReaderCreator() {
public XMLReader createXMLReader() {
// foreset parser cannot change the receivers while it's working,
// so we need to have one XMLFilter that works as a buffer
XMLFilter buffer = new XMLFilterImpl() {
@Override
public void parse(InputSource source) throws IOException, SAXException {
forest.createParser().parse( source, this, this, this );
}
};
XMLFilter f = new ExtensionBindingChecker(Const.RELAXNG_URI,opt,errorReceiver);
f.setParent(buffer);
f.setEntityResolver(opt.entityResolver);
return f;
}
};
Parseable p = new SAXParseable( opt.getGrammars()[0], errorReceiver, xrc );
return loadRELAXNG(p);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:ModelLoader.java
注:本文中的com.sun.tools.internal.xjc.reader.Const类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论