%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.util.descriptor.PortletPreferenceRule |
|
|
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.util.descriptor; |
|
18 | ||
19 | import java.util.ArrayList; |
|
20 | import java.util.List; |
|
21 | ||
22 | import org.apache.commons.digester.Rule; |
|
23 | import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
|
24 | import org.apache.jetspeed.om.preference.impl.PrefsPreference; |
|
25 | import org.apache.pluto.om.portlet.PortletApplicationDefinition; |
|
26 | import org.xml.sax.Attributes; |
|
27 | ||
28 | /** |
|
29 | * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a> |
|
30 | */ |
|
31 | 0 | public class PortletPreferenceRule extends Rule |
32 | { |
|
33 | ||
34 | ||
35 | protected PortletDefinitionComposite portlet; |
|
36 | ||
37 | protected String name; |
|
38 | protected boolean readOnly; |
|
39 | protected List values; |
|
40 | ||
41 | /** |
|
42 | * <p> |
|
43 | * begin |
|
44 | * </p> |
|
45 | * |
|
46 | * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes) |
|
47 | * @param arg0 |
|
48 | * @param arg1 |
|
49 | * @param arg2 |
|
50 | * @throws java.lang.Exception |
|
51 | */ |
|
52 | public void begin( String arg0, String arg1, Attributes arg2 ) throws Exception |
|
53 | { |
|
54 | 0 | Object peeked = digester.peek(); |
55 | 0 | portlet = (PortletDefinitionComposite) peeked; |
56 | 0 | portlet.setPortletApplicationDefinition((PortletApplicationDefinition) digester.getRoot()); |
57 | ||
58 | // reset properties to default values |
|
59 | // as the same instance of this rule can be used multiple times |
|
60 | 0 | values = new ArrayList(); |
61 | 0 | readOnly = false; |
62 | ||
63 | 0 | TempValueObject temp = new TempValueObject(); |
64 | 0 | digester.push(temp); |
65 | 0 | } |
66 | /** |
|
67 | * <p> |
|
68 | * end |
|
69 | * </p> |
|
70 | * |
|
71 | * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String) |
|
72 | * @param arg0 |
|
73 | * @param arg1 |
|
74 | * @throws java.lang.Exception |
|
75 | */ |
|
76 | public void end( String arg0, String arg1 ) throws Exception |
|
77 | { |
|
78 | 0 | PrefsPreference pref = new PrefsPreference(portlet, name); |
79 | 0 | pref.setValues(values); |
80 | 0 | pref.setReadOnly(readOnly); |
81 | 0 | digester.pop(); |
82 | 0 | } |
83 | ||
84 | 0 | public class TempValueObject |
85 | { |
|
86 | public void setName(String name) |
|
87 | { |
|
88 | PortletPreferenceRule.this.name = name; |
|
89 | } |
|
90 | ||
91 | public void setReadOnly(boolean readOnly) |
|
92 | { |
|
93 | PortletPreferenceRule.this.readOnly = readOnly; |
|
94 | } |
|
95 | ||
96 | public void addValue(String value) |
|
97 | { |
|
98 | PortletPreferenceRule.this.values.add(value); |
|
99 | } |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * <p> |
|
104 | * finish |
|
105 | * </p> |
|
106 | * |
|
107 | * @see org.apache.commons.digester.Rule#finish() |
|
108 | * @throws java.lang.Exception |
|
109 | */ |
|
110 | public void finish() throws Exception |
|
111 | { |
|
112 | 0 | if(values != null) |
113 | { |
|
114 | 0 | values.clear(); |
115 | } |
|
116 | 0 | super.finish(); |
117 | 0 | } |
118 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |