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.trinidad.bean;
20  
21  import java.util.Iterator;
22  
23  import org.apache.myfaces.trinidad.bean.FacesBeanImpl;
24  import org.apache.myfaces.trinidad.bean.PropertyKey;
25  
26  public class TestBean extends FacesBeanImpl
27  {
28    static public final Type TYPE = new Type();
29    static public final PropertyKey FIRST_KEY = 
30      TYPE.registerKey("first");
31    static public final PropertyKey SECOND_KEY = 
32      TYPE.registerKey("second");
33    static public final PropertyKey TRANSIENT_KEY = 
34      TYPE.registerKey("transient",
35                       PropertyKey.CAP_TRANSIENT);
36    static public final PropertyKey ITEMS_KEY = 
37      TYPE.registerKey("items",
38                       PropertyKey.CAP_LIST);
39    static public final PropertyKey CANT_BE_BOUND_KEY = 
40      TYPE.registerKey("cantBeBound",
41                       PropertyKey.CAP_NOT_BOUND);
42    static public final PropertyKey SILLY_KEY = 
43      TYPE.registerKey("silly",
44                       PropertyKey.CAP_STATE_HOLDER);
45    static public final PropertyKey FIRST_ALIAS_KEY = 
46      TYPE.registerAlias(FIRST_KEY, "firstAlias");
47  
48    static
49    {
50      TYPE.lock();
51    }
52  
53    public TestBean()
54    {
55    }
56  
57    @Override
58    public Type getType()
59    {
60      return TYPE;
61    }
62  
63  
64    public String getFirst()
65    {
66      return (String) getProperty(FIRST_KEY);
67    }
68  
69    public void setFirst(String first)
70    {
71      setProperty(FIRST_KEY, first);
72    }
73  
74    public String getFirstAlias()
75    {
76      return (String) getProperty(FIRST_ALIAS_KEY);
77    }
78  
79    public void setFirstAlias(String firstAlias)
80    {
81      setProperty(FIRST_ALIAS_KEY, firstAlias);
82    }
83  
84    public String getSecond()
85    {
86      return (String) getProperty(SECOND_KEY);
87    }
88  
89    public void setSecond(String second)
90    {
91      setProperty(SECOND_KEY, second);
92    }
93  
94  
95    public String getTransient()
96    {
97      return (String) getProperty(TRANSIENT_KEY);
98    }
99  
100   public void setTransient(String transientStr)
101   {
102     setProperty(TRANSIENT_KEY, transientStr);
103   }
104 
105   public String getCantBeBound()
106   {
107     return (String) getProperty(CANT_BE_BOUND_KEY);
108   }
109 
110   public void setCantBeBound(String cantBeBound)
111   {
112     setProperty(CANT_BE_BOUND_KEY, cantBeBound);
113   }
114 
115   public void addItem(Integer i)
116   {
117     addEntry(ITEMS_KEY, i);
118   }
119 
120   public void removeItem(Integer i)
121   {
122     removeEntry(ITEMS_KEY, i);
123   }
124 
125   public Integer[] getItems()
126   {
127     return (Integer[]) getEntries(ITEMS_KEY, Integer.class);
128   }
129 
130   public Iterator<Object> items()
131   {
132     return entries(ITEMS_KEY);
133   }
134 }