geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r452976 [1/2] - in /geronimo/specs/trunk: ./ geronimo-activation_1.0.2_spec/ geronimo-activation_1.1_spec/ geronimo-activation_1.1_spec/src/ geronimo-activation_1.1_spec/src/main/ geronimo-activation_1.1_spec/src/main/java/ geronimo-activat...
Date Wed, 04 Oct 2006 18:57:35 GMT
Author: rickmcguire
Date: Wed Oct  4 11:57:33 2006
New Revision: 452976

URL: http://svn.apache.org/viewvc?view=rev&rev=452976
Log:
GERONIMO-2466 Add a new Java Activation Framework 1.1 implementation.


Added:
    geronimo/specs/trunk/geronimo-activation_1.1_spec/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/mimetypes.default
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/apt/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java   (with props)
    geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java   (with props)
Modified:
    geronimo/specs/trunk/geronimo-activation_1.0.2_spec/pom.xml
    geronimo/specs/trunk/pom.xml

Modified: geronimo/specs/trunk/geronimo-activation_1.0.2_spec/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.0.2_spec/pom.xml?view=diff&rev=452976&r1=452975&r2=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.0.2_spec/pom.xml (original)
+++ geronimo/specs/trunk/geronimo-activation_1.0.2_spec/pom.xml Wed Oct  4 11:57:33 2006
@@ -20,16 +20,16 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
-    
+
     <parent>
         <groupId>org.apache.geronimo.specs</groupId>
         <artifactId>specs</artifactId>
         <version>1.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
-    
+
     <artifactId>geronimo-activation_1.0.2_spec</artifactId>
     <name>Activation 1.0.2</name>
