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.io.Serializable;
22  import java.util.ArrayList;
23  import java.util.Collection;
24  import java.util.Collections;
25  import java.util.List;
26  
27  /**
28   * @author Martin Marinschek
29   * @version $Revision$ $Date$
30   *
31       The "attribute" element represents a named, typed, value associated with
32       the parent UIComponent via the generic attributes mechanism.
33  
34       Attribute names must be unique within the scope of the parent (or related)
35       component.
36  
37       <!ELEMENT attribute       (description*, display-name*, icon*, attribute-name,
38  attribute-class, default-value?, suggested-value?, attribute-extension*)>
39  
40   *          <p/>
41   */
42  public class AttributeImpl extends org.apache.myfaces.config.element.Attribute implements Serializable
43  {
44      private List<String> _description;
45      private List<String> _displayName;
46      private List<String> _icon;
47      private String _attributeName;
48      private String _attributeClass;
49      private String _defaultValue;
50      private String _suggestedValue;
51      private List<String> _attributeExtension;
52  
53  
54      public void addDescription(String value)
55      {
56          if(_description == null)
57          {
58              _description = new ArrayList<String>();
59          }
60          
61          _description.add(value);
62      }
63  
64      public Collection<? extends String> getDescriptions()
65      {
66          if(_description == null)
67          {
68              return Collections.emptyList();
69          }
70          
71          return _description;
72      }
73  
74      public void addDisplayName(String value)
75      {
76          if(_displayName == null)
77          {
78              _displayName = new ArrayList<String>();
79          }
80  
81          _displayName.add(value);
82      }
83  
84      public Collection<? extends String> getDisplayNames()
85      {
86          if(_displayName == null)
87          {
88              return Collections.emptyList();
89          }
90          
91          return _displayName;
92      }
93  
94      public void addIcon(String value)
95      {
96          if(_icon == null)
97          {
98              _icon = new ArrayList<String>();
99          }
100         
101         _icon.add(value);
102     }
103 
104     public Collection<? extends String> getIcons()
105     {
106         if(_icon == null)
107         {
108             return Collections.emptyList();
109         }
110 
111         return _icon;
112     }
113 
114     public void setAttributeName(String attributeName)
115     {
116         _attributeName = attributeName;
117     }
118 
119     public String getAttributeName()
120     {
121         return _attributeName;
122     }
123 
124     public void setAttributeClass(String attributeClass)
125     {
126         _attributeClass = attributeClass;
127     }
128 
129     public String getAttributeClass()
130     {
131         return _attributeClass;
132     }
133 
134     public void setDefaultValue(String defaultValue)
135     {
136         _defaultValue = defaultValue;
137     }
138 
139     public String getDefaultValue()
140     {
141         return _defaultValue;
142     }
143 
144     public void setSuggestedValue(String suggestedValue)
145     {
146         _suggestedValue = suggestedValue;
147     }
148 
149     public String getSuggestedValue()
150     {
151         return _suggestedValue;
152     }
153 
154     public void addAttributeExtension(String attributeExtension)
155     {
156         if(_attributeExtension == null)
157         {
158             _attributeExtension = new ArrayList<String>();
159         }
160 
161         _attributeExtension.add(attributeExtension);
162     }
163 
164     public Collection<? extends String> getAttributeExtensions()
165     {
166         if(_attributeExtension == null)
167         {
168             return Collections.emptyList();
169         }
170 
171         return _attributeExtension;
172     }
173 }