Author: ebourg
Date: Fri Feb 15 07:54:36 2008
New Revision: 628093
URL: http://svn.apache.org/viewvc?rev=628093&view=rev
Log:
PropertyListConfiguration no longer requires commons-codec
Added:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
(with props)
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.java
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.jj
commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
commons/proper/configuration/branches/configuration2_experimental/xdocs/dependencies.xml
Added:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java?rev=628093&view=auto
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
(added)
+++
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
Fri Feb 15 07:54:36 2008
@@ -0,0 +1,108 @@
+/*
+ * 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.configuration2.plist;
+
+/**
+ * Hex encoder and decoder. This is a modified copy of the Hex class in
Commons Codec
+ *
+ * @since 1.1
+ * @author Apache Software Foundation
+ * @version $Id$
+ */
+class Hex {
+
+ /**
+ * Used to build output as Hex
+ */
+ private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+ /**
+ * Converts an array of characters representing hexidecimal values into an
+ * array of bytes of those same values. The returned array will be half the
+ * length of the passed array, as it takes two characters to represent any
+ * given byte. An exception is thrown if the passed char array has an odd
+ * number of elements.
+ *
+ * @param data An array of characters containing hexidecimal digits
+ * @return A byte array containing binary data decoded from
+ * the supplied char array.
+ * @throws Exception Thrown if an odd number or illegal of characters is
supplied
+ */
+ public static byte[] decodeHex(char[] data) throws Exception {
+
+ int len = data.length;
+
+ if ((len & 0x01) != 0) {
+ throw new Exception("Odd number of characters.");
+ }
+
+ byte[] out = new byte[len >> 1];
+
+ // two characters form the hex value.
+ for (int i = 0, j = 0; j < len; i++) {
+ int f = toDigit(data[j], j) << 4;
+ j++;
+ f = f | toDigit(data[j], j);
+ j++;
+ out[i] = (byte) (f & 0xFF);
+ }
+
+ return out;
+ }
+
+ /**
+ * Converts a hexadecimal character to an integer.
+ *
+ * @param ch A character to convert to an integer digit
+ * @param index The index of the character in the source
+ * @return An integer
+ * @throws Exception Thrown if ch is an illegal hex character
+ */
+ protected static int toDigit(char ch, int index) throws Exception {
+ int digit = Character.digit(ch, 16);
+ if (digit == -1) {
+ throw new Exception("Illegal hexadecimal charcter " + ch + " at
index " + index);
+ }
+ return digit;
+ }
+
+ /**
+ * Converts an array of bytes into an array of characters representing the
hexidecimal values of each byte in order.
+ * The returned array will be double the length of the passed array, as it
takes two characters to represent any
+ * given byte.
+ *
+ * @param data
+ * a byte[] to convert to Hex characters
+ * @return A char[] containing hexidecimal characters
+ */
+ public static char[] encodeHex(byte[] data) {
+
+ int l = data.length;
+
+ char[] out = new char[l << 1];
+
+ // two characters form the hex value.
+ for (int i = 0, j = 0; i < l; i++) {
+ out[j++] = DIGITS[(0xF0 & data[i]) >>> 4 ];
+ out[j++] = DIGITS[ 0x0F & data[i] ];
+ }
+
+ return out;
+ }
+}
+
Propchange:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/Hex.java
------------------------------------------------------------------------------
svn:keywords = Revision Id Date Author
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java?rev=628093&r1=628092&r2=628093&view=diff
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
(original)
+++
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
Fri Feb 15 07:54:36 2008
@@ -31,7 +31,6 @@
import java.util.Map;
import java.util.TimeZone;
-import org.apache.commons.codec.binary.Hex;
import org.apache.commons.configuration2.AbstractHierarchicalFileConfiguration;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.ConfigurationException;
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.java?rev=628093&r1=628092&r2=628093&view=diff
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.java
(original)
+++
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.java
Fri Feb 15 07:54:36 2008
@@ -9,7 +9,6 @@
import org.apache.commons.configuration2.HierarchicalConfiguration.Node;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.codec.binary.Hex;
/**
* JavaCC based parser for the PropertyList format.
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.jj
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.jj?rev=628093&r1=628092&r2=628093&view=diff
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.jj
(original)
+++
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListParser.jj
Fri Feb 15 07:54:36 2008
@@ -32,7 +32,6 @@
import org.apache.commons.configuration.HierarchicalConfiguration.Node;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.codec.binary.Hex;
/**
* JavaCC based parser for the PropertyList format.
Modified:
commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml?rev=628093&r1=628092&r2=628093&view=diff
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
(original)
+++
commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
Fri Feb 15 07:54:36 2008
@@ -25,6 +25,14 @@
<release version="2.0" date="in SVN" description="">
<action dev="oheger" type="update">
+ Commons Configuration now requires Java 5.
+ </action>
+ <action dev="oheger" type="update">
+ To avoid incompatibilities with older versions the package structure
+ has been changed. The main package is now
+ org.apache.commons.configuration2.
+ </action>
+ <action dev="oheger" type="update">
The dependency to commons-collections is no longer needed.
</action>
<action dev="ebourg" type="update">
@@ -33,13 +41,8 @@
bridging mechanism such as the one available for Log4J
(see
http://people.apache.org/~psmith/logging.apache.org/sandbox/jul-log4j-bridge/).
</action>
- <action dev="oheger" type="update">
- To avoid incompatibilities with older versions the package structure
- has been changed. The main package is now
- org.apache.commons.configuration2.
- </action>
- <action dev="oheger" type="update">
- Commons Configuration now requires Java 5.
+ <action dev="ebourg" type="update">
+ PropertyListConfiguration no longer requires commons-codec
</action>
<action dev="ebourg" type="update">
Calendar objects in PropertyListConfiguration are now saved with their
own time zone.
Modified:
commons/proper/configuration/branches/configuration2_experimental/xdocs/dependencies.xml
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/xdocs/dependencies.xml?rev=628093&r1=628092&r2=628093&view=diff
==============================================================================
---
commons/proper/configuration/branches/configuration2_experimental/xdocs/dependencies.xml
(original)
+++
commons/proper/configuration/branches/configuration2_experimental/xdocs/dependencies.xml
Fri Feb 15 07:54:36 2008
@@ -63,10 +63,6 @@
<td>commons-beanutils</td>
</tr>
<tr>
- <td>PropertyListConfiguration</td>
- <td>commons-codec</td>
- </tr>
- <tr>
<td>XMLPropertyListConfiguration</td>
<td>commons-codec</td>
</tr>