commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1084131 [1/2] - in /commons/sandbox/runtime/trunk: ./ src/ src/assembly/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/commons/ src/main/java/org/apache/commons/runtime/ src/main/java/org/ap...
Date Tue, 22 Mar 2011 11:04:50 GMT
Author: mturk
Date: Tue Mar 22 11:04:49 2011
New Revision: 1084131

URL: http://svn.apache.org/viewvc?rev=1084131&view=rev
Log:
Add back some old code

Added:
    commons/sandbox/runtime/trunk/src/
    commons/sandbox/runtime/trunk/src/assembly/
    commons/sandbox/runtime/trunk/src/assembly/src.xml   (with props)
    commons/sandbox/runtime/trunk/src/main/
    commons/sandbox/runtime/trunk/src/main/java/
    commons/sandbox/runtime/trunk/src/main/java/org/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/overview.html   (with props)
    commons/sandbox/runtime/trunk/src/main/native/
    commons/sandbox/runtime/trunk/src/main/native/include/
    commons/sandbox/runtime/trunk/src/main/native/include/acr/
    commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h   (with props)
    commons/sandbox/runtime/trunk/src/site/
    commons/sandbox/runtime/trunk/src/site/resources/
    commons/sandbox/runtime/trunk/src/site/resources/images/
    commons/sandbox/runtime/trunk/src/site/resources/images/logo.png   (with props)
    commons/sandbox/runtime/trunk/src/site/site.xml   (with props)
    commons/sandbox/runtime/trunk/src/site/xdoc/
    commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml   (with props)
    commons/sandbox/runtime/trunk/src/site/xdoc/index.xml   (with props)
    commons/sandbox/runtime/trunk/src/site/xdoc/issue-tracking.xml   (with props)
    commons/sandbox/runtime/trunk/src/site/xdoc/mail-lists.xml   (with props)
    commons/sandbox/runtime/trunk/src/site/xdoc/proposal.xml   (with props)
Modified:
    commons/sandbox/runtime/trunk/build.properties.default

Modified: commons/sandbox/runtime/trunk/build.properties.default
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.properties.default?rev=1084131&r1=1084130&r2=1084131&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.properties.default (original)
+++ commons/sandbox/runtime/trunk/build.properties.default Tue Mar 22 11:04:49 2011
@@ -27,12 +27,12 @@
 # ----- Vesion Control Flags --------------------------------------------------
 version.major=0
 version.minor=9
-version.patch=3
+version.patch=4
 version.suffix=-dev
 
 # ----- Default Compile options -----------------------------------------------
-compile.source=1.5
-compile.target=1.5
+compile.source=1.6
+compile.target=1.6
 compile.debug=off
 compile.optimize=on
 compile.deprecation=on

Added: commons/sandbox/runtime/trunk/src/assembly/src.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/assembly/src.xml?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/assembly/src.xml (added)
+++ commons/sandbox/runtime/trunk/src/assembly/src.xml Tue Mar 22 11:04:49 2011
@@ -0,0 +1,40 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<assembly>
+    <id>src</id>
+    <formats>
+        <format>tar.gz</format>
+        <format>zip</format>
+    </formats>
+    <baseDirectory>${artifactId}-${version}-src</baseDirectory>
+    <fileSets>
+        <fileSet>
+            <includes>
+                <include>build.properties.default</include>
+                <include>build.properties.in</include>
+                <include>build.xml</include>
+                <include>configure</include>
+                <include>LICENSE.txt</include>
+                <include>NOTICE.txt</include>
+                <include>pom.xml</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src</directory>
+        </fileSet>
+    </fileSets>
+</assembly>

