Example #1
0
 public void setProperty(String name, Object object)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException(
         JAXPValidationMessageFormatter.formatMessage(
             Locale.getDefault(), "ProperyNameNull", null));
   }
   if (name.equals(SECURITY_MANAGER)) {
     fSecurityManager = (SecurityManager) object;
     fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
     return;
   } else if (name.equals(XMLGRAMMAR_POOL)) {
     throw new SAXNotSupportedException(
         SAXMessageFormatter.formatMessage(
             Locale.getDefault(), "property-not-supported", new Object[] {name}));
   }
   try {
     fXMLSchemaLoader.setProperty(name, object);
   } catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               Locale.getDefault(), "property-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               Locale.getDefault(), "property-not-supported", new Object[] {identifier}));
     }
   }
 }
  /**
   * Query the state of a feature.
   *
   * <p>Query the current state of any feature in a SAX2 parser. The parser might not recognize the
   * feature.
   *
   * @param featureId The unique identifier (URI) of the feature being set.
   * @return The current state of the feature.
   * @exception org.xml.sax.SAXNotRecognizedException If the requested feature is not known.
   * @exception SAXNotSupportedException If the requested feature is known but not supported.
   */
  public boolean getFeature(String featureId)
      throws SAXNotRecognizedException, SAXNotSupportedException {

    try {

      // http://xml.org/sax/features/use-entity-resolver2
      //   controls whether the methods of an object implementing
      //   org.xml.sax.ext.EntityResolver2 will be used by the parser.
      //
      if (featureId.equals(USE_ENTITY_RESOLVER2)) {
        return fUseEntityResolver2;
      }

      //
      // Default handling
      //

      return fConfiguration.getFeature(featureId);
    } catch (XMLConfigurationException e) {
      String identifier = e.getIdentifier();
      if (e.getType() == Status.NOT_RECOGNIZED) {
        throw new SAXNotRecognizedException(
            SAXMessageFormatter.formatMessage(
                fConfiguration.getLocale(), "feature-not-recognized", new Object[] {identifier}));
      } else {
        throw new SAXNotSupportedException(
            SAXMessageFormatter.formatMessage(
                fConfiguration.getLocale(), "feature-not-supported", new Object[] {identifier}));
      }
    }
  } // getFeature(String):boolean
