    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.tree;
    018
    019import java.util.List;
    020
    021/**
    022 * <p>
    023 * An extension of the {@link NodeHandler} interface which allows access to
    024 * so-called <em>references</em> stored for a node.
    025 * </p>
    026 * <p>
    027 * Some specialized configuration implementations needs to store additional data
    028 * for the nodes representing configuration properties. This interface provides
    029 * methods for querying this data. For instance, it is possible to query a
    030 * reference object stored for a specific node.
    031 * </p>
    032 * <p>
    033 * {@link InMemoryNodeModel} supports references. It can be queried for a
    034 * {@code ReferenceNodeHandler} which can then be used for dealing with
    035 * references.
    036 * </p>
    037 *
    038 * @version $Id: ReferenceNodeHandler.java 1624601 2014-09-12 18:04:36Z oheger $
    039 * @since 2.0
    040 */
    041public interface ReferenceNodeHandler extends NodeHandler<ImmutableNode>
    042{
    043    /**
    044     * Returns the reference object associated with the specified node. If no
    045     * reference data is associated with this node, result is <b>null</b>.
    046     *
    047     * @param node the node in question
    048     * @return the reference object for this node or <b>null</b>
    049     */
    050    Object getReference(ImmutableNode node);
    051
    052    /**
    053     * Returns a list with the reference objects for nodes which have been
    054     * removed. Whenever a node associated with a reference object is removed
    055     * from the nodes structure managed by the owning model, the reference
    056     * object is recorded. This is necessary for instance to free some
    057     * resources. With this method all recorded reference objects can be
    058     * queried. They are typically returned in the order in which they have been
    059     * removed.
    060     *
    061     * @return a list with reference objects for nodes removed from the model
    062     */
    063    List<Object> removedReferences();
    064}