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 java.util.ArrayList;
23  import java.util.List;
24  
25  
26  public class TagInfo extends RendererInfo {
27    private List<PropertyInfo> properties = new ArrayList<>();
28    private String componentClassName;
29    /**
30     * @deprecated since 4.4.0
31     */
32    @Deprecated
33    private String componentType;
34    private String tagName;
35    private String componentFamily;
36    private PropertyInfo bodyContent;
37    private boolean checkBodyContent;
38  
39    public TagInfo(final String sourceClass, final String qualifiedName, final String[] rendererType) {
40      super(sourceClass, qualifiedName, rendererType);
41      tagName = ClassUtils.getSmallSimpleName(qualifiedName);
42    }
43  
44    /**
45     * @deprecated since 4.4.0
46     */
47    @Deprecated
48    public TagInfo(final String sourceClass, final String qualifiedName) {
49      super(sourceClass, qualifiedName);
50    }
51  
52    public PropertyInfo getBodyContent() {
53      if (!checkBodyContent) {
54        checkBodyContent = true;
55        for (final PropertyInfo info : properties) {
56          if (info.isBodyContent()) {
57            bodyContent = info;
58            break;
59          }
60        }
61      }
62      return bodyContent;
63    }
64  
65    public void setBodyContent(final PropertyInfo bodyContent) {
66      this.bodyContent = bodyContent;
67    }
68  
69    public List<PropertyInfo> getProperties() {
70      return properties;
71    }
72  
73    public int getPropertiesSize() {
74      return properties.size();
75    }
76  
77    public int getPropertiesSizePlusOne() {
78      return properties.size() + 1;
79    }
80  
81    public void setComponentClassName(final String componentClass) {
82      addImport(componentClass);
83      this.componentClassName = ClassUtils.getSimpleName(componentClass);
84    }
85  
86    public String getComponentClassName() {
87      return componentClassName;
88    }
89  
90    public String getComponentType() {
91      return componentType;
92    }
93  
94    public void setComponentType(final String componentType) {
95      this.componentType = componentType;
96    }
97  
98    public String getComponentFamily() {
99      return componentFamily;
100   }
101 
102   public void setComponentFamily(final String componentFamily) {
103     this.componentFamily = componentFamily;
104   }
105 
106   public String getTagName() {
107     return tagName;
108   }
109 }