Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8276143

Add XPathFactory setProperty and getProperty methods

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • xml
    • None
    • source, behavioral
    • minimal
    • None. Adding new methods to the abstract XPathFactory class with default implementation. This change has no requirement for implementations and does not affect applications.
    • Java API
    • SE

      Summary

      Add XPathFactory setProperty and getProperty methods.

      Problem

      The XPathFactory is the only one among XML factories that is missing the setProperty and getProperty methods, that makes it impossible to set any properties to the XPath processor through the API.

      The setFeature method was described as it could be used to "set a feature for this XPathFactory and XPaths created by this factory". This message can be misinterpreted as if a feature may be effective to any existing XPath objects. It's desirable to clarify the javadoc.

      Solution

      Add the setProperty and getProperty methods to XPathFactory.

      Clarify that a feature set through the setFeature method is effective to the XPath object created after the feature is set, but not any that may be created beforehand.

      Specification

      javax.xml.xpath
      
      public abstract class XPathFactory

      setProperty

      public void setProperty(String name, String value)
      
      Sets a property for this XPathFactory. The property applies to XPath objects that the XPathFactory creates. 
      It has no impact on XPath objects that are already created.
      
      A property can either be defined in this XPathFactory, or by the underlying implementation.
      
      Implementation Requirements:
          The default implementation throws UnsupportedOperationException.
      Parameters:
          name - the property name
          value - the value for the property
      Throws:
          IllegalArgumentException - if the property name is not recognized, or the value can not be assigned
          UnsupportedOperationException - if the implementation does not support the method
          NullPointerException - if the name is null. 
      
      Since:
          18

      getProperty

      public String getProperty(String name)
      
      Returns the value of the specified property.
      
      Implementation Requirements:
          The default implementation throws UnsupportedOperationException.
      Parameters:
          name - the property name
      Returns:
          the value of the property.
      Throws:
          IllegalArgumentException - if the property name is not recognized
          UnsupportedOperationException - if the implementation does not support the method
          NullPointerException - if the name is null. 
      
      Since:
          18

      setFeature javadoc clarification

      -   Set a feature for this XPathFactory and XPaths created by this factory.
      +   Sets a feature for this XPathFactory. The feature applies to XPath objects 
      +   that the XPathFactory creates. It has no impact on XPath objects that are
      +   already created.
      

            joehw Joe Wang
            joehw Joe Wang
            Iris Clark, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: