Package org.apache.commons.configuration2.tree.xpath

# Class ConfigurationNodePointerFactory

java.lang.Object
org.apache.commons.configuration2.tree.xpath.ConfigurationNodePointerFactory

All Implemented Interfaces:
  `org.apache.commons.jxpath.ri.model.NodePointerFactory`

public class ConfigurationNodePointerFactory extends Object implements org.apache.commons.jxpath.ri.model.NodePointerFactory

Implements the `NodePointerFactory` interface for configuration nodes.

This class is able to create `NodePointer`s for the nodes of hierarchical configurations. Because there is no common base class for configuration nodes (any specific configuration implementation can use its own node class) a trick is needed for activating this factory for a concrete JXPath query: The `wrapNode()` method has to be called with the node object and its corresponding `NodeHandler`. This creates a wrapper object containing all information required by the factory for processing a query. Then this wrapper object has to be passed to the query methods of the JXPath context.

Since:
  1.3

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `CONFIGURATION_NODE_POINTER_FACTORY_ORDER`
  Constant for the order of this factory.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConfigurationNodePointerFactory()`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.apache.commons.jxpath.ri.model.NodePointer`
  `createNodePointer(org.apache.commons.jxpath.ri.model.NodePointer parent, org.apache.commons.jxpath.ri.QName qName, Object bean)`
  Creates a node pointer for the specified bean.
  `org.apache.commons.jxpath.ri.model.NodePointer`
  `createNodePointer(org.apache.commons.jxpath.ri.QName qName, Object bean, Locale locale)`
  Creates a node pointer for the specified bean.
  `int`
  `getOrder()`
  Gets the order of this factory between other factories.
  `static <T> Object`
  `wrapNode(T node, NodeHandler<T> handler)`
  Creates a node wrapper for the specified node and its handler.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### CONFIGURATION_NODE_POINTER_FACTORY_ORDER

    public static final int CONFIGURATION_NODE_POINTER_FACTORY_ORDER
    Constant for the order of this factory.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ConfigurationNodePointerFactory

    public ConfigurationNodePointerFactory()
    Constructs a new instance.

- ## Method Details

  - ### wrapNode

    public static <T> Object wrapNode(T node, NodeHandler<T> handler)
    Creates a node wrapper for the specified node and its handler. This wrapper has to be passed to the JXPath context instead of the original node.
    Type Parameters:
      `T` - the type of the node
    Parameters:
      `node` - the node
      `handler` - the corresponding node handler
    Returns:
      a wrapper for this node

  - ### createNodePointer

    public org.apache.commons.jxpath.ri.model.NodePointer createNodePointer(org.apache.commons.jxpath.ri.model.NodePointer parent, org.apache.commons.jxpath.ri.QName qName, Object bean)
    Creates a node pointer for the specified bean. If the bean is a configuration node, a corresponding pointer is returned.
    Specified by:
      `createNodePointer` in interface `org.apache.commons.jxpath.ri.model.NodePointerFactory`
    Parameters:
      `parent` - the parent node
      `qName` - the name
      `bean` - the bean
    Returns:
      a pointer for a configuration node if the bean is such a node

  - ### createNodePointer

    public org.apache.commons.jxpath.ri.model.NodePointer createNodePointer(org.apache.commons.jxpath.ri.QName qName, Object bean, Locale locale)
    Creates a node pointer for the specified bean. If the bean is a configuration node (indicated by a wrapper object), a corresponding pointer is returned.
    Specified by:
      `createNodePointer` in interface `org.apache.commons.jxpath.ri.model.NodePointerFactory`
    Parameters:
      `qName` - the name of the node
      `bean` - the bean
      `locale` - the locale
    Returns:
      a pointer for a configuration node if the bean is such a node

  - ### getOrder

    public int getOrder()
    Gets the order of this factory between other factories.
    Specified by:
      `getOrder` in interface `org.apache.commons.jxpath.ri.model.NodePointerFactory`
    Returns:
      this order's factory