View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.configuration2.tree;
18  
19  import java.util.List;
20  
21  /**
22   * <p>
23   * An extension of the {@link NodeHandler} interface which allows access to so-called <em>references</em> stored for a
24   * node.
25   * </p>
26   * <p>
27   * Some specialized configuration implementations needs to store additional data for the nodes representing
28   * configuration properties. This interface provides methods for querying this data. For instance, it is possible to
29   * query a reference object stored for a specific node.
30   * </p>
31   * <p>
32   * {@link InMemoryNodeModel} supports references. It can be queried for a {@code ReferenceNodeHandler} which can then be
33   * used for dealing with references.
34   * </p>
35   *
36   * @since 2.0
37   */
38  public interface ReferenceNodeHandler extends NodeHandler<ImmutableNode> {
39      /**
40       * Gets the reference object associated with the specified node. If no reference data is associated with this node,
41       * result is <b>null</b>.
42       *
43       * @param node the node in question
44       * @return the reference object for this node or <b>null</b>
45       */
46      Object getReference(ImmutableNode node);
47  
48      /**
49       * Returns a list with the reference objects for nodes which have been removed. Whenever a node associated with a
50       * reference object is removed from the nodes structure managed by the owning model, the reference object is recorded.
51       * This is necessary for instance to free some resources. With this method all recorded reference objects can be
52       * queried. They are typically returned in the order in which they have been removed.
53       *
54       * @return a list with reference objects for nodes removed from the model
55       */
56      List<Object> removedReferences();
57  }