View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
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 net.sf.ehcache.config.generator.model;
18  
19  import java.util.List;
20  
21  /***
22   * Interface that abstracts the idea of an element. An element has a name, list of {@link NodeAttribute}'s, a parent element and child elements
23   * 
24   * @author Abhishek Sanoujam
25   * 
26   */
27  public interface NodeElement {
28  
29      /***
30       * The name of the element
31       * 
32       * @return Name of the element
33       */
34      String getName();
35  
36      /***
37       * Same as calling {@link #getFQName(String)} with the string "."
38       * 
39       * @return the fully qualified name of this element
40       */
41      String getFQName();
42  
43      /***
44       * The fully qualified name of the element. The fully qualified name of the name is the name from the root element till this element
45       * separated by the <code>delimiter</code> string
46       * 
47       * @param delimiter
48       * @return the fully qualified name of this element separated by delimiter
49       */
50      String getFQName(String delimiter);
51  
52      /***
53       * List of attributes of this element
54       * 
55       * @return list of attributes of this element
56       */
57      List<NodeAttribute> getAttributes();
58  
59      /***
60       * Returns the parent of this element. May be null.
61       * 
62       * @return parent of this element. May be null.
63       */
64      NodeElement getParent();
65  
66      /***
67       * Returns the list of child elements.
68       * 
69       * @return the list of child elements
70       */
71      List<NodeElement> getChildElements();
72  
73      /***
74       * Returns true if there is at least one child
75       * 
76       * @return true if there is at least one child, otherwise false
77       */
78      boolean hasChildren();
79  
80      /***
81       * The inner content of this element as string. Does not include the child elements
82       * 
83       * @return inner content of this element as string. This does not include the child elements
84       */
85      String getInnerContent();
86  
87      /***
88       * Add an attribute
89       * 
90       * @param attribute
91       *            add an attribute
92       */
93      void addAttribute(NodeAttribute attribute);
94  
95      /***
96       * Adds a child element.
97       * 
98       * @param childElement
99       *            adds a child element
100      */
101     void addChildElement(NodeElement childElement);
102 
103     /***
104      * Accepts an {@link NodeElementVisitor}
105      * 
106      * @param visitor
107      *            the visitor whose visit methods will be called
108      */
109     void accept(NodeElementVisitor visitor);
110 
111     /***
112      * Returns true if this element is optional
113      * 
114      * @return true if this element is optional
115      */
116     boolean isOptional();
117 
118     /***
119      * Sets optional or not
120      * 
121      * @param optional
122      */
123     void setOptional(boolean optional);
124 
125     /***
126      * Sets the inner content of this element
127      * 
128      * @param content
129      */
130     void setInnerContent(String content);
131 }