1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16   
17  package org.apache.commons.betwixt;
18  
19  import java.util.ArrayList;
20  import java.util.Iterator;
21  
22  /*** This is a child that has a property containing it's parent.
23    *
24    * @author Robert Burrell Donkin
25    * @version $Revision: 1.5 $
26    */
27  public class DoubleLinkedParentBean {
28  
29      private ArrayList children = new ArrayList();
30      private String name;
31      
32      public DoubleLinkedParentBean () {}
33      
34      public DoubleLinkedParentBean(String name) {
35          setName(name);
36      }
37      
38      public String getName() {
39          return name;
40      }	
41      
42      public void setName(String name) {
43          this.name = name;
44      }
45      
46      public Iterator getChildren() {
47          return children.iterator();
48      }
49      
50      public int getSize() {
51          return children.size();
52      }
53      
54      
55      public void addChild(DoubleLinkedChildBean child) {
56          children.add(child);
57          child.setParent(this);
58      }
59  }
60