View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.config.impl.digester.elements;
20  
21  import java.util.List;
22  import java.util.ArrayList;
23  import java.util.Iterator;
24  import java.util.Collections;
25  
26  /**
27   * @author Martin Marinschek
28   * @version $Revision: 684459 $ $Date: 2008-08-10 06:13:56 -0500 (Sun, 10 Aug 2008) $
29   *
30       The "attribute" element represents a named, typed, value associated with
31       the parent UIComponent via the generic attributes mechanism.
32  
33       Attribute names must be unique within the scope of the parent (or related)
34       component.
35  
36       <!ELEMENT attribute       (description*, display-name*, icon*, attribute-name, attribute-class, default-value?, suggested-value?, attribute-extension*)>
37  
38   *          <p/>
39   */
40  public class Attribute
41  {
42      private List<String> _description;
43      private List<String> _displayName;
44      private List<String> _icon;
45      private String _attributeName;
46      private String _attributeClass;
47      private String _defaultValue;
48      private String _suggestedValue;
49      private List<String> _attributeExtension;
50  
51  
52      public void addDescription(String value)
53      {
54          if(_description == null)
55              _description = new ArrayList<String>();
56  
57          _description.add(value);
58      }
59  
60      public Iterator<String> getDescriptions()
61      {
62          if(_description==null)
63              return Collections.EMPTY_LIST.iterator();
64  
65          return _description.iterator();
66      }
67  
68      public void addDisplayName(String value)
69      {
70          if(_displayName == null)
71              _displayName = new ArrayList<String>();
72  
73          _displayName.add(value);
74      }
75  
76      public Iterator<String> getDisplayNames()
77      {
78          if(_displayName==null)
79              return Collections.EMPTY_LIST.iterator();
80  
81          return _displayName.iterator();
82      }
83  
84      public void addIcon(String value)
85      {
86          if(_icon == null)
87              _icon = new ArrayList<String>();
88  
89          _icon.add(value);
90      }
91  
92      public Iterator<String> getIcons()
93      {
94          if(_icon==null)
95              return Collections.EMPTY_LIST.iterator();
96  
97          return _icon.iterator();
98      }
99  
100     public void setAttributeName(String attributeName)
101     {
102         _attributeName = attributeName;
103     }
104 
105     public String getAttributeName()
106     {
107         return _attributeName;
108     }
109 
110     public void setAttributeClass(String attributeClass)
111     {
112         _attributeClass = attributeClass;
113     }
114 
115     public String getAttributeClass()
116     {
117         return _attributeClass;
118     }
119 
120     public void setDefaultValue(String defaultValue)
121     {
122         _defaultValue = defaultValue;
123     }
124 
125     public String getDefaultValue()
126     {
127         return _defaultValue;
128     }
129 
130     public void setSuggestedValue(String suggestedValue)
131     {
132         _suggestedValue = suggestedValue;
133     }
134 
135     public String getSuggestedValue()
136     {
137         return _suggestedValue;
138     }
139 
140     public void addAttributeExtension(String attributeExtension)
141     {
142         if(_attributeExtension == null)
143             _attributeExtension = new ArrayList<String>();
144 
145         _attributeExtension.add(attributeExtension);
146     }
147 
148     public Iterator<String> getAttributeExtensions()
149     {
150         if(_attributeExtension==null)
151             return Collections.EMPTY_LIST.iterator();
152 
153         return _attributeExtension.iterator();
154     }
155 }