|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SettingDigester.java | 83.3% | 83.9% | 75% | 80.7% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
package org.asyrinx.brownie.core.xml.digester;
|
|
6 |
|
|
7 |
import java.util.regex.Pattern;
|
|
8 |
|
|
9 |
import javax.xml.parsers.SAXParser;
|
|
10 |
|
|
11 |
import org.apache.commons.digester.Digester;
|
|
12 |
import org.apache.commons.logging.Log;
|
|
13 |
import org.apache.commons.logging.LogFactory;
|
|
14 |
import org.xml.sax.XMLReader;
|
|
15 |
|
|
16 |
/**
|
|
17 |
* @author Akima
|
|
18 |
*/
|
|
19 |
public class SettingDigester extends Digester { |
|
20 |
|
|
21 |
static public final String ATTRIBUTE_CLASS_DEFAULT = "class"; |
|
22 |
|
|
23 |
/**
|
|
24 |
* Constructor for SettingDigester.
|
|
25 |
*/
|
|
26 | 9 |
public SettingDigester() {
|
27 | 9 |
super();
|
28 |
} |
|
29 |
|
|
30 |
/**
|
|
31 |
* Constructor for SettingDigester.
|
|
32 |
*
|
|
33 |
* @param parser
|
|
34 |
*/
|
|
35 | 0 |
public SettingDigester(SAXParser parser) {
|
36 | 0 |
super(parser);
|
37 |
} |
|
38 |
|
|
39 |
/**
|
|
40 |
* Constructor for SettingDigester.
|
|
41 |
*
|
|
42 |
* @param reader
|
|
43 |
*/
|
|
44 | 0 |
public SettingDigester(XMLReader reader) {
|
45 | 0 |
super(reader);
|
46 |
} |
|
47 |
|
|
48 |
protected final Log log = LogFactory.getLog(this.getClass()); |
|
49 |
|
|
50 |
/**
|
|
51 |
* Method addSettingRoot.
|
|
52 |
*
|
|
53 |
* @param string
|
|
54 |
* @param class
|
|
55 |
*/
|
|
56 | 9 |
public void addRoot(String pattern, Class clazz) { |
57 | 9 |
addRoot(pattern, ATTRIBUTE_CLASS_DEFAULT, clazz); |
58 |
} |
|
59 |
|
|
60 |
/**
|
|
61 |
* Method addSettingRoot.
|
|
62 |
*
|
|
63 |
* @param string
|
|
64 |
* @param class
|
|
65 |
*/
|
|
66 | 9 |
public void addRoot(String pattern, String attributeName, Class clazz) { |
67 | 9 |
addObjectCreate(pattern, attributeName, clazz); |
68 |
} |
|
69 |
|
|
70 |
/**
|
|
71 |
* Method addSettingRoot.
|
|
72 |
*
|
|
73 |
* @param string
|
|
74 |
* @param class
|
|
75 |
*/
|
|
76 | 0 |
public void addRoot(String pattern, String className) { |
77 | 0 |
addRoot(pattern, className, ATTRIBUTE_CLASS_DEFAULT); |
78 |
} |
|
79 |
|
|
80 |
/**
|
|
81 |
* Method addSettingRoot.
|
|
82 |
*
|
|
83 |
* @param string
|
|
84 |
* @param class
|
|
85 |
*/
|
|
86 | 0 |
public void addRoot(String pattern, String className, String attributeName) { |
87 | 0 |
addObjectCreate(pattern, className, attributeName); |
88 |
} |
|
89 |
|
|
90 | 1 |
public void addAsProp(String pattern, String propertyName) { |
91 | 1 |
addRule(pattern, new StackSetPropertyRule(propertyName));
|
92 |
} |
|
93 |
|
|
94 | 4 |
public void addProp(String pattern, Class clazz, String propertyName, boolean setProperties) { |
95 | 4 |
addObjectCreate(pattern, ATTRIBUTE_CLASS_DEFAULT, clazz); |
96 | 4 |
addRule(pattern, new StackSetPropertyRule(propertyName));
|
97 | 4 |
if (setProperties)
|
98 | 3 |
addSetProperties(pattern); |
99 |
} |
|
100 |
|
|
101 | 1 |
public void addProp(String pattern, Class clazz, String propertyName) { |
102 | 1 |
addProp(pattern, clazz, propertyName, true);
|
103 |
} |
|
104 |
|
|
105 |
/**
|
|
106 |
* Method addNewProperties.
|
|
107 |
*
|
|
108 |
* @param string
|
|
109 |
* @param class
|
|
110 |
* @param string1
|
|
111 |
*/
|
|
112 | 3 |
public void addProps(String pattern, Class clazz, String addingMethodName) { |
113 | 3 |
addObjectCreate(pattern, ATTRIBUTE_CLASS_DEFAULT, clazz); |
114 | 3 |
addSetProperties(pattern); |
115 | 3 |
addSetNext(pattern, addingMethodName); |
116 |
//addSetProperty(pattern, "property", "value");
|
|
117 | 3 |
addSetProperties(pattern); |
118 |
} |
|
119 |
|
|
120 |
/**
|
|
121 |
* Method addNewProperties.
|
|
122 |
*
|
|
123 |
* @param pattern
|
|
124 |
* @param clazz
|
|
125 |
*/
|
|
126 | 1 |
public void addProps(String pattern, Class clazz) { |
127 | 1 |
addProps(pattern, clazz, "add");
|
128 |
} |
|
129 |
|
|
130 |
/**
|
|
131 |
*
|
|
132 |
* @param pattern
|
|
133 |
* @param methodName
|
|
134 |
* @param paramTypes
|
|
135 |
* @param paramName
|
|
136 |
* @see org.apache.commons.digester.Digester#addCallMethod(java.lang.String,
|
|
137 |
* java.lang.String, int, java.lang.Class[])
|
|
138 |
*/
|
|
139 | 2 |
public void addCallMethod(String pattern, String methodName, Class[] paramTypes, String[] paramName) { |
140 | 2 |
addCallMethod(pattern, methodName, paramTypes.length, paramTypes); |
141 | 2 |
for (int i = 0; i < paramName.length; i++) { |
142 | 3 |
addCallParam(pattern, i, paramName[i]); |
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
/**
|
|
147 |
*
|
|
148 |
* @param patten
|
|
149 |
* @param propertyName
|
|
150 |
*/
|
|
151 | 1 |
public void addPushProperty(String patten, String propertyName) { |
152 | 1 |
addRule(patten, new PushPropertyRule(propertyName));
|
153 |
} |
|
154 |
|
|
155 |
/**
|
|
156 |
*
|
|
157 |
* @param patten
|
|
158 |
*/
|
|
159 | 1 |
public void addPop(String patten) { |
160 | 1 |
addRule(patten, new PopRule());
|
161 |
} |
|
162 |
|
|
163 |
/**
|
|
164 |
* @param string
|
|
165 |
* @param class1
|
|
166 |
* @param classes
|
|
167 |
* @param strings
|
|
168 |
*/
|
|
169 | 0 |
public void addConstructor(String patten, Class clazz, Class[] paramTypes, String[] paramNames) { |
170 | 0 |
addRule(patten, new ConstructorRule(clazz, paramTypes, paramNames));
|
171 |
} |
|
172 |
|
|
173 |
/**
|
|
174 |
* @param string
|
|
175 |
* @param class1
|
|
176 |
* @param classes
|
|
177 |
* @param strings
|
|
178 |
* @param propertyName
|
|
179 |
* @param setProperties
|
|
180 |
*/
|
|
181 | 1 |
public void addProp(String pattern, Class clazz, Class[] paramTypes, String[] paramNames, String propertyName) { |
182 | 1 |
addProp(pattern, clazz, paramTypes, paramNames, propertyName, true);
|
183 |
} |
|
184 |
|
|
185 |
/**
|
|
186 |
* @param string
|
|
187 |
* @param class1
|
|
188 |
* @param classes
|
|
189 |
* @param strings
|
|
190 |
* @param propertyName
|
|
191 |
* @param setProperties
|
|
192 |
*/
|
|
193 | 1 |
public void addProp(String pattern, Class clazz, Class[] paramTypes, String[] paramNames, String propertyName, |
194 |
boolean setProperties) {
|
|
195 | 1 |
addRule(pattern, new ConstructorRule(clazz, paramTypes, paramNames));
|
196 | 1 |
addRule(pattern, new StackSetPropertyRule(propertyName));
|
197 | 1 |
if (setProperties)
|
198 | 1 |
addSetProperties(pattern); |
199 |
} |
|
200 |
|
|
201 |
/**
|
|
202 |
* @param string
|
|
203 |
*/
|
|
204 | 1 |
public void addSetToMap(String pattern) { |
205 | 1 |
addRule(pattern, new SetToMapRule());
|
206 |
} |
|
207 |
|
|
208 |
/**
|
|
209 |
* @param string
|
|
210 |
* @param string2
|
|
211 |
*/
|
|
212 | 1 |
public void addBodyToProp(String pattern, String propertyName) { |
213 | 1 |
addRule(pattern, new SetBodyToPropertyRule(propertyName));
|
214 |
} |
|
215 |
} |
|