Example #3
0
 public void setFeature(String name, boolean value)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException(
         JAXPValidationMessageFormatter.formatMessage(
             Locale.getDefault(), "FeatureNameNull", null));
   }
   if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
     fSecurityManager = value ? new SecurityManager() : null;
     fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
     return;
   }
   try {
     fXMLSchemaLoader.setFeature(name, value);
   } catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               Locale.getDefault(), "feature-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               Locale.getDefault(), "feature-not-supported", new Object[] {identifier}));
     }
   }
 }
 public boolean getFeature(String name)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException(
         JAXPValidationMessageFormatter.formatMessage(
             fXMLSchemaLoader.getLocale(), "FeatureNameNull", null));
   }
   if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
     return (fSecurityManager != null);
   }
   try {
     return fXMLSchemaLoader.getFeature(name);
   } catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == Status.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               fXMLSchemaLoader.getLocale(), "feature-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               fXMLSchemaLoader.getLocale(), "feature-not-supported", new Object[] {identifier}));
     }
   }
 }
 public void setProperty0(String propertyId, Object value)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   try {
     fConfiguration.setProperty(propertyId, value);
   } catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == Status.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               fConfiguration.getLocale(), "property-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               fConfiguration.getLocale(), "property-not-supported", new Object[] {identifier}));
     }
   }
 } // setProperty(String,Object)
 public void setProperty(String name, Object object)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException();
   }
   try {
     fComponentManager.setProperty(name, object);
   } catch (XMLConfigurationException e) {
     final String identifier = e.getIdentifier();
     final String key =
         e.getType() == XMLConfigurationException.NOT_RECOGNIZED
             ? "property-not-recognized"
             : "property-not-supported";
     throw new SAXNotRecognizedException(
         SAXMessageFormatter.formatMessage(Locale.getDefault(), key, new Object[] {identifier}));
   }
 }
 public boolean getFeature(String name)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException();
   }
   try {
     return fComponentManager.getFeature(name);
   } catch (XMLConfigurationException e) {
     final String identifier = e.getIdentifier();
     final String key =
         e.getType() == XMLConfigurationException.NOT_RECOGNIZED
             ? "feature-not-recognized"
             : "feature-not-supported";
     throw new SAXNotRecognizedException(
         SAXMessageFormatter.formatMessage(Locale.getDefault(), key, new Object[] {identifier}));
   }
 }
 private void setSchemaValidatorFeature(String name, boolean value)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   try {
     fSAXParser.fSchemaValidator.setFeature(name, value);
   }
   // This should never be thrown from the schema validator.
   catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == Status.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               fConfiguration.getLocale(), "feature-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               fConfiguration.getLocale(), "feature-not-supported", new Object[] {identifier}));
     }
   }
 }
  /**
   * Query the value of a property.
   *
   * <p>Return the current value of a property in a SAX2 parser. The parser might not recognize the
   * property.
   *
   * @param propertyId The unique identifier (URI) of the property being set.
   * @return The current value of the property.
   * @exception org.xml.sax.SAXNotRecognizedException If the requested property is not known.
   * @exception SAXNotSupportedException If the requested property is known but not supported.
   */
  public Object getProperty(String propertyId)
      throws SAXNotRecognizedException, SAXNotSupportedException {

    if (propertyId.equals(CURRENT_ELEMENT_NODE)) {
      boolean deferred = false;
      try {
        deferred = getFeature(DEFER_NODE_EXPANSION);
      } catch (XMLConfigurationException e) {
        // ignore
      }
      if (deferred) {
        throw new SAXNotSupportedException(
            "Current element node cannot be queried when node expansion is deferred.");
      }
      return (fCurrentNode != null && fCurrentNode.getNodeType() == Node.ELEMENT_NODE)
          ? fCurrentNode
          : null;
    }

    try {
      XMLSecurityPropertyManager spm =
          (XMLSecurityPropertyManager) fConfiguration.getProperty(XML_SECURITY_PROPERTY_MANAGER);
      int index = spm.getIndex(propertyId);
      if (index > -1) {
        return spm.getValueByIndex(index);
      }

      return fConfiguration.getProperty(propertyId);
    } catch (XMLConfigurationException e) {
      String identifier = e.getIdentifier();
      if (e.getType() == Status.NOT_RECOGNIZED) {
        throw new SAXNotRecognizedException(
            SAXMessageFormatter.formatMessage(
                fConfiguration.getLocale(), "property-not-recognized", new Object[] {identifier}));
      } else {
        throw new SAXNotSupportedException(
            SAXMessageFormatter.formatMessage(
                fConfiguration.getLocale(), "property-not-supported", new Object[] {identifier}));
      }
    }
  } // getProperty(String):Object
 public void setFeature(String name, boolean value)
     throws SAXNotRecognizedException, SAXNotSupportedException {
   if (name == null) {
     throw new NullPointerException(
         JAXPValidationMessageFormatter.formatMessage(
             fXMLSchemaLoader.getLocale(), "FeatureNameNull", null));
   }
   if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
     if (System.getSecurityManager() != null && (!value)) {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(null, "jaxp-secureprocessing-feature", null));
     }
     fSecurityManager = value ? new SecurityManager() : null;
     fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
     fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
     fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
     return;
   } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
     // in secure mode, let _useServicesMechanism be determined by the constructor
     if (System.getSecurityManager() != null) return;
   }
   try {
     fXMLSchemaLoader.setFeature(name, value);
   } catch (XMLConfigurationException e) {
     String identifier = e.getIdentifier();
     if (e.getType() == Status.NOT_RECOGNIZED) {
       throw new SAXNotRecognizedException(
           SAXMessageFormatter.formatMessage(
               fXMLSchemaLoader.getLocale(), "feature-not-recognized", new Object[] {identifier}));
     } else {
       throw new SAXNotSupportedException(
           SAXMessageFormatter.formatMessage(
               fXMLSchemaLoader.getLocale(), "feature-not-supported", new Object[] {identifier}));
     }
   }
 }