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  
20  package org.apache.myfaces.tobago.component;
21  
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  import java.lang.invoke.MethodHandles;
26  
27  /**
28   * Name constants of the attributes of the Tobago components.
29   */
30  public enum Attributes {
31  
32    accessKey,
33    action,
34    actionExpression,
35    actionListener,
36    actionListenerExpression,
37    align,
38    alignItems,
39    alt,
40    autocomplete,
41    autoReload,
42    backgroundImage,
43    bodyContent,
44    border,
45    /**
46     * Used by a layout manager
47     */
48    borderBottom,
49    /**
50     * Used by a layout manager
51     */
52    borderLeft,
53    /**
54     * Used by a layout manager
55     */
56    borderRight,
57    /**
58     * Used by a layout manager
59     */
60    borderTop,
61    bottom,
62    charset,
63    clientProperties,
64    closed,
65    collapsed,
66    collapsedMode,
67    /**
68     * @deprecated since 4.0.0
69     */
70    @Deprecated
71    column,
72    columnSpan,
73    columnSpacing,
74    columns,
75    /**
76     * @deprecated since 4.3.0
77     */
78    @Deprecated
79    compact,
80    confirmation,
81    content,
82    converter,
83    customClass,
84    /**
85     * @deprecated since 4.0.0
86     */
87    @Deprecated
88    createSpan,
89    css,
90    cssClassesBlocks,
91    dateStyle,
92    defaultCommand,
93    delay,
94    directLinkCount,
95    disabled,
96    display,
97    enctype,
98    escape,
99    expanded,
100   execute,
101   event,
102   extraLarge,
103   extraSmall,
104   fieldId,
105   file,
106   filter,
107   first,
108   fixed,
109   flexGrow,
110   flexShrink,
111   flexBasis,
112   fragment,
113   frequency,
114   focus,
115   focusId,
116   formatPattern,
117   forValue("for"),
118   globalOnly,
119   gridColumn,
120   gridRow,
121   gridTemplateColumns,
122   gridTemplateRows,
123   help,
124   height,
125   hidden,
126   hover,
127   href,
128   hreflang,
129   httpEquiv,
130   i18n,
131   iconSize,
132   id,
133   immediate,
134   image,
135   inline,
136   itemDescription,
137   itemDisabled,
138   itemLabel,
139   itemImage,
140   itemValue,
141   justify,
142   justifyContent,
143   keepLineBreaks,
144   label,
145   labelLayout,
146   labelPosition,
147   labelWidth,
148   large,
149   layoutOrder,
150   lazy,
151   left,
152   level,
153   lang,
154   link,
155   localMenu,
156   /** @deprecated since 2.0.0 */
157   @Deprecated
158   margin,
159   /**
160    * Used by a layout manager
161    */
162   marginBottom,
163   /**
164    * Used by a layout manager
165    */
166   marginExtraLarge,
167   /**
168    * Used by a layout manager
169    */
170   marginExtraSmall,
171   /**
172    * Used by a layout manager
173    */
174   marginLarge,
175   /**
176    * Used by a layout manager
177    */
178   marginLeft,
179   /**
180    * Used by a layout manager
181    */
182   marginMedium,
183   /**
184    * Used by a layout manager
185    */
186   marginRight,
187   /**
188    * Used by a layout manager
189    */
190   marginSmall,
191   /**
192    * Used by a layout manager
193    */
194   marginTop,
195   marked,
196   markup,
197   max,
198   maxSeverity,
199   maxNumber,
200   maximumItems,
201   maximumHeight,
202   maximumWidth,
203   maxHeight,
204   maxWidth,
205   media,
206   method,
207   min,
208   minHeight,
209   minWidth,
210   minSeverity,
211   minimumCharacters,
212   minimumHeight,
213   minimumWidth,
214   medium,
215   modal,
216   mode,
217   multiple,
218   mutable,
219   name,
220   navigate,
221   numberStyle,
222   /**
223    * Used by a layout manager
224    */
225   offsetExtraSmall,
226   /**
227    * Used by a layout manager
228    */
229   offsetExtraLarge,
230   /**
231    * Used by a layout manager
232    */
233   offsetLarge,
234   /**
235    * Used by a layout manager
236    */
237   offsetMedium,
238   /**
239    * Used by a layout manager
240    */
241   offsetSmall,
242   /**
243    * Used by a layout manager
244    */
245   overwriteExtraLarge,
246   /**
247    * Used by a layout manager
248    */
249   overwriteExtraSmall,
250   /**
251    * Used by a layout manager
252    */
253   overwriteLarge,
254   /**
255    * Used by a layout manager
256    */
257   overwriteMarginExtraLarge,
258   /**
259    * Used by a layout manager
260    */
261   overwriteMarginExtraSmall,
262   /**
263    * Used by a layout manager
264    */
265   overwriteMarginLarge,
266   /**
267    * Used by a layout manager
268    */
269   overwriteMarginMedium,
270   /**
271    * Used by a layout manager
272    */
273   overwriteMarginSmall,
274   /**
275    * Used by a layout manager
276    */
277   overwriteMedium,
278   /**
279    * Used by a layout manager
280    */
281   overwriteSmall,
282   omit,
283   /**
284    * @deprecated since 3.0.0
285    */
286   @Deprecated
287   onclick,
288   /**
289    * @deprecated since 3.0.0
290    */
291   @Deprecated
292   onchange,
293   open,
294   orderBy,
295   orientation,
296   outcome,
297   overflowX,
298   overflowY,
299   /**
300    * Used by a layout manager
301    */
302   paddingBottom,
303   /**
304    * Used by a layout manager
305    */
306   paddingLeft,
307   /**
308    * Used by a layout manager
309    */
310   paddingRight,
311   /**
312    * Used by a layout manager
313    */
314   paddingTop,
315   pagingTarget,
316   password,
317   placeholder,
318   plain,
319   popupClose,
320   popupList,
321   popupReset,
322   popupCalendarId,
323   position,
324   preferredHeight,
325   preferredWidth,
326   preformated,
327   readonly,
328   reference,
329   rel,
330   relative,
331   rendered,
332   renderedIndex,
333   rendererType,
334   renderAs,
335   renderRange,
336   /**
337    * @deprecated since 4.2.0
338    */
339   @Deprecated
340   renderRangeExtern,
341   required,
342   resizable,
343   rev,
344   right,
345   /**
346    * @deprecated since 4.0.0
347    */
348   @Deprecated
349   rigid,
350   rowId,
351   /**
352    * @deprecated since 4.0.0
353    */
354   @Deprecated
355   row,
356   rowSpan,
357   rowSpacing,
358   rows,
359   sandbox,
360   sanitize,
361   scriptFiles,
362   scrollbarHeight,
363   scrollbars,
364   // Attribute name could not be the same as the method name
365   // this cause an infinite loop on attribute map
366   scrollPosition,
367   selectable,
368   selectedIndex,
369   selectedLabel,
370   selectedListString,
371   selector,
372   sheetAction,
373   showCheckbox,
374   showDirectLinks,
375   showDirectLinksArrows,
376   showHeader,
377   showJunctions,
378   showNavigationBar,
379   showPageRange,
380   showPageRangeArrows,
381   showPagingAlways,
382   showRoot,
383   showRootJunction,
384   showRowRange,
385   showSummary,
386   showDetail,
387   size,
388   sortable,
389   sortActionListener,
390   sortActionListenerExpression,
391   small,
392   spanX,
393   spanY,
394   src,
395   state,
396   stateChangeListener,
397   stateChangeListenerExpression,
398   statePreview,
399   step,
400   style,
401   suggestMethod,
402   suggestMethodExpression,
403   switchType,
404   tabChangeListener,
405   tabChangeListenerExpression,
406   tabIndex,
407   target,
408   timeStyle,
409   textAlign,
410   timezone,
411   title,
412   tip,
413   todayButton,
414   top,
415   totalCount,
416   transition,
417   type,
418   value,
419   valueChangeListener,
420   var,
421   verticalAlign,
422   unit,
423   unselectedLabel,
424   update,
425   validator,
426   viewport,
427   width,
428   widthList,
429   zIndex;
430 
431   /** This constants are needed for annotations, because they can't use the enums. */
432   public static final String EXECUTE = "execute";
433 
434   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
435 
436   private final String explicit;
437 
438   Attributes() {
439     this(null);
440   }
441 
442   Attributes(final String explicit) {
443     this.explicit = explicit;
444   }
445 
446   public String getName() {
447     if (explicit != null) {
448       return explicit;
449     } else {
450       return name();
451     }
452   }
453 
454   public static Attributes valueOfFailsafe(final String name) {
455     try {
456       return Attributes.valueOf(name);
457     } catch (final IllegalArgumentException e) {
458       LOG.warn("Can't find enum for {} with name '{}'", Attributes.class.getName(), name);
459       return null;
460     }
461   }
462 
463 }