|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| package org.apache.xindice.webadmin; |
|
21 |
| |
|
22 |
| import org.apache.xindice.util.XMLUtilities; |
|
23 |
| |
|
24 |
| import java.util.ArrayList; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| public class PartialResponse { |
|
35 |
| private final String href; |
|
36 |
| private ArrayList children; |
|
37 |
| |
|
38 |
12
| public PartialResponse(String href) {
|
|
39 |
12
| this.href = href;
|
|
40 |
| } |
|
41 |
| |
|
42 |
0
| public String getHref() {
|
|
43 |
0
| return href;
|
|
44 |
| } |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
0
| public void addContent(String name, String value) {
|
|
53 |
0
| Content child = new Content(name);
|
|
54 |
0
| child.setValue(value);
|
|
55 |
0
| addContent(child);
|
|
56 |
| } |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
16
| public void addContent(Content child) {
|
|
64 |
16
| if (children == null) {
|
|
65 |
12
| children = new ArrayList();
|
|
66 |
| } |
|
67 |
16
| children.add(child);
|
|
68 |
| } |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
12
| public String toString() {
|
|
76 |
12
| StringBuffer buf = new StringBuffer(1024);
|
|
77 |
12
| buf.append("<response>");
|
|
78 |
12
| buf.append("<href>").append(XMLUtilities.escape(href)).append("</href>");
|
|
79 |
| |
|
80 |
12
| if (children != null && children.size() != 0) {
|
|
81 |
12
| for (int i = 0; i < children.size(); i++) {
|
|
82 |
16
| buf.append(((Content) children.get(i)).getContent());
|
|
83 |
| } |
|
84 |
| } |
|
85 |
| |
|
86 |
12
| buf.append("</response>");
|
|
87 |
| |
|
88 |
12
| return buf.toString();
|
|
89 |
| } |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| public static class Content { |
|
97 |
| private ArrayList children; |
|
98 |
| private String name; |
|
99 |
| private String value; |
|
100 |
| |
|
101 |
86
| public Content(String name) {
|
|
102 |
86
| this.name = name;
|
|
103 |
| } |
|
104 |
| |
|
105 |
43
| public Content(String name, String value) {
|
|
106 |
43
| this.name = name;
|
|
107 |
43
| this.value = value;
|
|
108 |
| } |
|
109 |
| |
|
110 |
16
| public void setValue(String value) {
|
|
111 |
16
| this.value = value;
|
|
112 |
| } |
|
113 |
| |
|
114 |
7
| public Content addChild(String name) {
|
|
115 |
7
| Content child = new Content(name);
|
|
116 |
7
| addChild(child);
|
|
117 |
7
| return child;
|
|
118 |
| } |
|
119 |
| |
|
120 |
0
| public Content addChild(String name, String value) {
|
|
121 |
0
| Content child = addChild(name);
|
|
122 |
0
| child.setValue(value);
|
|
123 |
0
| return child;
|
|
124 |
| } |
|
125 |
| |
|
126 |
90
| public void addChild(Content child) {
|
|
127 |
90
| if (children == null) {
|
|
128 |
39
| children = new ArrayList();
|
|
129 |
| } |
|
130 |
90
| children.add(child);
|
|
131 |
| } |
|
132 |
| |
|
133 |
10
| public String getValue() {
|
|
134 |
10
| return value;
|
|
135 |
| } |
|
136 |
| |
|
137 |
104
| private StringBuffer getContent() {
|
|
138 |
104
| StringBuffer buf = new StringBuffer(1024);
|
|
139 |
| |
|
140 |
104
| buf.append("<").append(name).append(">");
|
|
141 |
104
| if (value != null) {
|
|
142 |
39
| buf.append(XMLUtilities.escape(value));
|
|
143 |
65
| } else if (children != null && children.size() != 0) {
|
|
144 |
37
| for (int i = 0; i < children.size(); i++) {
|
|
145 |
88
| buf.append(((Content) children.get(i)).getContent());
|
|
146 |
| } |
|
147 |
| } |
|
148 |
| |
|
149 |
104
| buf.append("</").append(name).append(">");
|
|
150 |
| |
|
151 |
104
| return buf;
|
|
152 |
| } |
|
153 |
| |
|
154 |
0
| public String toString() {
|
|
155 |
0
| return getContent().toString();
|
|
156 |
| } |
|
157 |
| } |
|
158 |
| } |