Propchange: commons/sandbox/runtime/trunk/src/assembly/src.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties Tue Mar 22 11:04:49 2011
@@ -0,0 +1,49 @@
+# -----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# Main Apache Commons Runtime properties file.
+# Notice: Properties defined inside platform specific Default.properties file
+# take precedence over the values in this file.
+#
+# -----------------------------------------------------------------------------
+
+# Version info provided at build time
+# Mostly used to determine the jar classpath name
+runtime.version.major = @VERSION_MAJOR@
+runtime.version.minor = @VERSION_MINOR@
+runtime.version.patch = @VERSION_PATCH@
+runtime.version.pname = @VERSION_PNAME@
+# Build stamps.
+runtime.version.built = @VERSION_BUILT@
+runtime.version.uuid  = @VERSION_UUID@
+
+# Indicates the caching policy for lookups on cpu object.
+# The TTL is number of milliseconds between two counter lookups.
+cpu.cache.ttl = 100
+cpu.cache.ttl.min = 1
+
+# Maximum number of opened OS descriptors
+os.open.max = 65536
+
+# Native library name
+# See platform/<os>/Default.properties for any additional libraries
+# that has to be loaded before this library
+#
+library.load = acr
+library.load.ssl = acrssl

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties Tue Mar 22 11:04:49 2011
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+os.ENOTIMPL=Apache Commons Runtime does not support this operating system
+os.EVERSION=Apache Commons Runtime does not support this operating system version
+waithow.EINVAL=Invalid WaitHow enum initializer ({0})
+reslimit.EINVAL=Invalid ResourceLimit enum initializer ({0})
+killcond.EINVAL=Invalid KillConditions enum initializer ({0})

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,253 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime;
+
+import java.util.EnumSet;
+import java.util.Properties;
+
+/**
+ * Class that uses system properties to match {@link Os} class
+ * for system name and processor.
+ * <p>
+ * Used when extracting the native libraries from the .jar to find
+ * the correct path of dynamic shared library and its dependencies.
+ * </p>
+ *
+ * @see Os
+ * @since Runtime 1.0
+ */
+public final class SystemId
+{
+
+    private static Properties props;
+    private SystemId() {
+        // No instance
+    }
+
+    static {
+        props = System.getProperties();
+    }
+
+    /**
+     * Name of the operating system implementation.
+     * @return {@code String} representing the operating system
+     * this {@code JVM} is running on.
+     */
+    public static String getSysname()
+    {
+        String name = props.getProperty("os.name");
+        String platform = "unknown";
+
+        if (name.startsWith("Windows"))
+            platform = "windows";
+        else if (name.startsWith("Mac OS"))
+            platform = "darwin";
+        else if (name.endsWith("BSD"))
+            platform = "bsd";
+        else if (name.equals("Linux"))
+            platform = "linux";
+        else if (name.equals("Solaris"))
+            platform = "solaris";
+        else if (name.equals("SunOS"))
+            platform = "solaris";
+        else if (name.equals("HP-UX"))
+            platform = "hpux";
+        else if (name.equals("AIX"))
+            platform = "aix";
+
+        return platform;
+    }
+
+    /**
+     * Data model of the operating system proccessor.
+     * @return {@code String} representing the processor
+     * data model {@code (32 or 64 bit)}.
+     */
+    public static String getDataModel()
+    {
+        String data = props.getProperty("sun.arch.data.model");
+
+        if (data == null) {
+            data = props.getProperty("com.ibm.vm.bitmode");
+        }
+        if (data == null) {
+            String arch = props.getProperty("os.arch");
+            if (arch.indexOf("64") < 0) {
+                /* TODO: Investigate other JVM's property for
+                 * figuring the data model (32 or 64)
+                 */
+                data = "32";
+            }
+            else {
+                data = "64";
+            }
+        }
+        return data;
+    }
+
+    /**
+     * Name of the operating system proccessor.
+     * @return {@code String} representing the processor
+     * this {@code JVM} is running on.
+     */
+    public static String getProcessor()
+    {
+        String cpu;
+        String name = props.getProperty("os.name");
+        String arch = props.getProperty("os.arch");
+        String data = getDataModel();
+
+        if (arch.endsWith("86")) {
+            cpu = "x86";
+            if (name.startsWith("Mac OS")) {
+                if (data.equals("64"))
+                    cpu = "x86_64";
+            }
+        }
+        else if (arch.startsWith("PA_RISC")) {
+            if (data.equals("64"))
+                cpu = "parisc64";
+            else
+                cpu = "parisc";
+        }
+        else if (arch.startsWith("IA64"))
+            cpu = "ia64";
+        else if (arch.startsWith("sparc")) {
+            if (data.equals("64"))
+                cpu = "sparc64";
+            else
+                cpu = "sparc";
+        }
+        else if (arch.startsWith("ppc")) {
+            if (data.equals("64"))
+                cpu = "ppc64";
+            else
+                cpu = "ppc";
+        }
+        else if (arch.equals("amd64"))
+            cpu = "x86_64";
+        else
+            cpu = arch;
+        return cpu;
+    }
+
+    private static int platformId()
+    {
+        String sys = getSysname();
+        String cpu = getProcessor();
+        int    pid = 0;
+
+        if (sys.equals("windows")) {
+            if (cpu.equals("x86"))
+                pid = 0x10000;
+            else if (cpu.equals("ia64"))
+                pid = 0x10011;
+            else
+                pid = 0x10010;
+        }
+        else if (sys.equals("linux")) {
+            if (cpu.equals("x86"))
+                pid = 0x20100;
+            else if (cpu.equals("ia64"))
+                pid = 0x20112;
+            else
+                pid = 0x20111;
+        }
+        else if (sys.equals("solaris")) {
+            if (cpu.equals("x86"))
+                pid = 0x20200;
+            else if (cpu.equals("sparc32"))
+                pid = 0x20201;
+            else if (cpu.equals("sparc64"))
+                pid = 0x20211;
+            else
+                pid = 0x20210;
+        }
+        else if (sys.equals("darwin")) {
+            if (cpu.equals("x86"))
+                pid = 0x20400;
+            else if (cpu.equals("x86_64"))
+                pid = 0x20410;
+            else
+                pid = 0x20401;
+        }
+        else if (sys.equals("hpux")) {
+            if (cpu.equals("x86"))
+                pid = 0x20800;
+            else if (cpu.equals("ia64"))
+                pid = 0x20811;
+            else if (cpu.equals("parisc32"))
+                pid = 0x20802;
+            else
+                pid = 0x20812;
+        }
+        return pid;
+    }
+
+    /**
+     * Platform Shared Object extension.
+     * @return {@code String} representing the System default shared object
+     *         extension.
+     */
+    public static String getSoExtension()
+    {
+        String sys = getSysname();
+        String ext;
+
+        if (sys.equals("windows")) {
+            ext = "dll";
+        }
+        else if (sys.equals("darwin")) {
+            ext = "jnilib";
+        }
+        else if (sys.equals("hpux")) {
+            if (getProcessor().startsWith("parisc"))
+                ext = "sl";
+            else
+                ext = "so";
+        }
+        else {
+            ext = "so";
+        }
+        return ext;
+    }
+
+    /**
+     * Platform Id string.
+     * <p>
+     * Platform Id string is used to name the native libraries inside
+     * {@code META-LIB} jar directory. This resource is then dynamically
+     * extracted to the {@code java.io.tmpdir} or system temporary
+     * directory and then loaded.
+     * </p>
+     * <p>
+     * <b>To be defined</b>
+     * </p>
+     * @return {@code String} representing the JVM platform Id.
+     */
+    public static String getPlatformId()
+    {
+        String pid = Integer.toHexString(platformId());
+        return ("00000" + pid).substring(pid.length());
+    }
+
+    public static EnumSet<OsType> getOsType()
+    {
+        return OsType.valueOf(platformId());
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.exception;
+
+/**
+ * OperatingSystemException
+ *
+ * @author Mladen Turk
+ *
+ */
+
+public class OperatingSystemException extends RuntimeException
+{
+
+    public OperatingSystemException()
+    {
+        super();
+    }
+
+    public OperatingSystemException(String msg)
+    {
+        super(msg);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,37 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.exception;
+
+/** UnsupportedOperatingSystemException
+ *
+ * @author Mladen Turk
+ *
+ */
+
+public class UnsupportedOperatingSystemException extends RuntimeException
+{
+
+    public UnsupportedOperatingSystemException()
+    {
+        super();
+    }
+
+    public UnsupportedOperatingSystemException(String msg)
+    {
+        super(msg);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/UnsupportedOperatingSystemException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,469 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.util;
+
+/**
+ * Character Classification routines.
+ *
+ * @author Mladen Turk
+ * @since Runtime 1.0
+ */
+public final class Ascii
+{
+
+    private static final char _XL_U   = 0x01;
+    private static final char _XL_L   = 0x02;
+    private static final char _XL_N   = 0x04;
+    private static final char _XL_S   = 0x08;
+    private static final char _XL_P   = 0x10;
+    private static final char _XL_C   = 0x20;
+    private static final char _XL_X   = 0x40;
+    private static final char _XL_B   = 0x80;
+
+    private static final char[] ccs_ctype = {
+        _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,
+        _XL_C,  _XL_C|_XL_S|_XL_B, _XL_C|_XL_S, _XL_C|_XL_S, _XL_C|_XL_S,
+        _XL_C|_XL_S,    _XL_C,  _XL_C,
+        _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,
+        _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,  _XL_C,
+        _XL_S|_XL_B, _XL_P,  _XL_P, _XL_P,   _XL_P,  _XL_P,  _XL_P,  _XL_P,
+        _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,
+        _XL_N,  _XL_N,  _XL_N,  _XL_N,  _XL_N,  _XL_N,  _XL_N,  _XL_N,
+        _XL_N,  _XL_N,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,
+        _XL_P,  _XL_U|_XL_X,    _XL_U|_XL_X,    _XL_U|_XL_X,    _XL_U|_XL_X,
+        _XL_U|_XL_X,    _XL_U|_XL_X,    _XL_U,
+        _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,
+        _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,  _XL_U,
+        _XL_U,  _XL_U,  _XL_U,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_P,
+        _XL_P,  _XL_L|_XL_X,    _XL_L|_XL_X,    _XL_L|_XL_X,    _XL_L|_XL_X,
+        _XL_L|_XL_X,    _XL_L|_XL_X,    _XL_L,
+        _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,
+        _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,  _XL_L,
+        _XL_L,  _XL_L,  _XL_L,  _XL_P,  _XL_P,  _XL_P,  _XL_P,  _XL_C
+    };
+
+    private static final char[] ccs_clower = {
+        0x00,    0x01,    0x02,    0x03,    0x04,    0x05,    0x06,    0x07,
+        0x08,    0x09,    0x0a,    0x0b,    0x0c,    0x0d,    0x0e,    0x0f,
+        0x10,    0x11,    0x12,    0x13,    0x14,    0x15,    0x16,    0x17,
+        0x18,    0x19,    0x1a,    0x1b,    0x1c,    0x1d,    0x1e,    0x1f,
+        0x20,    0x21,    0x22,    0x23,    0x24,    0x25,    0x26,    0x27,
+        0x28,    0x29,    0x2a,    0x2b,    0x2c,    0x2d,    0x2e,    0x2f,
+        0x30,    0x31,    0x32,    0x33,    0x34,    0x35,    0x36,    0x37,
+        0x38,    0x39,    0x3a,    0x3b,    0x3c,    0x3d,    0x3e,    0x3f,
+        0x40,    'a',     'b',     'c',     'd',     'e',     'f',     'g',
+        'h',     'i',     'j',     'k',     'l',     'm',     'n',     'o',
+        'p',     'q',     'r',     's',     't',     'u',     'v',     'w',
+        'x',     'y',     'z',     0x5b,    0x5c,    0x5d,    0x5e,    0x5f,
+        0x60,    'a',     'b',     'c',     'd',     'e',     'f',     'g',
+        'h',     'i',     'j',     'k',     'l',     'm',     'n',     'o',
+        'p',     'q',     'r',     's',     't',     'u',     'v',     'w',
+        'x',     'y',     'z',     0x7b,    0x7c,    0x7d,    0x7e,    0x7f,
+        0x80,    0x81,    0x82,    0x83,    0x84,    0x85,    0x86,    0x87,
+        0x88,    0x89,    0x8a,    0x8b,    0x8c,    0x8d,    0x8e,    0x8f,
+        0x90,    0x91,    0x92,    0x93,    0x94,    0x95,    0x96,    0x97,
+        0x98,    0x99,    0x9a,    0x9b,    0x9c,    0x9d,    0x9e,    0x9f,
+        0xa0,    0xa1,    0xa2,    0xa3,    0xa4,    0xa5,    0xa6,    0xa7,
+        0xa8,    0xa9,    0xaa,    0xab,    0xac,    0xad,    0xae,    0xaf,
+        0xb0,    0xb1,    0xb2,    0xb3,    0xb4,    0xb5,    0xb6,    0xb7,
+        0xb8,    0xb9,    0xba,    0xbb,    0xbc,    0xbd,    0xbe,    0xbf,
+        0xc0,    0xc1,    0xc2,    0xc3,    0xc4,    0xc5,    0xc6,    0xc7,
+        0xc8,    0xc9,    0xca,    0xcb,    0xcc,    0xcd,    0xce,    0xcf,
+        0xd0,    0xd1,    0xd2,    0xd3,    0xd4,    0xd5,    0xd6,    0xd7,
+        0xd8,    0xd9,    0xda,    0xdb,    0xdc,    0xdd,    0xde,    0xdf,
+        0xe0,    0xe1,    0xe2,    0xe3,    0xe4,    0xe5,    0xe6,    0xe7,
+        0xe8,    0xe9,    0xea,    0xeb,    0xec,    0xed,    0xee,    0xef,
+        0xf0,    0xf1,    0xf2,    0xf3,    0xf4,    0xf5,    0xf6,    0xf7,
+        0xf8,    0xf9,    0xfa,    0xfb,    0xfc,    0xfd,    0xfe,    0xff,
+    };
+
+    private static final char[] ccs_cupper = {
+        0x00,    0x01,    0x02,    0x03,    0x04,    0x05,    0x06,    0x07,
+        0x08,    0x09,    0x0a,    0x0b,    0x0c,    0x0d,    0x0e,    0x0f,
+        0x10,    0x11,    0x12,    0x13,    0x14,    0x15,    0x16,    0x17,
+        0x18,    0x19,    0x1a,    0x1b,    0x1c,    0x1d,    0x1e,    0x1f,
+        0x20,    0x21,    0x22,    0x23,    0x24,    0x25,    0x26,    0x27,
+        0x28,    0x29,    0x2a,    0x2b,    0x2c,    0x2d,    0x2e,    0x2f,
+        0x30,    0x31,    0x32,    0x33,    0x34,    0x35,    0x36,    0x37,
+        0x38,    0x39,    0x3a,    0x3b,    0x3c,    0x3d,    0x3e,    0x3f,
+        0x40,    'A',     'B',     'C',     'D',     'E',     'F',     'G',
+        'H',     'I',     'J',     'K',     'L',     'M',     'N',     'O',
+        'P',     'Q',     'R',     'S',     'T',     'U',     'V',     'W',
+        'X',     'Y',     'Z',     0x5b,    0x5c,    0x5d,    0x5e,    0x5f,
+        0x60,    'A',     'B',     'C',     'D',     'E',     'F',     'G',
+        'H',     'I',     'J',     'K',     'L',     'M',     'N',     'O',
+        'P',     'Q',     'R',     'S',     'T',     'U',     'V',     'W',
+        'X',     'Y',     'Z',     0x7b,    0x7c,    0x7d,    0x7e,    0x7f,
+        0x80,    0x81,    0x82,    0x83,    0x84,    0x85,    0x86,    0x87,
+        0x88,    0x89,    0x8a,    0x8b,    0x8c,    0x8d,    0x8e,    0x8f,
+        0x90,    0x91,    0x92,    0x93,    0x94,    0x95,    0x96,    0x97,
+        0x98,    0x99,    0x9a,    0x9b,    0x9c,    0x9d,    0x9e,    0x9f,
+        0xa0,    0xa1,    0xa2,    0xa3,    0xa4,    0xa5,    0xa6,    0xa7,
+        0xa8,    0xa9,    0xaa,    0xab,    0xac,    0xad,    0xae,    0xaf,
+        0xb0,    0xb1,    0xb2,    0xb3,    0xb4,    0xb5,    0xb6,    0xb7,
+        0xb8,    0xb9,    0xba,    0xbb,    0xbc,    0xbd,    0xbe,    0xbf,
+        0xc0,    0xc1,    0xc2,    0xc3,    0xc4,    0xc5,    0xc6,    0xc7,
+        0xc8,    0xc9,    0xca,    0xcb,    0xcc,    0xcd,    0xce,    0xcf,
+        0xd0,    0xd1,    0xd2,    0xd3,    0xd4,    0xd5,    0xd6,    0xd7,
+        0xd8,    0xd9,    0xda,    0xdb,    0xdc,    0xdd,    0xde,    0xdf,
+        0xe0,    0xe1,    0xe2,    0xe3,    0xe4,    0xe5,    0xe6,    0xe7,
+        0xe8,    0xe9,    0xea,    0xeb,    0xec,    0xed,    0xee,    0xef,
+        0xf0,    0xf1,    0xf2,    0xf3,    0xf4,    0xf5,    0xf6,    0xf7,
+        0xf8,    0xf9,    0xfa,    0xfb,    0xfc,    0xfd,    0xfe,    0xff,
+    };
+
+
+    public static boolean isascii(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return true;
+        else
+            return false;
+    }
+
+    public static boolean isalnum(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & (_XL_U|_XL_L|_XL_N)) != 0;
+        else
+            return false;
+    }
+
+    public static boolean isalpha(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & (_XL_U|_XL_L)) != 0;
+        else
+            return false;
+    }
+
+    public static boolean isdigit(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_N) != 0;
+        else
+            return false;
+    }
+
+    public static boolean isspace(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_S) != 0;
+        else
+            return false;
+    }
+
+    public static boolean isblank(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & (_XL_S|_XL_B)) == (_XL_S|_XL_B);
+        else
+            return false;
+    }
+
+    public static boolean iscntrl(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_C) != 0;
+        else
+            return false;
+    }
+
+    public static boolean islower(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_L) != 0;
+        else
+            return false;
+    }
+
+    public static boolean isupper(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_U) != 0;
+        else
+            return false;
+    }
+
+    public static boolean ispunct(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & _XL_P) != 0;
+        else
+            return false;
+    }
+
+
+    /**
+     * Checks for a hexadecimal digits, i.e. one of
+     * <pre>
+     * 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F.
+     * </pre>
+     *
+     * return {@code true} if the {@code c} is hexadecimal digit.
+     */
+    public static boolean isxdigit(int c)
+    {
+        c = c & 0xff;
+        if (c < _XL_B)
+            return (ccs_ctype[c] & (_XL_X|_XL_N)) != 0;
+        else
+            return false;
+    }
+
+    public static int tolower(int c)
+    {
+        return ccs_clower[c & 0xff];
+    }
+
+    public static int toupper(int c)
+    {
+        return ccs_cupper[c & 0xff];
+    }
+
+    public static void tolower(byte[] arr, int srcPos, int len)
+    {
+        for (int i = srcPos; i < len; i++)
+            arr[i] = (byte)ccs_clower[(int)arr[i] & 0xff];
+    }
+
+    public static void toupper(byte[] arr, int srcPos, int len)
+    {
+        for (int i = srcPos; i < len; i++)
+            arr[i] = (byte)ccs_cupper[(int)arr[i] & 0xff];
+    }
+
+    /**
+     * Convert characters in {@code arr} byte array to integer.
+     * <p>
+     * Skip white space and pick up leading {@code +/-} sign if any.
+     * If base is {@code 0}, allow {@code 0x} for hex and {@code 0} for octal,
+     * else assume decimal; if base is already {@code 16}, allow {@code 0x}.
+     * </p>
+     *
+     * @param arr input byte array
+     * @param srcPos starting position in the input array.
+     * @param len use at most {@code len} characters.
+     * @param base number base to use {@code (2 - 36)} or {@code 0} for guess. 
+     *
+     * @return integer value of the {@code Ascii} string pointed by {@code arr}.
+     */
+    public static int atoi(byte[] arr, int srcPos, int len, int base)
+    {
+        int  acc;
+        int  val;
+        int  neg;
+        int  any;
+        int  i = srcPos;
+        int  c;
+
+        // Skip leading spaces
+        if (len < 1)
+            return 0;
+        do {
+            c = arr[i++];
+        } while (isspace(c) && i < len);
+
+        if (c == '-') {
+            neg = 1;
+            if (i < len)
+                c = arr[i++];
+            else {
+                // EINVAL
+                return 0;
+            }
+        } else {
+            neg = 0;
+            if (c == '+') {
+                if (i < len)
+                    c = arr[i++];
+                else {
+                    // EINVAL
+                    return 0;
+                }
+            }
+        }
+        if ((base == 0 || base == 16) &&
+            c == '0' && i < len && (arr[i] == 'x' || arr[i] == 'X')) {
+            if ((i + 1) < len) {
+                c = arr[i + 1];
+                i += 2;
+                base = 16;
+            }
+            else {
+                // EINVAL
+                return 0;
+            }
+        }
+        if (base == 0)
+            base = c == '0' ? 8 : 10;
+            acc = any = 0;
+        if (base < 2 || base > 36) {
+            // EINVAL
+            return acc;
+        }
+        val = 0;
+        while (i <= len) {
+            if (c >= '0' && c <= '9')
+                c -= '0';
+            else if (c >= 'A' && c <= 'Z')
+                c -= 'A' - 10;
+            else if (c >= 'a' && c <= 'z')
+                c -= 'a' - 10;
+            else
+                break;
+            if (c >= base)
+                break;
+            val *= base;
+            if ((any < 0) || /* already noted an over/under flow - short circuit */
+                (neg != 0 && (val > acc || (val -= c) > acc)) ||    /* underflow */
+                (neg == 0 && (val < acc || (val += c) < acc))) {    /* overflow  */
+                any = -1;    /* once noted, over/underflows never go away */
+                break;
+            } else {
+                acc = val;
+                any = 1;
+            }
+            if (i < len)
+                c = arr[i];
+            i++;
+        }
+
+        if (any < 0) {
+            acc = neg == 0 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
+        } else if (any == 0) {
+            // EINVAL
+        }
+        return acc;
+    }
+
+    /**
+     * Convert characters in {@code arr} byte array to long.
+     * <p>
+     * Skip white space and pick up leading {@code +/-} sign if any.
+     * If base is {@code 0}, allow {@code 0x} for hex and {@code 0} for octal,
+     * else assume decimal; if base is already {@code 16}, allow {@code 0x}.
+     * </p>
+     *
+     * @param arr input byte array
+     * @param srcPos starting position in the input array.
+     * @param len use at most {@code len} characters.
+     * @param base number base to use {@code (2 - 36)} or {@code 0} for guess. 
+     *
+     * @return long value of the {@code Ascii} string pointed by {@code arr}.
+     */
+    public static long atol(byte[] arr, int srcPos, int len, int base)
+    {
+        long acc;
+        long val;
+        int  neg;
+        int  any;
+        int  i = srcPos;
+        int  c;
+
+        // Skip leading spaces
+        if (len < 1)
+            return 0;
+        do {
+            c = arr[i++];
+        } while (isspace(c) && i < len);
+
+        if (c == '-') {
+            neg = 1;
+            if (i < len)
+                c = arr[i++];
+            else {
+                // EINVAL
+                return 0;
+            }
+        } else {
+            neg = 0;
+            if (c == '+') {
+                if (i < len)
+                    c = arr[i++];
+                else {
+                    // EINVAL
+                    return 0;
+                }
+            }
+        }
+        if ((base == 0 || base == 16) &&
+            c == '0' && i < len && (arr[i] == 'x' || arr[i] == 'X')) {
+            if ((i + 1) < len) {
+                c = arr[i + 1];
+                i += 2;
+                base = 16;
+            }
+            else {
+                // EINVAL
+                return 0;
+            }
+        }
+        if (base == 0)
+            base = c == '0' ? 8 : 10;
+            acc = any = 0;
+        if (base < 2 || base > 36) {
+            // EINVAL
+            return acc;
+        }
+        val = 0;
+        while (i <= len) {
+            if (c >= '0' && c <= '9')
+                c -= '0';
+            else if (c >= 'A' && c <= 'Z')
+                c -= 'A' - 10;
+            else if (c >= 'a' && c <= 'z')
+                c -= 'a' - 10;
+            else
+                break;
+            if (c >= base)
+                break;
+            val *= base;
+            if ((any < 0) || /* already noted an over/under flow - short circuit */
+                (neg != 0 && (val > acc || (val -= c) > acc)) ||    /* underflow */
+                (neg == 0 && (val < acc || (val += c) < acc))) {    /* overflow  */
+                any = -1;    /* once noted, over/underflows never go away */
+                break;
+            } else {
+                acc = val;
+                any = 1;
+            }
+            if (i < len)
+                c = arr[i];
+            i++;
+        }
+
+        if (any < 0) {
+            acc = neg == 0 ? Long.MAX_VALUE : Long.MIN_VALUE;
+        } else if (any == 0) {
+            // EINVAL
+        }
+        return acc;
+    }
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,374 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.util;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Provides Base64 encoding and decoding as defined by {@code RFC 2045}.
+ * <p>
+ * This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite>
+ * from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite>
+ * by Freed and Borenstein.
+ * </p>
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
+ *
+ * @author Mladen Turk
+ *
+ */
+public class Base64
+{
+
+    private Base64()
+    {
+        // Disable creation
+    }
+
+    /**
+     * Wrap encoded lines after {@value} character.
+     * <p>
+     * The {@value} character limit does not count the trailing {@code CRLF},
+     * but counts all other characters, including any equal signs.
+     * </p>
+     *
+     * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
+     */
+    public  static final int    COLS    = 76;
+    private static final String CHARSET = Local.sm.get("base64.charset");
+    private static final char   padding = '=';
+    private static final char   CR      = '\r';
+    private static final char   LF      = '\n';
+    private static final byte[] base64b = {
+        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+        'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+        'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+        'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+        'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
+        '8', '9', '+', '/'
+    };
+    private static final char[] base64c = {
+        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+        'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+        'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+        'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+        'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
+        '8', '9', '+', '/'
+    };
+
+    // ASCII table
+    private static final byte[] pr2six = {
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 65, 65, 64, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 62, 65, 65, 65, 63,
+        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 65, 65, 65, 65, 65,
+        65,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
+        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 65, 65, 65, 65, 65,
+        65, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65
+    };
+
+    /**
+     * Calculate number of bytes needed to {@code Base64} encode
+     * the {@code src} array.
+     *
+     * @param src byte array to encode.
+     * @param srcPos offset from the start of the {@code data} byte array.
+     * @param len length in the {@code src} byte array.
+     * @param wrap Wrap encoded lines after {@code wrap} character.
+     *        Use {@code 0} to disable line wrapping.
+     *
+     * @return length needed to {@code Base64} encode the array.
+     */
+    public static int encodeLength(byte[] src, int srcPos, int len,
+                                   int wrap)
+    {
+        int dstlen;
+
+        if (len < 1)
+            len = src.length - srcPos;
+        dstlen = (((len + 2) / 3) * 4);
+        if (wrap == -1)
+            wrap = COLS;
+        if (wrap > 0)
+            dstlen += ((dstlen / wrap) * 2);
+
+        return dstlen;
+    }
+
+    public static int encode(byte[] src, int srcPos, byte[] dst,
+                             int dstPos, int len, int wrap)
+        throws IndexOutOfBoundsException, NullPointerException
+    {
+        int oc = 0;
+        int dp = dstPos;
+        int sc = srcPos;
+        int dl = dst.length;
+        int i;
+        int[] inp = new int[3];
+        int[] out = new int[4];
+
+        if (len < 1)
+            len = src.length - srcPos;
+        if (wrap == -1)
+            wrap = COLS;
+        while (len >= 3) {
+            inp[0] = (int)src[sc++] & 0xFF;
+            inp[1] = (int)src[sc++] & 0xFF;
+            inp[2] = (int)src[sc++] & 0xFF;
+            len   -= 3;
+
+            out[0] = ((inp[0] >> 2));
+            out[1] = ((inp[0] & 0x03) << 4) + (inp[1] >> 4);
+            out[2] = ((inp[1] & 0x0F) << 2) + (inp[2] >> 6);
+            out[3] = ((inp[2] & 0x3F));
+
+            if (dp + 4 > dl)
+                throw new IndexOutOfBoundsException(Local.sm.get("base64.invalidDestinationSize"));
+            dst[dp++] = base64b[out[0]];
+            dst[dp++] = base64b[out[1]];
+            dst[dp++] = base64b[out[2]];
+            dst[dp++] = base64b[out[3]];
+            if (wrap > 0) {
+                if (++oc % (wrap / 4) == 0) {
+                    dst[dp++] = CR;
+                    dst[dp++] = LF;
+                }
+            }
+        }
+        // Pad with remaining 1 or 2 bytes
+        if (len != 0) {
+            inp[0] = inp[1] = inp[2] = 0;
+            for (i = 0; i < len; i++)
+                inp[i] = (int)src[sc++] & 0xFF;
+
+            out[0] = ((inp[0] >> 2));
+            out[1] = ((inp[0] & 0x03) << 4) + (inp[1] >> 4);
+            out[2] = ((inp[1] & 0x0F) << 2) + (inp[2] >> 6);
+
+            if (dp + 4 > dl)
+                throw new IndexOutOfBoundsException(Local.sm.get("base64.invalidDestinationSize"));
+            dst[dp++] = base64b[out[0]];
+            dst[dp++] = base64b[out[1]];
+            if (len == 1)
+                dst[dp++] = padding;
+            else
+                dst[dp++] = base64b[out[2]];
+            dst[dp++] = padding;
+        }
+        return dp - dstPos;
+    }
+
+    public static int encode(byte[] src, int srcPos, char[] dst,
+                             int dstPos, int len, int wrap)
+        throws IndexOutOfBoundsException, NullPointerException
+    {
+        int oc = 0;
+        int dp = dstPos;
+        int sc = srcPos;
+        int dl = dst.length;
+        int i;
+        int[] inp = new int[3];
+        int[] out = new int[4];
+
+        if (len < 1)
+            len = src.length - srcPos;
+        if (wrap == -1)
+            wrap = COLS;
+        while (len >= 3) {
+            inp[0] = (int)src[sc++] & 0xFF;
+            inp[1] = (int)src[sc++] & 0xFF;
+            inp[2] = (int)src[sc++] & 0xFF;
+            len   -= 3;
+
+            out[0] = ((inp[0] >> 2));
+            out[1] = ((inp[0] & 0x03) << 4) + (inp[1] >> 4);
+            out[2] = ((inp[1] & 0x0F) << 2) + (inp[2] >> 6);
+            out[3] = ((inp[2] & 0x3F));
+
+            if (dp + 4 > dl)
+                throw new IndexOutOfBoundsException(Local.sm.get("base64.invalidDestinationSize"));
+            dst[dp++] = base64c[out[0]];
+            dst[dp++] = base64c[out[1]];
+            dst[dp++] = base64c[out[2]];
+            dst[dp++] = base64c[out[3]];
+            if (wrap > 0) {
+                if (++oc % (wrap / 4) == 0) {
+                    dst[dp++] = CR;
+                    dst[dp++] = LF;
+                }
+            }
+        }
+        // Pad with remaining 1 or 2 bytes
+        if (len != 0) {
+            inp[0] = inp[1] = inp[2] = 0;
+            for (i = 0; i < len; i++)
+                inp[i] = (int)src[sc++] & 0xFF;
+
+            out[0] = ((inp[0] >> 2));
+            out[1] = ((inp[0] & 0x03) << 4) + (inp[1] >> 4);
+            out[2] = ((inp[1] & 0x0F) << 2) + (inp[2] >> 6);
+
+            if (dp + 4 > dl)
+                throw new IndexOutOfBoundsException(Local.sm.get("base64.invalidDestinationSize"));
+            dst[dp++] = base64c[out[0]];
+            dst[dp++] = base64c[out[1]];
+            if (len == 1)
+                dst[dp++] = padding;
+            else
+                dst[dp++] = base64c[out[2]];
+            dst[dp++] = padding;
+        }
+        return dp - dstPos;
+    }
+
+    /**
+     * Encode String using Base64 encoding.
+     * <p>
+     * Input string is encoded from the {@code ISO-8859-1} charset.
+     * </p>
+     *
+     * @param string String to encode.
+     * @param wrap Wrap encoded lines after {@code wrap} character.
+     *        Use {@code 0} to disable line wrapping.
+     * @return {@code base64} encoded String.
+     */
+    public static String encode(String string, int wrap)
+    {
+        try {
+            byte [] data = string.getBytes(CHARSET);
+            char [] dest = new char[encodeLength(data, 0, data.length, 0)];
+
+            int nencoded = encode(data, 0, dest, 0, data.length, 0);
+            return new String(dest, 0, nencoded);
+        } catch (UnsupportedEncodingException e) {
+            return "";
+        }
+    }
+
+    /**
+     * Encode String using Base64 encoding.
+     * <p>
+     * Input string is encoded from the {@code ISO 8859-1} charset
+     * and wrapped on {@code COLS} characters.
+     * </p>
+     *
+     * @param string String to encode.
+     * @return {@code base64} encoded String.
+     */
+    public static String encode(String string)
+    {
+        return encode(string, COLS);
+    }
+
+    /**
+     * Calculate number of bytes needed to {@code Base64} decode
+     * the {@code src} array.
+     *
+     * @param src byte array to decode.
+     * @param srcPos offset from the start of the {@code data} byte array.
+     * @param len length in the {@code src} byte array.
+     *
+     * @return length needed to {@code Base64} decode the array.
+     */
+    public static int decodeLength(byte[] src, int srcPos, int len)
+    {
+        int sc = 0;
+        int lf = 0;
+        int nprbytes;
+
+        if (len < 1)
+            len = src.length - srcPos;
+        while (sc < len) {
+            int ch = (int)src[srcPos + sc] & 0xFF;
+             if (pr2six[ch] == 64)
+                 lf++;
+             if (pr2six[ch] == 65)
+                 break;
+             sc++;
+        }
+        return ((sc + 3) / 4) * 3 - lf;
+    }
+
+    public static int decode(byte[] src, int srcPos, byte[] dst,
+                             int dstPos, int len)
+        throws IndexOutOfBoundsException, NullPointerException
+    {
+        int sc = 0;
+        int sp = srcPos;
+        int dp = dstPos;
+        int nprbytes;
+
+        if (len < 1)
+            len = src.length - srcPos;
+        while (sc < len && pr2six[(int)src[srcPos + sc++] & 0xFF] <= 64);
+
+        nprbytes = sc - 1;
+        while (nprbytes > 4) {
+            if (src[sp] == CR || src[sp] == LF) {
+                /* Just skip any CRLF combination.
+                 * We don't care for format the validity.
+                 * For us any line ending is valid, eg.
+                 * LF, CRLF, CR, LFCR, ...
+                 */
+                sp += 1;
+                nprbytes -= 1;
+                continue;
+            }
+            dst[dp++] = (byte)(pr2six[src[sp + 0]] << 2 | pr2six[src[sp + 1]] >> 4);
+            dst[dp++] = (byte)(pr2six[src[sp + 1]] << 4 | pr2six[src[sp + 2]] >> 2);
+            dst[dp++] = (byte)(pr2six[src[sp + 2]] << 6 | pr2six[src[sp + 3]]);
+            sp += 4;
+            nprbytes -= 4;
+        }
+
+        /* Note: (nprbytes == 1) would be an error, so just ingore that case */
+        if (nprbytes > 1)
+            dst[dp++] = (byte)(pr2six[src[sp + 0]] << 2 | pr2six[src[sp + 1]] >> 4);
+        if (nprbytes > 2)
+            dst[dp++] = (byte)(pr2six[src[sp + 1]] << 4 | pr2six[src[sp + 2]] >> 2);
+        if (nprbytes > 3)
+            dst[dp++] = (byte)(pr2six[src[sp + 2]] << 6 | pr2six[src[sp + 3]]);
+
+        return dp - dstPos;
+    }
+
+    public static String decode(String string)
+    {
+        try {
+            byte [] data = string.getBytes(CHARSET);
+            byte [] dest = new byte[decodeLength(data, 0, data.length)];
+
+            int ndecoded = decode(data, 0, dest, 0, data.length);
+            return new String(dest, 0, ndecoded);
+        } catch (UnsupportedEncodingException e) {
+            return "";
+        }
+    }
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Base64.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties Tue Mar 22 11:04:49 2011
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+base64.charset=ISO-8859-1
+base64.invalidDestinationSize=Destination is too small
+uuid.invalidBufferSize=Must be at least 16 bytes
+utils.noWrittableTemp=Cannot find writable temporary directory
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/LocalStrings.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,143 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.commons.runtime.util;
+
+import java.text.MessageFormat;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * An internationalization / localization helper class which reduces
+ * the bother of handling ResourceBundles and takes care of the
+ * common cases of message formating which otherwise require the
+ * creation of Object arrays and such.
+ *
+ * <p>
+ * The StringManager operates on a package basis. One StringManager
+ * per package can be created and accessed via the getManager method
+ * call.
+ * </p>
+ * <p>
+ * The StringManager will look for a ResourceBundle named by
+ * the package name given plus the suffix of "LocalStrings". In
+ * practice, this means that the localized information will be contained
+ * in a LocalStrings.properties file located in the package
+ * directory of the classpath.
+ * </p>
+ * <p>
+ * Please see the documentation for java.util.ResourceBundle for
+ * more information.
+ * </p>
+ */
+public class StringManager
+{
+
+    /**
+     * The ResourceBundle for this StringManager.
+     */
+    private ResourceBundle bundle;
+    private Locale locale;
+
+    /**
+     * Creates a new StringManager for a given package. This is a
+     * private method and all access to it is arbitrated by the
+     * static getManager method call so that only one StringManager
+     * per package will be created.
+     *
+     * @param packageName Name of package to create StringManager for.
+     */
+    private StringManager(String packageName)
+    {
+        String bundleName = packageName + ".LocalStrings";
+        bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+        // Get the actual locale, which may be different from the requested one
+        locale = bundle.getLocale();
+    }
+
+    /**
+     * Get a string from the underlying resource bundle or return
+     * null if the String is not found.
+     *
+     * @param key to desired resource String
+     * @return resource String matching <i>key</i> from underlying
+     *         bundle or null if not found.
+     * @throws IllegalArgumentException if <i>key</i> is null.
+     */
+    public String get(final String key)
+        throws IllegalArgumentException
+    {
+        if (key == null) {
+            String msg = "key may not have a null value";
+            throw new IllegalArgumentException(msg);
+        }
+
+        String value = null;
+        try {
+            value = bundle.getString(key);
+        } catch (MissingResourceException mre) {
+            value = null;
+        }
+        return value;
+    }
+
+    /**
+     * Get a string from the underlying resource bundle and format
+     * it with the given set of arguments.
+     *
+     * @param key
+     * @param args
+     */
+    public String get(final String key, final Object... args)
+        throws IllegalArgumentException
+    {
+        String value = get(key);
+        if (value == null) {
+            value = key;
+        }
+
+        MessageFormat mf = new MessageFormat(value);
+        mf.setLocale(locale);
+        return mf.format(args, new StringBuffer(), null).toString();
+    }
+
+    // --------------------------------------------------------------
+    // STATIC SUPPORT METHODS
+    // --------------------------------------------------------------
+
+    private static Hashtable<String, StringManager> managers =
+        new Hashtable<String, StringManager>();
+
+    /**
+     * Get the StringManager for a particular package. If a manager for
+     * a package already exists, it will be reused, else a new
+     * StringManager will be created and returned.
+     *
+     * @param packageName The package name
+     */
+    public synchronized static StringManager getManager(String packageName)
+    {
+        StringManager mgr = managers.get(packageName);
+        if (mgr == null) {
+            mgr = new StringManager(packageName);
+            managers.put(packageName, mgr);
+        }
+        return mgr;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/StringManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,83 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.util;
+
+/**
+ * Generates 128-bit UUID
+ */
+public final class UUID
+{
+    private static native byte[] getb0()
+                                    throws UnsupportedOperationException;
+
+    private byte[] uuid;
+
+    /**
+     * Create new {@code UUID} instance.
+     */
+    public UUID()
+        throws UnsupportedOperationException
+    {
+        uuid = getb0();
+    }
+
+    public UUID(byte[] uuid)
+        throws IllegalArgumentException
+    {
+        if (uuid.length < 16)
+            throw new IllegalArgumentException(Local.sm.get("uuid.invalidBufferSize"));
+        this.uuid = uuid;
+    }
+
+    private String hex(byte val)
+    {
+        String h = Integer.toHexString(val);
+        if (h.length() == 1)
+            h = "0" + h;
+        return h.substring(h.length() - 2);
+    }
+
+    public String toString()
+    {
+        // TODO: Make more optimized version
+        // using pre-set char[] array.
+        // "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+
+        StringBuffer sb = new StringBuffer();
+        sb.append(hex(uuid[0]));
+        sb.append(hex(uuid[1]));
+        sb.append(hex(uuid[2]));
+        sb.append(hex(uuid[3]));
+        sb.append('-');
+        sb.append(hex(uuid[4]));
+        sb.append(hex(uuid[5]));
+        sb.append('-');
+        sb.append(hex(uuid[6]));
+        sb.append(hex(uuid[7]));
+        sb.append('-');
+        sb.append(hex(uuid[8]));
+        sb.append(hex(uuid[9]));
+        sb.append('-');
+        sb.append(hex(uuid[10]));
+        sb.append(hex(uuid[11]));
+        sb.append(hex(uuid[12]));
+        sb.append(hex(uuid[13]));
+        sb.append(hex(uuid[14]));
+        sb.append(hex(uuid[15]));
+        return sb.toString();
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java Tue Mar 22 11:04:49 2011
@@ -0,0 +1,315 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.runtime.util;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.PrintStream;
+import java.util.Random;
+import org.apache.commons.runtime.SystemId;
+
+/**
+ * General purpose utilities.
+ *
+ * @author Mladen Turk
+ */
+public final class Utils
+{
+
+    private Utils()
+    {
+        // Private to prevent creation.
+    }
+
+    private static long     counter                = 1024L;
+    private static long     timer                  = System.currentTimeMillis();
+    private static Random   rnd                    = new Random(timer);
+    private static File     tmpdir                 = null;
+    private static Object   lock                   = new Object();
+
+    private static final char[] hc = {
+                '0', '1', '2', '3', '4', '5', '6', '7',
+                '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+
+    /**
+     * Returns the unique 64 bit id.
+     * Values lower then 1024 are reseved for system ID's.
+     */
+    public static long Id()
+    {
+        long id;
+        synchronized (Utils.class) {
+            id = counter++;
+        }
+        return id;
+    }
+
+    public static void generateRandom(byte[] dst)
+    {
+        rnd.nextBytes(dst);
+    }
+
+    public static String hex(byte val)
+    {
+        String h = Integer.toHexString(val);
+        if (h.length() == 1)
+            h = "0" + h;
+        return h;
+    }
+
+    public static String hex(short val)
+    {
+        String h = Integer.toHexString(val);
+        return ("0000" + h).substring(h.length());
+    }
+
+    public static String hex(int val)
+    {
+        String h = Integer.toHexString(val);
+        return ("00000000" + h).substring(h.length());
+    }
+
+    public static String hex(long val)
+    {
+        String h = Long.toHexString(val);
+        return ("0000000000000000" + h).substring(h.length());
+    }
+
+    public static String hex(byte[] src, int srcPos, int len)
+    {
+        int    p = 0;
+        char[] c = new char[len * 2];
+        for (int i = srcPos; i < len; i++) {
+            c[p++] = hc[(src[i] >> 4) & 0x0F];
+            c[p++] = hc[(src[i] >> 0) & 0x0F];
+        }
+        return new String(c);
+    }
+
+    public static String hex(byte[] src)
+    {
+        return hex(src, 0, src.length);
+    }
+
+    public static String dumpBuffer(byte[] data, int offset, int len)
+    {
+        int i;
+        int p = offset;
+
+        if (offset >= data.length)
+            return null;
+        StringBuffer sb = new StringBuffer();
+        sb.append(hex((short)(offset & 0x7FFF)));
+        sb.append(": ");
+        for (i = 0; i < 16; i++) {
+            if (i < data.length) {
+                sb.append(hex(data[offset+i]));
+                if (i == 7)
+                    sb.append("|");
+                else
+                    sb.append(" ");
+            }
+            else {
+                sb.append("   ");
+            }
+        }
+        sb.append(" | ");
+        for (i = offset; i < offset + 16; i++) {
+            if (i < data.length) {
+                if (!Character.isISOControl((char)(data[i] & 0xFF)))
+                    sb.append(new Character((char)(data[i] & 0xFF)));
+                else
+                    sb.append(".");
+            }
+        }
+        return sb.toString();
+    }
+
+    public static String dumpBuffer(byte[] data)
+    {
+        return dumpBuffer(data, 0, data.length);
+    }
+
+    public static void dumpBuffer(byte[] data, int offset, int len,
+                                  PrintStream out)
+    {
+        out.println(dumpBuffer(data, offset, len));
+    }
+
+    public static void dumpBuffer(byte[] data, PrintStream out)
+    {
+        out.println(dumpBuffer(data));
+    }
+
+    private static final String [] try_envs = {
+        "TMPDIR",
+        "TEMP",
+        "TMP"
+    };
+    private static final String [] win_trys = {
+        "C:\\TMP",
+        "C:\\TEMP",
+        "C:\\WINDOWS\\TEMP"
+    };
+    private static final String [] psx_trys = {
+        "/tmp",
+        "/usr/tmp",
+        "/var/tmp"
+    };
+
+
+    private static File checkTempDir(String path)
+    {
+        if (path == null)
+            return null;
+        try {
+            File d = new File(path);
+            File f = File.createTempFile("test", ".acr", new File(path));
+            f.delete();
+            return d;
+        } catch (Exception ex) {
+            // Ignore
+        }
+        return null;
+    }
+
+    public static File getTempPath()
+    {
+
+        if (tmpdir != null)
+            return tmpdir;
+
+        synchronized(lock) { 
+            if (tmpdir != null)
+                return tmpdir;
+            tmpdir = checkTempDir(System.getProperty("java.io.tmpdir"));
+            if (tmpdir != null)
+                return tmpdir;
+
+            for (int i = 0; i < try_envs.length; i++) {
+                tmpdir = checkTempDir(System.getenv(try_envs[i]));
+                if (tmpdir != null)
+                    return tmpdir;
+            }
+
+            String [] try_path;
+            if (SystemId.getSysname().equals("windows"))
+                try_path = win_trys;
+            else
+                try_path = psx_trys;
+    
+            for (int i = 0; i < try_path.length; i++) {
+                tmpdir = checkTempDir(System.getenv(try_path[i]));
+                if (tmpdir != null)
+                    return tmpdir;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Create temporary directory.
+     * <p>
+     * Directory is created inside system dependant default temorary directory.
+     * This directory is specified by the system property
+     * {@code java.io.tmpdir}.
+     * </p>
+     * @param prefix The prefix string to be used in generating directory name.
+     *                Must be at least three characters long.
+     * @return An abstract pathname denoting newly-created empty directory.
+     */
+    public static File createTempDirectory(String prefix)
+        throws IllegalArgumentException, IOException
+    {
+        int tries  = 0;
+        byte [] rb = new byte[12];
+        char [] ec = new char[48];
+        File td    = getTempPath();
+
+        if (td == null) {
+            throw new IOException(Local.sm.get("utils.noWrittableTemp"));
+        }
+        while(true) {
+            try {
+                generateRandom(rb);
+                Base64.encode(rb, 0, ec, 0, 0, 0);
+                File tmpd = new File(td, prefix + new String(ec, 0, 8));
+                if (tmpd.mkdir()) {
+                    /* Directory is ceated
+                     */
+                    return tmpd;
+                }
+            } catch (Exception ex) {
+                // Ignore
+            }
+            if (tries++ > 5) {
+                if (tries > 10)
+                    break;
+                try {
+                    Thread.sleep(10 + 2 * tries);
+                } catch (InterruptedException ix) {
+                    // Ignore
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Recursively delete a directory.
+     * <p>
+     * This method behaves like {@code java.io.File#delete} method
+     * but allows deletion of non-empty directories.
+     * </p>
+     *
+     * @param dir The directory abstract pathname.
+     * @return {@code true} if the directory is successfully deleted;
+     *         {@code false} otherwise.
+     */
+    public static boolean deleteDirectory(File dir)
+    {
+        try {
+            if (dir.delete()) {
+                /* We are done */
+                return true;
+            }
+            else if (dir.isDirectory()) {
+                File[] entries = dir.listFiles();
+                if (entries != null) {
+                    for (int i = 0; i < entries.length; i++) {
+                        if (entries[i].isDirectory()) {
+                            /* Recursively delete a child directory
+                             */
+                            deleteDirectory(entries[i]);
+                        }
+                        else {
+                            /* Regular file
+                             */
+                            entries[i].delete();
+                        }
+                    }
+                }
+                return dir.delete();
+            }
+        } catch (Exception ex) {
+            // Ignore
+        }
+        return false;
+    }
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/overview.html
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/overview.html?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/overview.html (added)
+++ commons/sandbox/runtime/trunk/src/main/java/overview.html Tue Mar 22 11:04:49 2011
@@ -0,0 +1,27 @@
+<html>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
+<head>
+<title>Overview Documentation for Apache Commons Runtime</title>
+</head>
+<body bgcolor="white">
+<p>The <em>Runtime</em> component
+of the <em>Apache Commonss</em> project offers JNI wrappers around various
+system libraries.</p>
+
+</body>
+</html>

Propchange: commons/sandbox/runtime/trunk/src/main/java/overview.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h Tue Mar 22 11:04:49 2011
@@ -0,0 +1,91 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef _ACR_VERSION_H
+#define _ACR_VERSION_H
+
+/**
+ * @file version.h
+ * @brief
+ *
+ * ACR Version
+ *
+ * There are several different mechanisms for accessing the version. There
+ * is a string form, and a set of numbers; in addition, there are constants
+ * which can be compiled into your application, and you can query the library
+ * being used for its actual version.
+ *
+ * Note that it is possible for an application to detect that it has been
+ * compiled against a different version of ACR by use of the compile-time
+ * constants and the use of the run-time query function.
+ *
+ * ACR version numbering follows the guidelines specified in:
+ *
+ *     http://apr.apache.org/versioning.html
+ */
+
+/* The numeric compile-time version constants. These constants are the
+ * authoritative version numbers for ACR.
+ */
+
+/** major version
+ * Major API changes that could cause compatibility problems for older
+ * programs such as structure size changes.  No binary compatibility is
+ * possible across a change in the major version.
+ */
+#define ACR_MAJOR_VERSION       0
+
+/**
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading ACR_MAJOR_VERSION
+ */
+#define ACR_MINOR_VERSION       9
+
+/** patch level */
+#define ACR_PATCH_VERSION       4
+
+/**
+ *  This symbol is defined for internal, "development" copies of ACR.
+ *  This symbol will be #undef'd for releases.
+ */
+#define ACR_ISDEV_VERSION       1
+
+/** Properly quote a value as a string in the C preprocessor */
+#define ACR_STRINGIFY(n)        ACR_STRINGIFY_HELPER(n)
+/** Helper macro for ACR_STRINGIFY */
+#define ACR_STRINGIFY_HELPER(n) #n
+
+
+/** The formatted string of APU's version */
+#define ACR_VERSION_STRING \
+     ACR_STRINGIFY(ACR_MAJOR_VERSION) "."   \
+     ACR_STRINGIFY(ACR_MINOR_VERSION) "."   \
+     ACR_STRINGIFY(ACR_PATCH_VERSION)       \
+     ACR_IS_DEV_STRING
+
+/** Internal: string form of the "is dev" flag */
+#if ACR_ISDEV_VERSION
+#define ACR_ISDEV_STRING        "-dev"
+#else
+#define ACR_ISDEV_STRING        ""
+#endif
+
+/** Macro for Win32 .rc files using numeric csv representation */
+#define ACR_VERSION_STRING_CSV ACR_MAJOR_VERSION ##, \
+                             ##ACR_MINOR_VERSION ##, \
+                             ##ACR_PATCH_VERSION
+
+#endif /* _ACR_VERSION_H */

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/version.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/site/resources/images/logo.png
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/site/resources/images/logo.png?rev=1084131&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/sandbox/runtime/trunk/src/site/resources/images/logo.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: commons/sandbox/runtime/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/site/site.xml?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/site/site.xml (added)
+++ commons/sandbox/runtime/trunk/src/site/site.xml Tue Mar 22 11:04:49 2011
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<project name="runtime">
+  <bannerRight>
+    <name>Commons Runtime</name>
+    <src>/images/logo.png</src>
+    <href>/index.html</href>
+  </bannerRight>
+  <body>
+    <menu name="Runtime">
+      <item name="Overview"      href="/index.html" />
+    </menu>
+    <menu name="Development">
+      <item name="Mailing Lists"           href="/mail-lists.html"/>
+      <item name="Issue Tracking"          href="/issue-tracking.html"/>
+      <item name="Source Repository"       href="/source-repository.html"/>
+      <item name="Javadoc"                 href="/apidocs/index.html"/>
+    </menu>
+  </body>
+</project>

Propchange: commons/sandbox/runtime/trunk/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml?rev=1084131&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml (added)
+++ commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml Tue Mar 22 11:04:49 2011
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<!--
+ +======================================================================+
+ |****                                                              ****|
+ |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
+ |****                    DO NOT EDIT DIRECTLY                      ****|
+ |****                                                              ****|
+ +======================================================================+
+ | TEMPLATE FILE: no-download-page-template.xml                         |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ |                                                                      |
+ | 1) Re-generate using: mvn commons:download-page                      |
+ |                                                                      |
+ | 2) Set the following properties in the component's pom:              |
+ |    - commons.componentid (required, alphabetic, lower case)          |
+ |    - commons.release.version (required)                              |
+ |    - commons.binary.suffix (optional)                                |
+ |      (defaults to "-bin", set to "" for pre-maven2 releases)         |
+ |                                                                      |
+ | 3) Example Properties                                                |
+ |                                                                      |
+ |  <properties>                                                        |
+ |    <commons.componentid>math</commons.componentid>                   |
+ |    <commons.release.version>1.2</commons.release.version>            |
+ |  </properties>                                                       |
+ |                                                                      |
+ +======================================================================+
+-->
+<document>
+  <properties>
+    <title>Download Commons Runtime (Sandbox)</title>
+    <author email="dev@commons.apache.org">Commons Documentation Team</author>
+  </properties>
+  <body>
+    <section name="Download Commons Runtime (Sandbox)">
+      <p>
+        There are currently no official releases of this component.
+      </p>
+    </section>
+    <section name="Sandbox Policy">
+      <p>
+        <strong>NOTE:</strong> For <i>Sandbox</i> components, releases are
+        NOT permitted. <i>Sandbox</i> components need to be promoted to
+        <i>proper</i> components before a release can be made.
+      </p>
+    </section>
+  </body>
+</document>

Propchange: commons/sandbox/runtime/trunk/src/site/xdoc/download_runtime.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message