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.apt.generate;
21  
22  import org.apache.myfaces.tobago.apt.AnnotationUtils;
23  import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
24  
25  import javax.lang.model.element.TypeElement;
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  public class ComponentInfo extends TagInfo {
30    private List<PropertyInfo> nonTransientProperties = new ArrayList<PropertyInfo>();
31    private List<PropertyInfo> transientProperties = new ArrayList<PropertyInfo>();
32    private boolean invokeOnComponent;
33    private boolean messages;
34    private String description;
35    private boolean deprecated;
36    private int index = 0;
37    private int nonTransientIndex = 0;
38  
39    public ComponentInfo(TypeElement declaration, UIComponentTag componentTag) {
40      super(declaration.getQualifiedName().toString(), componentTag.uiComponent(), componentTag.rendererType());
41  
42      setComponentType(AnnotationUtils.componentType(componentTag));
43      setComponentFamily(componentTag.componentFamily());
44      setComponentClassName(componentTag.uiComponent());
45    }
46  
47    @Deprecated
48    public ComponentInfo(String sourceClass, String qualifiedName, String rendererType) {
49      super(sourceClass, qualifiedName, rendererType);
50    }
51  
52    public boolean isInvokeOnComponent() {
53      return invokeOnComponent;
54    }
55  
56    public void setInvokeOnComponent(boolean invokeOnComponent) {
57      this.invokeOnComponent = invokeOnComponent;
58    }
59  
60    public void addPropertyInfo(ComponentPropertyInfo propertyInfo) {
61      getProperties().add(propertyInfo);
62      propertyInfo.setIndex(index);
63      index++;
64      if (!propertyInfo.isTransient()) {
65        nonTransientProperties.add(propertyInfo);
66        propertyInfo.setNonTransientIndex(nonTransientIndex);
67        nonTransientIndex++;
68      } else {
69        transientProperties.add(propertyInfo);
70      }
71    }
72  
73    public List<PropertyInfo> getNonTransientProperties() {
74      return nonTransientProperties;
75    }
76  
77    public List<PropertyInfo> getTransientProperties() {
78      return transientProperties;
79    }
80  
81    public int getPropertiesSize() {
82      return index;
83    }
84  
85    public int getPropertiesSizePlusOne() {
86      return index + 1;
87    }
88  
89    public int getNonTransientPropertiesSize() {
90      return nonTransientIndex;
91    }
92  
93    public int getNonTransientPropertiesSizePlusOne() {
94      return nonTransientIndex + 1;
95    }
96  
97    public boolean isMessages() {
98      return messages;
99    }
100 
101   public void setMessages(boolean messages) {
102     this.messages = messages;
103   }
104 
105   public void setDescription(String description) {
106     this.description = description;
107   }
108 
109   public String getDescription() {
110     return description;
111   }
112 
113   public void setDeprecated(boolean deprecated) {
114     this.deprecated = deprecated;
115   }
116 
117   public boolean isDeprecated() {
118     return deprecated;
119   }
120 }