コード例 #1
0
 /** reset all XML 1.0 components before parsing and namespace context */
 protected void reset() throws XNIException {
   int count = fComponents.size();
   for (int i = 0; i < count; i++) {
     XMLComponent c = (XMLComponent) fComponents.get(i);
     c.reset(this);
   }
 } // reset()
コード例 #2
0
  /**
   * Adds all of the component's recognized features and properties to the list of default
   * recognized features and properties, and sets default values on the configuration for features
   * and properties which were previously absent from the configuration.
   *
   * @param component The component whose recognized features and properties will be added to the
   *     configuration
   */
  protected void addRecognizedParamsAndSetDefaults(XMLComponent component) {

    // register component's recognized features
    String[] recognizedFeatures = component.getRecognizedFeatures();
    addRecognizedFeatures(recognizedFeatures);

    // register component's recognized properties
    String[] recognizedProperties = component.getRecognizedProperties();
    addRecognizedProperties(recognizedProperties);

    // set default values
    if (recognizedFeatures != null) {
      for (int i = 0; i < recognizedFeatures.length; ++i) {
        String featureId = recognizedFeatures[i];
        Boolean state = component.getFeatureDefault(featureId);
        if (state != null) {
          // Do not overwrite values already set on the configuration.
          if (!fFeatures.containsKey(featureId)) {
            fFeatures.put(featureId, state);
            // For newly added components who recognize this feature
            // but did not offer a default value, we need to make
            // sure these components will get an opportunity to read
            // the value before parsing begins.
            fConfigUpdated = true;
          }
        }
      }
    }
    if (recognizedProperties != null) {
      for (int i = 0; i < recognizedProperties.length; ++i) {
        String propertyId = recognizedProperties[i];
        Object value = component.getPropertyDefault(propertyId);
        if (value != null) {
          // Do not overwrite values already set on the configuration.
          if (!fProperties.containsKey(propertyId)) {
            fProperties.put(propertyId, value);
            // For newly added components who recognize this property
            // but did not offer a default value, we need to make
            // sure these components will get an opportunity to read
            // the value before parsing begins.
            fConfigUpdated = true;
          }
        }
      }
    }
  }
コード例 #3
0
  /**
   * setProperty
   *
   * @param propertyId
   * @param value
   */
  public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
    fConfigUpdated = true;
    // forward to every XML 1.0 component
    int count = fComponents.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fComponents.get(i);
      c.setProperty(propertyId, value);
    }
    // forward it to every common Component
    count = fCommonComponents.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fCommonComponents.get(i);
      c.setProperty(propertyId, value);
    }
    // forward it to every XML 1.1 component
    count = fXML11Components.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fXML11Components.get(i);
      try {
        c.setProperty(propertyId, value);
      } catch (Exception e) {
        // ignore it
      }
    }

    // store value if noone "objects"
    super.setProperty(propertyId, value);
  } // setProperty(String,Object)
コード例 #4
0
  /**
   * Set the state of a feature.
   *
   * <p>Set the state of any feature in a SAX2 parser. The parser might not recognize the feature,
   * and if it does recognize it, it might not be able to fulfill the request.
   *
   * @param featureId The unique identifier (URI) of the feature.
   * @param state The requested state of the feature (true or false).
   * @exception org.apache.xerces.xni.parser.XMLConfigurationException If the requested feature is
   *     not known.
   */
  public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
    fConfigUpdated = true;
    // forward to every XML 1.0 component
    int count = fComponents.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fComponents.get(i);
      c.setFeature(featureId, state);
    }
    // forward it to common components
    count = fCommonComponents.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fCommonComponents.get(i);
      c.setFeature(featureId, state);
    }

    // forward to every XML 1.1 component
    count = fXML11Components.size();
    for (int i = 0; i < count; i++) {
      XMLComponent c = (XMLComponent) fXML11Components.get(i);
      try {
        c.setFeature(featureId, state);
      } catch (Exception e) {
        // no op
      }
    }
    // save state if noone "objects"
    super.setFeature(featureId, state);
  } // setFeature(String,boolean)