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: 1187700 $ $Date: 2011-10-22 07:19:37 -0500 (Sat, 22 Oct 2011) $
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, attribute-class, default-value?, suggested-value?, attribute-extension*)>
38  
39   *          <p/>
40   */
41  public class Attribute extends org.apache.myfaces.config.element.Attribute implements Serializable
42  {
43      private List<String> _description;
44      private List<String> _displayName;
45      private List<String> _icon;
46      private String _attributeName;
47      private String _attributeClass;
48      private String _defaultValue;
49      private String _suggestedValue;
50      private List<String> _attributeExtension;
51  
52  
53      public void addDescription(String value)
54      {
55          if(_description == null)
56          {
57              _description = new ArrayList<String>();
58          }
59          
60          _description.add(value);
61      }
62  
63      public Collection<? extends String> getDescriptions()
64      {
65          if(_description == null)
66          {
67              return Collections.emptyList();
68          }
69          
70          return _description;
71      }
72  
73      public void addDisplayName(String value)
74      {
75          if(_displayName == null)
76          {
77              _displayName = new ArrayList<String>();
78          }
79  
80          _displayName.add(value);
81      }
82  
83      public Collection<? extends String> getDisplayNames()
84      {
85          if(_displayName == null)
86          {
87              return Collections.emptyList();
88          }
89          
90          return _displayName;
91      }
92  
93      public void addIcon(String value)
94      {
95          if(_icon == null)
96          {
97              _icon = new ArrayList<String>();
98          }
99          
100         _icon.add(value);
101     }
102 
103     public Collection<? extends String> getIcons()
104     {
105         if(_icon == null)
106         {
107             return Collections.emptyList();
108         }
109 
110         return _icon;
111     }
112 
113     public void setAttributeName(String attributeName)
114     {
115         _attributeName = attributeName;
116     }
117 
118     public String getAttributeName()
119     {
120         return _attributeName;
121     }
122 
123     public void setAttributeClass(String attributeClass)
124     {
125         _attributeClass = attributeClass;
126     }
127 
128     public String getAttributeClass()
129     {
130         return _attributeClass;
131     }
132 
133     public void setDefaultValue(String defaultValue)
134     {
135         _defaultValue = defaultValue;
136     }
137 
138     public String getDefaultValue()
139     {
140         return _defaultValue;
141     }
142 
143     public void setSuggestedValue(String suggestedValue)
144     {
145         _suggestedValue = suggestedValue;
146     }
147 
148     public String getSuggestedValue()
149     {
150         return _suggestedValue;
151     }
152 
153     public void addAttributeExtension(String attributeExtension)
154     {
155         if(_attributeExtension == null)
156         {
157             _attributeExtension = new ArrayList<String>();
158         }
159 
160         _attributeExtension.add(attributeExtension);
161     }
162 
163     public Collection<? extends String> getAttributeExtensions()
164     {
165         if(_attributeExtension == null)
166         {
167             return Collections.emptyList();
168         }
169 
170         return _attributeExtension;
171     }
172 }