You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/03 22:39:40 UTC
svn commit: r391146 - in
/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar:
Pack200.java PackFactory.java
Author: gharley
Date: Mon Apr 3 13:39:39 2006
New Revision: 391146
URL: http://svn.apache.org/viewcvs?rev=391146&view=rev
Log:
HARMONY-163 : awaiting default implementations and developer test code.
Added:
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java (with props)
Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java?rev=391146&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java Mon Apr 3 13:39:39 2006
@@ -0,0 +1,325 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 java.util.jar;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.SortedMap;
+
+/**
+ * Class that initialize Packer and Unpacker
+ *
+ * @see JSR200
+ */
+public abstract class Pack200 {
+
+ private static final String SYSTEM_PROPERTY_PACKER = "java.util.jar.Pack200.Packer"; //$NON-NLS-1$
+
+ private static final String SYSTEM_PROPERTY_UNPACKER = "java.util.jar.Pack200.Unpacker"; //$NON-NLS-1$
+
+ /**
+ * The method first read from system property for the classname of a Packer,
+ * if such property exsists,the class shall be initialized; or the default
+ * Packer will be returned
+ *
+ * @return a instance of Packer
+ */
+ public static Pack200.Packer newPacker() {
+ Packer packer = (Packer) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ String className = System
+ .getProperty(SYSTEM_PROPERTY_PACKER);
+ if (null != className) {
+ try {
+ return ClassLoader.getSystemClassLoader()
+ .loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new Error();
+ }
+ }
+ return null;
+ }
+ });
+ if (null != packer)
+ return packer;
+ return PackFactory.newPacker();
+ }
+
+ /**
+ * The method first read from system property for the classname of a
+ * Unpacker, if such property exsists,the class shall be initialized; or the
+ * default Unpacker will be returned
+ *
+ * @return a instance of Unpacker
+ */
+ public static Pack200.Unpacker newUnpacker() {
+ Unpacker unpacker = (Unpacker) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ String className = System
+ .getProperty(SYSTEM_PROPERTY_UNPACKER);
+ if (null != className) {
+ try {
+ return ClassLoader.getSystemClassLoader()
+ .loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new Error();
+ }
+ }
+ return null;
+ }
+ });
+ if (null != unpacker)
+ return unpacker;
+ return PackFactory.newUnpacker();
+ }
+
+ /**
+ * interface of Packer
+ *
+ * @see JSR 200 specification
+ */
+ public static interface Packer {
+
+ /**
+ * the format of a class attribute name
+ */
+ static final String CLASS_ATTRIBUTE_PFX = "pack.class.attribute."; //$NON-NLS-1$
+
+ /**
+ * the format of a code attribute name
+ */
+ static final String CODE_ATTRIBUTE_PFX = "pack.code.attribute."; //$NON-NLS-1$
+
+ /**
+ * the deflation hint to set in the output archive
+ */
+ static final String DEFLATE_HINT = "pack.deflate.hint";//$NON-NLS-1$
+
+ /**
+ * the indicated amount of effort to use in compressing the archive.
+ */
+ static final String EFFORT = "pack.effort";//$NON-NLS-1$
+
+ /**
+ * a String of error
+ */
+ static final String ERROR = "error";//$NON-NLS-1$
+
+ /**
+ * a String of false
+ */
+ static final String FALSE = "false";//$NON-NLS-1$
+
+ /**
+ * the format of a field attribute name
+ */
+ static final String FIELD_ATTRIBUTE_PFX = "pack.field.attribute.";//$NON-NLS-1$
+
+ /**
+ * a String of keep
+ */
+ static final String KEEP = "keep";//$NON-NLS-1$
+
+ /**
+ * decide if all elements shall transmit in their original order
+ */
+ static final String KEEP_FILE_ORDER = "pack.keep.file.order";//$NON-NLS-1$
+
+ /**
+ * a String of latest
+ */
+ static final String LATEST = "latest";//$NON-NLS-1$
+
+ /**
+ * the format of a method attribute name
+ */
+ static final String METHOD_ATTRIBUTE_PFX = "pack.method.attribute.";//$NON-NLS-1$
+
+ /**
+ * Packer shall attempt to determine the latest modification time if
+ * this is set to LASTEST
+ */
+ static final String MODIFICATION_TIME = "pack.modification.time";//$NON-NLS-1$
+
+ /**
+ * a String of pass
+ */
+ static final String PASS = "pass";//$NON-NLS-1$
+
+ /**
+ * the file that will not be compressed.
+ */
+ static final String PASS_FILE_PFX = "pack.pass.file.";//$NON-NLS-1$
+
+ /**
+ * packer progress as a percentage
+ */
+ static final String PROGRESS = "pack.progress";//$NON-NLS-1$
+
+ /**
+ * The number of bytes of each archive segment.
+ */
+ static final String SEGMENT_LIMIT = "pack.segment.limit";//$NON-NLS-1$
+
+ /**
+ * a String of strip
+ */
+ static final String STRIP = "strip";//$NON-NLS-1$
+
+ /**
+ * a String of true
+ */
+ static final String TRUE = "true";//$NON-NLS-1$
+
+ /**
+ * the action to take if an unknown attribute is encountered.
+ */
+ static final String UNKNOWN_ATTRIBUTE = "pack.unknown.attribute";//$NON-NLS-1$
+
+ /**
+ *
+ * @return the properties of packer
+ */
+ SortedMap properties();
+
+ /**
+ * Pack jarfile with pack arithmetic
+ *
+ * @param in
+ * jarfile to be compact
+ * @param out
+ * stream of compact data
+ * @throws IOException
+ * if I/O exception occurs
+ */
+ void pack(JarFile in, OutputStream out) throws IOException;
+
+ /**
+ * Pack jarStream with pack arithmetic
+ *
+ * @param in
+ * stream of uncompact jar data
+ * @param out
+ * stream of compact data
+ * @throws IOException
+ * if I/O exception occurs
+ */
+ void pack(JarInputStream in, OutputStream out) throws IOException;
+
+ /**
+ * add a listener for PropertyChange events
+ *
+ * @param listener
+ * the listener to listen if PropertyChange events occurs
+ */
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * remove a listener
+ *
+ * @param listener
+ * listener to remove
+ */
+ void removePropertyChangeListener(PropertyChangeListener listener);
+ }
+
+ /**
+ * interface of unpacker
+ *
+ * @see JSR 200 specification
+ */
+ public static interface Unpacker {
+
+ /**
+ * The String indicating if the unpacker should ignore all transmitted
+ * values,can be replaced by either true or false
+ */
+ static final String DEFLATE_HINT = "unpack.deflate.hint";//$NON-NLS-1$
+
+ /**
+ * a String of false
+ */
+ static final String FALSE = "false";//$NON-NLS-1$
+
+ /**
+ * a String of keep
+ */
+ static final String KEEP = "keep";//$NON-NLS-1$
+
+ /**
+ * the progress as a percentage
+ */
+ static final String PROGRESS = "unpack.progress";//$NON-NLS-1$
+
+ /**
+ * a String of true
+ */
+ static final String TRUE = "true";//$NON-NLS-1$
+
+ /**
+ *
+ * @return the properties of unpacker
+ */
+ SortedMap properties();
+
+ /**
+ * unpack stream into jarfile with pack arithmetic
+ *
+ * @param in
+ * stream to uncompact
+ * @param out
+ * jarstream of uncompact data
+ * @throws IOException
+ * if I/O exception occurs
+ */
+ void unpack(InputStream in, JarOutputStream out) throws IOException;
+
+ /**
+ * unpack File into jarfile with pack arithmetic
+ *
+ * @param in
+ * file to be uncompact
+ * @param out
+ * jarstream of uncompact data
+ * @throws IOException
+ * if I/O exception occurs
+ */
+ void unpack(File in, JarOutputStream out) throws IOException;
+
+ /**
+ * add a listener for PropertyChange events
+ *
+ * @param listener
+ * the listener to listen if PropertyChange events occurs
+ */
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * remove a listener
+ *
+ * @param listener
+ * listener to remove
+ */
+ void removePropertyChangeListener(PropertyChangeListener listener);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java?rev=391146&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java Mon Apr 3 13:39:39 2006
@@ -0,0 +1,28 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 java.util.jar;
+
+class PackFactory {
+ static Pack200.Packer newPacker() {
+ // TODO implement
+ return null;
+ }
+
+ static Pack200.Unpacker newUnpacker() {
+ // TODO implement
+ return null;
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/PackFactory.java
------------------------------------------------------------------------------
svn:eol-style = native