summaryrefslogtreecommitdiffstats
path: root/sandbox/mobile-android/android-jdk-classes/src
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/mobile-android/android-jdk-classes/src')
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/XMLConstants.java196
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/namespace/QName.java515
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Result.java70
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Source.java36
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java122
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java195
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/ContextRegistry.java55
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexResource.java190
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLConnection.java128
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandler.java15
-rw-r--r--sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandlerFactory.java33
11 files changed, 1555 insertions, 0 deletions
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/XMLConstants.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/XMLConstants.java
new file mode 100644
index 0000000000..2159723b20
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/XMLConstants.java
@@ -0,0 +1,196 @@
+/*
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the "License"). You may not use this file except
+ * in compliance with the License.
+ *
+ * You can obtain a copy of the license at
+ * https://jaxp.dev.java.net/CDDLv1.0.html.
+ * See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * HEADER in each file and include the License file at
+ * https://jaxp.dev.java.net/CDDLv1.0.html
+ * If applicable add the following below this CDDL HEADER
+ * with the fields enclosed by brackets "[]" replaced with
+ * your own identifying information: Portions Copyright
+ * [year] [name of copyright owner]
+ */
+
+/*
+ * $Id: XMLEntityReader.java,v 1.3 2005/11/03 17:02:21 jeffsuttor Exp $
+ * @(#)XMLConstants.java 1.15 05/11/17
+ *
+ * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+ */
+
+package javax.xml;
+
+/**
+ * <p>Utility class to contain basic XML values as constants.</p>
+ *
+ * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
+ * @version $Revision: 1.2 $, $Date: 2005/06/10 03:50:26 $
+ * @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
+ * @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>
+ * @see <a href="http://www.w3.org/XML/xml-V10-2e-errata">XML 1.0 Second Edition Specification Errata</a>
+ * @see <a href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</a>
+ * @see <a href="http://www.w3.org/TR/REC-xml-names">Namespaces in XML</a>
+ * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata">Namespaces in XML Errata</a>
+ * @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>
+ * @since 1.5
+ **/
+
+public final class XMLConstants {
+
+ /**
+ * <p>Private constructor to prevent instantiation.</p>
+ */
+ private XMLConstants() {
+ }
+
+ /**
+ * <p>Namespace URI to use to represent that there is no Namespace.</p>
+ *
+ * <p>Defined by the Namespace specification to be "".</p>
+ *
+ * @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">
+ * Namespaces in XML, 5.2 Namespace Defaulting</a>
+ */
+ public static final String NULL_NS_URI = "";
+
+ /**
+ * <p>Prefix to use to represent the default XML Namespace.</p>
+ *
+ * <p>Defined by the XML specification to be "".</p>
+ *
+ * @see <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML, 3. Qualified Names</a>
+ */
+ public static final String DEFAULT_NS_PREFIX = "";
+
+ /**
+ * <p>The official XML Namespace name URI.</p>
+ *
+ * <p>Defined by the XML specification to be
+ * "<code>http://www.w3.org/XML/1998/namespace</code>".</p>
+ *
+ * @see <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML, 3. Qualified Names</a>
+ */
+ public static final String XML_NS_URI =
+ "http://www.w3.org/XML/1998/namespace";
+
+ /**
+ * <p>The official XML Namespace prefix.</p>
+ *
+ * <p>Defined by the XML specification to be "<code>xml</code>".</p>
+ *
+ * @see <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML, 3. Qualified Names<</a>
+ */
+ public static final String XML_NS_PREFIX = "xml";
+
+ /**
+ * <p>The official XML attribute used for specifying XML Namespace
+ * declarations, {@link #XMLNS_ATTRIBUTE
+ * XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.</p>
+ *
+ * <p>Defined by the XML specification to be
+ * "<code>http://www.w3.org/2000/xmlns/</code>".</p>
+ *
+ * @see <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML, 3. Qualified Names</a>
+ * @see <a
+ * href="http://www.w3.org/XML/xml-names-19990114-errata/">
+ * Namespaces in XML Errata</a>
+ */
+ public static final String XMLNS_ATTRIBUTE_NS_URI =
+ "http://www.w3.org/2000/xmlns/";
+
+ /**
+ * <p>The official XML attribute used for specifying XML Namespace
+ * declarations.</p>
+ *
+ * <p>It is <strong><em>NOT</em></strong> valid to use as a
+ * prefix. Defined by the XML specification to be
+ * "<code>xmlns</code>".</p>
+ *
+ * @see <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML, 3. Qualified Names</a>
+ */
+ public static final String XMLNS_ATTRIBUTE = "xmlns";
+
+ /**
+ * <p>W3C XML Schema Namespace URI.</p>
+ *
+ * <p>Defined to be "<code>http://www.w3.org/2001/XMLSchema</code>".
+ *
+ * @see <a href=
+ * "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
+ * XML Schema Part 1:
+ * Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
+ */
+ public static final String W3C_XML_SCHEMA_NS_URI =
+ "http://www.w3.org/2001/XMLSchema";
+
+ /**
+ * <p>W3C XML Schema Instance Namespace URI.</p>
+ *
+ * <p>Defined to be "<code>http://www.w3.org/2001/XMLSchema-instance</code>".</p>
+ *
+ * @see <a href=
+ * "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
+ * XML Schema Part 1:
+ * Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
+ */
+ public static final String W3C_XML_SCHEMA_INSTANCE_NS_URI =
+ "http://www.w3.org/2001/XMLSchema-instance";
+
+ /**
+ * <p>W3C XPath Datatype Namespace URI.</p>
+ *
+ * <p>Defined to be "<code>http://www.w3.org/2003/11/xpath-datatypes</code>".</p>
+ *
+ * @see <a href="http://www.w3.org/TR/xpath-datamodel">XQuery 1.0 and XPath 2.0 Data Model</a>
+ */
+ public static final String W3C_XPATH_DATATYPE_NS_URI = "http://www.w3.org/2003/11/xpath-datatypes";
+
+ /**
+ * <p>XML Document Type Declaration Namespace URI as an arbitrary value.</p>
+ *
+ * <p>Since not formally defined by any existing standard, arbitrarily define to be "<code>http://www.w3.org/TR/REC-xml</code>".
+ */
+ public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";
+
+ /**
+ * <p>RELAX NG Namespace URI.</p>
+ *
+ * <p>Defined to be "<code>http://relaxng.org/ns/structure/1.0</code>".</p>
+ *
+ * @see <a href="http://relaxng.org/spec-20011203.html">RELAX NG Specification</a>
+ */
+ public static final String RELAXNG_NS_URI = "http://relaxng.org/ns/structure/1.0";
+
+ /**
+ * <p>Feature for secure processing.</p>
+ *
+ * <ul>
+ * <li>
+ * <code>true</code> instructs the implementation to process XML securely.
+ * This may set limits on XML constructs to avoid conditions such as denial of service attacks.
+ * </li>
+ * <li>
+ * <code>false</code> instructs the implementation to process XML acording the letter of the XML specifications
+ * ingoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.
+ * </li>
+ * </ul>
+ */
+ public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/namespace/QName.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/namespace/QName.java
new file mode 100644
index 0000000000..3461dd1cab
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/namespace/QName.java
@@ -0,0 +1,515 @@
+
+/*
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the "License"). You may not use this file except
+ * in compliance with the License.
+ *
+ * You can obtain a copy of the license at
+ * https://jaxp.dev.java.net/CDDLv1.0.html.
+ * See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * HEADER in each file and include the License file at
+ * https://jaxp.dev.java.net/CDDLv1.0.html
+ * If applicable add the following below this CDDL HEADER
+ * with the fields enclosed by brackets "[]" replaced with
+ * your own identifying information: Portions Copyright
+ * [year] [name of copyright owner]
+ */
+
+/*
+ * $Id: QName.java,v 1.5 2005/11/03 19:34:20 jeffsuttor Exp $
+ * @(#)QName.java 1.17 06/04/07
+ *
+ * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ */
+
+package javax.xml.namespace;
+
+import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.XMLConstants;
+
+/**
+ * <p><code>QName</code> represents a <strong>qualified name</strong>
+ * as defined in the XML specifications: <a
+ * href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part2:
+ * Datatypes specification</a>, <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
+ * in XML</a>, <a
+ * href="http://www.w3.org/XML/xml-names-19990114-errata">Namespaces
+ * in XML Errata</a>.</p>
+ *
+ * <p>The value of a <code>QName</code> contains a <strong>Namespace
+ * URI</strong>, <strong>local part</strong> and
+ * <strong>prefix</strong>.</p>
+ *
+ * <p>The prefix is included in <code>QName</code> to retain lexical
+ * information <strong><em>when present</em></strong> in an {@link
+ * javax.xml.transform.Source XML input source}. The prefix is
+ * <strong><em>NOT</em></strong> used in {@link #equals(Object)
+ * QName.equals(Object)} or to compute the {@link #hashCode()
+ * QName.hashCode()}. Equality and the hash code are defined using
+ * <strong><em>only</em></strong> the Namespace URI and local part.</p>
+ *
+ * <p>If not specified, the Namespace URI is set to {@link
+ * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI}.
+ * If not specified, the prefix is set to {@link
+ * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
+ * XMLConstants.DEFAULT_NS_PREFIX}.</p>
+ *
+ * <p><code>QName</code> is immutable.</p>
+ *
+ * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
+ * @version $Revision: 1.5 $, $Date: 2005/11/03 19:34:20 $
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#QName">
+ * XML Schema Part2: Datatypes specification</a>
+ * @see <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
+ * Namespaces in XML</a>
+ * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata">
+ * Namespaces in XML Errata</a>
+ * @since 1.5
+ */
+
+public class QName implements Serializable {
+
+ /**
+ * <p>Stream Unique Identifier.</p>
+ *
+ * <p>Due to a historical defect, QName was released with multiple
+ * serialVersionUID values even though its serialization was the
+ * same.</p>
+ *
+ * <p>To workaround this issue, serialVersionUID is set with either
+ * a default value or a compatibility value. To use the
+ * compatiblity value, set the system property:</p>
+ *
+ * <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code>
+ *
+ * <p>This workaround was inspired by classes in the javax.management
+ * package, e.g. ObjectName, etc.
+ * See CR6267224 for original defect report.</p>
+ */
+ private static final long serialVersionUID;
+ /**
+ * <p>Default <code>serialVersionUID</code> value.</p>
+ */
+ private static final long defaultSerialVersionUID = -9120448754896609940L;
+ /**
+ * <p>Compatibility <code>serialVersionUID</code> value.</p>
+ */
+ private static final long compatibleSerialVersionUID = 4418622981026545151L;
+ /**
+ * <p>Flag to use default or campatible serialVersionUID.</p>
+ */
+ private static boolean useDefaultSerialVersionUID = true;
+ static {
+ try {
+ // use a privileged block as reading a system property
+ String valueUseCompatibleSerialVersionUID = (String) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("com.sun.xml.namespace.QName.useCompatibleSerialVersionUID");
+ }
+ }
+ );
+ useDefaultSerialVersionUID = (valueUseCompatibleSerialVersionUID != null && valueUseCompatibleSerialVersionUID.equals("1.0")) ? false : true;
+ } catch (Exception exception) {
+ // use default if any Exceptions
+ useDefaultSerialVersionUID = true;
+ }
+
+ // set serialVersionUID to desired value
+ if (useDefaultSerialVersionUID) {
+ serialVersionUID = defaultSerialVersionUID;
+ } else {
+ serialVersionUID = compatibleSerialVersionUID;
+ }
+ }
+
+ /**
+ * <p>Namespace URI of this <code>QName</code>.</p>
+ */
+ private final String namespaceURI;
+
+ /**
+ * <p>local part of this <code>QName</code>.</p>
+ */
+ private final String localPart;
+
+ /**
+ * <p>prefix of this <code>QName</code>.</p>
+ */
+ private final String prefix;
+
+ /**
+ * <p><code>QName</code> constructor specifying the Namespace URI
+ * and local part.</p>
+ *
+ * <p>If the Namespace URI is <code>null</code>, it is set to
+ * {@link javax.xml.XMLConstants#NULL_NS_URI
+ * XMLConstants.NULL_NS_URI}. This value represents no
+ * explicitly defined Namespace as defined by the <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
+ * in XML</a> specification. This action preserves compatible
+ * behavior with QName 1.0. Explicitly providing the {@link
+ * javax.xml.XMLConstants#NULL_NS_URI
+ * XMLConstants.NULL_NS_URI} value is the preferred coding
+ * style.</p>
+ *
+ * <p>If the local part is <code>null</code> an
+ * <code>IllegalArgumentException</code> is thrown.
+ * A local part of "" is allowed to preserve
+ * compatible behavior with QName 1.0. </p>
+ *
+ * <p>When using this constructor, the prefix is set to {@link
+ * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
+ * XMLConstants.DEFAULT_NS_PREFIX}.</p>
+ *
+ * <p>The Namespace URI is not validated as a
+ * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
+ * The local part is not validated as a
+ * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
+ * as specified in <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces
+ * in XML</a>.</p>
+ *
+ * @param namespaceURI Namespace URI of the <code>QName</code>
+ * @param localPart local part of the <code>QName</code>
+ *
+ * @throws IllegalArgumentException When <code>localPart</code> is
+ * <code>null</code>
+ *
+ * @see #QName(String namespaceURI, String localPart, String
+ * prefix) QName(String namespaceURI, String localPart, String
+ * prefix)
+ */
+ public QName(final String namespaceURI, final String localPart) {
+ this(namespaceURI, localPart, XMLConstants.DEFAULT_NS_PREFIX);
+ }
+
+ /**
+ * <p><code>QName</code> constructor specifying the Namespace URI,
+ * local part and prefix.</p>
+ *
+ * <p>If the Namespace URI is <code>null</code>, it is set to
+ * {@link javax.xml.XMLConstants#NULL_NS_URI
+ * XMLConstants.NULL_NS_URI}. This value represents no
+ * explicitly defined Namespace as defined by the <a
+ * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
+ * in XML</a> specification. This action preserves compatible
+ * behavior with QName 1.0. Explicitly providing the {@link
+ * javax.xml.XMLConstants#NULL_NS_URI
+ * XMLConstants.NULL_NS_URI} value is the preferred coding
+ * style.</p>
+ *
+ * <p>If the local part is <code>null</code> an
+ * <code>IllegalArgumentException</code> is thrown.
+ * A local part of "" is allowed to preserve
+ * compatible behavior with QName 1.0. </p>
+ *
+ * <p>If the prefix is <code>null</code>, an
+ * <code>IllegalArgumentException</code> is thrown. Use {@link
+ * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
+ * XMLConstants.DEFAULT_NS_PREFIX} to explicitly indicate that no
+ * prefix is present or the prefix is not relevant.</p>
+ *
+ * <p>The Namespace URI is not validated as a
+ * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
+ * The local part and prefix are not validated as a
+ * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
+ * as specified in <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces
+ * in XML</a>.</p>
+ *
+ * @param namespaceURI Namespace URI of the <code>QName</code>
+ * @param localPart local part of the <code>QName</code>
+ * @param prefix prefix of the <code>QName</code>
+ *
+ * @throws IllegalArgumentException When <code>localPart</code>
+ * or <code>prefix</code> is <code>null</code>
+ */
+ public QName(String namespaceURI, String localPart, String prefix) {
+
+ // map null Namespace URI to default
+ // to preserve compatibility with QName 1.0
+ if (namespaceURI == null) {
+ this.namespaceURI = XMLConstants.NULL_NS_URI;
+ } else {
+ this.namespaceURI = namespaceURI;
+ }
+
+ // local part is required.
+ // "" is allowed to preserve compatibility with QName 1.0
+ if (localPart == null) {
+ throw new IllegalArgumentException(
+ "local part cannot be \"null\" when creating a QName");
+ }
+ this.localPart = localPart;
+
+ // prefix is required
+ if (prefix == null) {
+ throw new IllegalArgumentException(
+ "prefix cannot be \"null\" when creating a QName");
+ }
+ this.prefix = prefix;
+ }
+
+ /**
+ * <p><code>QName</code> constructor specifying the local part.</p>
+ *
+ * <p>If the local part is <code>null</code> an
+ * <code>IllegalArgumentException</code> is thrown.
+ * A local part of "" is allowed to preserve
+ * compatible behavior with QName 1.0. </p>
+ *
+ * <p>When using this constructor, the Namespace URI is set to
+ * {@link javax.xml.XMLConstants#NULL_NS_URI
+ * XMLConstants.NULL_NS_URI} and the prefix is set to {@link
+ * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
+ * XMLConstants.DEFAULT_NS_PREFIX}.</p>
+ *
+ * <p><em>In an XML context, all Element and Attribute names exist
+ * in the context of a Namespace. Making this explicit during the
+ * construction of a <code>QName</code> helps prevent hard to
+ * diagnosis XML validity errors. The constructors {@link
+ * #QName(String namespaceURI, String localPart) QName(String
+ * namespaceURI, String localPart)} and
+ * {@link #QName(String namespaceURI, String localPart, String prefix)}
+ * are preferred.</em></p>
+ *
+ * <p>The local part is not validated as a
+ * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
+ * as specified in <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces
+ * in XML</a>.</p>
+ *
+ * @param localPart local part of the <code>QName</code>
+ *
+ * @throws IllegalArgumentException When <code>localPart</code> is
+ * <code>null</code>
+ *
+ * @see #QName(String namespaceURI, String localPart) QName(String
+ * namespaceURI, String localPart)
+ * @see #QName(String namespaceURI, String localPart, String
+ * prefix) QName(String namespaceURI, String localPart, String
+ * prefix)
+ */
+ public QName(String localPart) {
+ this(
+ XMLConstants.NULL_NS_URI,
+ localPart,
+ XMLConstants.DEFAULT_NS_PREFIX);
+ }
+
+ /**
+ * <p>Get the Namespace URI of this <code>QName</code>.</p>
+ *
+ * @return Namespace URI of this <code>QName</code>
+ */
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ /**
+ * <p>Get the local part of this <code>QName</code>.</p>
+ *
+ * @return local part of this <code>QName</code>
+ */
+ public String getLocalPart() {
+ return localPart;
+ }
+
+ /**
+ * <p>Get the prefix of this <code>QName</code>.</p>
+ *
+ * <p>The prefix assigned to a <code>QName</code> might
+ * <strong><em>NOT</em></strong> be valid in a different
+ * context. For example, a <code>QName</code> may be assigned a
+ * prefix in the context of parsing a document but that prefix may
+ * be invalid in the context of a different document.</p>
+ *
+ * @return prefix of this <code>QName</code>
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * <p>Test this <code>QName</code> for equality with another
+ * <code>Object</code>.</p>
+ *
+ * <p>If the <code>Object</code> to be tested is not a
+ * <code>QName</code> or is <code>null</code>, then this method
+ * returns <code>false</code>.</p>
+ *
+ * <p>Two <code>QName</code>s are considered equal if and only if
+ * both the Namespace URI and local part are equal. This method
+ * uses <code>String.equals()</code> to check equality of the
+ * Namespace URI and local part. The prefix is
+ * <strong><em>NOT</em></strong> used to determine equality.</p>
+ *
+ * <p>This method satisfies the general contract of {@link
+ * java.lang.Object#equals(Object) Object.equals(Object)}</p>
+ *
+ * @param objectToTest the <code>Object</code> to test for
+ * equality with this <code>QName</code>
+ * @return <code>true</code> if the given <code>Object</code> is
+ * equal to this <code>QName</code> else <code>false</code>
+ */
+ public final boolean equals(Object objectToTest) {
+ if (objectToTest == null || !(objectToTest instanceof QName)) {
+ return false;
+ }
+
+ QName qName = (QName) objectToTest;
+
+ return namespaceURI.equals(qName.namespaceURI)
+ && localPart.equals(qName.localPart);
+ }
+
+ /**
+ * <p>Generate the hash code for this <code>QName</code>.</p>
+ *
+ * <p>The hash code is calculated using both the Namespace URI and
+ * the local part of the <code>QName</code>. The prefix is
+ * <strong><em>NOT</em></strong> used to calculate the hash
+ * code.</p>
+ *
+ * <p>This method satisfies the general contract of {@link
+ * java.lang.Object#hashCode() Object.hashCode()}.</p>
+ *
+ * @return hash code for this <code>QName</code> <code>Object</code>
+ */
+ public final int hashCode() {
+ return namespaceURI.hashCode() ^ localPart.hashCode();
+ }
+
+ /**
+ * <p><code>String</code> representation of this
+ * <code>QName</code>.</p>
+ *
+ * <p>The commonly accepted way of representing a <code>QName</code>
+ * as a <code>String</code> was
+ * <a href="http://jclark.com/xml/xmlns.htm">defined</a>
+ * by James Clark. Although this is not a <em>standard</em>
+ * specification, it is in common use, e.g. {@link
+ * javax.xml.transform.Transformer#setParameter(String name, Object value)}.
+ * This implementation represents a <code>QName</code> as:
+ * "{" + Namespace URI + "}" + local part. If the Namespace URI
+ * <code>.equals(XMLConstants.NULL_NS_URI)</code>, only the
+ * local part is returned. An appropriate use of this method is
+ * for debugging or logging for human consumption.</p>
+ *
+ * <p>Note the prefix value is <strong><em>NOT</em></strong>
+ * returned as part of the <code>String</code> representation.</p>
+ *
+ * <p>This method satisfies the general contract of {@link
+ * java.lang.Object#toString() Object.toString()}.</p>
+ *
+ * @return <code>String</code> representation of this <code>QName</code>
+ */
+ public String toString() {
+ if (namespaceURI.equals(XMLConstants.NULL_NS_URI)) {
+ return localPart;
+ } else {
+ return "{" + namespaceURI + "}" + localPart;
+ }
+ }
+
+ /**
+ * <p><code>QName</code> derived from parsing the formatted
+ * <code>String</code>.</p>
+ *
+ * <p>If the <code>String</code> is <code>null</code> or does not conform to
+ * {@link #toString() QName.toString()} formatting, an
+ * <code>IllegalArgumentException</code> is thrown.</p>
+ *
+ * <p><em>The <code>String</code> <strong>MUST</strong> be in the
+ * form returned by {@link #toString() QName.toString()}.</em></p>
+ *
+ * <p>The commonly accepted way of representing a <code>QName</code>
+ * as a <code>String</code> was
+ * <a href="http://jclark.com/xml/xmlns.htm">defined</a>
+ * by James Clark. Although this is not a <em>standard</em>
+ * specification, it is in common use, e.g. {@link
+ * javax.xml.transform.Transformer#setParameter(String name, Object value)}.
+ * This implementation parses a <code>String</code> formatted
+ * as: "{" + Namespace URI + "}" + local part. If the Namespace
+ * URI <code>.equals(XMLConstants.NULL_NS_URI)</code>, only the
+ * local part should be provided.</p>
+ *
+ * <p>The prefix value <strong><em>CANNOT</em></strong> be
+ * represented in the <code>String</code> and will be set to
+ * {@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX
+ * XMLConstants.DEFAULT_NS_PREFIX}.</p>
+ *
+ * <p>This method does not do full validation of the resulting
+ * <code>QName</code>.
+ * <p>The Namespace URI is not validated as a
+ * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
+ * The local part is not validated as a
+ * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
+ * as specified in
+ * <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.</p>
+ *
+ * @param qNameAsString <code>String</code> representation
+ * of the <code>QName</code>
+ *
+ * @throws IllegalArgumentException When <code>qNameAsString</code> is
+ * <code>null</code> or malformed
+ *
+ * @return <code>QName</code> corresponding to the given <code>String</code>
+ * @see #toString() QName.toString()
+ */
+ public static QName valueOf(String qNameAsString) {
+
+ // null is not valid
+ if (qNameAsString == null) {
+ throw new IllegalArgumentException(
+ "cannot create QName from \"null\" or \"\" String");
+ }
+
+ // "" local part is valid to preserve compatible behavior with QName 1.0
+ if (qNameAsString.length() == 0) {
+ return new QName(
+ XMLConstants.NULL_NS_URI,
+ qNameAsString,
+ XMLConstants.DEFAULT_NS_PREFIX);
+ }
+
+ // local part only?
+ if (qNameAsString.charAt(0) != '{') {
+ return new QName(
+ XMLConstants.NULL_NS_URI,
+ qNameAsString,
+ XMLConstants.DEFAULT_NS_PREFIX);
+ }
+
+ // Namespace URI improperly specified?
+ if (qNameAsString.startsWith("{" + XMLConstants.NULL_NS_URI + "}")) {
+ throw new IllegalArgumentException(
+ "Namespace URI .equals(XMLConstants.NULL_NS_URI), "
+ + ".equals(\"" + XMLConstants.NULL_NS_URI + "\"), "
+ + "only the local part, "
+ + "\""
+ + qNameAsString.substring(2 + XMLConstants.NULL_NS_URI.length())
+ + "\", "
+ + "should be provided.");
+ }
+
+ // Namespace URI and local part specified
+ int endOfNamespaceURI = qNameAsString.indexOf('}');
+ if (endOfNamespaceURI == -1) {
+ throw new IllegalArgumentException(
+ "cannot create QName from \""
+ + qNameAsString
+ + "\", missing closing \"}\"");
+ }
+ return new QName(
+ qNameAsString.substring(1, endOfNamespaceURI),
+ qNameAsString.substring(endOfNamespaceURI + 1),
+ XMLConstants.DEFAULT_NS_PREFIX);
+ }
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Result.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Result.java
new file mode 100644
index 0000000000..dd3517c8cc
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Result.java
@@ -0,0 +1,70 @@
+// $Id: Result.java,v 1.2 2003/10/22 03:53:16 jsuttor Exp $
+
+/*
+ * @(#)Result.java 1.13 04/07/26
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+package javax.xml.transform;
+
+/**
+ * <p>An object that implements this interface contains the information
+ * needed to build a transformation result tree.</p>
+ *
+ * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
+ */
+public interface Result {
+
+ /**
+ * The name of the processing instruction that is sent if the
+ * result tree disables output escaping.
+ *
+ * <p>Normally, result tree serialization escapes & and < (and
+ * possibly other characters) when outputting text nodes.
+ * This ensures that the output is well-formed XML. However,
+ * it is sometimes convenient to be able to produce output that is
+ * almost, but not quite well-formed XML; for example,
+ * the output may include ill-formed sections that will
+ * be transformed into well-formed XML by a subsequent non-XML aware
+ * process. If a processing instruction is sent with this name,
+ * serialization should be output without any escaping. </p>
+ *
+ * <p>Result DOM trees may also have PI_DISABLE_OUTPUT_ESCAPING and
+ * PI_ENABLE_OUTPUT_ESCAPING inserted into the tree.</p>
+ *
+ * @see <a href="http://www.w3.org/TR/xslt#disable-output-escaping">disable-output-escaping in XSLT Specification</a>
+ */
+ public static final String PI_DISABLE_OUTPUT_ESCAPING =
+ "javax.xml.transform.disable-output-escaping";
+
+ /**
+ * The name of the processing instruction that is sent
+ * if the result tree enables output escaping at some point after having
+ * received a PI_DISABLE_OUTPUT_ESCAPING processing instruction.
+ *
+ * @see <a href="http://www.w3.org/TR/xslt#disable-output-escaping">disable-output-escaping in XSLT Specification</a>
+ */
+ public static final String PI_ENABLE_OUTPUT_ESCAPING =
+ "javax.xml.transform.enable-output-escaping";
+
+ /**
+ * Set the system identifier for this Result.
+ *
+ * <p>If the Result is not to be written to a file, the system identifier is optional.
+ * The application may still want to provide one, however, for use in error messages
+ * and warnings, or to resolve relative output identifiers.</p>
+ *
+ * @param systemId The system identifier as a URI string.
+ */
+ public void setSystemId(String systemId);
+
+ /**
+ * Get the system identifier that was set with setSystemId.
+ *
+ * @return The system identifier that was set with setSystemId,
+ * or null if setSystemId was not called.
+ */
+ public String getSystemId();
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Source.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Source.java
new file mode 100644
index 0000000000..5467229cc7
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/Source.java
@@ -0,0 +1,36 @@
+// $Id: Source.java,v 1.2 2003/09/07 23:02:09 jsuttor Exp $
+/*
+ * @(#)Source.java 1.14 04/07/26
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+package javax.xml.transform;
+
+/**
+ * An object that implements this interface contains the information
+ * needed to act as source input (XML source or transformation instructions).
+ */
+public interface Source {
+
+ /**
+ * Set the system identifier for this Source.
+ *
+ * <p>The system identifier is optional if the source does not
+ * get its data from a URL, but it may still be useful to provide one.
+ * The application can use a system identifier, for example, to resolve
+ * relative URIs and to include in error messages and warnings.</p>
+ *
+ * @param systemId The system identifier as a URL string.
+ */
+ public void setSystemId(String systemId);
+
+ /**
+ * Get the system identifier that was set with setSystemId.
+ *
+ * @return The system identifier that was set with setSystemId, or null
+ * if setSystemId was not called.
+ */
+ public String getSystemId();
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java
new file mode 100644
index 0000000000..a55864a04c
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java
@@ -0,0 +1,122 @@
+// $Id: DOMSource.java,v 1.5.14.1.2.2 2004/07/13 22:27:49 jsuttor Exp $
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+/*
+ * @(#)DOMSource.java 1.16 04/07/13
+ */
+package javax.xml.transform.dom;
+
+import javax.xml.transform.Source;
+
+import org.w3c.dom.Node;
+
+/**
+ * <p>Acts as a holder for a transformation Source tree in the
+ * form of a Document Object Model (DOM) tree.</p>
+ *
+ * <p>Note that XSLT requires namespace support. Attempting to transform a DOM
+ * that was not contructed with a namespace-aware parser may result in errors.
+ * Parsers can be made namespace aware by calling
+ * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.</p>
+ *
+ * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
+ * @version $Revision: 1.5.14.1.2.2 $, $Date: 2004/07/13 22:27:49 $
+ * @see <a href="http://www.w3.org/TR/DOM-Level-2">Document Object Model (DOM) Level 2 Specification</a>
+ */
+public class DOMSource implements Source {
+
+ /**
+ * <p><code>Node</code> to serve as DOM source.</p>
+ */
+ private Node node;
+
+ /**
+ * <p>The base ID (URL or system ID) from where URLs
+ * will be resolved.</p>
+ */
+ private String systemID;
+
+ /** If {@link javax.xml.transform.TransformerFactory#getFeature}
+ * returns true when passed this value as an argument,
+ * the Transformer supports Source input of this type.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.dom.DOMSource/feature";
+
+ /**
+ * <p>Zero-argument default constructor. If this constructor is used, and
+ * no DOM source is set using {@link #setNode(Node node)} , then the
+ * <code>Transformer</code> will
+ * create an empty source {@link org.w3c.dom.Document} using
+ * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.</p>
+ *
+ * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
+ */
+ public DOMSource() { }
+
+ /**
+ * Create a new input source with a DOM node. The operation
+ * will be applied to the subtree rooted at this node. In XSLT,
+ * a "/" pattern still means the root of the tree (not the subtree),
+ * and the evaluation of global variables and parameters is done
+ * from the root node also.
+ *
+ * @param n The DOM node that will contain the Source tree.
+ */
+ public DOMSource(Node n) {
+ setNode(n);
+ }
+
+ /**
+ * Create a new input source with a DOM node, and with the
+ * system ID also passed in as the base URI.
+ *
+ * @param node The DOM node that will contain the Source tree.
+ * @param systemID Specifies the base URI associated with node.
+ */
+ public DOMSource(Node node, String systemID) {
+ setNode(node);
+ setSystemId(systemID);
+ }
+
+ /**
+ * Set the node that will represents a Source DOM tree.
+ *
+ * @param node The node that is to be transformed.
+ */
+ public void setNode(Node node) {
+ this.node = node;
+ }
+
+ /**
+ * Get the node that represents a Source DOM tree.
+ *
+ * @return The node that is to be transformed.
+ */
+ public Node getNode() {
+ return node;
+ }
+
+ /**
+ * Set the base ID (URL or system ID) from where URLs
+ * will be resolved.
+ *
+ * @param systemID Base URL for this DOM tree.
+ */
+ public void setSystemId(String systemID) {
+ this.systemID = systemID;
+ }
+
+ /**
+ * Get the base ID (URL or system ID) from where URLs
+ * will be resolved.
+ *
+ * @return Base URL for this DOM tree.
+ */
+ public String getSystemId() {
+ return this.systemID;
+ }
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java
new file mode 100644
index 0000000000..cc09fee0ae
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java
@@ -0,0 +1,195 @@
+// $Id: SAXSource.java,v 1.7.14.1.2.2 2004/07/13 22:27:50 jsuttor Exp $
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+/*
+ * @(#)SAXSource.java 1.15 04/07/13
+ */
+package javax.xml.transform.sax;
+
+import javax.xml.transform.Source;
+//import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * <p>Acts as an holder for SAX-style Source.</p>
+ *
+ * <p>Note that XSLT requires namespace support. Attempting to transform an
+ * input source that is not
+ * generated with a namespace-aware parser may result in errors.
+ * Parsers can be made namespace aware by calling the
+ * {@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method.</p>
+ *
+ * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
+ * @version $Revision: 1.7.14.1.2.2 $, $Date: 2004/07/13 22:27:50 $
+ */
+public class SAXSource implements Source {
+
+ /**
+ * If {@link javax.xml.transform.TransformerFactory#getFeature}
+ * returns true when passed this value as an argument,
+ * the Transformer supports Source input of this type.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.sax.SAXSource/feature";
+
+ /**
+ * <p>Zero-argument default constructor. If this constructor is used, and
+ * no SAX source is set using
+ * {@link #setInputSource(InputSource inputSource)} , then the
+ * <code>Transformer</code> will
+ * create an empty source {@link org.xml.sax.InputSource} using
+ * {@link org.xml.sax.InputSource#InputSource() new InputSource()}.</p>
+ *
+ * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
+ */
+ public SAXSource() { }
+
+ /**
+ * Create a <code>SAXSource</code>, using an {@link org.xml.sax.XMLReader}
+ * and a SAX InputSource. The {@link javax.xml.transform.Transformer}
+ * or {@link javax.xml.transform.sax.SAXTransformerFactory} will set itself
+ * to be the reader's {@link org.xml.sax.ContentHandler}, and then will call
+ * reader.parse(inputSource).
+ *
+ * @param reader An XMLReader to be used for the parse.
+ * @param inputSource A SAX input source reference that must be non-null
+ * and that will be passed to the reader parse method.
+ */
+ public SAXSource(XMLReader reader, InputSource inputSource) {
+ this.reader = reader;
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Create a <code>SAXSource</code>, using a SAX <code>InputSource</code>.
+ * The {@link javax.xml.transform.Transformer} or
+ * {@link javax.xml.transform.sax.SAXTransformerFactory} creates a
+ * reader via {@link org.xml.sax.helpers.XMLReaderFactory}
+ * (if setXMLReader is not used), sets itself as
+ * the reader's {@link org.xml.sax.ContentHandler}, and calls
+ * reader.parse(inputSource).
+ *
+ * @param inputSource An input source reference that must be non-null
+ * and that will be passed to the parse method of the reader.
+ */
+ public SAXSource(InputSource inputSource) {
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Set the XMLReader to be used for the Source.
+ *
+ * @param reader A valid XMLReader or XMLFilter reference.
+ */
+ public void setXMLReader(XMLReader reader) {
+ this.reader = reader;
+ }
+
+ /**
+ * Get the XMLReader to be used for the Source.
+ *
+ * @return A valid XMLReader or XMLFilter reference, or null.
+ */
+ public XMLReader getXMLReader() {
+ return reader;
+ }
+
+ /**
+ * Set the SAX InputSource to be used for the Source.
+ *
+ * @param inputSource A valid InputSource reference.
+ */
+ public void setInputSource(InputSource inputSource) {
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Get the SAX InputSource to be used for the Source.
+ *
+ * @return A valid InputSource reference, or null.
+ */
+ public InputSource getInputSource() {
+ return inputSource;
+ }
+
+ /**
+ * Set the system identifier for this Source. If an input source
+ * has already been set, it will set the system ID or that
+ * input source, otherwise it will create a new input source.
+ *
+ * <p>The system identifier is optional if there is a byte stream
+ * or a character stream, but it is still useful to provide one,
+ * since the application can use it to resolve relative URIs
+ * and can include it in error messages and warnings (the parser
+ * will attempt to open a connection to the URI only if
+ * no byte stream or character stream is specified).</p>
+ *
+ * @param systemId The system identifier as a URI string.
+ */
+ public void setSystemId(String systemId) {
+
+ if (null == inputSource) {
+ inputSource = new InputSource(systemId);
+ } else {
+ inputSource.setSystemId(systemId);
+ }
+ }
+
+ /**
+ * <p>Get the base ID (URI or system ID) from where URIs
+ * will be resolved.</p>
+ *
+ * @return Base URL for the <code>Source</code>, or <code>null</code>.
+ */
+ public String getSystemId() {
+
+ if (inputSource == null) {
+ return null;
+ } else {
+ return inputSource.getSystemId();
+ }
+ }
+
+ /**
+ * The XMLReader to be used for the source tree input. May be null.
+ */
+ private XMLReader reader;
+
+ /**
+ * <p>The SAX InputSource to be used for the source tree input.
+ * Should not be <code>null<code>.</p>
+ */
+ private InputSource inputSource;
+/*
+ *//**
+ * Attempt to obtain a SAX InputSource object from a Source
+ * object.
+ *
+ * @param source Must be a non-null Source reference.
+ *
+ * @return An InputSource, or null if Source can not be converted.
+ *//*
+ public static InputSource sourceToInputSource(Source source) {
+
+ if (source instanceof SAXSource) {
+ return ((SAXSource) source).getInputSource();
+ } else if (source instanceof StreamSource) {
+ StreamSource ss = (StreamSource) source;
+ InputSource isource = new InputSource(ss.getSystemId());
+
+ isource.setByteStream(ss.getInputStream());
+ isource.setCharacterStream(ss.getReader());
+ isource.setPublicId(ss.getPublicId());
+
+ return isource;
+ } else {
+ return null;
+ }
+ }*/
+}
+
diff --git a/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/ContextRegistry.java b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/ContextRegistry.java
new file mode 100644
index 0000000000..312c0059db
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/ContextRegistry.java
@@ -0,0 +1,55 @@
+package org.apache.tuscany.sca.android;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+
+import android.content.Context;
+
+public class ContextRegistry {
+
+ private static Hashtable<String, HashSet<Context>> contexts = new Hashtable<String, HashSet<Context>>();
+
+ public static void registerContext(Context context) {
+ String packageName = context.getPackageName();
+ HashSet<Context> packContexts = contexts.get(packageName);
+
+ if (packContexts == null) {
+ packContexts = new HashSet<Context>();
+ contexts.put(packageName, packContexts);
+
+ }
+
+ packContexts.add(context);
+
+ }
+
+ public static void unregisterContext(Context context) {
+ String packageName = context.getPackageName();
+ HashSet<Context> packContexts = contexts.get(packageName);
+
+ if (packContexts != null) {
+ packContexts.remove(context);
+
+ if (packContexts.isEmpty()) {
+ contexts.remove(packageName);
+ }
+
+ }
+
+ }
+
+ public static Context[] getContexts(String packageName) {
+ HashSet<Context> packageContexts = contexts.get(packageName);
+
+ if (packageContexts == null) {
+ return new Context[0];
+ }
+
+ Context[] ret = new Context[packageContexts.size()];
+ packageContexts.toArray(ret);
+
+ return ret;
+
+ }
+
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexResource.java b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexResource.java
new file mode 100644
index 0000000000..fb9029547f
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexResource.java
@@ -0,0 +1,190 @@
+package org.apache.tuscany.sca.android;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import android.content.Context;
+
+public class DexResource {
+
+ private URL url;
+
+ private String folder;
+
+ private String file;
+
+ public DexResource(URL url) {
+ String protocol = url.getProtocol();
+
+ if (!"dex".equals(protocol)) {
+ throw new IllegalArgumentException("The URL protocol should be \"dex\"");
+ }
+
+ String host = url.getHost();
+
+ if ("".equals(host)) {
+ throw new IllegalArgumentException("The host should not be empty!");
+ }
+
+ String path = url.getPath();
+ file = getFile(path);
+ folder = getFolder(path);
+
+ if (file != null && file.indexOf('/') != -1) {
+ throw new IllegalArgumentException("The dex URL format should be: dex:/<package>/[<folder>]/[<file>] only");
+ }
+
+ this.url = url;
+
+ }
+
+ public static String getFolder(String path) {
+ String file = path.trim();
+
+ int firstSlashIndex = file.indexOf('/');
+
+ if ("".equals(file) || "/".equals(file) || firstSlashIndex == -1 || firstSlashIndex >= file.length() - 1) {
+ return null;
+ }
+
+ int secondSlashIndex = file.indexOf("/", firstSlashIndex + 1);
+
+ if (secondSlashIndex == -1 || secondSlashIndex >= file.length() - 1 || firstSlashIndex == secondSlashIndex - 1) {
+ return null;
+ }
+
+ return file.substring(firstSlashIndex + 1, secondSlashIndex);
+
+ }
+
+ public static String getFile(String path) {
+ String file = path.trim();
+
+ int firstSlashIndex = file.indexOf('/');
+
+ if ("".equals(file) || "/".equals(file) || firstSlashIndex == -1 || firstSlashIndex >= file.length() - 1) {
+ return null;
+ }
+
+ int secondSlashIndex = file.indexOf("/", firstSlashIndex + 1);
+
+ if (secondSlashIndex == -1 || secondSlashIndex >= file.length() - 1 || firstSlashIndex == secondSlashIndex - 1) {
+ return null;
+ }
+
+ return file.substring(secondSlashIndex + 1);
+
+ }
+
+ public String getFolderName() {
+ return folder;
+ }
+
+ public Context getContext() {
+ Context[] contexts = ContextRegistry.getContexts(url.getHost());
+
+ if (contexts.length == 0) {
+ return null;
+ }
+
+ return contexts[0];
+
+ }
+
+ public String getFileName() {
+ return file;
+ }
+
+ public boolean isPackage() {
+ return folder == null;
+ }
+
+ public boolean isFolder() {
+ return file == null && folder != null;
+ }
+
+ public boolean isFile() {
+ return file != null;
+ }
+
+ public String getPackageName() {
+ return url.getHost();
+ }
+
+ public URI[] getContentFiles() throws IOException {
+
+ if (isFile()) {
+ throw new UnsupportedOperationException("Not supported when the resource is a file!");
+ }
+
+ String packageName = url.getHost();
+
+ Context[] contexts = ContextRegistry.getContexts(packageName);
+
+ if (contexts.length == 0) {
+ throw new IOException("Android context not found!");
+ }
+
+ Context context = contexts[0];
+
+ ArrayList<URI> files = new ArrayList<URI>();
+ StringBuffer className = new StringBuffer(packageName).append(".R");
+
+ if (isPackage()) {
+ ClassLoader classLoader = context.getClass().getClassLoader();
+
+ try {
+
+ for (String folderName : new String[] {"raw", "xml"}) {
+ Class clazz = classLoader.loadClass(className.toString() + '$' + folderName);
+ folderName = '/' + folderName + '/';
+ Field[] fields = clazz.getFields();
+
+ for (Field field : fields) {
+ try {
+ files.add(new URI("dex://" + packageName + folderName + field.getName()));
+ } catch (URISyntaxException e) {}
+ }
+
+ }
+
+ } catch (ClassNotFoundException e) {}
+
+ } else {
+
+ try {
+ className.append('$').append(folder);
+ Class clazz = getClass().getClassLoader().loadClass(className.toString());
+ String folderName = '/' + clazz.getSimpleName() + '/';
+ Field[] fields = clazz.getFields();
+
+ for (Field field : fields) {
+ try {
+ files.add(new URI("dex://" + packageName + folderName + field.getName()));
+ } catch (URISyntaxException e) {}
+ }
+
+ } catch (ClassNotFoundException e) {
+ throw new IOException("Resource not found!");
+ }
+
+ }
+
+
+
+ URI[] ret = new URI[files.size()];
+ files.toArray(ret);
+
+ return ret;
+
+ }
+
+ public URL getURL() {
+ return url;
+ }
+
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLConnection.java b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLConnection.java
new file mode 100644
index 0000000000..af0e93b043
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLConnection.java
@@ -0,0 +1,128 @@
+package org.apache.tuscany.sca.android;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.UnknownServiceException;
+
+import android.content.Context;
+
+public class DexURLConnection extends URLConnection {
+
+ private InputStream input;
+
+ protected DexURLConnection(URL url) {
+ super(url);
+ setAllowUserInteraction(false);
+ setUseCaches(false);
+ setDefaultUseCaches(false);
+ setConnectTimeout(0);
+ setReadTimeout(0);
+ setDoInput(true);
+ setDoOutput(false);
+
+ }
+
+ public InputStream getInputStream() throws IOException {
+
+ if (input == null) {
+ connect();
+ }
+
+ return input;
+
+ }
+
+ private String guessContentTypeFromInput() {
+
+ if (!connected) {
+
+ try {
+ connect();
+ } catch (IOException e) {
+ return null;
+ }
+
+ }
+
+ try {
+ return guessContentTypeFromStream(input);
+ } catch (IOException e) {
+ return null;
+ }
+
+ }
+
+ @Override
+ public String getContentType() {
+
+ if (DexResource.getFolder(url.getPath()) == null || DexResource.getFile(url.getPath()) == null) {
+ return "application/x-dex";
+ }
+
+ return guessContentTypeFromInput();
+
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ throw new UnknownServiceException("Output not supported!");
+ }
+
+ public void connect() throws IOException {
+
+ if (!connected) {
+ String host = url.getHost();
+ Context[] contexts = ContextRegistry.getContexts(host);
+
+ if (contexts.length == 0) {
+ throw new IOException("Android context not found!");
+ }
+
+ Context context = contexts[0];
+
+ if ("".equals(host)) {
+ throw new IOException("not valid host name: \"\"");
+ }
+
+ String path = url.getPath();
+ String file = DexResource.getFile(path);
+ String folder = DexResource.getFolder(path);
+
+ if (file == null) {
+ return;
+ }
+
+ file = file.replace('.', '_');
+
+ try {
+
+ StringBuffer sb = new StringBuffer(context.getPackageName());
+ sb.append('.').append('R').append('$').append(folder);
+
+ Class clazz = getClass().getClassLoader().loadClass(sb.toString());
+ Field field = clazz.getDeclaredField(file);
+
+ int id = field.getInt(null);
+ input = context.getResources().openRawResource(id);
+ connected = true;
+
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ } catch (SecurityException e) {
+ throw new IOException(e.getMessage());
+ } catch (NoSuchFieldException e) {
+ throw new IOException(e.getMessage());
+ } catch (IllegalArgumentException e) {
+ throw new IOException(e.getMessage());
+ } catch (IllegalAccessException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ }
+
+ }
+
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandler.java b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandler.java
new file mode 100644
index 0000000000..a5c1507e0d
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandler.java
@@ -0,0 +1,15 @@
+package org.apache.tuscany.sca.android;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public class DexURLStreamHandler extends URLStreamHandler {
+
+ @Override
+ protected URLConnection openConnection(URL url) throws IOException {
+ return new DexURLConnection(url);
+ }
+
+}
diff --git a/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandlerFactory.java b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandlerFactory.java
new file mode 100644
index 0000000000..5bb53dcd2e
--- /dev/null
+++ b/sandbox/mobile-android/android-jdk-classes/src/org/apache/tuscany/sca/android/DexURLStreamHandlerFactory.java
@@ -0,0 +1,33 @@
+package org.apache.tuscany.sca.android;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+public class DexURLStreamHandlerFactory implements URLStreamHandlerFactory {
+
+ private static DexURLStreamHandlerFactory instance;
+
+ public static DexURLStreamHandlerFactory getInstance() {
+
+ if (instance == null) {
+ instance = new DexURLStreamHandlerFactory();
+ }
+
+ return instance;
+
+ }
+
+ public DexURLStreamHandlerFactory() {}
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ URLStreamHandler urlStreamHandler = null;
+
+ if ("dex".equals(protocol)) {
+ urlStreamHandler = new DexURLStreamHandler();
+ }
+
+ return urlStreamHandler;
+
+ }
+
+}