1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared.test; |
20 | |
|
21 | |
import java.util.List; |
22 | |
import java.util.ArrayList; |
23 | |
|
24 | |
import org.xml.sax.Attributes; |
25 | |
import org.xml.sax.SAXException; |
26 | |
import org.xml.sax.helpers.DefaultHandler; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class ClassElementHandler extends DefaultHandler |
33 | |
{ |
34 | |
|
35 | |
private boolean clazz ; |
36 | 0 | private List elementName = new ArrayList(); |
37 | 0 | private List className = new ArrayList(); |
38 | |
private StringBuffer buffer ; |
39 | |
|
40 | |
public ClassElementHandler() |
41 | 0 | { |
42 | |
|
43 | 0 | elementName.add("component-class"); |
44 | 0 | elementName.add("tag-class"); |
45 | 0 | elementName.add("renderer-class"); |
46 | 0 | elementName.add("validator-class"); |
47 | 0 | elementName.add("converter-class"); |
48 | 0 | elementName.add("action-listener"); |
49 | 0 | elementName.add("navigation-handler"); |
50 | 0 | elementName.add("variable-resolver"); |
51 | 0 | elementName.add("property-resolver"); |
52 | 0 | elementName.add("phase-listener"); |
53 | |
|
54 | 0 | } |
55 | |
|
56 | |
public void characters(char[] ch, int start, int length) |
57 | |
throws SAXException |
58 | |
{ |
59 | 0 | if (clazz) |
60 | |
{ |
61 | 0 | String string = new String(ch, start, length); |
62 | 0 | if(string != null) |
63 | |
{ |
64 | 0 | buffer.append(string.trim()); |
65 | |
} |
66 | |
} |
67 | 0 | } |
68 | |
|
69 | |
public void startElement( |
70 | |
String ns, String local, String qName, Attributes atts) |
71 | |
throws SAXException |
72 | |
{ |
73 | |
|
74 | 0 | clazz = elementName.contains(qName); |
75 | |
|
76 | 0 | if(clazz) |
77 | |
{ |
78 | 0 | buffer = new StringBuffer(); |
79 | |
} |
80 | |
|
81 | 0 | } |
82 | |
|
83 | |
public void endElement(String ns, String local, String qName) |
84 | |
throws SAXException |
85 | |
{ |
86 | |
|
87 | 0 | if(clazz) |
88 | |
{ |
89 | 0 | className.add(buffer.toString()); |
90 | 0 | clazz = false; |
91 | |
} |
92 | |
|
93 | 0 | } |
94 | |
|
95 | |
public List getClassName() |
96 | |
{ |
97 | 0 | return className; |
98 | |
} |
99 | |
|
100 | |
} |