You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/08/28 23:46:37 UTC

svn commit: r437854 [4/7] - in /incubator/harmony/enhanced/classlib/trunk/modules: accessibility/ accessibility/make/ accessibility/src/main/java/org/ accessibility/src/main/java/org/apache/ accessibility/src/main/java/org/apache/harmony/ accessibility...

Added: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java Mon Aug 28 14:46:26 2006
@@ -0,0 +1,241 @@
+/* Copyright 1998, 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.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten 
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.math.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ * <p>
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the <code>
+ *    org.apache.harmony.math.internal.nls.messages
+ * </code>
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the <em>KEY</em>
+ * should a reasonable human-readable (english) string.
+ * 
+ */
+public class Messages {
+
+    // ResourceBundle holding the system messages.
+    static private ResourceBundle bundle = null;
+
+    /**
+     * Retrieves a message which has no arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg) {
+        if (bundle == null)
+            return msg;
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            return "Missing message: " + msg; //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieves a message which takes 1 argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            Object the object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg) {
+        return getString(msg, new Object[] { arg });
+    }
+
+    /**
+     * Retrieves a message which takes 1 integer argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            int the integer to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, int arg) {
+        return getString(msg, new Object[] { Integer.toString(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 1 character argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            char the character to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, char arg) {
+        return getString(msg, new Object[] { String.valueOf(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 2 arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg1
+     *            Object an object to insert in the formatted output.
+     * @param arg2
+     *            Object another object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg1, Object arg2) {
+        return getString(msg, new Object[] { arg1, arg2 });
+    }
+
+    /**
+     * Retrieves a message which takes several arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param args
+     *            Object[] the objects to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object[] args) {
+        String format = msg;
+
+        if (bundle != null) {
+            try {
+                format = bundle.getString(msg);
+            } catch (MissingResourceException e) {
+            }
+        }
+
+        return format(format, args);
+    }
+    
+    /**
+     * Generates a formatted text string given a source string containing
+     * "argument markers" of the form "{argNum}" where each argNum must be in
+     * the range 0..9. The result is generated by inserting the toString of each
+     * argument into the position indicated in the string.
+     * <p>
+     * To insert the "{" character into the output, use a single backslash
+     * character to escape it (i.e. "\{"). The "}" character does not need to be
+     * escaped.
+     * 
+     * @param format
+     *            String the format to use when printing.
+     * @param args
+     *            Object[] the arguments to use.
+     * @return String the formatted message.
+     */
+    public static String format(String format, Object[] args) {
+        StringBuilder answer = new StringBuilder(format.length()
+                + (args.length * 20));
+        String[] argStrings = new String[args.length];
+        for (int i = 0; i < args.length; ++i) {
+            if (args[i] == null)
+                argStrings[i] = "<null>";	//$NON-NLS-1$
+            else
+                argStrings[i] = args[i].toString();
+        }
+        int lastI = 0;
+        for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+                lastI)) {
+            if (i != 0 && format.charAt(i - 1) == '\\') {
+                // It's escaped, just print and loop.
+                if (i != 1)
+                    answer.append(format.substring(lastI, i - 1));
+                answer.append('{');
+                lastI = i + 1;
+            } else {
+                // It's a format character.
+                if (i > format.length() - 3) {
+                    // Bad format, just print and loop.
+                    answer.append(format.substring(lastI, format.length()));
+                    lastI = format.length();
+                } else {
+                    int argnum = (byte) Character.digit(format.charAt(i + 1),
+                            10);
+                    if (argnum < 0 || format.charAt(i + 2) != '}') {
+                        // Bad format, just print and loop.
+						answer.append(format.substring(lastI, i + 1));
+						lastI = i + 1;
+                    } else {
+                        // Got a good one!
+                        answer.append(format.substring(lastI, i));
+                        if (argnum >= argStrings.length)
+                            answer.append("<missing argument>");	//$NON-NLS-1$
+                        else
+                            answer.append(argStrings[argnum]);
+						lastI = i + 3;
+                    }
+                }
+            }
+        }
+        if (lastI < format.length())
+            answer.append(format.substring(lastI, format.length()));
+        return answer.toString();
+    }
+
+    /**
+     * Changes the locale of the messages.
+     * 
+     * @param locale
+     *            Locale the locale to change to.
+     */
+    static public ResourceBundle setLocale(final Locale locale,
+            final String resource) {
+        try {
+            final ClassLoader loader = VM.bootCallerClassLoader();
+            return (ResourceBundle) AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            return ResourceBundle.getBundle(resource, locale,
+                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
+                        }
+                    });
+        } catch (MissingResourceException e) {
+        }
+        return null;
+    }
+
+    static {
+        // Attempt to load the messages.
+        try {
+            bundle = setLocale(Locale.getDefault(),
+                    "org.apache.harmony.math.internal.nls.messages"); //$NON-NLS-1$
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties Mon Aug 28 14:46:26 2006
@@ -0,0 +1,16 @@
+# Copyright 1998, 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.
+# 
+
+# messages for EN locale

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/misc/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/misc/build.xml?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/misc/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/misc/build.xml Mon Aug 28 14:46:26 2006
@@ -1,165 +1,174 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    Copyright 2005, 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.
--->
-
-<project name="MISC Build" default="build" basedir=".">
-    <description>Build for MISC component</description>
-
-    <!-- import common properties -->
-    <import file="${basedir}/../../make/properties.xml" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <includesfile name="${hy.misc}/make/patternset.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
-    </fileset>
-
-    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
-	     use the Eclipse Java compiler. -->
-    <property name="build.compiler" value="modern" />
-
-    <target name="build" depends="compile.java, build.jar" />
-
-    <target name="test" depends="build, compile.tests, run.tests" />
-
-    <target name="clean">
-        <delete failonerror="false">
-            <fileset refid="classes" />
-            <fileset dir="${hy.misc.bin.test}" />
-        </delete>
-    </target>
-
-    <target name="compile.java">
-        <echo message="Compiling MISC classes" />
-
-        <mkdir dir="${hy.build}" />
-
-        <javac sourcepath=""
-               srcdir="${hy.misc.src.main.java}"
-               destdir="${hy.build}"
-               source="${hy.javac.source}"
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-        </javac>
-    </target>
-
-    <target name="build.jar" depends="svn-info">
-        <jar destfile="${hy.jdk}/jre/lib/boot/${hy.misc.packaging.jarname}.jar"
-             manifest="${hy.misc}/META-INF/MANIFEST.MF">
-            <fileset refid="classes" />
-            <manifest>
-                <attribute name="Implementation-Version" value="${svn.info}"/> 
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="build.native" >
-    	<make dir="${hy.misc.src.main.native}/accessors/${hy.os}" />
-
-	<!-- Copy the built shared libs over to the jre/bin dir -->
-	<copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-	    <fileset dir="${hy.misc.src.main.native}/accessors">
-                <patternset includes="*${shlib.suffix}*" />
-            </fileset>
-        </copy>
-    </target>
-	
-    <!-- Clean natives -->
-    <target name="clean.native">
-    	<make dir="${hy.misc.src.main.native}/accessors/${hy.os}"
-              target="clean" />
-    </target>
-
-    <target name="compile.tests">
-        <echo message="Compiling MISC tests" />
-
-        <mkdir dir="${hy.misc.bin.test}" />
-
-        <javac srcdir="${hy.misc.src.test.java}"
-               destdir="${hy.misc.bin.test}"
-               sourcepath=""
-               source="${hy.javac.source}"
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="../../build/tests" />
-        </javac>
-    </target>
-
-    <target name="run.tests">
-
-        <mkdir dir="${hy.tests.reports}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-               forkmode="once"
-               printsummary="withOutAndErr"
-               errorproperty="test.errors"
-               failureproperty="test.failures"
-               showoutput="on"
-               dir="${basedir}"
-               jvm="${test.jre.home}/bin/java">
-
-            <jvmarg value="-showversion"/>
-
-            <env key="JAVA_HOME" value="${test.jre.home}"/>
-
-            <classpath>
-                <pathelement path="${hy.misc.bin.test}"/>
-            </classpath>
-
-            <formatter type="xml" />
-
-            <test name="${test.case}" todir="${hy.tests.reports}"
-                 if="test.case" />
-
-            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
-                unless="test.case">
-
-                <fileset dir="${hy.misc.src.test.java}"/>
-            </batchtest>
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
-    </target>
-
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${hy.tests.reports}/test.failures"
-            append="true">misc${line.separator}</echo>
-    </target>
-
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${hy.tests.reports}/test.errors"
-            append="true">misc${line.separator}</echo>
-    </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2005, 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.
+-->
+
+<project name="MISC Build" default="build" basedir=".">
+    <description>Build for MISC component</description>
+
+    <!-- import common properties -->
+    <import file="${basedir}/../../make/properties.xml" />
+
+    <!-- set global properties for this build. -->
+    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+
+    <fileset id="classes" dir="${hy.build}">
+        <includesfile name="${hy.misc}/make/patternset.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
+    </fileset>
+
+    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
+         use the Eclipse Java compiler. -->
+    <property name="build.compiler" value="modern" />
+
+    <target name="build" depends="compile.java, copy.resources, build.jar" />
+
+    <target name="test" depends="build, compile.tests, run.tests" />
+
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset refid="classes" />
+            <fileset dir="${hy.misc.bin.test}" />
+        </delete>
+    </target>
+
+    <target name="compile.java">
+        <echo message="Compiling MISC classes" />
+
+        <mkdir dir="${hy.build}" />
+
+        <javac sourcepath=""
+               srcdir="${hy.misc.src.main.java}"
+               destdir="${hy.build}"
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+        </javac>
+    </target>
+
+    <target name="copy.resources">
+        <mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.misc.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="build.jar" depends="svn-info">
+        <jar destfile="${hy.jdk}/jre/lib/boot/${hy.misc.packaging.jarname}.jar"
+             manifest="${hy.misc}/META-INF/MANIFEST.MF">
+            <fileset refid="classes" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="build.native" >
+        <make dir="${hy.misc.src.main.native}/accessors/${hy.os}" />
+
+    <!-- Copy the built shared libs over to the jre/bin dir -->
+    <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+        <fileset dir="${hy.misc.src.main.native}/accessors">
+                <patternset includes="*${shlib.suffix}*" />
+            </fileset>
+        </copy>
+    </target>
+    
+    <!-- Clean natives -->
+    <target name="clean.native">
+        <make dir="${hy.misc.src.main.native}/accessors/${hy.os}"
+              target="clean" />
+    </target>
+
+    <target name="compile.tests">
+        <echo message="Compiling MISC tests" />
+
+        <mkdir dir="${hy.misc.bin.test}" />
+
+        <javac srcdir="${hy.misc.src.test.java}"
+               destdir="${hy.misc.bin.test}"
+               sourcepath=""
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+            <classpath location="../../build/tests" />
+        </javac>
+    </target>
+
+    <target name="run.tests">
+
+        <mkdir dir="${hy.tests.reports}" />
+
+        <property name="test.jre.home" value="${hy.jdk}/jre" />
+
+        <junit fork="yes"
+               forkmode="once"
+               printsummary="withOutAndErr"
+               errorproperty="test.errors"
+               failureproperty="test.failures"
+               showoutput="on"
+               dir="${basedir}"
+               jvm="${test.jre.home}/bin/java">
+
+            <jvmarg value="-showversion"/>
+
+            <env key="JAVA_HOME" value="${test.jre.home}"/>
+
+            <classpath>
+                <pathelement path="${hy.misc.bin.test}"/>
+            </classpath>
+
+            <formatter type="xml" />
+
+            <test name="${test.case}" todir="${hy.tests.reports}"
+                 if="test.case" />
+
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+                unless="test.case">
+
+                <fileset dir="${hy.misc.src.test.java}"/>
+            </batchtest>
+        </junit>
+        <antcall target="touch-failures-file" />
+        <antcall target="touch-errors-file" />
+    </target>
+
+    <target name="touch-failures-file" if="test.failures">
+        <echo file="${hy.tests.reports}/test.failures"
+            append="true">misc${line.separator}</echo>
+    </target>
+
+    <target name="touch-errors-file" if="test.errors">
+        <echo file="${hy.tests.reports}/test.errors"
+            append="true">misc${line.separator}</echo>
+    </target>
+
+</project>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/misc/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/misc/make/patternset.txt?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/misc/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/misc/make/patternset.txt Mon Aug 28 14:46:26 2006
@@ -14,3 +14,5 @@
 #
 org/apache/harmony/misc/*
 org/apache/harmony/misc/accessors/*
+
+org/apache/harmony/misc/internal/nls/*

Added: incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java Mon Aug 28 14:46:26 2006
@@ -0,0 +1,241 @@
+/* Copyright 1998, 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.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten 
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.misc.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ * <p>
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the <code>
+ *    org.apache.harmony.misc.internal.nls.messages
+ * </code>
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the <em>KEY</em>
+ * should a reasonable human-readable (english) string.
+ * 
+ */
+public class Messages {
+
+    // ResourceBundle holding the system messages.
+    static private ResourceBundle bundle = null;
+
+    /**
+     * Retrieves a message which has no arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg) {
+        if (bundle == null)
+            return msg;
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            return "Missing message: " + msg; //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieves a message which takes 1 argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            Object the object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg) {
+        return getString(msg, new Object[] { arg });
+    }
+
+    /**
+     * Retrieves a message which takes 1 integer argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            int the integer to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, int arg) {
+        return getString(msg, new Object[] { Integer.toString(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 1 character argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            char the character to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, char arg) {
+        return getString(msg, new Object[] { String.valueOf(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 2 arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg1
+     *            Object an object to insert in the formatted output.
+     * @param arg2
+     *            Object another object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg1, Object arg2) {
+        return getString(msg, new Object[] { arg1, arg2 });
+    }
+
+    /**
+     * Retrieves a message which takes several arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param args
+     *            Object[] the objects to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object[] args) {
+        String format = msg;
+
+        if (bundle != null) {
+            try {
+                format = bundle.getString(msg);
+            } catch (MissingResourceException e) {
+            }
+        }
+
+        return format(format, args);
+    }
+    
+    /**
+     * Generates a formatted text string given a source string containing
+     * "argument markers" of the form "{argNum}" where each argNum must be in
+     * the range 0..9. The result is generated by inserting the toString of each
+     * argument into the position indicated in the string.
+     * <p>
+     * To insert the "{" character into the output, use a single backslash
+     * character to escape it (i.e. "\{"). The "}" character does not need to be
+     * escaped.
+     * 
+     * @param format
+     *            String the format to use when printing.
+     * @param args
+     *            Object[] the arguments to use.
+     * @return String the formatted message.
+     */
+    public static String format(String format, Object[] args) {
+        StringBuilder answer = new StringBuilder(format.length()
+                + (args.length * 20));
+        String[] argStrings = new String[args.length];
+        for (int i = 0; i < args.length; ++i) {
+            if (args[i] == null)
+                argStrings[i] = "<null>";	//$NON-NLS-1$
+            else
+                argStrings[i] = args[i].toString();
+        }
+        int lastI = 0;
+        for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+                lastI)) {
+            if (i != 0 && format.charAt(i - 1) == '\\') {
+                // It's escaped, just print and loop.
+                if (i != 1)
+                    answer.append(format.substring(lastI, i - 1));
+                answer.append('{');
+                lastI = i + 1;
+            } else {
+                // It's a format character.
+                if (i > format.length() - 3) {
+                    // Bad format, just print and loop.
+                    answer.append(format.substring(lastI, format.length()));
+                    lastI = format.length();
+                } else {
+                    int argnum = (byte) Character.digit(format.charAt(i + 1),
+                            10);
+                    if (argnum < 0 || format.charAt(i + 2) != '}') {
+                        // Bad format, just print and loop.
+						answer.append(format.substring(lastI, i + 1));
+						lastI = i + 1;
+                    } else {
+                        // Got a good one!
+                        answer.append(format.substring(lastI, i));
+                        if (argnum >= argStrings.length)
+                            answer.append("<missing argument>");	//$NON-NLS-1$
+                        else
+                            answer.append(argStrings[argnum]);
+						lastI = i + 3;
+                    }
+                }
+            }
+        }
+        if (lastI < format.length())
+            answer.append(format.substring(lastI, format.length()));
+        return answer.toString();
+    }
+
+    /**
+     * Changes the locale of the messages.
+     * 
+     * @param locale
+     *            Locale the locale to change to.
+     */
+    static public ResourceBundle setLocale(final Locale locale,
+            final String resource) {
+        try {
+            final ClassLoader loader = VM.bootCallerClassLoader();
+            return (ResourceBundle) AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            return ResourceBundle.getBundle(resource, locale,
+                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
+                        }
+                    });
+        } catch (MissingResourceException e) {
+        }
+        return null;
+    }
+
+    static {
+        // Attempt to load the messages.
+        try {
+            bundle = setLocale(Locale.getDefault(),
+                    "org.apache.harmony.misc.internal.nls.messages"); //$NON-NLS-1$
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties Mon Aug 28 14:46:26 2006
@@ -0,0 +1,16 @@
+# Copyright 1998, 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.
+# 
+
+# messages for EN locale

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml Mon Aug 28 14:46:26 2006
@@ -17,168 +17,177 @@
 -->
 
 <project name="NIO Build" default="build" basedir=".">
-	<description>Build for NIO component</description>
+    <description>Build for NIO component</description>
 
-	<!-- import common properties -->
-	<import file="${basedir}/../../make/properties.xml" />
+    <!-- import common properties -->
+    <import file="${basedir}/../../make/properties.xml" />
 
-	<!-- set global properties for this build. -->
-	<xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+    <!-- set global properties for this build. -->
+    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
 
-	<fileset id="classes" dir="${hy.build}">
-		<includesfile name="${hy.nio}/make/patternset.txt" />
-		<excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
-		<excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
-	</fileset>
-
-	<!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
-	     use the Eclipse Java compiler. -->
-	<property name="build.compiler" value="modern" />
+    <fileset id="classes" dir="${hy.build}">
+        <includesfile name="${hy.nio}/make/patternset.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
+    </fileset>
+
+    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
+         use the Eclipse Java compiler. -->
+    <property name="build.compiler" value="modern" />
 
         <property name="hy.nio.src.test.java.platform"
                   value="${hy.nio.src.test.java}/../${hy.os}" />
 
-	<target name="build" depends="compile.java, build.jar" />
+    <target name="build" depends="compile.java, copy.resources, build.jar" />
 
-	<target name="test" depends="build, compile.tests, run.tests" />
+    <target name="test" depends="build, compile.tests, run.tests" />
 
-	<!-- Build natives.-->
-	<target name="build.native">
-		<make dir="${hy.nio.src.main.native}/nio/${hy.os}" />
-
-		<!-- Copy the built shared libs over to the jre/bin dir -->
-		<copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-			<fileset dir="${hy.nio.src.main.native}/nio">
-				<patternset includes="*${shlib.suffix}*" />
-			</fileset>
-		</copy>
-	</target>
-
-	<target name="clean">
-		<delete includeemptydirs="true" failonerror="false">
-			<fileset refid="classes" />
-			<fileset dir="${hy.nio.bin.test}" />
-		</delete>
-	</target>
-
-	<!-- Clean natives. -->
-	<target name="clean.native">
-		<make dir="${hy.nio.src.main.native}/nio/${hy.os}"
+    <!-- Build natives.-->
+    <target name="build.native">
+        <make dir="${hy.nio.src.main.native}/nio/${hy.os}" />
+
+        <!-- Copy the built shared libs over to the jre/bin dir -->
+        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+            <fileset dir="${hy.nio.src.main.native}/nio">
+                <patternset includes="*${shlib.suffix}*" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="clean">
+        <delete includeemptydirs="true" failonerror="false">
+            <fileset refid="classes" />
+            <fileset dir="${hy.nio.bin.test}" />
+        </delete>
+    </target>
+
+    <!-- Clean natives. -->
+    <target name="clean.native">
+        <make dir="${hy.nio.src.main.native}/nio/${hy.os}"
                       target="clean" />
-	</target>
+    </target>
 
 
-	<target name="compile.java">
-		<echo message="Compiling NIO classes" />
+    <target name="compile.java">
+        <echo message="Compiling NIO classes" />
 
-		<mkdir dir="${hy.build}" />
+        <mkdir dir="${hy.build}" />
 
-		<javac sourcepath=""
-			srcdir="${hy.nio.src.main.java}"
-			destdir="${hy.build}"
-			source="${hy.javac.source}"
-			target="${hy.javac.target}"
-			debug="${hy.javac.debug}">
-
-			<bootclasspath>
-				<fileset dir="${hy.jdk}/jre/lib/boot">
-					<include name="**/*.jar" />
-				</fileset>
-			</bootclasspath>
-		</javac>
-	</target>
-
-	<target name="build.jar" depends="svn-info">
-		<jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
-			manifest="${hy.nio}/META-INF/MANIFEST.MF">
+        <javac sourcepath=""
+            srcdir="${hy.nio.src.main.java}"
+            destdir="${hy.build}"
+            source="${hy.javac.source}"
+            target="${hy.javac.target}"
+            debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+        </javac>
+    </target>
+
+    <target name="copy.resources">
+        <mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.nio.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="build.jar" depends="svn-info">
+        <jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
+            manifest="${hy.nio}/META-INF/MANIFEST.MF">
 
-			<fileset refid="classes" />
+            <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 
             </manifest>
-		</jar>
-	</target>
+        </jar>
+    </target>
 
-	<target name="compile.tests" depends="copy.test.resources">
-		<echo message="Compiling NIO tests" />
+    <target name="compile.tests" depends="copy.test.resources">
+        <echo message="Compiling NIO tests" />
 
-		<mkdir dir="${hy.nio.bin.test}" />
+        <mkdir dir="${hy.nio.bin.test}" />
 
-		<javac destdir="${hy.nio.bin.test}"
-		       sourcepath=""
-		       source="${hy.javac.source}"
-		       target="${hy.javac.target}"
-		       debug="${hy.javac.debug}">
+        <javac destdir="${hy.nio.bin.test}"
+               sourcepath=""
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
 
                     <src>
                         <pathelement location="${hy.nio.src.test.java}"/>
                         <pathelement
                              location="${hy.nio.src.test.java.platform}"/>
                     </src>
-		    <bootclasspath>
-			<fileset dir="${hy.jdk}/jre/lib/boot">
-			    <include name="**/*.jar" />
-			</fileset>
-		    </bootclasspath>
-		    <classpath location="${hy.hdk}/build/test/support.jar" />
-		</javac>
-	</target>
-
-	<target name="run.tests">
-		<mkdir dir="${hy.tests.reports}" />
-
-		<property name="test.jre.home" value="${hy.jdk}/jre" />
-
-		<junit fork="yes"
-			forkmode="once"
-			printsummary="withOutAndErr"
-			errorproperty="test.errors"
-			failureproperty="test.failures"
-			showoutput="on"
-			dir="${basedir}"
-			jvm="${test.jre.home}/bin/java">
-
-			<jvmarg value="-showversion" />
-
-			<env key="JAVA_HOME" value="${test.jre.home}" />
-
-			<classpath>
-				<pathelement path="${hy.nio.bin.test}" />
-				<pathelement path="${hy.hdk}/build/test/support.jar" />
-			</classpath>
-
-			<formatter type="xml" />
-
-			<test name="${test.case}" todir="${hy.tests.reports}" if="test.case" />
-
-			<batchtest todir="${hy.tests.reports}" haltonfailure="no" unless="test.case">
-				<fileset dir="${hy.nio.src.test.java}">
-					<include name="**/*Test.java" />
-				</fileset>
-				<fileset dir="${hy.nio.src.test.java.platform}">
-					<include name="**/*Test.java" />
-				</fileset>
-			</batchtest>
-		</junit>
-		<antcall target="touch-failures-file" />
-		<antcall target="touch-errors-file" />
-	</target>
-
-	<target name="touch-failures-file" if="test.failures">
-		<echo file="${hy.tests.reports}/test.failures" append="true">nio${line.separator}</echo>
-	</target>
-
-	<target name="touch-errors-file" if="test.errors">
-		<echo file="${hy.tests.reports}/test.errors" append="true">nio${line.separator}</echo>
-	</target>
-
-	<target name="copy.test.resources">
-		<mkdir dir="${hy.nio.bin.test}" />
-		<copy todir="${hy.nio.bin.test}" includeemptydirs="false">
-			<fileset dir="${hy.nio.src.test.resources}">
-				<exclude name="**/*.java" />
-			</fileset>
-		</copy>
-	</target>
+            <bootclasspath>
+            <fileset dir="${hy.jdk}/jre/lib/boot">
+                <include name="**/*.jar" />
+            </fileset>
+            </bootclasspath>
+            <classpath location="${hy.hdk}/build/test/support.jar" />
+        </javac>
+    </target>
+
+    <target name="run.tests">
+        <mkdir dir="${hy.tests.reports}" />
+
+        <property name="test.jre.home" value="${hy.jdk}/jre" />
+
+        <junit fork="yes"
+            forkmode="once"
+            printsummary="withOutAndErr"
+            errorproperty="test.errors"
+            failureproperty="test.failures"
+            showoutput="on"
+            dir="${basedir}"
+            jvm="${test.jre.home}/bin/java">
+
+            <jvmarg value="-showversion" />
+
+            <env key="JAVA_HOME" value="${test.jre.home}" />
+
+            <classpath>
+                <pathelement path="${hy.nio.bin.test}" />
+                <pathelement path="${hy.hdk}/build/test/support.jar" />
+            </classpath>
+
+            <formatter type="xml" />
+
+            <test name="${test.case}" todir="${hy.tests.reports}" if="test.case" />
+
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no" unless="test.case">
+                <fileset dir="${hy.nio.src.test.java}">
+                    <include name="**/*Test.java" />
+                </fileset>
+                <fileset dir="${hy.nio.src.test.java.platform}">
+                    <include name="**/*Test.java" />
+                </fileset>
+            </batchtest>
+        </junit>
+        <antcall target="touch-failures-file" />
+        <antcall target="touch-errors-file" />
+    </target>
+
+    <target name="touch-failures-file" if="test.failures">
+        <echo file="${hy.tests.reports}/test.failures" append="true">nio${line.separator}</echo>
+    </target>
+
+    <target name="touch-errors-file" if="test.errors">
+        <echo file="${hy.tests.reports}/test.errors" append="true">nio${line.separator}</echo>
+    </target>
+
+    <target name="copy.test.resources">
+        <mkdir dir="${hy.nio.bin.test}" />
+        <copy todir="${hy.nio.bin.test}" includeemptydirs="false">
+            <fileset dir="${hy.nio.src.test.resources}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
 
 </project>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/make/patternset.txt?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/make/patternset.txt Mon Aug 28 14:46:26 2006
@@ -1,21 +1,22 @@
-# Copyright 2005 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.
-
-java/nio/*
-java/nio/channels/*
-java/nio/channels/spi/*
-
-org/apache/harmony/nio/*
-org/apache/harmony/nio/internal/*
-
+# Copyright 2005 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.
+
+java/nio/*
+java/nio/channels/*
+java/nio/channels/spi/*
+
+org/apache/harmony/nio/*
+org/apache/harmony/nio/internal/*
+
+org/apache/harmony/nio/internal/nls/*

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java Mon Aug 28 14:46:26 2006
@@ -0,0 +1,241 @@
+/* Copyright 1998, 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.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten 
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.nio.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ * <p>
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the <code>
+ *    org.apache.harmony.nio.internal.nls.messages
+ * </code>
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the <em>KEY</em>
+ * should a reasonable human-readable (english) string.
+ * 
+ */
+public class Messages {
+
+    // ResourceBundle holding the system messages.
+    static private ResourceBundle bundle = null;
+
+    /**
+     * Retrieves a message which has no arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg) {
+        if (bundle == null)
+            return msg;
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            return "Missing message: " + msg; //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieves a message which takes 1 argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            Object the object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg) {
+        return getString(msg, new Object[] { arg });
+    }
+
+    /**
+     * Retrieves a message which takes 1 integer argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            int the integer to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, int arg) {
+        return getString(msg, new Object[] { Integer.toString(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 1 character argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            char the character to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, char arg) {
+        return getString(msg, new Object[] { String.valueOf(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 2 arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg1
+     *            Object an object to insert in the formatted output.
+     * @param arg2
+     *            Object another object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg1, Object arg2) {
+        return getString(msg, new Object[] { arg1, arg2 });
+    }
+
+    /**
+     * Retrieves a message which takes several arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param args
+     *            Object[] the objects to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object[] args) {
+        String format = msg;
+
+        if (bundle != null) {
+            try {
+                format = bundle.getString(msg);
+            } catch (MissingResourceException e) {
+            }
+        }
+
+        return format(format, args);
+    }
+    
+    /**
+     * Generates a formatted text string given a source string containing
+     * "argument markers" of the form "{argNum}" where each argNum must be in
+     * the range 0..9. The result is generated by inserting the toString of each
+     * argument into the position indicated in the string.
+     * <p>
+     * To insert the "{" character into the output, use a single backslash
+     * character to escape it (i.e. "\{"). The "}" character does not need to be
+     * escaped.
+     * 
+     * @param format
+     *            String the format to use when printing.
+     * @param args
+     *            Object[] the arguments to use.
+     * @return String the formatted message.
+     */
+    public static String format(String format, Object[] args) {
+        StringBuilder answer = new StringBuilder(format.length()
+                + (args.length * 20));
+        String[] argStrings = new String[args.length];
+        for (int i = 0; i < args.length; ++i) {
+            if (args[i] == null)
+                argStrings[i] = "<null>";	//$NON-NLS-1$
+            else
+                argStrings[i] = args[i].toString();
+        }
+        int lastI = 0;
+        for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+                lastI)) {
+            if (i != 0 && format.charAt(i - 1) == '\\') {
+                // It's escaped, just print and loop.
+                if (i != 1)
+                    answer.append(format.substring(lastI, i - 1));
+                answer.append('{');
+                lastI = i + 1;
+            } else {
+                // It's a format character.
+                if (i > format.length() - 3) {
+                    // Bad format, just print and loop.
+                    answer.append(format.substring(lastI, format.length()));
+                    lastI = format.length();
+                } else {
+                    int argnum = (byte) Character.digit(format.charAt(i + 1),
+                            10);
+                    if (argnum < 0 || format.charAt(i + 2) != '}') {
+                        // Bad format, just print and loop.
+						answer.append(format.substring(lastI, i + 1));
+						lastI = i + 1;
+                    } else {
+                        // Got a good one!
+                        answer.append(format.substring(lastI, i));
+                        if (argnum >= argStrings.length)
+                            answer.append("<missing argument>");	//$NON-NLS-1$
+                        else
+                            answer.append(argStrings[argnum]);
+						lastI = i + 3;
+                    }
+                }
+            }
+        }
+        if (lastI < format.length())
+            answer.append(format.substring(lastI, format.length()));
+        return answer.toString();
+    }
+
+    /**
+     * Changes the locale of the messages.
+     * 
+     * @param locale
+     *            Locale the locale to change to.
+     */
+    static public ResourceBundle setLocale(final Locale locale,
+            final String resource) {
+        try {
+            final ClassLoader loader = VM.bootCallerClassLoader();
+            return (ResourceBundle) AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            return ResourceBundle.getBundle(resource, locale,
+                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
+                        }
+                    });
+        } catch (MissingResourceException e) {
+        }
+        return null;
+    }
+
+    static {
+        // Attempt to load the messages.
+        try {
+            bundle = setLocale(Locale.getDefault(),
+                    "org.apache.harmony.nio.internal.nls.messages"); //$NON-NLS-1$
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties Mon Aug 28 14:46:26 2006
@@ -0,0 +1,16 @@
+# Copyright 1998, 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.
+# 
+
+# messages for EN locale

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio_char/build.xml?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio_char/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio_char/build.xml Mon Aug 28 14:46:26 2006
@@ -32,10 +32,10 @@
     </fileset>
                                
     <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
-	     use the Eclipse Java compiler. -->
+         use the Eclipse Java compiler. -->
     <property name="build.compiler" value="modern" />
 
-    <target name="build" depends="compile.java, build.jar" />
+    <target name="build" depends="compile.java, copy.resources, build.jar" />
 
     <target name="test" depends="build, compile.tests, run.tests" />
 
@@ -64,6 +64,15 @@
                 </fileset>
             </bootclasspath>
         </javac>
+    </target>
+
+    <target name="copy.resources">
+        <mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.nio_char.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
     </target>
 
     <target name="build.jar" depends="svn-info">

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio_char/make/patternset.txt?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio_char/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio_char/make/patternset.txt Mon Aug 28 14:46:26 2006
@@ -1,16 +1,18 @@
-# Copyright 2005 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.
-
-java/nio/charset/*
-java/nio/charset/spi/*
\ No newline at end of file
+# Copyright 2005 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.
+
+java/nio/charset/*
+java/nio/charset/spi/*
+
+org/apache/harmony/niochar/internal/nls/*

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java Mon Aug 28 14:46:26 2006
@@ -0,0 +1,241 @@
+/* Copyright 1998, 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.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten 
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.niochar.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ * <p>
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the <code>
+ *    org.apache.harmony.niochar.internal.nls.messages
+ * </code>
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the <em>KEY</em>
+ * should a reasonable human-readable (english) string.
+ * 
+ */
+public class Messages {
+
+    // ResourceBundle holding the system messages.
+    static private ResourceBundle bundle = null;
+
+    /**
+     * Retrieves a message which has no arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg) {
+        if (bundle == null)
+            return msg;
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            return "Missing message: " + msg; //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieves a message which takes 1 argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            Object the object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg) {
+        return getString(msg, new Object[] { arg });
+    }
+
+    /**
+     * Retrieves a message which takes 1 integer argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            int the integer to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, int arg) {
+        return getString(msg, new Object[] { Integer.toString(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 1 character argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            char the character to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, char arg) {
+        return getString(msg, new Object[] { String.valueOf(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 2 arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg1
+     *            Object an object to insert in the formatted output.
+     * @param arg2
+     *            Object another object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg1, Object arg2) {
+        return getString(msg, new Object[] { arg1, arg2 });
+    }
+
+    /**
+     * Retrieves a message which takes several arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param args
+     *            Object[] the objects to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object[] args) {
+        String format = msg;
+
+        if (bundle != null) {
+            try {
+                format = bundle.getString(msg);
+            } catch (MissingResourceException e) {
+            }
+        }
+
+        return format(format, args);
+    }
+    
+    /**
+     * Generates a formatted text string given a source string containing
+     * "argument markers" of the form "{argNum}" where each argNum must be in
+     * the range 0..9. The result is generated by inserting the toString of each
+     * argument into the position indicated in the string.
+     * <p>
+     * To insert the "{" character into the output, use a single backslash
+     * character to escape it (i.e. "\{"). The "}" character does not need to be
+     * escaped.
+     * 
+     * @param format
+     *            String the format to use when printing.
+     * @param args
+     *            Object[] the arguments to use.
+     * @return String the formatted message.
+     */
+    public static String format(String format, Object[] args) {
+        StringBuilder answer = new StringBuilder(format.length()
+                + (args.length * 20));
+        String[] argStrings = new String[args.length];
+        for (int i = 0; i < args.length; ++i) {
+            if (args[i] == null)
+                argStrings[i] = "<null>";	//$NON-NLS-1$
+            else
+                argStrings[i] = args[i].toString();
+        }
+        int lastI = 0;
+        for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+                lastI)) {
+            if (i != 0 && format.charAt(i - 1) == '\\') {
+                // It's escaped, just print and loop.
+                if (i != 1)
+                    answer.append(format.substring(lastI, i - 1));
+                answer.append('{');
+                lastI = i + 1;
+            } else {
+                // It's a format character.
+                if (i > format.length() - 3) {
+                    // Bad format, just print and loop.
+                    answer.append(format.substring(lastI, format.length()));
+                    lastI = format.length();
+                } else {
+                    int argnum = (byte) Character.digit(format.charAt(i + 1),
+                            10);
+                    if (argnum < 0 || format.charAt(i + 2) != '}') {
+                        // Bad format, just print and loop.
+						answer.append(format.substring(lastI, i + 1));
+						lastI = i + 1;
+                    } else {
+                        // Got a good one!
+                        answer.append(format.substring(lastI, i));
+                        if (argnum >= argStrings.length)
+                            answer.append("<missing argument>");	//$NON-NLS-1$
+                        else
+                            answer.append(argStrings[argnum]);
+						lastI = i + 3;
+                    }
+                }
+            }
+        }
+        if (lastI < format.length())
+            answer.append(format.substring(lastI, format.length()));
+        return answer.toString();
+    }
+
+    /**
+     * Changes the locale of the messages.
+     * 
+     * @param locale
+     *            Locale the locale to change to.
+     */
+    static public ResourceBundle setLocale(final Locale locale,
+            final String resource) {
+        try {
+            final ClassLoader loader = VM.bootCallerClassLoader();
+            return (ResourceBundle) AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            return ResourceBundle.getBundle(resource, locale,
+                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
+                        }
+                    });
+        } catch (MissingResourceException e) {
+        }
+        return null;
+    }
+
+    static {
+        // Attempt to load the messages.
+        try {
+            bundle = setLocale(Locale.getDefault(),
+                    "org.apache.harmony.niochar.internal.nls.messages"); //$NON-NLS-1$
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties?rev=437854&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties Mon Aug 28 14:46:26 2006
@@ -0,0 +1,16 @@
+# Copyright 1998, 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.
+# 
+
+# messages for EN locale
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/build.xml?rev=437854&r1=437853&r2=437854&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/build.xml Mon Aug 28 14:46:26 2006
@@ -1,183 +1,192 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-
-<project name="PREFS Build" default="build" basedir=".">
-    <description>Build for PREFS component</description>
-
-    <!-- import common properties -->
-    <import file="${basedir}/../../make/properties.xml" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <includesfile name="${hy.prefs}/make/patternset.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
-    </fileset>
-                               
-    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
-	     use the Eclipse Java compiler. -->
-    <property name="build.compiler" value="modern" />
-
-    <target name="build" depends="compile.java, build.jar" />
-
-    <target name="test" depends="build, compile.tests, run.tests" />
-
-    <!-- Build natives. Currently there are only windows natives for
-	 prefs, so we check if we are on a windows platform -->
-    <target name="build.native" if="is.windows">
-	<make dir="${hy.prefs.src.main.native}/prefs/${hy.os}" />
-
-	<!-- Copy the built shared libs over to the jre/bin dir -->
-	<copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.prefs.src.main.native}/prefs">
-                <patternset includes="*${shlib.suffix}*" />
-            </fileset>
-        </copy>
-    </target>
-
-    <target name="clean">
-        <delete failonerror="false">
-            <fileset refid="classes" />
-            <fileset dir="${hy.prefs.bin.test}" />
-        </delete>
-    </target>
-
-    <!-- Clean natives. Currently there are only windows natives for
-	 prefs, so we check if we are on a windows platform -->
-    <target name="clean.native" if="is.windows">
-	<make dir="${hy.prefs.src.main.native}/prefs/${hy.os}" target="clean" />
-    </target>
-
-
-    <target name="compile.java">
-        <echo message="Compiling PREFS classes" />
-
-        <mkdir dir="${hy.build}" />
-
-        <javac sourcepath=""
-               srcdir="${hy.prefs.src.main.java}"
-               destdir="${hy.build}"
-               source="${hy.javac.source}"
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-        </javac>
-    </target>
-
-    <target name="build.jar" depends="svn-info">
-        <jar destfile="${hy.jdk}/jre/lib/boot/prefs.jar"
-             manifest="${hy.prefs}/META-INF/MANIFEST.MF">
-            <fileset refid="classes" />
-            <manifest>
-                <attribute name="Implementation-Version" value="${svn.info}"/> 
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="compile.tests" depends="copy.test.resources">
-        <echo message="Compiling PREFS tests" />
-
-        <mkdir dir="${hy.prefs.bin.test}" />
-
-        <javac srcdir="${hy.prefs.src.test.java}"
-               destdir="${hy.prefs.bin.test}"
-               sourcepath=""
-               source="${hy.javac.source}"
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="../../build/tests" />
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-        </javac>
-    </target>
-
-    <target name="run.tests">
-
-        <mkdir dir="${hy.tests.reports}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-            forkmode="once"
-            printsummary="withOutAndErr"
-            errorproperty="test.errors"
-            failureproperty="test.failures"
-            showoutput="on"
-            dir="${basedir}"
-            jvm="${test.jre.home}/bin/java">
-
-            <jvmarg value="-showversion"/>
-
-            <env key="JAVA_HOME" value="${test.jre.home}"/>
-
-            <classpath>
-                <pathelement path="${hy.prefs.bin.test}"/>
-            </classpath>
-            <classpath location="../../build/tests" />
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-
-            <formatter type="xml" />
-
-            <test name="${test.case}" todir="${hy.tests.reports}"
-                 if="test.case" />
-
-            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
-                unless="test.case">
-
-                <fileset dir="${hy.prefs.src.test.java}">
-                    <include name="**/*Test.java"/>
-                    <exclude name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java"/>
-                </fileset>
-            </batchtest>
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
-    </target>
-
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${hy.tests.reports}/test.failures"
-            append="true">prefs${line.separator}</echo>
-    </target>
-
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${hy.tests.reports}/test.errors"
-            append="true">prefs${line.separator}</echo>
-    </target>
-
-    <target name="copy.test.resources">
-        <mkdir dir="${hy.prefs.bin.test}" />
-        <copy todir="${hy.prefs.bin.test}" includeemptydirs="false">
-            <fileset dir="${hy.prefs.src.test.resources}">
-                <exclude name="**/*.java" />
-            </fileset>
-        </copy>
-    </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<project name="PREFS Build" default="build" basedir=".">
+    <description>Build for PREFS component</description>
+
+    <!-- import common properties -->
+    <import file="${basedir}/../../make/properties.xml" />
+
+    <!-- set global properties for this build. -->
+    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+
+    <fileset id="classes" dir="${hy.build}">
+        <includesfile name="${hy.prefs}/make/patternset.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
+    </fileset>
+                               
+    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
+         use the Eclipse Java compiler. -->
+    <property name="build.compiler" value="modern" />
+
+    <target name="build" depends="compile.java, copy.resources, build.jar" />
+
+    <target name="test" depends="build, compile.tests, run.tests" />
+
+    <!-- Build natives. Currently there are only windows natives for
+     prefs, so we check if we are on a windows platform -->
+    <target name="build.native" if="is.windows">
+    <make dir="${hy.prefs.src.main.native}/prefs/${hy.os}" />
+
+    <!-- Copy the built shared libs over to the jre/bin dir -->
+    <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+            <fileset dir="${hy.prefs.src.main.native}/prefs">
+                <patternset includes="*${shlib.suffix}*" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset refid="classes" />
+            <fileset dir="${hy.prefs.bin.test}" />
+        </delete>
+    </target>
+
+    <!-- Clean natives. Currently there are only windows natives for
+     prefs, so we check if we are on a windows platform -->
+    <target name="clean.native" if="is.windows">
+    <make dir="${hy.prefs.src.main.native}/prefs/${hy.os}" target="clean" />
+    </target>
+
+
+    <target name="compile.java">
+        <echo message="Compiling PREFS classes" />
+
+        <mkdir dir="${hy.build}" />
+
+        <javac sourcepath=""
+               srcdir="${hy.prefs.src.main.java}"
+               destdir="${hy.build}"
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+        </javac>
+    </target>
+
+    <target name="copy.resources">
+        <mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.prefs.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="build.jar" depends="svn-info">
+        <jar destfile="${hy.jdk}/jre/lib/boot/prefs.jar"
+             manifest="${hy.prefs}/META-INF/MANIFEST.MF">
+            <fileset refid="classes" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="compile.tests" depends="copy.test.resources">
+        <echo message="Compiling PREFS tests" />
+
+        <mkdir dir="${hy.prefs.bin.test}" />
+
+        <javac srcdir="${hy.prefs.src.test.java}"
+               destdir="${hy.prefs.bin.test}"
+               sourcepath=""
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+            <classpath location="../../build/tests" />
+            <classpath location="${hy.hdk}/build/test/support.jar" />
+        </javac>
+    </target>
+
+    <target name="run.tests">
+
+        <mkdir dir="${hy.tests.reports}" />
+
+        <property name="test.jre.home" value="${hy.jdk}/jre" />
+
+        <junit fork="yes"
+            forkmode="once"
+            printsummary="withOutAndErr"
+            errorproperty="test.errors"
+            failureproperty="test.failures"
+            showoutput="on"
+            dir="${basedir}"
+            jvm="${test.jre.home}/bin/java">
+
+            <jvmarg value="-showversion"/>
+
+            <env key="JAVA_HOME" value="${test.jre.home}"/>
+
+            <classpath>
+                <pathelement path="${hy.prefs.bin.test}"/>
+            </classpath>
+            <classpath location="../../build/tests" />
+            <classpath location="${hy.hdk}/build/test/support.jar" />
+
+            <formatter type="xml" />
+
+            <test name="${test.case}" todir="${hy.tests.reports}"
+                 if="test.case" />
+
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+                unless="test.case">
+
+                <fileset dir="${hy.prefs.src.test.java}">
+                    <include name="**/*Test.java"/>
+                    <exclude name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java"/>
+                </fileset>
+            </batchtest>
+        </junit>
+        <antcall target="touch-failures-file" />
+        <antcall target="touch-errors-file" />
+    </target>
+
+    <target name="touch-failures-file" if="test.failures">
+        <echo file="${hy.tests.reports}/test.failures"
+            append="true">prefs${line.separator}</echo>
+    </target>
+
+    <target name="touch-errors-file" if="test.errors">
+        <echo file="${hy.tests.reports}/test.errors"
+            append="true">prefs${line.separator}</echo>
+    </target>
+
+    <target name="copy.test.resources">
+        <mkdir dir="${hy.prefs.bin.test}" />
+        <copy todir="${hy.prefs.bin.test}" includeemptydirs="false">
+            <fileset dir="${hy.prefs.src.test.resources}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+</project>