KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ajaxtags > helpers > ValueItem


1 /**
2  * Copyright 2007 Jens Kapitza
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.ajaxtags.helpers;
17
18 import java.util.List JavaDoc;
19 import java.util.ArrayList JavaDoc;
20 import java.util.Arrays JavaDoc;
21
22 /**
23  * holding the data for ValueListXmlBuilder
24  *
25  * @author Jens Kapitza
26  * @version $Revision: 1.1 $ $Date: 2007/07/22 16:29:15 $ $Author: jenskapitza $
27  */

28 public class ValueItem extends Item<ArrayList JavaDoc<String JavaDoc>> {
29     private static final long serialVersionUID = -5641651833544439174L;
30
31     /**
32      * build a SimpleNode
33      *
34      * @param tagName
35      * name
36      * @param asCData
37      * true if is cdate or false otherwise
38      */

39     public ValueItem(String JavaDoc tagName, boolean asCData) {
40         this(tagName, null, asCData);
41     }
42
43     /**
44      * build a SimpleNode
45      *
46      * @param tagName
47      * name
48      * @param value
49      * add one value
50      * @param asCData
51      * true if is cdate or false otherwise
52      */

53     public ValueItem(String JavaDoc tagName, String JavaDoc value, boolean asCData) {
54         this(tagName, asCData, value);
55     }
56
57     /**
58      * build a SimpleNode
59      *
60      * @param tagName
61      * name
62      * @param asCData
63      * true if is cdate or false otherwise
64      * @param value
65      * a list of values
66      */

67     public ValueItem(String JavaDoc tagName, boolean asCData, String JavaDoc... value) {
68         super(tagName, new ArrayList JavaDoc<String JavaDoc>(), asCData);
69         getValue().addAll(Arrays.asList(value));
70     }
71
72     /**
73      * try to find the index of value
74      *
75      * @param value
76      * the value to find
77      * @return the index of this value
78      * @see ArrayList#indexOf(Object)
79      */

80     public int indexOfValue(String JavaDoc value) {
81         return getValue().indexOf(value);
82     }
83
84     /**
85      * add values to this valueitem
86      *
87      * @param values
88      * the value
89      */

90     public void addValue(String JavaDoc... values) {
91         getValue().addAll(Arrays.asList(values));
92     }
93
94     /**
95      * add values to this valueitem
96      *
97      * @param values
98      * the value
99      */

100     public void addValue(List JavaDoc<String JavaDoc> values) {
101         getValue().addAll(values);
102     }
103
104     /**
105      * add a value to this valueitem
106      *
107      * @param value
108      * the value
109      */

110     public void addValue(String JavaDoc value) {
111         getValue().add(String.valueOf(value));
112     }
113
114     /**
115      * removes an item at index i
116      *
117      * @param i
118      * the index to remove
119      * @return the removed item
120      */

121     public String JavaDoc remove(int i) {
122         return getValue().remove(i);
123     }
124
125 }
126
Popular Tags