Skip to content

Commit 1f5561b

Browse files
committed
Initial code
1 parent b126ba2 commit 1f5561b

7 files changed

Lines changed: 856 additions & 38 deletions

File tree

library/build.gradle

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,31 @@ android {
2626
dependencies {
2727
compile 'com.android.support:support-annotations:23.4.0'
2828

29-
// UNIT TESTS
30-
testCompile 'junit:junit:4.12'
31-
testCompile 'org.assertj:assertj-core:1.7.0'
32-
testCompile 'com.squareup.assertj:assertj-android:1.0.0'
33-
testCompile 'org.mockito:mockito-core:1.10.19'
34-
testCompile 'com.android.support:support-annotations:23.4.0'
35-
36-
testCompile('org.robolectric:robolectric:3.0') {
37-
exclude module: 'classworlds'
38-
exclude module: 'commons-logging'
39-
exclude module: 'httpclient'
40-
exclude module: 'maven-artifact'
41-
exclude module: 'maven-artifact-manager'
42-
exclude module: 'maven-error-diagnostics'
43-
exclude module: 'maven-model'
44-
exclude module: 'maven-project'
45-
exclude module: 'maven-settings'
46-
exclude module: 'plexus-container-default'
47-
exclude module: 'plexus-interpolation'
48-
exclude module: 'plexus-utils'
49-
exclude module: 'support-v4'
50-
exclude module: 'wagon-file'
51-
exclude module: 'wagon-http-lightweight'
52-
exclude module: 'wagon-provider-api'
53-
}
54-
55-
29+
// TODO UNIT TESTS
30+
// testCompile 'junit:junit:4.12'
31+
// testCompile 'org.assertj:assertj-core:1.7.0'
32+
// testCompile 'com.squareup.assertj:assertj-android:1.0.0'
33+
// testCompile 'org.mockito:mockito-core:1.10.19'
34+
// testCompile 'com.android.support:support-annotations:23.4.0'
35+
//
36+
// testCompile('org.robolectric:robolectric:3.0') {
37+
// exclude module: 'classworlds'
38+
// exclude module: 'commons-logging'
39+
// exclude module: 'httpclient'
40+
// exclude module: 'maven-artifact'
41+
// exclude module: 'maven-artifact-manager'
42+
// exclude module: 'maven-error-diagnostics'
43+
// exclude module: 'maven-model'
44+
// exclude module: 'maven-project'
45+
// exclude module: 'maven-settings'
46+
// exclude module: 'plexus-container-default'
47+
// exclude module: 'plexus-interpolation'
48+
// exclude module: 'plexus-utils'
49+
// exclude module: 'support-v4'
50+
// exclude module: 'wagon-file'
51+
// exclude module: 'wagon-http-lightweight'
52+
// exclude module: 'wagon-provider-api'
53+
// }
5654
}
5755

5856
// Additional tasks for jitpack.io
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package fr.xgouchet.axml;
2+
3+
public class Attribute {
4+
5+
/**
6+
* @return the name
7+
*/
8+
public String getName() {
9+
return mName;
10+
}
11+
12+
/**
13+
* @return the prefix
14+
*/
15+
public String getPrefix() {
16+
return mPrefix;
17+
}
18+
19+
/**
20+
* @return the namespace
21+
*/
22+
public String getNamespace() {
23+
return mNamespace;
24+
}
25+
26+
/**
27+
* @return the value
28+
*/
29+
public String getValue() {
30+
return mValue;
31+
}
32+
33+
/**
34+
* @param name
35+
* the name to set
36+
*/
37+
public void setName(final String name) {
38+
mName = name;
39+
}
40+
41+
/**
42+
* @param prefix
43+
* the prefix to set
44+
*/
45+
public void setPrefix(final String prefix) {
46+
mPrefix = prefix;
47+
}
48+
49+
/**
50+
* @param namespace
51+
* the namespace to set
52+
*/
53+
public void setNamespace(final String namespace) {
54+
mNamespace = namespace;
55+
}
56+
57+
/**
58+
* @param value
59+
* the value to set
60+
*/
61+
public void setValue(final String value) {
62+
mValue = value;
63+
}
64+
65+
private String mName, mPrefix, mNamespace, mValue;
66+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package fr.xgouchet.axml;
2+
3+
import java.util.Stack;
4+
5+
import javax.xml.parsers.DocumentBuilder;
6+
import javax.xml.parsers.DocumentBuilderFactory;
7+
import javax.xml.parsers.ParserConfigurationException;
8+
9+
import org.w3c.dom.Document;
10+
import org.w3c.dom.Element;
11+
import org.w3c.dom.Node;
12+
13+
import android.text.TextUtils;
14+
15+
public class CompressedXmlDomListener implements CompressedXmlParserListener {
16+
17+
/**
18+
* @throws ParserConfigurationException
19+
* if a DocumentBuilder can't be created
20+
*/
21+
public CompressedXmlDomListener() throws ParserConfigurationException {
22+
mBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
23+
mStack = new Stack<Node>();
24+
}
25+
26+
public void startDocument() {
27+
mDocument = mBuilder.newDocument();
28+
mStack.push(mDocument);
29+
}
30+
31+
public void endDocument() {
32+
}
33+
34+
public void startPrefixMapping(String prefix, String uri) {
35+
}
36+
37+
public void endPrefixMapping(String prefix, String uri) {
38+
}
39+
40+
public void startElement(final String uri, final String localName,
41+
final String qName, final Attribute[] attrs) {
42+
Element elt;
43+
44+
// create elt
45+
if (TextUtils.isEmpty(uri)) {
46+
elt = mDocument.createElement(localName);
47+
} else {
48+
elt = mDocument.createElementNS(uri, qName);
49+
}
50+
51+
// add attrs
52+
for (Attribute attr : attrs) {
53+
if (TextUtils.isEmpty(attr.getNamespace())) {
54+
elt.setAttribute(attr.getName(), attr.getValue());
55+
} else {
56+
elt.setAttributeNS(attr.getNamespace(), attr.getPrefix() + ':'
57+
+ attr.getName(), attr.getValue());
58+
}
59+
}
60+
61+
// handle stack
62+
mStack.peek().appendChild(elt);
63+
mStack.push(elt);
64+
}
65+
66+
public void endElement(String uri, String localName, String qName) {
67+
mStack.pop();
68+
}
69+
70+
public void characterData(String data) {
71+
mStack.peek().appendChild(mDocument.createCDATASection(data));
72+
}
73+
74+
public void text(String data) {
75+
mStack.peek().appendChild(mDocument.createTextNode(data));
76+
}
77+
78+
public void processingInstruction(String target, String data) {
79+
}
80+
81+
/**
82+
*
83+
*/
84+
public Document getDocument() {
85+
return mDocument;
86+
}
87+
88+
private Stack<Node> mStack;
89+
private Document mDocument;
90+
private final DocumentBuilder mBuilder;
91+
}

0 commit comments

Comments
 (0)