本文整理汇总了Java中com.sun.org.apache.xerces.internal.impl.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于com.sun.org.apache.xerces.internal.impl包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Parse the given XML string an create/update the corresponding entities
*
* @param xml
* the XML string
* @return the parse return code
* @throws Exception
*/
public int parse(byte[] xml) throws Exception {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SchemaFactory sf = SchemaFactory
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try (InputStream inputStream = ResourceLoader.getResourceAsStream(
getClass(), getSchemaName())) {
Schema schema = sf.newSchema(new StreamSource(inputStream));
spf.setSchema(schema);
}
SAXParser saxParser = spf.newSAXParser();
XMLReader reader = saxParser.getXMLReader();
reader.setFeature(Constants.XERCES_FEATURE_PREFIX
+ Constants.DISALLOW_DOCTYPE_DECL_FEATURE, true);
reader.setContentHandler(this);
reader.parse(new InputSource(new ByteArrayInputStream(xml)));
return 0;
}
示例2: checkProperty
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Check a property. If the property is know and supported, this method
* simply returns. Otherwise, the appropriate exception is thrown.
*
* @param propertyId The unique identifier (URI) of the property
* being set.
*
* @throws XMLConfigurationException Thrown for configuration error.
* In general, components should
* only throw this exception if
* it is <strong>really</strong>
* a critical error.
*/
protected PropertyState checkProperty(String propertyId)
throws XMLConfigurationException {
//
// Xerces Properties
//
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
return PropertyState.RECOGNIZED;
}
}
//
// Not recognized
//
return super.checkProperty(propertyId);
}
示例3: startParameterEntity
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* This method notifies of the start of a parameter entity. The parameter
* entity name start with a '%' character.
*
* @param name The name of the parameter entity.
* @param identifier The resource identifier.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal parameter entities).
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startParameterEntity (String name,
XMLResourceIdentifier identifier,
String encoding,
Augmentations augs) throws XNIException {
if (DEBUG_EVENTS) {
System.out.println ("==>startParameterEntity: "+name);
if (DEBUG_BASEURI) {
System.out.println (" expandedSystemId: "+identifier.getExpandedSystemId ());
System.out.println (" baseURI:"+ identifier.getBaseSystemId ());
}
}
if (augs != null && fInternalSubset != null &&
!fInDTDExternalSubset &&
Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
fInternalSubset.append(name).append(";\n");
}
fBaseURIStack.push (identifier.getExpandedSystemId ());
}
示例4: checkFeature
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Check a feature. If feature is know and supported, this method simply
* returns. Otherwise, the appropriate exception is thrown.
*
* @param featureId The unique identifier (URI) of the feature.
*
* @throws XMLConfigurationException Thrown for configuration error.
* In general, components should
* only throw this exception if
* it is <strong>really</strong>
* a critical error.
*/
protected FeatureState checkFeature(String featureId)
throws XMLConfigurationException {
//
// Xerces Features
//
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
//
// special performance feature: no one by component manager is allowed to set it
//
if (suffixLength == Constants.PARSER_SETTINGS.length() &&
featureId.endsWith(Constants.PARSER_SETTINGS)) {
return FeatureState.NOT_SUPPORTED;
}
}
return super.checkFeature(featureId);
}
示例5: startGeneralEntity
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* This method notifies of the start of an entity. The DTD has the
* pseudo-name of "[dtd]" parameter entity names start with '%'; and
* general entity names are just the entity name.
* <p>
* <strong>Note:</strong> Since the document is an entity, the handler
* will be notified of the start of the document entity by calling the
* startEntity method with the entity name "[xml]" <em>before</em> calling
* the startDocument method. When exposing entity boundaries through the
* SAX API, the document entity is never reported, however.
* <p>
* <strong>Note:</strong> This method is not called for entity references
* appearing as part of attribute values.
*
* @param name The name of the entity.
* @param identifier The resource identifier.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal parameter entities).
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startGeneralEntity(String name, XMLResourceIdentifier identifier,
String encoding, Augmentations augs)
throws XNIException {
try {
// Only report startEntity if this entity was actually read.
if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
// report skipped entity to content handler
if (fContentHandler != null) {
fContentHandler.skippedEntity(name);
}
}
else {
// SAX2 extension
if (fLexicalHandler != null) {
fLexicalHandler.startEntity(name);
}
}
}
catch (SAXException e) {
throw new XNIException(e);
}
}
示例6: reset
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Resets the parser state.
*
* @throws SAXException Thrown on initialization error.
*/
public void reset () {
super.reset ();
// get state of namespace-declarations parameter.
fNamespaceDeclarations =
fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
// DOM Filter
if (fSkippedElemStack!=null) {
fSkippedElemStack.removeAllElements ();
}
fSchemaLocations.clear ();
fRejectedElementDepth = 0;
fFilterReject = false;
fSchemaType = null;
}
示例7: startParameterEntity
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* This method notifies of the start of parameter entity. The DTD has the
* pseudo-name of "[dtd]" parameter entity names start with '%'; and
* general entity names are just the entity name.
* <p>
* <strong>Note:</strong> Since the document is an entity, the handler
* will be notified of the start of the document entity by calling the
* startEntity method with the entity name "[xml]" <em>before</em> calling
* the startDocument method. When exposing entity boundaries through the
* SAX API, the document entity is never reported, however.
* <p>
* <strong>Note:</strong> This method is not called for entity references
* appearing as part of attribute values.
*
* @param name The name of the parameter entity.
* @param identifier The resource identifier.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal parameter entities).
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startParameterEntity(String name,
XMLResourceIdentifier identifier,
String encoding, Augmentations augs)
throws XNIException {
try {
// Only report startEntity if this entity was actually read.
if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
// report skipped entity to content handler
if (fContentHandler != null) {
fContentHandler.skippedEntity(name);
}
}
else {
// SAX2 extension
if (fLexicalHandler != null && fLexicalHandlerParameterEntities) {
fLexicalHandler.startEntity(name);
}
}
}
catch (SAXException e) {
throw new XNIException(e);
}
}
示例8: endElement
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
public void endElement(QName element, Augmentations augs)
throws XNIException {
final Node currentElement = fDOMValidatorHelper.getCurrentElement();
// Write type information to this element
if (augs != null && fDocumentImpl != null) {
ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
if (elementPSVI != null) {
if (fStorePSVI) {
((PSVIElementNSImpl) currentElement).setPSVI(elementPSVI);
}
XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
if (type == null) {
type = elementPSVI.getTypeDefinition();
}
((ElementNSImpl) currentElement).setType(type);
}
}
}
示例9: endElement
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
public void endElement(QName element, Augmentations augs)
throws XNIException {
// write type information to this element
if (augs != null && fDocumentImpl != null) {
ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
if (elementPSVI != null) {
if (fStorePSVI) {
((PSVIElementNSImpl)fCurrentNode).setPSVI(elementPSVI);
}
XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
if (type == null) {
type = elementPSVI.getTypeDefinition();
}
((ElementNSImpl)fCurrentNode).setType(type);
}
}
// adjust current node reference
if (fCurrentNode == fFragmentRoot) {
fCurrentNode = null;
fFragmentRoot = null;
return;
}
fCurrentNode = fCurrentNode.getParentNode();
}
示例10: setProperty
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Sets the value of a property. This method is called by the component
* manager any time after reset when a property changes value.
* <p>
* <strong>Note:</strong> Components should silently ignore properties
* that do not affect the operation of the component.
*
* @param propertyId The property identifier.
* @param value The value of the property.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
fSecurityManager = (XMLSecurityManager)value;
maxNodeLimit = (fSecurityManager != null) ?
fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
return;
}
if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
fErrorReporter = (XMLErrorReporter)value;
return;
}
}
}
示例11: validate
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
public final boolean validate(){
// Do validation if all of the following are true:
// 1. The JAXP Schema Language property is not XML Schema
// REVISIT: since only DTD and Schema are supported at this time,
// such checking is sufficient. but if more schema types
// are introduced in the future, we'll need to change it
// to something like
// (fSchemaType == null || fSchemaType == NS_XML_DTD)
// 2. One of the following is true (validation features)
// 2.1 Dynamic validation is off, and validation is on
// 2.2 Dynamic validation is on, and DOCTYPE was seen
// 3 Xerces schema validation feature is off, or DOCTYPE was seen.
return (fSchemaType != Constants.NS_XMLSCHEMA) &&
(!fDynamicValidation && fValidation ||
fDynamicValidation && fSeenDoctypeDecl) &&
(fDTDValidation || fSeenDoctypeDecl);
}
示例12: loadSchema
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
* Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
* to resolve the location of the schema in XSDDescription
* @param desc
* @param source
* @param locationPairs
* @return An XML Schema grammar
* @throws IOException
* @throws XNIException
*/
SchemaGrammar loadSchema(XSDDescription desc,
XMLInputSource source,
Map locationPairs) throws IOException, XNIException {
// this should only be done once per invocation of this object;
// unless application alters JAXPSource in the mean time.
if(!fJAXPProcessed) {
processJAXPSchemaSource(locationPairs);
}
if (desc.isExternal()) {
String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
if (accessError != null) {
throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"schema_reference.access",
new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
}
}
SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);
return grammar;
}
示例13: setScannerVersion
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
public void setScannerVersion(short version) {
if(version == Constants.XML_VERSION_1_0) {
if(fXML10EntityScanner == null) {
fXML10EntityScanner = new XMLEntityScanner();
}
fXML10EntityScanner.reset(fSymbolTable, this, fErrorReporter);
fEntityScanner = fXML10EntityScanner;
fEntityScanner.setCurrentEntity(fCurrentEntity);
} else {
if(fXML11EntityScanner == null) {
fXML11EntityScanner = new XML11EntityScanner();
}
fXML11EntityScanner.reset(fSymbolTable, this, fErrorReporter);
fEntityScanner = fXML11EntityScanner;
fEntityScanner.setCurrentEntity(fCurrentEntity);
}
}
示例14: setFeature
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Sets the state of a feature. This method is called by the component
* manager any time after reset when a feature changes state.
* <p>
* <strong>Note:</strong> Components should silently ignore features
* that do not affect the operation of the component.
*
* @param featureId The feature identifier.
* @param state The state of the feature.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
public void setFeature(String featureId, boolean state)
throws XMLConfigurationException {
// xerces features
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
if (suffixLength == Constants.ALLOW_JAVA_ENCODINGS_FEATURE.length() &&
featureId.endsWith(Constants.ALLOW_JAVA_ENCODINGS_FEATURE)) {
fAllowJavaEncodings = state;
}
if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
fLoadExternalDTD = state;
return;
}
}
}
示例15: reset
import com.sun.org.apache.xerces.internal.impl.Constants; //导入依赖的package包/类
/**
* Resets the parser state.
*
* @throws SAXException Thrown on initialization error.
*/
public void reset () {
super.reset();
// get state of namespace-declarations parameter.
fNamespaceDeclarations =
fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
// DOM Filter
if (fSkippedElemStack != null) {
fSkippedElemStack.removeAllElements();
}
fRejectedElementDepth = 0;
fFilterReject = false;
fSchemaType = null;
}