%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.om.page.impl.FragmentPreferenceImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.om.page.impl; |
|
18 | ||
19 | import java.util.Iterator; |
|
20 | import java.util.List; |
|
21 | ||
22 | import org.apache.jetspeed.om.preference.FragmentPreference; |
|
23 | import org.apache.jetspeed.page.impl.DatabasePageManagerUtils; |
|
24 | import org.apache.pluto.om.common.Preference; |
|
25 | import org.apache.pluto.om.common.PreferenceCtrl; |
|
26 | ||
27 | /** |
|
28 | * FragmentPreferenceImpl |
|
29 | * |
|
30 | * @author <a href="mailto:rwatler@apache.org">Randy Watler</a> |
|
31 | * @version $Id$ |
|
32 | */ |
|
33 | 0 | public class FragmentPreferenceImpl implements Preference, PreferenceCtrl, FragmentPreference |
34 | { |
|
35 | private int id; |
|
36 | private String name; |
|
37 | private boolean readOnly; |
|
38 | private List values; |
|
39 | ||
40 | private FragmentPreferenceValueList preferenceValues; |
|
41 | ||
42 | /** |
|
43 | * accessValues |
|
44 | * |
|
45 | * Access mutable persistent collection member for List wrappers. |
|
46 | * |
|
47 | * @return persistent collection |
|
48 | */ |
|
49 | List accessValues() |
|
50 | { |
|
51 | // create initial collection if necessary |
|
52 | 0 | if (values == null) |
53 | { |
|
54 | 0 | values = DatabasePageManagerUtils.createList(); |
55 | } |
|
56 | 0 | return values; |
57 | } |
|
58 | ||
59 | /* (non-Javadoc) |
|
60 | * @see org.apache.jetspeed.om.preference.FragmentPreference#getName() |
|
61 | * @see org.apache.pluto.om.common.Preference#getName() |
|
62 | */ |
|
63 | public String getName() |
|
64 | { |
|
65 | 0 | return name; |
66 | } |
|
67 | ||
68 | /* (non-Javadoc) |
|
69 | * @see org.apache.jetspeed.om.preference.FragmentPreference#setName(java.lang.String) |
|
70 | * @see org.apache.pluto.om.common.PreferenceCtrl#setName(java.lang.String) |
|
71 | */ |
|
72 | public void setName(String name) |
|
73 | { |
|
74 | 0 | this.name = name; |
75 | 0 | } |
76 | ||
77 | /* (non-Javadoc) |
|
78 | * @see org.apache.jetspeed.om.preference.FragmentPreference#isReadOnly() |
|
79 | * @see org.apache.pluto.om.common.Preference#isReadOnly() |
|
80 | */ |
|
81 | public boolean isReadOnly() |
|
82 | { |
|
83 | 0 | return readOnly; |
84 | } |
|
85 | ||
86 | /* (non-Javadoc) |
|
87 | * @see org.apache.jetspeed.om.preference.FragmentPreference#setReadOnly(boolean) |
|
88 | */ |
|
89 | public void setReadOnly(boolean readOnly) |
|
90 | { |
|
91 | 0 | this.readOnly = readOnly; |
92 | 0 | } |
93 | ||
94 | /* (non-Javadoc) |
|
95 | * @see org.apache.jetspeed.om.preference.FragmentPreference#getValueList() |
|
96 | */ |
|
97 | public List getValueList() |
|
98 | { |
|
99 | // return mutable preference value list |
|
100 | // using list wrapper to manage value order |
|
101 | 0 | if (preferenceValues == null) |
102 | { |
|
103 | 0 | preferenceValues = new FragmentPreferenceValueList(this); |
104 | } |
|
105 | 0 | return preferenceValues; |
106 | } |
|
107 | ||
108 | /* (non-Javadoc) |
|
109 | * @see org.apache.jetspeed.om.preference.FragmentPreference#setValueList(java.util.List) |
|
110 | */ |
|
111 | public void setValueList(List values) |
|
112 | { |
|
113 | // set preference values by replacing existing |
|
114 | // entries with new elements if new collection |
|
115 | // is specified |
|
116 | 0 | List preferenceValues = getValueList(); |
117 | 0 | if (values != preferenceValues) |
118 | { |
|
119 | // replace all values |
|
120 | 0 | preferenceValues.clear(); |
121 | 0 | if (values != null) |
122 | { |
|
123 | 0 | preferenceValues.addAll(values); |
124 | } |
|
125 | } |
|
126 | 0 | } |
127 | ||
128 | /* (non-Javadoc) |
|
129 | * @see org.apache.pluto.om.common.Preference#getValues() |
|
130 | */ |
|
131 | public Iterator getValues() |
|
132 | { |
|
133 | 0 | return getValueList().iterator(); |
134 | } |
|
135 | ||
136 | /* (non-Javadoc) |
|
137 | * @see org.apache.pluto.om.common.Preference#isValueSet() |
|
138 | */ |
|
139 | public boolean isValueSet() |
|
140 | { |
|
141 | 0 | return !getValueList().isEmpty(); |
142 | } |
|
143 | ||
144 | /* (non-Javadoc) |
|
145 | * @see org.apache.pluto.om.common.PreferenceCtrl#setValues(java.util.List) |
|
146 | */ |
|
147 | public void setValues(List values) |
|
148 | { |
|
149 | 0 | setValueList(values); |
150 | 0 | } |
151 | ||
152 | /* (non-Javadoc) |
|
153 | * @see org.apache.pluto.om.common.PreferenceCtrl#setReadOnly(java.lang.String) |
|
154 | */ |
|
155 | public void setReadOnly(String readOnly) |
|
156 | { |
|
157 | 0 | setReadOnly(new Boolean(readOnly).booleanValue()); |
158 | 0 | } |
159 | ||
160 | /* (non-Javadoc) |
|
161 | * @see java.lang.Object#equals(java.lang.Object) |
|
162 | */ |
|
163 | public boolean equals(Object o) |
|
164 | { |
|
165 | 0 | if (o instanceof FragmentPreferenceImpl) |
166 | { |
|
167 | 0 | if (name != null) |
168 | { |
|
169 | 0 | return name.equals(((FragmentPreferenceImpl)o).getName()); |
170 | } |
|
171 | 0 | return (((FragmentPreferenceImpl)o).getName() == null); |
172 | } |
|
173 | 0 | return false; |
174 | } |
|
175 | ||
176 | /* (non-Javadoc) |
|
177 | * @see java.lang.Object#hashCode() |
|
178 | */ |
|
179 | public int hashCode() |
|
180 | { |
|
181 | 0 | if (name != null) |
182 | { |
|
183 | 0 | return name.hashCode(); |
184 | } |
|
185 | 0 | return 0; |
186 | } |
|
187 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |