Java Doc for XPathFactory.java in  » 6.0-JDK-Core » xml » javax » xml » xpath » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » xml » javax.xml.xpath 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.xml.xpath.XPathFactory

XPathFactory
abstract public class XPathFactory (Code)

An XPathFactory instance can be used to create javax.xml.xpath.XPath objects.

See XPathFactory.newInstance(String uri) for lookup mechanism.

The XPathFactory class is not thread-safe. In other words, it is the application's responsibility to ensure that at most one thread is using a XPathFactory object at any given moment. Implementations are encouraged to mark methods as synchronized to protect themselves from broken clients.

XPathFactory is not re-entrant. While one of the newInstance methods is being invoked, applications may not attempt to recursively invoke a newInstance method, even from the same thread.
author:
   Norman Walsh
author:
   Jeff Suttor
version:
   $Revision: 1.4 $, $Date: 2005/11/03 19:34:16 $
since:
   1.5



Field Summary
final public static  StringDEFAULT_OBJECT_MODEL_URI
    
final public static  StringDEFAULT_PROPERTY_NAME
    

Constructor Summary
protected  XPathFactory()
    

Method Summary
abstract public  booleangetFeature(String name)
    

Get the state of the named feature.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. An XPathFactoryConfigurationException is thrown if this XPathFactory or the XPaths it creates cannot support the feature. It is possible for an XPathFactory to expose a feature value but be unable to change its state.


Parameters:
  name - Feature name.
abstract public  booleanisObjectModelSupported(String objectModel)
    

Is specified object model supported by this XPathFactory?


Parameters:
  objectModel - Specifies the object model which the returned XPathFactory will understand.
final public static  XPathFactorynewInstance()
    
final public static  XPathFactorynewInstance(String uri)
    

Get a new XPathFactory instance using the specified object model.

To find a XPathFactory object, this method looks the following places in the following order where "the class loader" refers to the context class loader:

  1. If the system property XPathFactory.DEFAULT_PROPERTY_NAME + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
  2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
  3. The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:
    XPathFactory.isObjectModelSupported(String objectModel) 
    The first service provider found in class loader order that supports the specified object model is returned.
  4. Platform default XPathFactory is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e.
public static  XPathFactorynewInstance(String uri, String factoryClassName, ClassLoader classLoader)
    

Obtain a new instance of a XPathFactory from a factory class name.

abstract public  XPathnewXPath()
    
abstract public  voidsetFeature(String name, boolean value)
    

Set a feature for this XPathFactory and XPaths created by this factory.

Feature names are fully qualified java.net.URI s.

abstract public  voidsetXPathFunctionResolver(XPathFunctionResolver resolver)
    
abstract public  voidsetXPathVariableResolver(XPathVariableResolver resolver)
    

Field Detail
DEFAULT_OBJECT_MODEL_URI
final public static String DEFAULT_OBJECT_MODEL_URI(Code)

Default Object Model URI.




DEFAULT_PROPERTY_NAME
final public static String DEFAULT_PROPERTY_NAME(Code)

The default property name according to the JAXP spec.





Constructor Detail
XPathFactory
protected XPathFactory()(Code)

Protected constructor as XPathFactory.newInstance() or XPathFactory.newInstance(String uri) or XPathFactory.newInstance(String uri,String factoryClassName,ClassLoader classLoader) should be used to create a new instance of an XPathFactory.





Method Detail
getFeature
abstract public boolean getFeature(String name) throws XPathFactoryConfigurationException(Code)

Get the state of the named feature.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. An XPathFactoryConfigurationException is thrown if this XPathFactory or the XPaths it creates cannot support the feature. It is possible for an XPathFactory to expose a feature value but be unable to change its state.


Parameters:
  name - Feature name. State of the named feature.
throws:
  XPathFactoryConfigurationException - if thisXPathFactory or the XPathsit creates cannot support this feature.
throws:
  NullPointerException - if name is null.



isObjectModelSupported
abstract public boolean isObjectModelSupported(String objectModel)(Code)

Is specified object model supported by this XPathFactory?


Parameters:
  objectModel - Specifies the object model which the returned XPathFactory will understand. true if XPathFactory supports objectModel, else false.
throws:
  NullPointerException - If objectModel is null.
throws:
  IllegalArgumentException - If objectModel.length() == 0.



newInstance
final public static XPathFactory newInstance()(Code)

Get a new XPathFactory instance using the default object model, XPathFactory.DEFAULT_OBJECT_MODEL_URI , the W3C DOM.

This method is functionally equivalent to:

 newInstance(DEFAULT_OBJECT_MODEL_URI)
 

