001// Copyright 2004, 2005 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry.contrib.tree.model; 016 017import java.util.Iterator; 018 019/** 020 * The interface that defines a suitable data model for a <code>TreeView component</code>. 021 * 022 * @author ceco 023 */ 024public interface ITreeDataModel 025{ 026 /** 027 * Returns the root node of the tree 028 */ 029 Object getRoot(); 030 031 /** 032 * Returns the number of children of parent node. 033 * @param objParent is the parent object whose nr of children are sought 034 */ 035 int getChildCount(Object objParent); 036 037 /** 038 * Get an iterator to the Collection of children belonging to the parent node object 039 * @param objParent is the parent object whose children are requested 040 */ 041 Iterator getChildren(Object objParent); 042 043 /** 044 * Get the actual node object based on some identifier (for example an UUID) 045 * @param objUniqueKey is the unique identifier of the node object being retrieved 046 * @return the instance of the node object identified by the key 047 */ 048 Object getObject(Object objUniqueKey); 049 050 /** 051 * Get the unique identifier (UUID) of the node object with a certain parent node 052 * @param objTarget is the Object whose identifier is required 053 * @param objParentUniqueKey is the unique id of the parent of objTarget 054 * @return the unique identifier of objTarget 055 */ 056 Object getUniqueKey(Object objTarget, Object objParentUniqueKey); 057 058 /** 059 * Get the unique identifier of the parent of an object 060 * @param objChildUniqueKey is the identifier of the Object for which the parent identifier is sought 061 * @return the identifier (possibly UUID) of the parent of objChildUniqueKey 062 */ 063 Object getParentUniqueKey(Object objChildUniqueKey); 064 065 /** 066 * Check to see (on the basis of some node object identifier) whether the parent node is indeed the parent of the object 067 * @param objChildUniqueKey is the identifier of the object whose parent is being checked 068 * @param objParentUniqueKey is the identifier of the parent which is to be checked against 069 */ 070 boolean isAncestorOf(Object objChildUniqueKey, Object objParentUniqueKey); 071 072}