-    <version>${geronimoSpecsActivationVersion}</version>
+    <version>${geronimoSpecsActivation102Version}</version>
 
 </project>

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt Wed Oct  4 11:57:33 2006
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt Wed Oct  4 11:57:33 2006
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml Wed Oct  4 11:57:33 2006
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>specs</artifactId>
+        <version>1.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>geronimo-activation_1.1_spec</artifactId>
+    <name>Activation 1.1</name>
+    <version>${geronimoSpecsActivation11Version}</version>
+
+</project>

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.io.InputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ActivationDataFlavor extends DataFlavor {
+    private final Class representationClass;
+    private final String mimeType;
+    private String humanPresentableName;
+
+    public ActivationDataFlavor(Class representationClass, String mimeType, String humanPresentableName) {
+        this.representationClass = representationClass;
+        this.mimeType = mimeType;
+        this.humanPresentableName = humanPresentableName;
+    }
+
+    public ActivationDataFlavor(Class representationClass, String humanPresentableName) {
+        this.representationClass = representationClass;
+        this.mimeType = "application/x-java-serialized-object";
+        this.humanPresentableName = humanPresentableName;
+    }
+
+    public ActivationDataFlavor(String mimeType, String humanPresentableName) {
+        this.mimeType = mimeType;
+        this.representationClass = InputStream.class;
+        this.humanPresentableName = humanPresentableName;
+    }
+
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    public Class getRepresentationClass() {
+        return representationClass;
+    }
+
+    public String getHumanPresentableName() {
+        return humanPresentableName;
+    }
+
+    public void setHumanPresentableName(String humanPresentableName) {
+        this.humanPresentableName = humanPresentableName;
+    }
+
+    public boolean equals(DataFlavor dataFlavor) {
+        return this.isMimeTypeEqual(dataFlavor.getMimeType()) && representationClass == dataFlavor.getRepresentationClass();
+    }
+
+    public boolean isMimeTypeEqual(String mimeType) {
+        try {
+            MimeType thisType = new MimeType(this.mimeType);
+            MimeType thatType = new MimeType(mimeType);
+            return thisType.match(thatType);
+        } catch (MimeTypeParseException e) {
+            return false;
+        }
+    }
+
+    protected String normalizeMimeTypeParameter(String parameterName, String parameterValue) {
+        return parameterName + "=" + parameterValue;
+    }
+
+    protected String normalizeMimeType(String mimeType) {
+        return mimeType;
+    }
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/ActivationDataFlavor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,85 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.beans.Beans;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CommandInfo {
+    private final String commandName;
+    private final String commandClass;
+
+    /**
+     * Constructor for a CommandInfo
+     *
+     * @param commandName  the command name
+     * @param commandClass the name of the command's implementation class
+     */
+    public CommandInfo(String commandName, String commandClass) {
+        this.commandName = commandName;
+        this.commandClass = commandClass;
+    }
+
+    /**
+     * Return the command name.
+     *
+     * @return the command name
+     */
+    public String getCommandName() {
+        return commandName;
+    }
+
+    /**
+     * Return the implementation class name.
+     *
+     * @return the name of the command's implementation class; may be null
+     */
+    public String getCommandClass() {
+        return commandClass;
+    }
+
+    /**
+     * Instantiate and return a command JavaBean.
+     * The bean is created using Beans.instantiate(loader, commandClass).
+     * If the new bean implements CommandObject then its setCommandContext(String, DataHandler)
+     * method is called.
+     * Otherwise if it implements Externalizable and the supplied DataHandler is not null
+     * then its readExternal(ObjectInputStream) method is called with a stream obtained from
+     * DataHandler.getInputStream().
+     *
+     * @param dh a DataHandler that provides the data to be passed to the command
+     * @param loader the ClassLoader to be used to instantiate the command
+     * @return a new command instance
+     * @throws IOException if there was a problem initializing the command
+     * @throws ClassNotFoundException if the command class could not be found
+     */
+    public Object getCommandObject(DataHandler dh, ClassLoader loader) throws IOException, ClassNotFoundException {
+        Object bean = Beans.instantiate(loader, commandClass);
+        if (bean instanceof CommandObject) {
+            ((CommandObject) bean).setCommandContext(commandName, dh);
+        } else if (bean instanceof Externalizable && dh != null) {
+            ((Externalizable) bean).readExternal(new ObjectInputStream(dh.getInputStream()));
+        }
+        return bean;
+    }
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,167 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class CommandMap {
+    private static CommandMap defaultCommandMap = new MailcapCommandMap();
+
+    /**
+     * Return the default CommandMap. If this has not been explictly set
+     * using setDefaultCommandMap() then a MailcapCommandMap is returned.
+     * @return the default CommandMap
+     */
+    public static CommandMap getDefaultCommandMap() {
+        return defaultCommandMap;
+    }
+
+    /**
+     * Set the default CommandMap.
+     *
+     * @param commandMap the new default CommandMap; if null resets to a MailcapCommandMap
+     * @throws SecurityException if the caller does not have "SetFactory" RuntimePermission
+     */
+    public static void setDefaultCommandMap(CommandMap commandMap) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkSetFactory();
+        }
+        defaultCommandMap = commandMap == null ? new MailcapCommandMap() : commandMap;
+    }
+
+    public CommandMap() {
+    }
+
+    /**
+     * Get the preferred commands for the given
+     * mimetype, as modified by the DataSource.  The
+     * default implementation is just a delegation to
+     * getPreferredCommands(mimeType), but the concrete
+     * implementations can define additional behavior.
+     *
+     * @param mimeType The mimeType name.
+     * @param ds       The datasource providing the type object.
+     *
+     * @return The array of CommandInfo[] objects associated with
+     *         this mimeType/DataSource combo.
+     */
+    public CommandInfo[] getPreferredCommands(String mimeType, DataSource ds) {
+        return getPreferredCommands(mimeType);
+    }
+
+    /**
+     * Get the preferred commands for the given
+     * mimetype.  The concrete implementations define the
+     * actual behaviour.
+     *
+     * @param mimeType The mimeType name.
+     *
+     * @return The array of CommandInfo[] objects associated with
+     *         this mimeType combo.
+     */
+    public abstract CommandInfo[] getPreferredCommands(String mimeType);
+
+
+    /**
+     * Get the entire command set for the given
+     * mimetype, as modified by the DataSource.  The
+     * default implementation is just a delegation to
+     * getAllCommands(mimeType), but the concrete
+     * implementations can define additional behavior.
+     *
+     * @param mimeType The mimeType name.
+     * @param ds       The datasource providing the type object.
+     *
+     * @return The array of CommandInfo[] objects associated with
+     *         this mimeType/DataSource combo.
+     */
+    public CommandInfo[] getAllCommands(String mimeType, DataSource ds) {
+        return getAllCommands(mimeType);
+    }
+
+
+    /**
+     * Get all available commands for the given
+     * mimetype.  The concrete implementations define the
+     * actual behaviour.
+     *
+     * @param mimeType The mimeType name.
+     *
+     * @return The array of CommandInfo[] objects associated with
+     *         this mimeType combo.
+     */
+    public abstract CommandInfo[] getAllCommands(String mimeType);
+
+    /**
+     * Get the default command implementation for a
+     * given mimeType/DataSource combo.
+     *
+     * The default implementation just delegates to
+     * getCommand(mimeType, cmdName).  Subclasses may
+     * provide more specialized behavior.
+     *
+     * @param mimeType The name of the mime type
+     * @param cmdName  The command action we wish to perform.
+     * @param ds       The modifying DataSource.
+     *
+     * @return A CommandInfo object corresponding to the command
+     *         mapping.
+     */
+    public CommandInfo getCommand(String mimeType, String cmdName, DataSource ds) {
+        return getCommand(mimeType, cmdName);
+    }
+
+    /**
+     * Get the default command implementation for a
+     * give mimeType
+     *
+     * @param mimeType The name of the mime type
+     * @param cmdName  The command action we wish to perform.
+     *
+     * @return A CommandInfo object corresponding to the command
+     *         mapping.
+     */
+    public abstract CommandInfo getCommand(String mimeType, String cmdName);
+
+    /**
+     * Locate a DataContentHandler for the given mime
+     * type.  The concrete implementations determine
+     * how this mapping is performed.
+     *
+     * @param mimeType The target MIME type.
+     * @param ds       The DataSource associated with this request.
+     *
+     * @return The DataContentHandler for the MIME type.
+     */
+    public DataContentHandler createDataContentHandler(String mimeType, DataSource ds) {
+        return createDataContentHandler(mimeType);
+    }
+
+    /**
+     * Locate a DataContentHandler for the given mime
+     * type.  The concrete implementations determine
+     * how this mapping is performed.
+     *
+     * @param mimeType The target MIME type.
+     *
+     * @return The DataContentHandler for the MIME type.
+     */
+    public abstract DataContentHandler createDataContentHandler(String mimeType);
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandMap.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.IOException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface CommandObject {
+    public void setCommandContext(String verb, DataHandler dh) throws IOException;
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/CommandObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface DataContentHandler {
+    public DataFlavor[] getTransferDataFlavors();
+
+    public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException;
+
+    public Object getContent(DataSource ds) throws IOException;
+
+    public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException;
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface DataContentHandlerFactory {
+    public DataContentHandler createDataContentHandler(String mimeType);
+}

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataContentHandlerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,310 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DataHandler implements Transferable {
+    private final DataSource ds;
+    private final DataFlavor flavor;
+
+    private CommandMap commandMap;
+    private DataContentHandler dch;
+
+    public DataHandler(DataSource ds) {
+        this.ds = ds;
+        this.flavor = new ActivationDataFlavor(ds.getContentType(), null);
+    }
+
+    public DataHandler(Object data, String type) {
+        this.ds = new ObjectDataSource(data, type);
+        this.flavor = new ActivationDataFlavor(data.getClass(), null);
+    }
+
+    public DataHandler(URL url) {
+        this.ds = new URLDataSource(url);
+        this.flavor = new ActivationDataFlavor(ds.getContentType(), null);
+    }
+
+    public DataSource getDataSource() {
+        return ds;
+    }
+
+    public String getName() {
+        return ds.getName();
+    }
+
+    public String getContentType() {
+        return ds.getContentType();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return ds.getInputStream();
+    }
+
+    public void writeTo(OutputStream os) throws IOException {
+        if (ds instanceof ObjectDataSource) {
+            ObjectDataSource ods = (ObjectDataSource) ds;
+            DataContentHandler dch = getDataContentHandler();
+            if (dch == null) {
+                throw new UnsupportedDataTypeException(ods.mimeType);
+            }
+            dch.writeTo(ods.data, ods.mimeType, os);
+        } else {
+            byte[] buffer = new byte[1024];
+            InputStream is = getInputStream();
+            try {
+                int count;
+                while ((count = is.read(buffer)) != -1) {
+                    os.write(buffer, 0, count);
+                }
+            } finally {
+                is.close();
+            }
+        }
+    }
+
+    public OutputStream getOutputStream() throws IOException {
+        return ds.getOutputStream();
+    }
+
+    public synchronized DataFlavor[] getTransferDataFlavors() {
+        return getDataContentHandler().getTransferDataFlavors();
+    }
+
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        DataFlavor[] flavors = getTransferDataFlavors();
+        for (int i = 0; i < flavors.length; i++) {
+            DataFlavor dataFlavor = flavors[i];
+            if (dataFlavor.equals(flavor)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+        DataContentHandler dch = getDataContentHandler();
+        if (dch != null) {
+            return dch.getTransferData(flavor, ds);
+        } else if (this.flavor.match(flavor)) {
+            if (ds instanceof ObjectDataSource) {
+                return ((ObjectDataSource) ds).data;
+            } else {
+                return ds.getInputStream();
+            }
+        } else {
+            throw new UnsupportedFlavorException(flavor);
+        }
+    }
+
+    public CommandInfo[] getPreferredCommands() {
+        return getCommandMap().getPreferredCommands(ds.getContentType());
+    }
+
+    public CommandInfo[] getAllCommands() {
+        return getCommandMap().getAllCommands(ds.getContentType());
+    }
+
+    public CommandInfo getCommand(String cmdName) {
+        return getCommandMap().getCommand(ds.getContentType(), cmdName);
+    }
+
+    public Object getContent() throws IOException {
+        if (ds instanceof ObjectDataSource) {
+            return ((ObjectDataSource) ds).data;
+        } else {
+            DataContentHandler dch = getDataContentHandler();
+            if (dch != null) {
+                return dch.getContent(ds);
+            } else {
+                return ds.getInputStream();
+            }
+        }
+    }
+
+    public Object getBean(CommandInfo cmdinfo) {
+        try {
+            return cmdinfo.getCommandObject(this, this.getClass().getClassLoader());
+        } catch (IOException e) {
+            return null;
+        } catch (ClassNotFoundException e) {
+            return null;
+        }
+    }
+
+    /**
+     * A local implementation of DataSouce used to wrap an Object and mime-type.
+     */
+    private class ObjectDataSource implements DataSource {
+        private final Object data;
+        private final String mimeType;
+
+        public ObjectDataSource(Object data, String mimeType) {
+            this.data = data;
+            this.mimeType = mimeType;
+        }
+
+        public String getName() {
+            return null;
+        }
+
+        public String getContentType() {
+            return mimeType;
+        }
+
+        public InputStream getInputStream() throws IOException {
+            final DataContentHandler dch = getDataContentHandler();
+            if (dch == null) {
+                throw new UnsupportedDataTypeException(mimeType);
+            }
+            final PipedInputStream is = new PipedInputStream();
+            final PipedOutputStream os = new PipedOutputStream(is);
+            Thread thread = new Thread("DataHandler Pipe Pump") {
+                public void run() {
+                    try {
+                        try {
+                            dch.writeTo(data, mimeType, os);
+                        } finally {
+                            os.close();
+                        }
+                    } catch (IOException e) {
+                        // ignore, per spec - doh!
+                    }
+                }
+            };
+            thread.start();
+            return is;
+        }
+
+        public OutputStream getOutputStream() throws IOException {
+            return null;
+        }
+    }
+
+    public synchronized void setCommandMap(CommandMap commandMap) {
+        this.commandMap = commandMap;
+        this.dch = null;
+    }
+
+    private synchronized CommandMap getCommandMap() {
+        return commandMap != null ? commandMap : CommandMap.getDefaultCommandMap();
+    }
+
+    /**
+     * Search for a DataContentHandler for our mime type.
+     * The search is performed by first checking if a global factory has been set using
+     * {@link #setDataContentHandlerFactory(DataContentHandlerFactory)};
+     * if found then it is called to attempt to create a handler.
+     * If this attempt fails, we then call the command map set using {@link #setCommandMap(CommandMap)}
+     * (or if that has not been set, the default map returned by {@link CommandMap#getDefaultCommandMap()})
+     * to create the handler.
+     *
+     * The resulting handler is cached until the global factory is changed.
+     *
+     * @return
+     */
+    private synchronized DataContentHandler getDataContentHandler() {
+        DataContentHandlerFactory localFactory;
+        synchronized (DataHandler.class) {
+            if (factory != originalFactory) {
+                // setDCHF was called - clear our cached copy of the DCH and DCHF
+                dch = null;
+                originalFactory = factory;
+            }
+            localFactory = originalFactory;
+        }
+        if (dch == null) {
+            // get the main mime-type portion of the content.
+            String mimeType = getMimeType(ds.getContentType());
+            if (localFactory != null) {
+                dch = localFactory.createDataContentHandler(mimeType);
+            }
+            if (dch == null) {
+                if (commandMap != null) {
+                    dch = commandMap.createDataContentHandler(mimeType);
+                } else {
+                    dch = CommandMap.getDefaultCommandMap().createDataContentHandler(mimeType);
+                }
+            }
+        }
+        return dch;
+    }
+
+    /**
+     * Retrieve the base MIME type from a content type.  This parses
+     * the type into its base components, stripping off any parameter
+     * information.
+     *
+     * @param contentType
+     *               The content type string.
+     *
+     * @return The MIME type identifier portion of the content type.
+     */
+    private String getMimeType(String contentType) {
+        try {
+            MimeType mimeType = new MimeType(contentType);
+            return mimeType.getBaseType();
+        } catch (MimeTypeParseException e) {
+        }
+        return contentType;
+    }
+
+    /**
+     * This is used to check if the DataContentHandlerFactory has been changed.
+     * This is not specified behaviour but this check is required to make this work like the RI.
+     */
+    private DataContentHandlerFactory originalFactory;
+
+    {
+        synchronized (DataHandler.class) {
+            originalFactory = factory;
+        }
+    }
+
+    private static DataContentHandlerFactory factory;
+
+    /**
+     * Set the DataContentHandlerFactory to use.
+     * If this method has already been called then an Error is raised.
+     *
+     * @param newFactory the new factory
+     * @throws SecurityException if the caller does not have "SetFactory" RuntimePermission
+     */
+    public static synchronized void setDataContentHandlerFactory(DataContentHandlerFactory newFactory) {
+        if (factory != null) {
+            throw new Error("javax.activation.DataHandler.setDataContentHandlerFactory has already been defined");
+        }
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkSetFactory();
+        }
+        factory = newFactory;
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface DataSource {
+    public abstract InputStream getInputStream() throws IOException;
+
+    public abstract OutputStream getOutputStream() throws IOException;
+
+    public abstract String getContentType();
+
+    public abstract String getName();
+}

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/DataSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,93 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FileDataSource implements DataSource {
+    private final File file;
+    private FileTypeMap fileTypeMap;
+
+    /**
+     * Creates a FileDataSource from a File object
+     */
+    public FileDataSource(File file) {
+        this.file = file;
+    }
+
+    /**
+     * Creates a FileDataSource from the specified path name
+     */
+    public FileDataSource(String name) {
+        this(new File(name));
+    }
+
+    /**
+     * Return the InputStream obtained from the data source
+     */
+    public InputStream getInputStream() throws IOException {
+        return new FileInputStream(file);
+    }
+
+    /**
+     * Return the OutputStream obtained from the data source
+     */
+    public OutputStream getOutputStream() throws IOException {
+        return new FileOutputStream(file);
+    }
+
+    /**
+     * Returns the content type of the data source
+     */
+    public String getContentType() {
+        if (fileTypeMap == null) {
+            return FileTypeMap.getDefaultFileTypeMap().getContentType(file);
+        } else {
+            return fileTypeMap.getContentType(file);
+        }
+    }
+
+    /**
+     * Returns the name of the data source object
+     */
+    public String getName() {
+        return file.getName();
+    }
+
+    /**
+     * Returns the data source file
+     */
+    public File getFile() {
+        return file;
+    }
+
+    /**
+     * Sets the FileTypeMap associated with the data source
+     */
+    public void setFileTypeMap(FileTypeMap map) {
+        fileTypeMap = map;
+    }
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileDataSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.File;
+
+/**
+ * FileTypeMap is an abstract class that provides a data type interface for files.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class FileTypeMap {
+    // we use null here rather than a default because
+    // the constructor for MimetypesFileTypeMap does a lot of I/O
+    private static FileTypeMap defaultFileTypeMap = null;
+
+    /**
+     * Sets the default FileTypeMap for the system.
+     * @param fileMap the new default FileTypeMap
+     * @throws SecurityException if the caller does not have "SetFactory" RuntimePermission
+     */
+    public static void setDefaultFileTypeMap(FileTypeMap fileMap) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkSetFactory();
+        }
+        defaultFileTypeMap = fileMap;
+    }
+
+    /**
+     * Returns the default FileTypeMap
+     * @return the default FileTYpeMap; if null returns a MimetypesFileTypeMap
+     */
+    public synchronized static FileTypeMap getDefaultFileTypeMap() {
+        if (defaultFileTypeMap == null) {
+            defaultFileTypeMap = new MimetypesFileTypeMap();
+        }
+        return defaultFileTypeMap;
+    }
+
+    public FileTypeMap() {
+    }
+
+    public abstract String getContentType(File file);
+
+    public abstract String getContentType(String filename);
+}
\ No newline at end of file

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/FileTypeMap.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,504 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MailcapCommandMap extends CommandMap {
+    private final Map mimeTypes = new HashMap();
+    private final Map preferredCommands = new HashMap();
+    private final Map allCommands = new HashMap();
+    // the unparsed commands from the mailcap file.
+    private final Map nativeCommands = new HashMap();
+    // commands identified as fallbacks...these are used last, and also used as wildcards.
+    private final Map fallbackCommands = new HashMap();
+    private URL url;
+
+    public MailcapCommandMap() {
+        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+        // process /META-INF/mailcap.default
+        try {
+            InputStream is = MailcapCommandMap.class.getResourceAsStream("/META-INF/mailcap.default");
+            if (is != null) {
+                try {
+                    parseMailcap(is);
+                } finally {
+                    is.close();
+                }
+            }
+        } catch (IOException e) {
+            // ignore
+        }
+
+        // process /META-INF/mailcap resources
+        try {
+            Enumeration e = contextLoader.getResources("META-INF/mailcap");
+            while (e.hasMoreElements()) {
+                url = ((URL) e.nextElement());
+                try {
+                    InputStream is = url.openStream();
+                    try {
+                        parseMailcap(is);
+                    } finally {
+                        is.close();
+                    }
+                } catch (IOException e1) {
+                    continue;
+                }
+            }
+        } catch (SecurityException e) {
+            // ignore
+        } catch (IOException e) {
+            // ignore
+        }
+
+        // process ${java.home}/lib/mailcap
+        try {
+            File file = new File(System.getProperty("java.home"), "lib/mailcap");
+            InputStream is = new FileInputStream(file);
+            try {
+                parseMailcap(is);
+            } finally {
+                is.close();
+            }
+        } catch (SecurityException e) {
+            // ignore
+        } catch (IOException e) {
+            // ignore
+        }
+
+        // process ${user.home}/lib/mailcap
+        try {
+            File file = new File(System.getProperty("user.home"), ".mailcap");
+            InputStream is = new FileInputStream(file);
+            try {
+                parseMailcap(is);
+            } finally {
+                is.close();
+            }
+        } catch (SecurityException e) {
+            // ignore
+        } catch (IOException e) {
+            // ignore
+        }
+    }
+
+    public MailcapCommandMap(String fileName) throws IOException {
+        this();
+        FileReader reader = new FileReader(fileName);
+        try {
+            parseMailcap(reader);
+        } finally {
+            reader.close();
+        }
+    }
+
+    public MailcapCommandMap(InputStream is) {
+        this();
+        parseMailcap(is);
+    }
+
+    private void parseMailcap(InputStream is) {
+        try {
+            parseMailcap(new InputStreamReader(is));
+        } catch (IOException e) {
+            // spec API means all we can do is swallow this
+        }
+    }
+
+    void parseMailcap(Reader reader) throws IOException {
+        BufferedReader br = new BufferedReader(reader);
+        String line;
+        while ((line = br.readLine()) != null) {
+            addMailcap(line);
+        }
+    }
+
+    public synchronized void addMailcap(String mail_cap) {
+        int index = 0;
+        // skip leading whitespace
+        index = skipSpace(mail_cap, index);
+        if (index == mail_cap.length() || mail_cap.charAt(index) == '#') {
+            return;
+        }
+
+        // get primary type
+        int start = index;
+        index = getToken(mail_cap, index);
+        if (start == index) {
+            return;
+        }
+        String mimeType = mail_cap.substring(start, index);
+
+        // skip any spaces after the primary type
+        index = skipSpace(mail_cap, index);
+        if (index == mail_cap.length() || mail_cap.charAt(index) == '#') {
+            return;
+        }
+
+        // get sub-type
+        if (mail_cap.charAt(index) == '/') {
+            index = skipSpace(mail_cap, ++index);
+            start = index;
+            index = getToken(mail_cap, index);
+            mimeType = mimeType + '/' + mail_cap.substring(start, index);
+        } else {
+
+            mimeType = mimeType + "/*";
+        }
+
+        // we record all mappings using the lowercase version.
+        mimeType = mimeType.toLowerCase();
+
+        // skip spaces after mime type
+        index = skipSpace(mail_cap, index);
+
+        // expect a ';' to terminate field 1
+        if (index == mail_cap.length() || mail_cap.charAt(index) != ';') {
+            return;
+        }
+        // ok, we've parsed the mime text field, now parse the view field.  If there's something
+        // there, then we add this to the native text.
+        index = skipSpace(mail_cap, index + 1);
+        // if the next encountered text is not a ";", then we have a view.  This gets added to the
+        // native list.
+        if (index == mail_cap.length() || mail_cap.charAt(index) != ';') {
+            ArrayList nativeCommandList = (ArrayList)nativeCommands.get(mimeType);
+
+            // if this is the first for this mimetype, create a holder
+            if (nativeCommandList == null) {
+                nativeCommandList = new ArrayList();
+                nativeCommands.put(mimeType, nativeCommandList);
+            }
+
+            // now add this as an entry in the list.
+            nativeCommandList.add(mail_cap);
+            // now skip forward to the next field marker, if any
+            index = getMText(mail_cap, index);
+        }
+
+        // we don't know which list this will be added to until we finish parsing, as there
+        // can be an x-java-fallback-entry parameter that moves this to the fallback list.
+        List commandList = new ArrayList();
+        // but by default, this is not a fallback.
+        boolean fallback = false;
+
+        int fieldNumber = 0;
+
+        // parse fields
+        while (index < mail_cap.length() && mail_cap.charAt(index) == ';') {
+            index = skipSpace(mail_cap, index + 1);
+            start = index;
+            index = getToken(mail_cap, index);
+            String fieldName = mail_cap.substring(start, index).toLowerCase();
+            index = skipSpace(mail_cap, index);
+            if (index < mail_cap.length() && mail_cap.charAt(index) == '=') {
+                index = skipSpace(mail_cap, index + 1);
+                start = index;
+                index = getMText(mail_cap, index);
+                String value = mail_cap.substring(start, index);
+                index = skipSpace(mail_cap, index);
+                if (fieldName.startsWith("x-java-") && fieldName.length() > 7) {
+                    String command = fieldName.substring(7);
+                    value = value.trim();
+                    if (command.equals("fallback-entry")) {
+                        if (value.equals("true")) {
+                            fallback = true;
+                        }
+                    }
+                    else {
+                        // create a CommandInfo item and add it the accumulator
+                        CommandInfo info = new CommandInfo(command, value);
+                        commandList.add(info);
+                    }
+                }
+            }
+        }
+        addCommands(mimeType, commandList, fallback);
+    }
+
+    /**
+     * Add a parsed list of commands to the appropriate command list.
+     *
+     * @param mimeType The mimeType name this is added under.
+     * @param commands A List containing the command information.
+     * @param fallback The target list identifier.
+     */
+    private void addCommands(String mimeType, List commands, boolean fallback) {
+        // add this to the mimeType set
+        mimeTypes.put(mimeType, mimeType);
+        // the target list changes based on the type of entry.
+        Map target = fallback ? fallbackCommands : preferredCommands;
+
+        // now process
+        for (Iterator i = commands.iterator(); i.hasNext();) {
+            CommandInfo info = (CommandInfo)i.next();
+            addCommand(target, mimeType, info);
+            // if this is not a fallback position, then this to the allcommands list.
+            if (!fallback) {
+                List cmdList = (List) allCommands.get(mimeType);
+                if (cmdList == null) {
+                    cmdList = new ArrayList();
+                    allCommands.put(mimeType, cmdList);
+                }
+                cmdList.add(info);
+            }
+        }
+    }
+
+
+    /**
+     * Add a command to a target command list (preferred or fallback).
+     *
+     * @param commandList
+     *                 The target command list.
+     * @param mimeType The MIME type the command is associated with.
+     * @param command  The command information.
+     */
+    private void addCommand(Map commandList, String mimeType, CommandInfo command) {
+
+        Map commands = (Map) commandList.get(mimeType);
+        if (commands == null) {
+            commands = new HashMap();
+            commandList.put(mimeType, commands);
+        }
+        commands.put(command.getCommandName(), command);
+    }
+
+
+    private int skipSpace(String s, int index) {
+        while (index < s.length() && Character.isWhitespace(s.charAt(index))) {
+            index++;
+        }
+        return index;
+    }
+
+    private int getToken(String s, int index) {
+        while (index < s.length() && s.charAt(index) != '#' && !MimeType.isSpecial(s.charAt(index))) {
+            index++;
+        }
+        return index;
+    }
+
+    private int getMText(String s, int index) {
+        while (index < s.length()) {
+            char c = s.charAt(index);
+            if (c == '#' || c == ';' || Character.isISOControl(c)) {
+                return index;
+            }
+            if (c == '\\') {
+                index++;
+                if (index == s.length()) {
+                    return index;
+                }
+            }
+            index++;
+        }
+        return index;
+    }
+
+    public synchronized CommandInfo[] getPreferredCommands(String mimeType) {
+        // get the mimetype as a lowercase version.
+        mimeType = mimeType.toLowerCase();
+
+        Map commands = (Map) preferredCommands.get(mimeType);
+        if (commands == null) {
+            commands = (Map) preferredCommands.get(getWildcardMimeType(mimeType));
+        }
+
+        Map fallbackCommands = getFallbackCommands(mimeType);
+
+        // if we have fall backs, then we need to merge this stuff.
+        if (fallbackCommands != null) {
+            // if there's no command list, we can just use this as the master list.
+            if (commands == null) {
+                commands = fallbackCommands;
+            }
+            else {
+                // merge the two lists.  The ones in the commands list will take precedence.
+                commands = mergeCommandMaps(commands, fallbackCommands);
+            }
+        }
+
+        // now convert this into an array result.
+        if (commands == null) {
+            return new CommandInfo[0];
+        }
+        return (CommandInfo[]) commands.values().toArray(new CommandInfo[commands.size()]);
+    }
+
+    private Map getFallbackCommands(String mimeType) {
+        Map commands = (Map) fallbackCommands.get(mimeType);
+
+        // now we also need to search this as if it was a wildcard.  If we get a wildcard hit,
+        // we have to merge the two lists.
+        Map wildcardCommands = (Map)fallbackCommands.get(getWildcardMimeType(mimeType));
+        // no wildcard version
+        if (wildcardCommands == null) {
+            return commands;
+        }
+        // we need to merge these.
+        return mergeCommandMaps(commands, wildcardCommands);
+    }
+
+
+    private Map mergeCommandMaps(Map main, Map fallback) {
+        // create a cloned copy of the second map.  We're going to use a PutAll operation to
+        // overwrite any duplicates.
+        Map result = new HashMap(fallback);
+        result.putAll(main);
+
+        return result;
+    }
+
+    public synchronized CommandInfo[] getAllCommands(String mimeType) {
+        mimeType = mimeType.toLowerCase();
+        List exactCommands = (List) allCommands.get(mimeType);
+        if (exactCommands == null) {
+            exactCommands = Collections.EMPTY_LIST;
+        }
+        List wildCommands = (List) allCommands.get(getWildcardMimeType(mimeType));
+        if (wildCommands == null) {
+            wildCommands = Collections.EMPTY_LIST;
+        }
+
+        Map fallbackCommands = getFallbackCommands(mimeType);
+        if (fallbackCommands == null) {
+            fallbackCommands = Collections.EMPTY_MAP;
+        }
+
+
+        CommandInfo[] result = new CommandInfo[exactCommands.size() + wildCommands.size() + fallbackCommands.size()];
+        int j = 0;
+        for (int i = 0; i < exactCommands.size(); i++) {
+            result[j++] = (CommandInfo) exactCommands.get(i);
+        }
+        for (int i = 0; i < wildCommands.size(); i++) {
+            result[j++] = (CommandInfo) wildCommands.get(i);
+        }
+
+        for (Iterator i = fallbackCommands.keySet().iterator(); i.hasNext();) {
+            result[j++] = (CommandInfo) fallbackCommands.get((String)i.next());
+        }
+        return result;
+    }
+
+    public synchronized CommandInfo getCommand(String mimeType, String cmdName) {
+        mimeType = mimeType.toLowerCase();
+        // strip any parameters from the supplied mimeType
+        int i = mimeType.indexOf(';');
+        if (i != -1) {
+            mimeType = mimeType.substring(0, i).trim();
+        }
+
+        // search for an exact match
+        Map commands = (Map) preferredCommands.get(mimeType);
+        if (commands == null) {
+            // then a wild card match
+            commands = (Map) preferredCommands.get(getWildcardMimeType(mimeType));
+            if (commands == null) {
+                // then fallback searches, both standard and wild card.
+                commands = (Map) fallbackCommands.get(mimeType);
+                if (commands == null) {
+                    commands = (Map) fallbackCommands.get(getWildcardMimeType(mimeType));
+                }
+                if (commands == null) {
+                    return null;
+                }
+            }
+        }
+        return (CommandInfo) commands.get(cmdName.toLowerCase());
+    }
+
+    private String getWildcardMimeType(String mimeType) {
+        int i = mimeType.indexOf('/');
+        if (i == -1) {
+            return mimeType + "/*";
+        } else {
+            return mimeType.substring(0, i + 1) + "*";
+        }
+    }
+
+    public synchronized DataContentHandler createDataContentHandler(String mimeType) {
+
+        CommandInfo info = getCommand(mimeType, "content-handler");
+        if (info == null) {
+            return null;
+        }
+
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if (cl == null) {
+            cl = getClass().getClassLoader();
+        }
+        try {
+            return (DataContentHandler) cl.loadClass(info.getCommandClass()).newInstance();
+        } catch (ClassNotFoundException e) {
+            return null;
+        } catch (IllegalAccessException e) {
+            return null;
+        } catch (InstantiationException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Get all MIME types known to this command map.
+     *
+     * @return A String array of the MIME type names.
+     */
+    public synchronized String[] getMimeTypes() {
+        ArrayList types = new ArrayList(mimeTypes.values());
+        return (String[])types.toArray(new String[types.size()]);
+    }
+
+    /**
+     * Return the list of raw command strings parsed
+     * from the mailcap files for a given mimeType.
+     *
+     * @param mimeType The target mime type
+     *
+     * @return A String array of the raw command strings.  Returns
+     *         an empty array if the mimetype is not currently known.
+     */
+    public synchronized String[] getNativeCommands(String mimeType) {
+        ArrayList commands = (ArrayList)nativeCommands.get(mimeType.toLowerCase());
+        if (commands == null) {
+            return new String[0];
+        }
+        return (String[])commands.toArray(new String[commands.size()]);
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MailcapCommandMap.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java Wed Oct  4 11:57:33 2006
@@ -0,0 +1,141 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.activation;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimeType implements Externalizable {
+    private static final String SPECIALS = "()<>@,;:\\\"/[]?=";
+
+    static boolean isSpecial(char c) {
+        return Character.isWhitespace(c) || Character.isISOControl(c) || SPECIALS.indexOf(c) != -1;
+    }
+
+    private String primaryType = "application";
+    private String subType = "*";
+    private final MimeTypeParameterList parameterList = new MimeTypeParameterList();;
+
+    public MimeType() {
+    }
+
+    public MimeType(String rawdata) throws MimeTypeParseException {
+        parseMimeType(rawdata);
+    }
+
+    public MimeType(String primary, String sub) throws MimeTypeParseException {
+        setPrimaryType(primary);
+        setSubType(sub);
+    }
+
+    public String getPrimaryType() {
+        return primaryType;
+    }
+
+    public void setPrimaryType(String primary) throws MimeTypeParseException {
+        primaryType = parseToken(primary);
+    }
+
+    public String getSubType() {
+        return subType;
+    }
+
+    public void setSubType(String sub) throws MimeTypeParseException {
+        subType = parseToken(sub);
+    }
+
+    public MimeTypeParameterList getParameters() {
+        return parameterList;
+    }
+
+    public String getParameter(String name) {
+        return parameterList.get(name);
+    }
+
+    public void setParameter(String name, String value) {
+        parameterList.set(name, value);
+    }
+
+    public void removeParameter(String name) {
+        parameterList.remove(name);
+    }
+
+    public String toString() {
+        return getBaseType() + parameterList.toString();
+    }
+
+    public String getBaseType() {
+        return getPrimaryType() + '/' + getSubType();
+    }
+
+    public boolean match(MimeType type) {
+        if (!primaryType.equals(type.primaryType)) return false;
+        if ("*".equals(subType)) return true;
+        if ("*".equals(type.subType)) return true;
+        return subType.equals(type.subType);
+    }
+
+    public boolean match(String rawdata) throws MimeTypeParseException {
+        return match(new MimeType(rawdata));
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeUTF(toString());
+        out.flush();
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        try {
+            parseMimeType(in.readUTF());
+        } catch (MimeTypeParseException mtpex) {
+            throw new IOException(mtpex.getMessage());
+        }
+    }
+
+    private void parseMimeType(String rawData) throws MimeTypeParseException {
+        int index = rawData.indexOf('/');
+        if (index == -1) {
+            throw new MimeTypeParseException("Expected '/'");
+        }
+        setPrimaryType(rawData.substring(0, index));
+        int index2 = rawData.indexOf(';', index+1);
+        if (index2 == -1) {
+            setSubType(rawData.substring(index+1));
+        } else {
+            setSubType(rawData.substring(index+1, index2));
+            parameterList.parse(rawData.substring(index2));
+        }
+    }
+
+    private static String parseToken(String tokenString) throws MimeTypeParseException {
+        tokenString = tokenString.trim();
+        for (int i=0; i < tokenString.length(); i++) {
+            char c = tokenString.charAt(i);
+            if (isSpecial(c)) {
+                throw new MimeTypeParseException("Special '" + c + "' not allowed in token");
+            }
+        }
+        return tokenString;
+    }
+}



Mime
View raw message