Since the implementation for the W3C DOM is always available, this method will never fail.

Instance of an XPathFactory.
throws:
  RuntimeException - When there is a failure in creating anXPathFactory for the default object model.



newInstance
final public static XPathFactory newInstance(String uri) throws XPathFactoryConfigurationException(Code)

Get a new XPathFactory instance using the specified object model.

To find a XPathFactory object, this method looks the following places in the following order where "the class loader" refers to the context class loader:

  1. If the system property XPathFactory.DEFAULT_PROPERTY_NAME + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
  2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
  3. The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:
    XPathFactory.isObjectModelSupported(String objectModel) 
    The first service provider found in class loader order that supports the specified object model is returned.
  4. Platform default XPathFactory is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. XPathFactory.DEFAULT_OBJECT_MODEL_URI .

If everything fails, an XPathFactoryConfigurationException will be thrown.

Tip for Trouble-shooting:

See java.util.Properties.load(java.io.InputStream) for exactly how a property file is parsed. In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it. For example:

 http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
 

Parameters:
  uri - Identifies the underlying object model.The specification only defines the URI XPathFactory.DEFAULT_OBJECT_MODEL_URI,http://java.sun.com/jaxp/xpath/dom for the W3C DOM,the org.w3c.dom package, and implementations are free to introduce other URIs for other object models. Instance of an XPathFactory.
throws:
  XPathFactoryConfigurationException - If the specified object model is unavailable.
throws:
  NullPointerException - If uri is null.
throws:
  IllegalArgumentException - If uri is nullor uri.length() == 0.



newInstance
public static XPathFactory newInstance(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException(Code)

Obtain a new instance of a XPathFactory from a factory class name. XPathFactory is returned if specified factory class supports the specified object model. This function is useful when there are multiple providers in the classpath. It gives more control to the application as it can specify which provider should be loaded.

Tip for Trouble-shooting

Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.

If you have problems try:

 java -Djaxp.debug=1 YourProgram ....
 

Parameters:
  uri - Identifies the underlying object model. The specification only defines the URI XPathFactory.DEFAULT_OBJECT_MODEL_URI,http://java.sun.com/jaxp/xpath/domfor the W3C DOM, the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.
Parameters:
  factoryClassName - fully qualified factory class name that provides implementation of javax.xml.xpath.XPathFactory.
Parameters:
  classLoader - ClassLoader used to load the factory class. If null current Thread's context classLoader is used to load the factory class. New instance of a XPathFactory
throws:
  XPathFactoryConfigurationException - if factoryClassName is null, or the factory class cannot be loaded, instantiated or the factory class does not support the object model specified in the uri parameter.
throws:
  NullPointerException - If uri is null.
throws:
  IllegalArgumentException - If uri is nullor uri.length() == 0.
See Also:   XPathFactory.newInstance()
See Also:   XPathFactory.newInstance(String uri)
since:
   1.6



newXPath
abstract public XPath newXPath()(Code)

Return a new XPath using the underlying object model determined when the XPathFactory was instantiated.

New instance of an XPath.



setFeature
abstract public void setFeature(String name, boolean value) throws XPathFactoryConfigurationException(Code)

Set a feature for this XPathFactory and XPaths created by this factory.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. An XPathFactoryConfigurationException is thrown if this XPathFactory or the XPaths it creates cannot support the feature. It is possible for an XPathFactory to expose a feature value but be unable to change its state.

All implementations are required to support the javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING feature. When the feature is true, any reference to an external function is an error. Under these conditions, the implementation must not call the XPathFunctionResolver and must throw an XPathFunctionException .


Parameters:
  name - Feature name.
Parameters:
  value - Is feature state true or false.
throws:
  XPathFactoryConfigurationException - if this XPathFactory or the XPathsit creates cannot support this feature.
throws:
  NullPointerException - if name is null.



setXPathFunctionResolver
abstract public void setXPathFunctionResolver(XPathFunctionResolver resolver)(Code)

Establish a default function resolver.

Any XPath objects constructed from this factory will use the specified resolver by default.

A NullPointerException is thrown if resolver is null.


Parameters:
  resolver - XPath function resolver.
throws:
  NullPointerException - If resolver isnull.



setXPathVariableResolver
abstract public void setXPathVariableResolver(XPathVariableResolver resolver)(Code)

Establish a default variable resolver.

Any XPath objects constructed from this factory will use the specified resolver by default.

A NullPointerException is thrown if resolver is null.


Parameters:
  resolver - Variable resolver.
throws:
  NullPointerException - If resolver isnull.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.