Revision 240418be src/com/rackspace/cloud/files/api/client/parsers/ContainerObjectXMLparser.java
b/src/com/rackspace/cloud/files/api/client/parsers/ContainerObjectXMLparser.java | ||
---|---|---|
8 | 8 |
import android.util.Log; |
9 | 9 |
|
10 | 10 |
import com.rackspace.cloud.files.api.client.ContainerObjects; |
11 |
/** |
|
11 |
|
|
12 |
/** |
|
12 | 13 |
* |
13 | 14 |
* @author Phillip Toohill |
14 |
* |
|
15 |
*
|
|
15 | 16 |
*/ |
16 | 17 |
public class ContainerObjectXMLparser extends DefaultHandler { |
17 | 18 |
|
... | ... | |
20 | 21 |
|
21 | 22 |
private StringBuffer currentData; |
22 | 23 |
public String LOG = "ViewFilesXMLparser"; |
23 |
|
|
24 |
|
|
24 | 25 |
public void startDocument() { |
25 | 26 |
Log.v(LOG, "startDocument"); |
26 | 27 |
} |
... | ... | |
29 | 30 |
Log.v(LOG, "endDocument = true"); |
30 | 31 |
} |
31 | 32 |
|
32 |
public void startElement(String uri, String name, String qName, Attributes atts) { |
|
33 |
public void startElement(String uri, String name, String qName, |
|
34 |
Attributes atts) { |
|
33 | 35 |
|
34 | 36 |
currentData = new StringBuffer(); |
35 | 37 |
if ("container".equals(name)) { |
36 |
files = new ArrayList<ContainerObjects>();
|
|
38 |
files = new ArrayList<ContainerObjects>(); |
|
37 | 39 |
} else if ("object".equals(name)) { |
38 | 40 |
object = new ContainerObjects(); |
39 | 41 |
} |
... | ... | |
42 | 44 |
public void endElement(String uri, String name, String qName) { |
43 | 45 |
|
44 | 46 |
String value = currentData.toString().trim(); |
45 |
|
|
46 |
if ("container".equals(name)) {
|
|
47 |
|
|
47 |
|
|
48 |
if ("container".equals(name)) { |
|
49 |
|
|
48 | 50 |
} else if ("object".equals(name)) { |
49 | 51 |
if (files != null) { |
50 | 52 |
files.add(object); |
51 | 53 |
} |
52 |
}else if ("name".equals(name)){
|
|
54 |
} else if ("name".equals(name)) {
|
|
53 | 55 |
object.setCName(value); |
54 |
}else if ("content_type".equals(name)){
|
|
56 |
} else if ("content_type".equals(name)) {
|
|
55 | 57 |
object.setContentType(value); |
56 |
}else if ("hash".equals(name)){
|
|
58 |
} else if ("hash".equals(name)) {
|
|
57 | 59 |
object.setHash(value); |
58 |
}else if ("bytes".equals(name)){
|
|
60 |
} else if ("bytes".equals(name)) {
|
|
59 | 61 |
object.setBytes(Integer.parseInt(value)); |
60 |
}else if ("last_modified".equals(name)){
|
|
62 |
} else if ("last_modified".equals(name)) {
|
|
61 | 63 |
object.setLastMod(value); |
62 |
|
|
63 |
|
|
64 |
|
|
64 | 65 |
} |
65 | 66 |
} |
66 | 67 |
|
67 |
|
|
68 | 68 |
public void characters(char ch[], int start, int length) { |
69 |
|
|
69 |
|
|
70 | 70 |
System.out.print("Characters: \""); |
71 |
|
|
71 |
|
|
72 | 72 |
for (int i = start; i < start + length; i++) { |
73 | 73 |
switch (ch[i]) { |
74 | 74 |
case '\\': |
... | ... | |
92 | 92 |
} |
93 | 93 |
} |
94 | 94 |
System.out.print("\"\n"); |
95 |
//String strCharacters = new String(ch, start, length);
|
|
95 |
// String strCharacters = new String(ch, start, length);
|
|
96 | 96 |
for (int i = start; i < (start + length); i++) { |
97 | 97 |
currentData.append(ch[i]); |
98 | 98 |
} |
99 | 99 |
} |
100 |
|
|
100 |
|
|
101 | 101 |
public ContainerObjects getObject() { |
102 | 102 |
return object; |
103 | 103 |
} |
... | ... | |
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
/** |
117 |
* @param files the servers to set |
|
117 |
* @param files |
|
118 |
* the servers to set |
|
118 | 119 |
*/ |
119 | 120 |
public void setFiles(ArrayList<ContainerObjects> files) { |
120 | 121 |
this.files = files; |
121 | 122 |
} |
122 | 123 |
|
123 |
|
|
124 | 124 |
} |
Also available in: Unified diff