harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r422501 [1/2] - in /incubator/harmony/enhanced/classlib/trunk/modules/text: ./ src/main/java/java/text/ src/test/java/org/apache/harmony/text/tests/java/text/
Date Sun, 16 Jul 2006 19:10:15 GMT
Author: ndbeyer
Date: Sun Jul 16 12:10:14 2006
New Revision: 422501

URL: http://svn.apache.org/viewvc?rev=422501&view=rev
Log:
Cleanup source and add some tests; mark failing tests

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedString.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/build.xml?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/build.xml Sun Jul 16 12:10:14 2006
@@ -157,10 +157,12 @@
 
                 <fileset dir="${hy.text.src.test.java}">
                     <include name="**/*Test.java"/>
+                	<!--
                     <exclude name="org/apache/harmony/text/tests/java/text/CollationKeyTest.java"/>
                     <exclude name="org/apache/harmony/text/tests/java/text/CollatorTest.java"/>
                     <exclude name="org/apache/harmony/text/tests/java/text/DecimalFormatTest.java"/>
                     <exclude name="org/apache/harmony/text/tests/java/text/MessageFormatTest.java"/>
+                    -->
                 </fileset>
             </batchtest>
         </junit>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedString.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedString.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedString.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedString.java Sun Jul 16 12:10:14 2006
@@ -1,26 +1,29 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+/*
+ * 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
+ * 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
+ * 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.
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
  */
 
 package java.text;
 
-
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
@@ -32,470 +35,482 @@
  */
 public class AttributedString {
 
-	String text;
+    String text;
+
+    Map<AttributedCharacterIterator.Attribute, List<Range>> attributeMap;
+
+    static class Range {
+        int start;
+
+        int end;
+
+        Object value;
+
+        Range(int s, int e, Object v) {
+            start = s;
+            end = e;
+            value = v;
+        }
+    }
+
+    static class AttributedIterator implements AttributedCharacterIterator {
+
+        private int begin, end, offset;
+
+        private AttributedString attrString;
+
+        private HashSet<Attribute> attributesAllowed;
+
+        AttributedIterator(AttributedString attrString) {
+            this.attrString = attrString;
+            begin = 0;
+            end = attrString.text.length();
+            offset = 0;
+        }
+
+        AttributedIterator(AttributedString attrString,
+                AttributedCharacterIterator.Attribute[] attributes, int begin, int end) {
+            if (begin < 0 || end > attrString.text.length() || begin > end) {
+                throw new IllegalArgumentException();
+            }
+            this.begin = begin;
+            this.end = end;
+            offset = begin;
+            this.attrString = attrString;
+            if (attributes != null) {
+                HashSet<Attribute> set = new HashSet<Attribute>((attributes.length * 4 / 3) + 1);
+                for (int i = attributes.length; --i >= 0;) {
+                    set.add(attributes[i]);
+                }
+                attributesAllowed = set;
+            }
+        }
+
+        /**
+         * Answers a new StringCharacterIterator with the same source String,
+         * begin, end, and current index as this StringCharacterIterator.
+         * 
+         * @return a shallow copy of this StringCharacterIterator
+         * 
+         * @see java.lang.Cloneable
+         */
+        public Object clone() {
+            try {
+                AttributedIterator clone = (AttributedIterator) super.clone();
+                if (attributesAllowed != null) {
+                    clone.attributesAllowed = (HashSet<Attribute>) attributesAllowed.clone();
+                }
+                return clone;
+            } catch (CloneNotSupportedException e) {
+                return null;
+            }
+        }
+
+        /**
+         * Answers the character at the current index in the source String.
+         * 
+         * @return the current character, or DONE if the current index is past
+         *         the end
+         */
+        public char current() {
+            if (offset == end) {
+                return DONE;
+            }
+            return attrString.text.charAt(offset);
+        }
+
+        /**
+         * Sets the current position to the begin index and answers the
+         * character at the begin index.
+         * 
+         * @return the character at the begin index
+         */
+        public char first() {
+            if (begin == end) {
+                return DONE;
+            }
+            offset = begin;
+            return attrString.text.charAt(offset);
+        }
+
+        /**
+         * Answers the begin index in the source String.
+         * 
+         * @return the index of the first character to iterate
+         */
+        public int getBeginIndex() {
+            return begin;
+        }
+
+        /**
+         * Answers the end index in the source String.
+         * 
+         * @return the index one past the last character to iterate
+         */
+        public int getEndIndex() {
+            return end;
+        }
+
+        /**
+         * Answers the current index in the source String.
+         * 
+         * @return the current index
+         */
+        public int getIndex() {
+            return offset;
+        }
+
+        private boolean inRange(Range range) {
+            if (!(range.value instanceof Annotation)) {
+                return true;
+            }
+            return range.start >= begin && range.start < end && range.end > begin
+                    && range.end <= end;
+        }
+
+        private boolean inRange(List<Range> ranges) {
+            Iterator<Range> it = ranges.iterator();
+            while (it.hasNext()) {
+                Range range = it.next();
+                if (range.start >= begin && range.start < end) {
+                    return !(range.value instanceof Annotation)
+                            || (range.end > begin && range.end <= end);
+                } else if (range.end > begin && range.end <= end) {
+                    return !(range.value instanceof Annotation)
+                            || (range.start >= begin && range.start < end);
+                }
+            }
+            return false;
+        }
+
+        public Set<AttributedIterator.Attribute> getAllAttributeKeys() {
+            if (begin == 0 && end == attrString.text.length() && attributesAllowed == null) {
+                return attrString.attributeMap.keySet();
+            }
+
+            Set<AttributedIterator.Attribute> result = new HashSet<Attribute>(
+                    (attrString.attributeMap.size() * 4 / 3) + 1);
+            Iterator<Map.Entry<Attribute, List<Range>>> it = attrString.attributeMap.entrySet().iterator();
+            while (it.hasNext()) {
+                Map.Entry<Attribute, List<Range>> entry = it.next();
+                if (attributesAllowed == null || attributesAllowed.contains(entry.getKey())) {
+                    List<Range> ranges = entry.getValue();
+                    if (inRange(ranges)) {
+                        result.add(entry.getKey());
+                    }
+                }
+            }
+            return result;
+        }
+
+        private Object currentValue(List<Range> ranges) {
+            Iterator<Range> it = ranges.iterator();
+            while (it.hasNext()) {
+                Range range = it.next();
+                if (offset >= range.start && offset < range.end) {
+                    return inRange(range) ? range.value : null;
+                }
+            }
+            return null;
+        }
+
+        public Object getAttribute(AttributedCharacterIterator.Attribute attribute) {
+            if (attributesAllowed != null && !attributesAllowed.contains(attribute)) {
+                return null;
+            }
+            ArrayList<Range> ranges = (ArrayList<Range>) attrString.attributeMap.get(attribute);
+            if (ranges == null) {
+                return null;
+            }
+            return currentValue(ranges);
+        }
 
-	Map<AttributedCharacterIterator.Attribute, ArrayList> attributeMap;
+        public Map<Attribute, Object> getAttributes() {
+            Map<Attribute, Object> result = new HashMap<Attribute, Object>(
+                    (attrString.attributeMap.size() * 4 / 3) + 1);
+            Iterator<Map.Entry<Attribute, List<Range>>> it = attrString.attributeMap.entrySet()
+                    .iterator();
+            while (it.hasNext()) {
+                Map.Entry<Attribute, List<Range>> entry = it.next();
+                if (attributesAllowed == null || attributesAllowed.contains(entry.getKey())) {
+                    Object value = currentValue(entry.getValue());
+                    if (value != null) {
+                        result.put(entry.getKey(), value);
+                    }
+                }
+            }
+            return result;
+        }
 
-	static class Range {
-		int start, end;
+        public int getRunLimit() {
+            return getRunLimit(getAllAttributeKeys());
+        }
 
-		Object value;
+        private int runLimit(List<Range> ranges) {
+            int result = end;
+            ListIterator<Range> it = ranges.listIterator(ranges.size());
+            while (it.hasPrevious()) {
+                Range range = it.previous();
+                if (range.end <= begin) {
+                    break;
+                }
+                if (offset >= range.start && offset < range.end) {
+                    return inRange(range) ? range.end : result;
+                } else if (offset >= range.end) {
+                    break;
+                }
+                result = range.start;
+            }
+            return result;
+        }
 
-		Range(int s, int e, Object v) {
-			start = s;
-			end = e;
-			value = v;
-		}
-	}
-
-	static class AttributedIterator implements AttributedCharacterIterator {
-
-		private int begin, end, offset;
-
-		private AttributedString attrString;
-
-		private HashSet attributesAllowed;
-
-		AttributedIterator(AttributedString attrString) {
-			this.attrString = attrString;
-			begin = 0;
-			end = attrString.text.length();
-			offset = 0;
-		}
-
-		AttributedIterator(AttributedString attrString,
-				AttributedCharacterIterator.Attribute[] attributes, int begin,
-				int end) {
-			if (begin < 0 || end > attrString.text.length() || begin > end)
-				throw new IllegalArgumentException();
-			this.begin = begin;
-			this.end = end;
-			offset = begin;
-			this.attrString = attrString;
-			if (attributes != null) {
-				HashSet set = new HashSet((attributes.length * 4 / 3) + 1);
-				for (int i = attributes.length; --i >= 0;)
-					set.add(attributes[i]);
-				attributesAllowed = set;
-			}
-		}
-
-		/**
-		 * Answers a new StringCharacterIterator with the same source String,
-		 * begin, end, and current index as this StringCharacterIterator.
-		 * 
-		 * @return a shallow copy of this StringCharacterIterator
-		 * 
-		 * @see java.lang.Cloneable
-		 */
-		public Object clone() {
-			try {
-				AttributedIterator clone = (AttributedIterator) super.clone();
-				if (attributesAllowed != null)
-					clone.attributesAllowed = (HashSet) attributesAllowed
-							.clone();
-				return clone;
-			} catch (CloneNotSupportedException e) {
-				return null;
-			}
-		}
-
-		/**
-		 * Answers the character at the current index in the source String.
-		 * 
-		 * @return the current character, or DONE if the current index is past
-		 *         the end
-		 */
-		public char current() {
-			if (offset == end)
-				return DONE;
-			return attrString.text.charAt(offset);
-		}
-
-		/**
-		 * Sets the current position to the begin index and answers the
-		 * character at the begin index.
-		 * 
-		 * @return the character at the begin index
-		 */
-		public char first() {
-			if (begin == end)
-				return DONE;
-			offset = begin;
-			return attrString.text.charAt(offset);
-		}
-
-		/**
-		 * Answers the begin index in the source String.
-		 * 
-		 * @return the index of the first character to iterate
-		 */
-		public int getBeginIndex() {
-			return begin;
-		}
-
-		/**
-		 * Answers the end index in the source String.
-		 * 
-		 * @return the index one past the last character to iterate
-		 */
-		public int getEndIndex() {
-			return end;
-		}
-
-		/**
-		 * Answers the current index in the source String.
-		 * 
-		 * @return the current index
-		 */
-		public int getIndex() {
-			return offset;
-		}
-
-		private boolean inRange(Range range) {
-			if (!(range.value instanceof Annotation))
-				return true;
-			return range.start >= begin && range.start < end
-					&& range.end > begin && range.end <= end;
-		}
-
-		private boolean inRange(ArrayList ranges) {
-			Iterator it = ranges.iterator();
-			while (it.hasNext()) {
-				Range range = (Range) it.next();
-				if (range.start >= begin && range.start < end) {
-					return !(range.value instanceof Annotation)
-							|| (range.end > begin && range.end <= end);
-				} else if (range.end > begin && range.end <= end) {
-					return !(range.value instanceof Annotation)
-							|| (range.start >= begin && range.start < end);
-				}
-			}
-			return false;
-		}
-
-		public Set<AttributedIterator.Attribute> getAllAttributeKeys() {
-			if (begin == 0 && end == attrString.text.length()
-					&& attributesAllowed == null)
-				return attrString.attributeMap.keySet();
-
-            Set<AttributedIterator.Attribute> result = new HashSet(
-					(attrString.attributeMap.size() * 4 / 3) + 1);
-			Iterator it = attrString.attributeMap.entrySet().iterator();
-			while (it.hasNext()) {
-				Map.Entry entry = (Map.Entry) it.next();
-				if (attributesAllowed == null
-						|| attributesAllowed.contains(entry.getKey())) {
-					ArrayList ranges = (ArrayList) entry.getValue();
-					if (inRange(ranges))
-						result.add((AttributedIterator.Attribute)entry.getKey());
-				}
-			}
-			return result;
-		}
-
-		private Object currentValue(ArrayList ranges) {
-			Iterator it = ranges.iterator();
-			while (it.hasNext()) {
-				Range range = (Range) it.next();
-				if (offset >= range.start && offset < range.end)
-					return inRange(range) ? range.value : null;
-			}
-			return null;
-		}
-
-		public Object getAttribute(
-				AttributedCharacterIterator.Attribute attribute) {
-			if (attributesAllowed != null
-					&& !attributesAllowed.contains(attribute))
-				return null;
-			ArrayList ranges = (ArrayList) attrString.attributeMap
-					.get(attribute);
-			if (ranges == null)
-				return null;
-			return currentValue(ranges);
-		}
-
-		public Map getAttributes() {
-			Map result = new HashMap(
-					(attrString.attributeMap.size() * 4 / 3) + 1);
-			Iterator it = attrString.attributeMap.entrySet().iterator();
-			while (it.hasNext()) {
-				Map.Entry entry = (Map.Entry) it.next();
-				if (attributesAllowed == null
-						|| attributesAllowed.contains(entry.getKey())) {
-					Object value = currentValue((ArrayList) entry.getValue());
-					if (value != null)
-						result.put(entry.getKey(), value);
-				}
-			}
-			return result;
-		}
-
-		public int getRunLimit() {
-			return getRunLimit(getAllAttributeKeys());
-		}
-
-		private int runLimit(ArrayList ranges) {
-			int result = end;
-			ListIterator it = ranges.listIterator(ranges.size());
-			while (it.hasPrevious()) {
-				Range range = (Range) it.previous();
-				if (range.end <= begin)
-					break;
-				if (offset >= range.start && offset < range.end) {
-					return inRange(range) ? range.end : result;
-				} else if (offset >= range.end)
-					break;
-				result = range.start;
-			}
-			return result;
-		}
-
-		public int getRunLimit(AttributedCharacterIterator.Attribute attribute) {
-			if (attributesAllowed != null
-					&& !attributesAllowed.contains(attribute))
-				return end;
-			ArrayList ranges = (ArrayList) attrString.attributeMap
-					.get(attribute);
-			if (ranges == null)
-				return end;
-			return runLimit(ranges);
-		}
-
-		public int getRunLimit(Set attributes) {
-			int limit = end;
-			Iterator it = attributes.iterator();
-			while (it.hasNext()) {
-				AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
-						.next();
-				int newLimit = getRunLimit(attribute);
-				if (newLimit < limit)
-					limit = newLimit;
-			}
-			return limit;
-		}
-
-		public int getRunStart() {
-			return getRunStart(getAllAttributeKeys());
-		}
-
-		private int runStart(ArrayList ranges) {
-			int result = begin;
-			Iterator it = ranges.iterator();
-			while (it.hasNext()) {
-				Range range = (Range) it.next();
-				if (range.start >= end)
-					break;
-				if (offset >= range.start && offset < range.end) {
-					return inRange(range) ? range.start : result;
-				} else if (offset < range.start)
-					break;
-				result = range.end;
-			}
-			return result;
-		}
-
-		public int getRunStart(AttributedCharacterIterator.Attribute attribute) {
-			if (attributesAllowed != null
-					&& !attributesAllowed.contains(attribute))
-				return begin;
-			ArrayList ranges = (ArrayList) attrString.attributeMap
-					.get(attribute);
-			if (ranges == null)
-				return begin;
-			return runStart(ranges);
-		}
-
-		public int getRunStart(Set attributes) {
-			int start = begin;
-			Iterator it = attributes.iterator();
-			while (it.hasNext()) {
-				AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
-						.next();
-				int newStart = getRunStart(attribute);
-				if (newStart > start)
-					start = newStart;
-			}
-			return start;
-		}
-
-		/**
-		 * Sets the current position to the end index - 1 and answers the
-		 * character at the current position.
-		 * 
-		 * @return the character before the end index
-		 */
-		public char last() {
-			if (begin == end)
-				return DONE;
-			offset = end - 1;
-			return attrString.text.charAt(offset);
-		}
-
-		/**
-		 * Increments the current index and returns the character at the new
-		 * index.
-		 * 
-		 * @return the character at the next index, or DONE if the next index is
-		 *         past the end
-		 */
-		public char next() {
-			if (offset >= (end - 1)) {
-				offset = end;
-				return DONE;
-			}
-			return attrString.text.charAt(++offset);
-		}
-
-		/**
-		 * Decrements the current index and returns the character at the new
-		 * index.
-		 * 
-		 * @return the character at the previous index, or DONE if the previous
-		 *         index is past the beginning
-		 */
-		public char previous() {
-			if (offset == begin)
-				return DONE;
-			return attrString.text.charAt(--offset);
-		}
-
-		/**
-		 * Sets the current index in the source String.
-		 * 
-		 * @return the character at the new index, or DONE if the index is past
-		 *         the end
-		 * 
-		 * @exception IllegalArgumentException
-		 *                when the new index is less than the begin index or
-		 *                greater than the end index
-		 */
-		public char setIndex(int location) {
-			if (location < begin || location > end)
-				throw new IllegalArgumentException();
-			offset = location;
-			if (offset == end)
-				return DONE;
-			return attrString.text.charAt(offset);
-		}
-	}
+        public int getRunLimit(AttributedCharacterIterator.Attribute attribute) {
+            if (attributesAllowed != null && !attributesAllowed.contains(attribute)) {
+                return end;
+            }
+            ArrayList<Range> ranges = (ArrayList<Range>) attrString.attributeMap.get(attribute);
+            if (ranges == null) {
+                return end;
+            }
+            return runLimit(ranges);
+        }
 
-	public AttributedString(AttributedCharacterIterator iterator) {
+        public int getRunLimit(Set<? extends Attribute> attributes) {
+            int limit = end;
+            Iterator<? extends Attribute> it = attributes.iterator();
+            while (it.hasNext()) {
+                AttributedCharacterIterator.Attribute attribute = it.next();
+                int newLimit = getRunLimit(attribute);
+                if (newLimit < limit) {
+                    limit = newLimit;
+                }
+            }
+            return limit;
+        }
+
+        public int getRunStart() {
+            return getRunStart(getAllAttributeKeys());
+        }
+
+        private int runStart(List<Range> ranges) {
+            int result = begin;
+            Iterator<Range> it = ranges.iterator();
+            while (it.hasNext()) {
+                Range range = it.next();
+                if (range.start >= end) {
+                    break;
+                }
+                if (offset >= range.start && offset < range.end) {
+                    return inRange(range) ? range.start : result;
+                } else if (offset < range.start) {
+                    break;
+                }
+                result = range.end;
+            }
+            return result;
+        }
+
+        public int getRunStart(AttributedCharacterIterator.Attribute attribute) {
+            if (attributesAllowed != null && !attributesAllowed.contains(attribute)) {
+                return begin;
+            }
+            ArrayList<Range> ranges = (ArrayList<Range>) attrString.attributeMap.get(attribute);
+            if (ranges == null) {
+                return begin;
+            }
+            return runStart(ranges);
+        }
+
+        public int getRunStart(Set<? extends Attribute> attributes) {
+            int start = begin;
+            Iterator<? extends Attribute> it = attributes.iterator();
+            while (it.hasNext()) {
+                AttributedCharacterIterator.Attribute attribute = it.next();
+                int newStart = getRunStart(attribute);
+                if (newStart > start) {
+                    start = newStart;
+                }
+            }
+            return start;
+        }
+
+        /**
+         * Sets the current position to the end index - 1 and answers the
+         * character at the current position.
+         * 
+         * @return the character before the end index
+         */
+        public char last() {
+            if (begin == end) {
+                return DONE;
+            }
+            offset = end - 1;
+            return attrString.text.charAt(offset);
+        }
+
+        /**
+         * Increments the current index and returns the character at the new
+         * index.
+         * 
+         * @return the character at the next index, or DONE if the next index is
+         *         past the end
+         */
+        public char next() {
+            if (offset >= (end - 1)) {
+                offset = end;
+                return DONE;
+            }
+            return attrString.text.charAt(++offset);
+        }
+
+        /**
+         * Decrements the current index and returns the character at the new
+         * index.
+         * 
+         * @return the character at the previous index, or DONE if the previous
+         *         index is past the beginning
+         */
+        public char previous() {
+            if (offset == begin) {
+                return DONE;
+            }
+            return attrString.text.charAt(--offset);
+        }
+
+        /**
+         * Sets the current index in the source String.
+         * 
+         * @return the character at the new index, or DONE if the index is past
+         *         the end
+         * 
+         * @exception IllegalArgumentException when the new index is less than
+         *            the begin index or greater than the end index
+         */
+        public char setIndex(int location) {
+            if (location < begin || location > end) {
+                throw new IllegalArgumentException();
+            }
+            offset = location;
+            if (offset == end) {
+                return DONE;
+            }
+            return attrString.text.charAt(offset);
+        }
+    }
+
+    public AttributedString(AttributedCharacterIterator iterator) {
         StringBuffer buffer = new StringBuffer();
         while (iterator.current() != CharacterIterator.DONE) {
             buffer.append(iterator.current());
             iterator.next();
         }
         text = buffer.toString();
-        Set<AttributedCharacterIterator.Attribute> attributes = iterator
-                .getAllAttributeKeys();
-        attributeMap = new HashMap((attributes.size() * 4 / 3) + 1);
+        Set<AttributedCharacterIterator.Attribute> attributes = iterator.getAllAttributeKeys();
+        attributeMap = new HashMap<Attribute, List<Range>>((attributes.size() * 4 / 3) + 1);
 
-        Iterator it = attributes.iterator();
+        Iterator<Attribute> it = attributes.iterator();
         while (it.hasNext()) {
-            AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
-                    .next();
+            AttributedCharacterIterator.Attribute attribute = it.next();
             iterator.setIndex(0);
             while (iterator.current() != CharacterIterator.DONE) {
                 int start = iterator.getRunStart(attribute);
                 int limit = iterator.getRunLimit(attribute);
                 Object value = iterator.getAttribute(attribute);
-                if (value != null)
+                if (value != null) {
                     addAttribute(attribute, value, start, limit);
+                }
                 iterator.setIndex(limit);
             }
         }
     }
 
-	private AttributedString(AttributedCharacterIterator iterator, int start,
-			int end, Set attributes) {
-		if (start < iterator.getBeginIndex() || end > iterator.getEndIndex()
-				|| start > end)
-			throw new IllegalArgumentException();
-
-		StringBuffer buffer = new StringBuffer();
-		iterator.setIndex(start);
-		while (iterator.getIndex() < end) {
-			buffer.append(iterator.current());
-			iterator.next();
-		}
-		text = buffer.toString();
-		attributeMap = new HashMap((attributes.size() * 4 / 3) + 1);
-
-		Iterator it = attributes.iterator();
-		while (it.hasNext()) {
-			AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
-					.next();
-			iterator.setIndex(start);
-			while (iterator.getIndex() < end) {
-				Object value = iterator.getAttribute(attribute);
-				int runStart = iterator.getRunStart(attribute);
-				int limit = iterator.getRunLimit(attribute);
-				if ((value instanceof Annotation && runStart >= start && limit <= end)
-						|| (value != null && !(value instanceof Annotation))) {
-					addAttribute(attribute, value, (runStart < start ? start
-							: runStart)
-							- start, (limit > end ? end : limit) - start);
-				}
-				iterator.setIndex(limit);
-			}
-		}
-	}
-
-	public AttributedString(AttributedCharacterIterator iterator, int start,
-			int end) {
-		this(iterator, start, end, iterator.getAllAttributeKeys());
-	}
-
-	public AttributedString(AttributedCharacterIterator iterator, int start,
-			int end, AttributedCharacterIterator.Attribute[] attributes) {
-		this(iterator, start, end, new HashSet(Arrays.asList(attributes)));
-	}
-
-	public AttributedString(String value) {
-		if (value == null)
-			throw new NullPointerException();
-		text = value;
-		attributeMap = new HashMap(11);
-	}
+    private AttributedString(AttributedCharacterIterator iterator, int start, int end,
+            Set<Attribute> attributes) {
+        if (start < iterator.getBeginIndex() || end > iterator.getEndIndex() || start > end) {
+            throw new IllegalArgumentException();
+        }
 
-	public AttributedString(String value,
+        StringBuffer buffer = new StringBuffer();
+        iterator.setIndex(start);
+        while (iterator.getIndex() < end) {
+            buffer.append(iterator.current());
+            iterator.next();
+        }
+        text = buffer.toString();
+        attributeMap = new HashMap<Attribute, List<Range>>((attributes.size() * 4 / 3) + 1);
+
+        Iterator<Attribute> it = attributes.iterator();
+        while (it.hasNext()) {
+            AttributedCharacterIterator.Attribute attribute = it.next();
+            iterator.setIndex(start);
+            while (iterator.getIndex() < end) {
+                Object value = iterator.getAttribute(attribute);
+                int runStart = iterator.getRunStart(attribute);
+                int limit = iterator.getRunLimit(attribute);
+                if ((value instanceof Annotation && runStart >= start && limit <= end)
+                        || (value != null && !(value instanceof Annotation))) {
+                    addAttribute(attribute, value, (runStart < start ? start : runStart)
+                            - start, (limit > end ? end : limit) - start);
+                }
+                iterator.setIndex(limit);
+            }
+        }
+    }
+
+    public AttributedString(AttributedCharacterIterator iterator, int start, int end) {
+        this(iterator, start, end, iterator.getAllAttributeKeys());
+    }
+
+    public AttributedString(AttributedCharacterIterator iterator, int start, int end,
+            AttributedCharacterIterator.Attribute[] attributes) {
+        this(iterator, start, end, new HashSet<Attribute>(Arrays.asList(attributes)));
+    }
+
+    public AttributedString(String value) {
+        if (value == null) {
+            throw new NullPointerException();
+        }
+        text = value;
+        attributeMap = new HashMap<Attribute, List<Range>>(11);
+    }
+
+    public AttributedString(String value,
             Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) {
-        if (value == null)
+        if (value == null) {
             throw new NullPointerException();
-        if (value.length() == 0 && !attributes.isEmpty())
+        }
+        if (value.length() == 0 && !attributes.isEmpty()) {
             throw new IllegalArgumentException(Msg.getString("K000e"));
+        }
         text = value;
-        attributeMap = new HashMap((attributes.size() * 4 / 3) + 1);
-        Iterator it = attributes.entrySet().iterator();
+        attributeMap = new HashMap<Attribute, List<Range>>((attributes.size() * 4 / 3) + 1);
+        Iterator<?> it = attributes.entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
+            Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
             ArrayList<Range> ranges = new ArrayList<Range>(1);
             ranges.add(new Range(0, text.length(), entry.getValue()));
-            attributeMap.put((AttributedCharacterIterator.Attribute) entry
-                    .getKey(), ranges);
+            attributeMap.put((AttributedCharacterIterator.Attribute) entry.getKey(), ranges);
         }
     }
 
-	public void addAttribute(AttributedCharacterIterator.Attribute attribute,
-			Object value) {
-		if (text.length() == 0)
-			throw new IllegalArgumentException();
-
-		ArrayList<Range> ranges = attributeMap.get(attribute);
-		if (ranges == null) {
-			ranges = new ArrayList<Range>(1);
-			attributeMap.put(attribute, ranges);
-		} else {
-			ranges.clear();
-		}
-		ranges.add(new Range(0, text.length(), value));
-	}
-
-	public void addAttribute(AttributedCharacterIterator.Attribute attribute,
-			Object value, int start, int end) {
-		if (start < 0 || end > text.length() || start >= end) {
+    public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value) {
+        if (text.length() == 0) {
+            throw new IllegalArgumentException();
+        }
+
+        List<Range> ranges = attributeMap.get(attribute);
+        if (ranges == null) {
+            ranges = new ArrayList<Range>(1);
+            attributeMap.put(attribute, ranges);
+        } else {
+            ranges.clear();
+        }
+        ranges.add(new Range(0, text.length(), value));
+    }
+
+    public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value,
+            int start, int end) {
+        if (start < 0 || end > text.length() || start >= end) {
             throw new IllegalArgumentException();
         }
 
@@ -503,98 +518,96 @@
             return;
         }
 
-        ArrayList<Range> ranges = attributeMap.get(attribute);
-		if (ranges == null) {
-			ranges = new ArrayList<Range>(1);
-			ranges.add(new Range(start, end, value));
-			attributeMap.put(attribute, ranges);
-			return;
-		}
-		ListIterator<Range> it = ranges.listIterator();
-		while (it.hasNext()) {
-			Range range = (Range) it.next();
-			if (end <= range.start) {
-				it.previous();
-				break;
-			} else if (start < range.end
-					|| (start == range.end && (value == null ? range.value == null
-							: value.equals(range.value)))) {
-				Range r1 = null, r3;
-				it.remove();
-				r1 = new Range(range.start, start, range.value);
-				r3 = new Range(end, range.end, range.value);
-
-				while (end > range.end && it.hasNext()) {
-					range = (Range) it.next();
-					if (end <= range.end) {
-						if (end > range.start
-								|| (end == range.start && (value == null ? range.value == null
-										: value.equals(range.value)))) {
-							it.remove();
-							r3 = new Range(end, range.end, range.value);
-							break;
-						}
-					} else
-						it.remove();
-				}
-
-				if (value == null ? r1.value == null : value.equals(r1.value)) {
-					if (value == null ? r3.value == null : value
-							.equals(r3.value)) {
-						it.add(new Range(r1.start < start ? r1.start : start,
-								r3.end > end ? r3.end : end, r1.value));
-					} else {
-						it.add(new Range(r1.start < start ? r1.start : start,
-								end, r1.value));
-						if (r3.start < r3.end)
-							it.add(r3);
-					}
-				} else {
-					if (value == null ? r3.value == null : value
-							.equals(r3.value)) {
-						if (r1.start < r1.end)
-							it.add(r1);
-						it.add(new Range(start, r3.end > end ? r3.end : end,
-								r3.value));
-					} else {
-						if (r1.start < r1.end)
-							it.add(r1);
-						it.add(new Range(start, end, value));
-						if (r3.start < r3.end)
-							it.add(r3);
-					}
-				}
-				return;
-			}
-		}
-		it.add(new Range(start, end, value));
-	}
+        List<Range> ranges = attributeMap.get(attribute);
+        if (ranges == null) {
+            ranges = new ArrayList<Range>(1);
+            ranges.add(new Range(start, end, value));
+            attributeMap.put(attribute, ranges);
+            return;
+        }
+        ListIterator<Range> it = ranges.listIterator();
+        while (it.hasNext()) {
+            Range range = it.next();
+            if (end <= range.start) {
+                it.previous();
+                break;
+            } else if (start < range.end
+                    || (start == range.end && (value == null ? range.value == null : value
+                            .equals(range.value)))) {
+                Range r1 = null, r3;
+                it.remove();
+                r1 = new Range(range.start, start, range.value);
+                r3 = new Range(end, range.end, range.value);
+
+                while (end > range.end && it.hasNext()) {
+                    range = it.next();
+                    if (end <= range.end) {
+                        if (end > range.start
+                                || (end == range.start && (value == null ? range.value == null
+                                        : value.equals(range.value)))) {
+                            it.remove();
+                            r3 = new Range(end, range.end, range.value);
+                            break;
+                        }
+                    } else {
+                        it.remove();
+                    }
+                }
+
+                if (value == null ? r1.value == null : value.equals(r1.value)) {
+                    if (value == null ? r3.value == null : value.equals(r3.value)) {
+                        it.add(new Range(r1.start < start ? r1.start : start,
+                                r3.end > end ? r3.end : end, r1.value));
+                    } else {
+                        it.add(new Range(r1.start < start ? r1.start : start, end, r1.value));
+                        if (r3.start < r3.end) {
+                            it.add(r3);
+                        }
+                    }
+                } else {
+                    if (value == null ? r3.value == null : value.equals(r3.value)) {
+                        if (r1.start < r1.end) {
+                            it.add(r1);
+                        }
+                        it.add(new Range(start, r3.end > end ? r3.end : end, r3.value));
+                    } else {
+                        if (r1.start < r1.end) {
+                            it.add(r1);
+                        }
+                        it.add(new Range(start, end, value));
+                        if (r3.start < r3.end) {
+                            it.add(r3);
+                        }
+                    }
+                }
+                return;
+            }
+        }
+        it.add(new Range(start, end, value));
+    }
 
-	public void addAttributes(
-            Map<? extends AttributedCharacterIterator.Attribute, ?> attributes,
-            int start, int end) {
-        Iterator it = attributes.entrySet().iterator();
+    public void addAttributes(
+            Map<? extends AttributedCharacterIterator.Attribute, ?> attributes, int start,
+            int end) {
+        Iterator<?> it = attributes.entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
-            addAttribute(
-                    (AttributedCharacterIterator.Attribute) entry.getKey(),
-                    entry.getValue(), start, end);
+            Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
+            addAttribute((AttributedCharacterIterator.Attribute) entry.getKey(), entry
+                    .getValue(), start, end);
         }
     }
 
-	public AttributedCharacterIterator getIterator() {
-		return new AttributedIterator(this);
-	}
-
-	public AttributedCharacterIterator getIterator(
-			AttributedCharacterIterator.Attribute[] attributes) {
-		return new AttributedIterator(this, attributes, 0, text.length());
-	}
-
-	public AttributedCharacterIterator getIterator(
-			AttributedCharacterIterator.Attribute[] attributes, int start,
-			int end) {
-		return new AttributedIterator(this, attributes, start, end);
-	}
+    public AttributedCharacterIterator getIterator() {
+        return new AttributedIterator(this);
+    }
+
+    public AttributedCharacterIterator getIterator(
+            AttributedCharacterIterator.Attribute[] attributes) {
+        return new AttributedIterator(this, attributes, 0, text.length());
+    }
 
+    public AttributedCharacterIterator getIterator(
+            AttributedCharacterIterator.Attribute[] attributes, int start, int end) {
+        return new AttributedIterator(this, attributes, start, end);
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java Sun Jul 16 12:10:14 2006
@@ -89,12 +89,13 @@
 	 * @see TextAttribute.RUN_DIRECTION
 	 */
 	public Bidi(AttributedCharacterIterator paragraph) {
-        if (paragraph == null)
+        if (paragraph == null) {
             throw new IllegalArgumentException("paragraph is null");
         /*
          * TODO: dependency on java.awt.font.TextAttribute and
          * java.awt.font.NumericShaper which is not implemented yet.
          */
+        }
     }
 
 	/**
@@ -106,7 +107,7 @@
 	 *            the start offset of the text array to perform the algorithm.
 	 * @param embeddings
 	 *            the embedding level array of the paragraph text, specifying
-	 *            the embedding level infomation for each character. Values
+	 *            the embedding level information for each character. Values
 	 *            between -1 and -62 denote overrides at the level's absolute
 	 *            value, values from 1 to 62 indicate embeddings, and the 0
 	 *            value indicates the level is calculated by the algorithm
@@ -415,7 +416,7 @@
 
 			int[] indices = BidiWrapper.ubidi_reorderVisual(realLevels, count);
 
-			LinkedList result = new LinkedList();
+			LinkedList<Object> result = new LinkedList<Object>();
 			for (int i = 0; i < count; i++) {
 				result.addLast(objects[objectStart + indices[i]]);
 			}
@@ -457,7 +458,7 @@
 	/**
 	 * Return the internal message of the Bidi object, used in debugging.
 	 * 
-	 * @return a string containing the internal messsage.
+	 * @return a string containing the internal message.
 	 */
 	public String toString() {
 		return super.toString() + "[direction: " + direction + " baselevel: " + baseLevel

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java Sun Jul 16 12:10:14 2006
@@ -16,11 +16,12 @@
 package java.text;
 
 
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Vector;
+import java.util.List;
 
 /**
- * ChoiceFormat is used to assocate strings with ranges of double values. The
+ * ChoiceFormat is used to associate strings with ranges of double values. The
  * strings and ranges are either specified using arrays or with a pattern which
  * is parsed to determine the Strings and ranges.
  */
@@ -76,7 +77,7 @@
 	 */
 	public void applyPattern(String template) {
 		double[] limits = new double[5];
-		Vector formats = new Vector();
+		List<String> formats = new ArrayList<String>();
 		int length = template.length(), limitCount = 0, index = 0;
 		StringBuffer buffer = new StringBuffer();
 		NumberFormat format = NumberFormat.getInstance();
@@ -84,15 +85,16 @@
 		while (true) {
 			index = skipWhitespace(template, index);
 			if (index >= length) {
-				if (limitCount == limits.length)
-					choiceLimits = limits;
-				else {
+				if (limitCount == limits.length) {
+                    choiceLimits = limits;
+                } else {
 					choiceLimits = new double[limitCount];
 					System.arraycopy(limits, 0, choiceLimits, 0, limitCount);
 				}
 				choiceFormats = new String[formats.size()];
-				for (int i = 0; i < formats.size(); i++)
-					choiceFormats[i] = (String) formats.elementAt(i);
+				for (int i = 0; i < formats.size(); i++) {
+                    choiceFormats[i] = formats.get(i);
+                }
 				return;
 			}
 
@@ -123,14 +125,15 @@
 			default:
 				throw new IllegalArgumentException();
 			}
-			if (limitCount > 0 && next <= limits[limitCount - 1])
-				throw new IllegalArgumentException();
+			if (limitCount > 0 && next <= limits[limitCount - 1]) {
+                throw new IllegalArgumentException();
+            }
 			buffer.setLength(0);
 			position.setIndex(index);
 			upTo(template, position, buffer, '|');
 			index = position.getIndex();
 			limits[limitCount++] = next;
-			formats.addElement(buffer.toString());
+			formats.add(buffer.toString());
 		}
 	}
 
@@ -144,8 +147,8 @@
 	 */
 	public Object clone() {
 		ChoiceFormat clone = (ChoiceFormat) super.clone();
-		clone.choiceLimits = (double[]) choiceLimits.clone();
-		clone.choiceFormats = (String[]) choiceFormats.clone();
+		clone.choiceLimits = choiceLimits.clone();
+		clone.choiceFormats = choiceFormats.clone();
 		return clone;
 	}
 
@@ -162,10 +165,12 @@
 	 * @see #hashCode
 	 */
 	public boolean equals(Object object) {
-		if (this == object)
-			return true;
-		if (!(object instanceof ChoiceFormat))
-			return false;
+		if (this == object) {
+            return true;
+        }
+		if (!(object instanceof ChoiceFormat)) {
+            return false;
+        }
 		ChoiceFormat choice = (ChoiceFormat) object;
 		return Arrays.equals(choiceLimits, choice.choiceLimits)
 				&& Arrays.equals(choiceFormats, choice.choiceFormats);
@@ -186,11 +191,14 @@
 	public StringBuffer format(double value, StringBuffer buffer,
 			FieldPosition field) {
 		if (Double.isNaN(value)
-				|| (choiceLimits.length > 1 && value < choiceLimits[1]))
-			return buffer.append(choiceFormats[0]);
-		for (int i = 2; i < choiceLimits.length; i++)
-			if (value >= choiceLimits[i - 1] && value < choiceLimits[i])
-				return buffer.append(choiceFormats[i - 1]);
+				|| (choiceLimits.length > 1 && value < choiceLimits[1])) {
+            return buffer.append(choiceFormats[0]);
+        }
+		for (int i = 2; i < choiceLimits.length; i++) {
+            if (value >= choiceLimits[i - 1] && value < choiceLimits[i]) {
+                return buffer.append(choiceFormats[i - 1]);
+            }
+        }
 		return buffer.append(choiceFormats[choiceFormats.length - 1]);
 	}
 
@@ -258,14 +266,16 @@
 	 * @return the next larger double value
 	 */
 	public static final double nextDouble(double value) {
-		if (value == Double.POSITIVE_INFINITY)
-			return value;
+		if (value == Double.POSITIVE_INFINITY) {
+            return value;
+        }
 		long bits;
 		// Handle -0.0
-		if (value == 0)
-			bits = 0;
-		else
-			bits = Double.doubleToLongBits(value);
+		if (value == 0) {
+            bits = 0;
+        } else {
+            bits = Double.doubleToLongBits(value);
+        }
 		return Double.longBitsToDouble(value < 0 ? bits - 1 : bits + 1);
 	}
 
@@ -320,14 +330,16 @@
 	 * @return the next smaller double value
 	 */
 	public static final double previousDouble(double value) {
-		if (value == Double.NEGATIVE_INFINITY)
-			return value;
+		if (value == Double.NEGATIVE_INFINITY) {
+            return value;
+        }
 		long bits;
 		// Handle 0.0
-		if (value == 0)
-			bits = 0x8000000000000000L;
-		else
-			bits = Double.doubleToLongBits(value);
+		if (value == 0) {
+            bits = 0x8000000000000000L;
+        } else {
+            bits = Double.doubleToLongBits(value);
+        }
 		return Double.longBitsToDouble(value <= 0 ? bits + 1 : bits - 1);
 	}
 
@@ -344,16 +356,18 @@
 	 *            range is at the same index as the string.
 	 */
 	public void setChoices(double[] limits, String[] formats) {
-		if (limits.length != formats.length)
-			throw new IllegalArgumentException();
+		if (limits.length != formats.length) {
+            throw new IllegalArgumentException();
+        }
 		choiceLimits = limits;
 		choiceFormats = formats;
 	}
 
 	private int skipWhitespace(String string, int index) {
 		int length = string.length();
-		while (index < length && Character.isWhitespace(string.charAt(index)))
-			index++;
+		while (index < length && Character.isWhitespace(string.charAt(index))) {
+            index++;
+        }
 		return index;
 	}
 
@@ -366,8 +380,9 @@
 	public String toPattern() {
 		StringBuffer buffer = new StringBuffer();
 		for (int i = 0; i < choiceLimits.length; i++) {
-            if (i != 0) //if appending another format add OR symbol first
+            if (i != 0) {
                 buffer.append('|');
+            }
 			String previous = String.valueOf(previousDouble(choiceLimits[i]));
 			String limit = String.valueOf(choiceLimits[i]);
 			if (previous.length() < limit.length()) {
@@ -378,11 +393,13 @@
 				buffer.append('#');
 			}
 			boolean quote = (choiceFormats[i].indexOf('|') != -1);
-			if (quote)
-				buffer.append('\'');
+			if (quote) {
+                buffer.append('\'');
+            }
 			buffer.append(choiceFormats[i]);
-			if (quote)
-				buffer.append('\'');
+			if (quote) {
+                buffer.append('\'');
+            }
 		}
 		return buffer.toString();
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java Sun Jul 16 12:10:14 2006
@@ -73,24 +73,25 @@
 
 	private static int CACHE_SIZE;
 
-	private static Vector cache = new Vector(CACHE_SIZE);
-
-	// Wrapper class of ICU4J Collator
-	com.ibm.icu.text.Collator icuColl;
-
 	static {
 		// CACHE_SIZE includes key and value, so needs to be double
-		String cacheSize = (String) AccessController
-				.doPrivileged(new PriviAction("collator.cache")); //$NON-NLS-1$
+		String cacheSize = AccessController.doPrivileged(new PriviAction<String>(
+                "collator.cache")); //$NON-NLS-1$
 		if (cacheSize != null) {
 			try {
 				CACHE_SIZE = Integer.parseInt(cacheSize);
 			} catch (NumberFormatException e) {
 				CACHE_SIZE = 6;
 			}
-		} else
-			CACHE_SIZE = 6;
-	}
+		} else {
+            CACHE_SIZE = 6;
+        }
+	}
+    
+    private static Vector<Collator> cache = new Vector<Collator>(CACHE_SIZE);
+    
+    // Wrapper class of ICU4J Collator
+    com.ibm.icu.text.Collator icuColl;
 
 	Collator(com.ibm.icu.text.Collator wrapper) {
 		this.icuColl = wrapper;
@@ -163,8 +164,9 @@
 	 * @see #hashCode
 	 */
 	public boolean equals(Object object) {
-		if (!(object instanceof Collator))
-			return false;
+		if (!(object instanceof Collator)) {
+            return false;
+        }
 		Collator collator = (Collator) object;
 		return this.icuColl == null ? collator.icuColl == null : this.icuColl
 				.equals(collator.icuColl);
@@ -196,7 +198,7 @@
 
 	/**
 	 * Answers a CollationKey for the specified String for this Collator with
-	 * the current decomposition rule and stength value.
+	 * the current decomposition rule and strength value.
 	 * 
 	 * @param string
 	 *            the collation key.
@@ -234,8 +236,9 @@
 	public static Collator getInstance(Locale locale) {
 		String key = locale.toString();
 		for (int i = cache.size() - 1; i >= 0; i -= 2) {
-			if (cache.elementAt(i).equals(key))
-				return (Collator) ((Collator) cache.elementAt(i - 1)).clone();
+			if (cache.elementAt(i).equals(key)) {
+                return (Collator) (cache.elementAt(i - 1)).clone();
+            }
 		}
 
 		return new RuleBasedCollator(com.ibm.icu.text.Collator

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java Sun Jul 16 12:10:14 2006
@@ -186,10 +186,12 @@
 	 * @see #hashCode
 	 */
 	public boolean equals(Object object) {
-		if (this == object)
-			return true;
-		if (!(object instanceof DateFormat))
-			return false;
+		if (this == object) {
+            return true;
+        }
+		if (!(object instanceof DateFormat)) {
+            return false;
+        }
 		DateFormat dateFormat = (DateFormat) object;
 		return numberFormat.equals(dateFormat.numberFormat)
 				&& calendar.getTimeZone().equals(
@@ -209,7 +211,7 @@
 	 * 
 	 * @param object
 	 *            the object to format, must be a Date or a Number. If the
-	 *            object is a Number, a Date is contructed using the
+	 *            object is a Number, a Date is constructed using the
 	 *            <code>longValue()</code> of the Number.
 	 * @param buffer
 	 *            the StringBuffer
@@ -222,11 +224,13 @@
 	 */
 	public final StringBuffer format(Object object, StringBuffer buffer,
 			FieldPosition field) {
-		if (object instanceof Date)
-			return format((Date) object, buffer, field);
-		if (object instanceof Number)
-			return format(new Date(((Number) object).longValue()), buffer,
+		if (object instanceof Date) {
+            return format((Date) object, buffer, field);
+        }
+		if (object instanceof Number) {
+            return format(new Date(((Number) object).longValue()), buffer,
 					field);
+        }
 		throw new IllegalArgumentException();
 	}
 
@@ -487,8 +491,9 @@
 	public Date parse(String string) throws ParseException {
 		ParsePosition position = new ParsePosition(0);
 		Date date = parse(string, position);
-		if (position.getErrorIndex() != -1 || position.getIndex() == 0)
-			throw new ParseException(null, position.getErrorIndex());
+		if (position.getErrorIndex() != -1 || position.getIndex() == 0) {
+            throw new ParseException(null, position.getErrorIndex());
+        }
 		return date;
 	}
 
@@ -575,7 +580,9 @@
 	 */
 	public static class Field extends Format.Field {
 
-		private static Hashtable table = new Hashtable();
+        private static final long serialVersionUID = 7441350119349544720L;
+        
+		private static Hashtable<Integer, Field> table = new Hashtable<Integer, Field>();
 
 		public final static Field ERA = new Field("era", Calendar.ERA);
 
@@ -622,7 +629,7 @@
 		public final static Field TIME_ZONE = new Field("time zone", -1);
 
 		/**
-		 * The Calender field that this Field represents.
+		 * The Calendar field that this Field represents.
 		 */
 		private int calendarField = -1;
 
@@ -634,8 +641,9 @@
 			super(fieldName);
 			this.calendarField = calendarField;
 			if (calendarField != -1
-					&& table.get(new Integer(calendarField)) == null)
-				table.put(new Integer(calendarField), this);
+					&& table.get(new Integer(calendarField)) == null) {
+                table.put(new Integer(calendarField), this);
+            }
 		}
 
 		/**
@@ -655,32 +663,37 @@
 		 * @return null if there is no Field for this calendar field
 		 */
 		public static Field ofCalendarField(int calendarField) {
-			if (calendarField < 0 || calendarField >= Calendar.FIELD_COUNT)
-				throw new IllegalArgumentException();
+			if (calendarField < 0 || calendarField >= Calendar.FIELD_COUNT) {
+                throw new IllegalArgumentException();
+            }
 
-			return (Field) table.get(new Integer(calendarField));
+			return table.get(new Integer(calendarField));
 		}
 
 		/**
-		 * serizalization method resolve instances to the constant
+		 * Serialization method resolve instances to the constant
 		 * DateFormat.Field values
 		 */
 		protected Object readResolve() throws InvalidObjectException {
 			if (calendarField != -1) {
 				try {
 					Field result = ofCalendarField(calendarField);
-					if (result != null && this.equals(result))
-						return result;
+					if (result != null && this.equals(result)) {
+                        return result;
+                    }
 				} catch (IllegalArgumentException e) {
 					throw new InvalidObjectException(Msg.getString("K000d"));
 				}
 			} else {
-				if (this.equals(TIME_ZONE))
-					return TIME_ZONE;
-				if (this.equals(HOUR1))
-					return HOUR1;
-				if (this.equals(HOUR_OF_DAY1))
-					return HOUR_OF_DAY1;
+				if (this.equals(TIME_ZONE)) {
+                    return TIME_ZONE;
+                }
+				if (this.equals(HOUR1)) {
+                    return HOUR1;
+                }
+				if (this.equals(HOUR_OF_DAY1)) {
+                    return HOUR_OF_DAY1;
+                }
 			}
 
 			throw new InvalidObjectException(Msg.getString("K000d"));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java Sun Jul 16 12:10:14 2006
@@ -55,21 +55,20 @@
 	}
 
 	static ResourceBundle getBundle(final Locale locale) {
-		return (ResourceBundle) AccessController
-				.doPrivileged(new PrivilegedAction() {
-					public Object run() {
-						return ResourceBundle.getBundle(
-								"org.apache.harmony.luni.internal.locale.Locale", locale);
-					}
-				});
-	}
+        return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
+            public ResourceBundle run() {
+                return ResourceBundle.getBundle(
+                        "org.apache.harmony.luni.internal.locale.Locale", locale);
+            }
+        });
+    }
 
 	String convertPattern(String template, String fromChars, String toChars,
 			boolean check) {
 		if (!check && fromChars.equals(toChars))
 			return template;
 		boolean quote = false;
-		StringBuffer output = new StringBuffer();
+		StringBuilder output = new StringBuilder();
 		int length = template.length();
 		for (int i = 0; i < length; i++) {
 			int index;
@@ -233,6 +232,8 @@
 	 */
 	public static class Field extends AttributedCharacterIterator.Attribute {
 
+        private static final long serialVersionUID = 276966692217360283L;
+        
 		/**
 		 * Constructs a new instance of Field with the given fieldName.
 		 */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java?rev=422501&r1=422500&r2=422501&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java Sun Jul 16 12:10:14 2006
@@ -94,20 +94,21 @@
 		int length = template.length();
 		StringBuffer buffer = new StringBuffer();
 		ParsePosition position = new ParsePosition(0);
-		Vector localStrings = new Vector();
+		Vector<String> localStrings = new Vector<String>();
 		int argCount = 0;
 		int[] args = new int[10];
 		int maxArg = -1;
-		Vector localFormats = new Vector();
+		Vector<Format> localFormats = new Vector<Format>();
 		while (position.getIndex() < length) {
 			if (Format.upTo(template, position, buffer, '{')) {
 				byte arg;
 				int offset = position.getIndex();
 				if (offset >= length
 						|| (arg = (byte) Character.digit(template
-								.charAt(offset++), 10)) == -1)
-					throw new IllegalArgumentException(Msg
+								.charAt(offset++), 10)) == -1) {
+                    throw new IllegalArgumentException(Msg
 							.getString("K001d"));
+                }
 				position.setIndex(offset);
 				localFormats.addElement(parseVariable(template, position));
 				if (argCount >= args.length) {
@@ -116,19 +117,22 @@
 					args = newArgs;
 				}
 				args[argCount++] = arg;
-				if (arg > maxArg)
-					maxArg = arg;
+				if (arg > maxArg) {
+                    maxArg = arg;
+                }
 			}
 			localStrings.addElement(buffer.toString());
 			buffer.setLength(0);
 		}
 		this.strings = new String[localStrings.size()];
-		for (int i = 0; i < localStrings.size(); i++)
-			this.strings[i] = (String) localStrings.elementAt(i);
+		for (int i = 0; i < localStrings.size(); i++) {
+            this.strings[i] = localStrings.elementAt(i);
+        }
 		argumentNumbers = args;
 		this.formats = new Format[argCount];
-		for (int i = 0; i < argCount; i++)
-			this.formats[i] = (Format) localFormats.elementAt(i);
+		for (int i = 0; i < argCount; i++) {
+            this.formats[i] = localFormats.elementAt(i);
+        }
 		maxOffset = argCount - 1;
 		maxArgumentIndex = maxArg;
 	}
@@ -145,8 +149,9 @@
 		MessageFormat clone = (MessageFormat) super.clone();
 		Format[] array = new Format[formats.length];
 		for (int i = formats.length; --i >= 0;) {
-			if (formats[i] != null)
-				array[i] = (Format) formats[i].clone();
+			if (formats[i] != null) {
+                array[i] = (Format) formats[i].clone();
+            }
 		}
 		clone.formats = array;
 		return clone;
@@ -165,18 +170,22 @@
 	 * @see #hashCode
 	 */
 	public boolean equals(Object object) {
-		if (this == object)
-			return true;
-		if (!(object instanceof MessageFormat))
-			return false;
+		if (this == object) {
+            return true;
+        }
+		if (!(object instanceof MessageFormat)) {
+            return false;
+        }
 		MessageFormat format = (MessageFormat) object;
-		if (maxOffset != format.maxOffset)
-			return false;
+		if (maxOffset != format.maxOffset) {
+            return false;
+        }
 		// Must use a loop since the lengths may be different due
 		// to serialization cross-loading
 		for (int i = 0; i <= maxOffset; i++) {
-			if (argumentNumbers[i] != format.argumentNumbers[i])
-				return false;
+			if (argumentNumbers[i] != format.argumentNumbers[i]) {
+                return false;
+            }
 		}
 		return locale.equals(format.locale)
 				&& Arrays.equals(strings, format.strings)
@@ -199,11 +208,12 @@
 	 *                by this Format
 	 */
 	public AttributedCharacterIterator formatToCharacterIterator(Object object) {
-		if (object == null)
-			throw new NullPointerException();
+		if (object == null) {
+            throw new NullPointerException();
+        }
 
 		StringBuffer buffer = new StringBuffer();
-		Vector fields = new Vector();
+		Vector<FieldContainer> fields = new Vector<FieldContainer>();
 
 		// format the message, and find fields
 		formatImpl((Object[]) object, buffer, new FieldPosition(0), fields);
@@ -213,7 +223,7 @@
 
 		// add MessageFormat field attributes and values to the AttributedString
 		for (int i = 0; i < fields.size(); i++) {
-			FieldContainer fc = (FieldContainer) fields.elementAt(i);
+			FieldContainer fc = fields.elementAt(i);
 			as.addAttribute(fc.attribute, fc.value, fc.start, fc.end);
 		}
 
@@ -227,7 +237,7 @@
 	 * <p>
 	 * If Field Attribute of the FieldPosition supplied is
 	 * MessageFormat.Field.ARGUMENT, then begin and end index of this
-	 * fieldposition is set to the location of the first occurance of a message
+	 * field position is set to the location of the first occurrence of a message
 	 * format argument. Otherwise the FieldPosition is ignored
 	 * <p>
 	 * 
@@ -246,15 +256,15 @@
 	}
 
 	private StringBuffer formatImpl(Object[] objects, StringBuffer buffer,
-			FieldPosition position, Vector fields) {
+			FieldPosition position, Vector<FieldContainer> fields) {
 		FieldPosition passedField = new FieldPosition(0);
 		for (int i = 0; i <= maxOffset; i++) {
 			buffer.append(strings[i]);
 			int begin = buffer.length();
 			Object arg;
-			if (objects != null && argumentNumbers[i] < objects.length)
-				arg = objects[argumentNumbers[i]];
-			else {
+			if (objects != null && argumentNumbers[i] < objects.length) {
+                arg = objects[argumentNumbers[i]];
+            } else {
 				buffer.append('{');
 				buffer.append(argumentNumbers[i]);
 				buffer.append('}');
@@ -264,11 +274,11 @@
 			}
 			Format format = formats[i];
 			if (format == null || arg == null) {
-				if (arg instanceof Number)
-					format = NumberFormat.getInstance();
-				else if (arg instanceof Date)
-					format = DateFormat.getInstance();
-				else {
+				if (arg instanceof Number) {
+                    format = NumberFormat.getInstance();
+                } else if (arg instanceof Date) {
+                    format = DateFormat.getInstance();
+                } else {
 					buffer.append(arg);
 					handleArgumentField(begin, buffer.length(),
 							argumentNumbers[i], position, fields);
@@ -290,8 +300,9 @@
 				handleformat(format, arg, begin, fields);
 			}
 		}
-		if (maxOffset + 1 < strings.length)
-			buffer.append(strings[maxOffset + 1]);
+		if (maxOffset + 1 < strings.length) {
+            buffer.append(strings[maxOffset + 1]);
+        }
 		return buffer;
 	}
 
@@ -308,11 +319,11 @@
 	 * @param fields
 	 */
 	private void handleArgumentField(int begin, int end, int argnumber,
-			FieldPosition position, Vector fields) {
-		if (fields != null)
-			fields.add(new FieldContainer(begin, end, Field.ARGUMENT,
+			FieldPosition position, Vector<FieldContainer> fields) {
+		if (fields != null) {
+            fields.add(new FieldContainer(begin, end, Field.ARGUMENT,
 					new Integer(argnumber)));
-		else {
+        } else {
 			if (position != null
 					&& position.getFieldAttribute() == Field.ARGUMENT
 					&& position.getEndIndex() == 0) {
@@ -357,7 +368,7 @@
 	 *            FieldContainer.
 	 */
 	private void handleformat(Format format, Object arg, int begin,
-			Vector fields) {
+			Vector<FieldContainer> fields) {
 		if (fields != null) {
 			AttributedCharacterIterator iterator = format
 					.formatToCharacterIterator(arg);
@@ -365,7 +376,7 @@
 				int start = iterator.getRunStart();
 				int end = iterator.getRunLimit();
 
-				Iterator it = iterator.getAttributes().keySet().iterator();
+				Iterator<?> it = iterator.getAttributes().keySet().iterator();
 				while (it.hasNext()) {
 					AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
 							.next();
@@ -420,7 +431,7 @@
 	 * @return an array of Format
 	 */
 	public Format[] getFormats() {
-		return (Format[]) formats.clone();
+		return formats.clone();
 	}
 
 	/**
@@ -447,8 +458,9 @@
 	 */
 	public void setFormatByArgumentIndex(int argIndex, Format format) {
 		for (int i = 0; i < maxOffset + 1; i++) {
-			if (argumentNumbers[i] == argIndex)
-				formats[i] = format;
+			if (argumentNumbers[i] == argIndex) {
+                formats[i] = format;
+            }
 		}
 	}
 
@@ -461,8 +473,9 @@
 	public void setFormatsByArgumentIndex(Format[] formats) {
 		for (int j = 0; j < formats.length; j++) {
 			for (int i = 0; i < maxOffset + 1; i++) {
-				if (argumentNumbers[i] == j)
-					this.formats[i] = formats[j];
+				if (argumentNumbers[i] == j) {
+                    this.formats[i] = formats[j];
+                }
 			}
 		}
 	}
@@ -488,11 +501,13 @@
 		int hashCode = 0;
 		for (int i = 0; i <= maxOffset; i++) {
 			hashCode += argumentNumbers[i] + strings[i].hashCode();
-			if (formats[i] != null)
-				hashCode += formats[i].hashCode();
+			if (formats[i] != null) {
+                hashCode += formats[i].hashCode();
+            }
 		}
-		if (maxOffset + 1 < strings.length)
-			hashCode += strings[maxOffset + 1].hashCode();
+		if (maxOffset + 1 < strings.length) {
+            hashCode += strings[maxOffset + 1].hashCode();
+        }
 		return hashCode + locale.hashCode();
 	}
 
@@ -510,8 +525,9 @@
 	public Object[] parse(String string) throws ParseException {
 		ParsePosition position = new ParsePosition(0);
 		Object[] result = parse(string, position);
-		if (position.getErrorIndex() != -1 || position.getIndex() == 0)
-			throw new ParseException(null, position.getErrorIndex());
+		if (position.getErrorIndex() != -1 || position.getIndex() == 0) {
+            throw new ParseException(null, position.getErrorIndex());
+        }
 		return result;
 	}
 
@@ -531,8 +547,9 @@
 	 *         if there is an error
 	 */
 	public Object[] parse(String string, ParsePosition position) {
-		if (string == null)
-			return new Object[0];
+		if (string == null) {
+            return new Object[0];
+        }
 		ParsePosition internalPos = new ParsePosition(0);
 		int offset = position.getIndex();
 		Object[] result = new Object[maxArgumentIndex + 1];
@@ -603,8 +620,9 @@
 	private int match(String string, ParsePosition position, boolean last,
 			String[] tokens) {
 		int length = string.length(), offset = position.getIndex(), token = -1;
-		while (offset < length && Character.isWhitespace(string.charAt(offset)))
-			offset++;
+		while (offset < length && Character.isWhitespace(string.charAt(offset))) {
+            offset++;
+        }
 		for (int i = tokens.length; --i >= 0;) {
 			if (string.regionMatches(true, offset, tokens[i], 0, tokens[i]
 					.length())) {
@@ -612,11 +630,13 @@
 				break;
 			}
 		}
-		if (token == -1)
-			return -1;
+		if (token == -1) {
+            return -1;
+        }
 		offset += tokens[token].length();
-		while (offset < length && Character.isWhitespace(string.charAt(offset)))
-			offset++;
+		while (offset < length && Character.isWhitespace(string.charAt(offset))) {
+            offset++;
+        }
 		char ch;
 		if (offset < length
 				&& ((ch = string.charAt(offset)) == '}' || (!last && ch == ','))) {
@@ -630,26 +650,30 @@
 		int length = string.length(), offset = position.getIndex();
 		char ch;
 		if (offset >= length
-				|| ((ch = string.charAt(offset++)) != '}' && ch != ','))
-			throw new IllegalArgumentException(Msg
+				|| ((ch = string.charAt(offset++)) != '}' && ch != ',')) {
+            throw new IllegalArgumentException(Msg
 					.getString("K001e"));
+        }
 		position.setIndex(offset);
-		if (ch == '}')
-			return null;
+		if (ch == '}') {
+            return null;
+        }
 		int type = match(string, position, false, new String[] { "time",
 				"date", "number", "choice" });
-		if (type == -1)
-			throw new IllegalArgumentException(Msg
+		if (type == -1) {
+            throw new IllegalArgumentException(Msg
 					.getString("K001f"));
+        }
 		StringBuffer buffer = new StringBuffer();
 		ch = string.charAt(position.getIndex() - 1);
 		switch (type) {
 		case 0: // time
 		case 1: // date
-			if (ch == '}')
-				return type == 1 ? DateFormat.getDateInstance(
+			if (ch == '}') {
+                return type == 1 ? DateFormat.getDateInstance(
 						DateFormat.DEFAULT, locale) : DateFormat
 						.getTimeInstance(DateFormat.DEFAULT, locale);
+            }
 			int dateStyle = match(string, position, true, new String[] {
 					"full", "long", "medium", "short" });
 			if (dateStyle == -1) {
@@ -673,8 +697,9 @@
 			return type == 1 ? DateFormat.getDateInstance(dateStyle, locale)
 					: DateFormat.getTimeInstance(dateStyle, locale);
 		case 2: // number
-			if (ch == '}')
-				return NumberFormat.getInstance();
+			if (ch == '}') {
+                return NumberFormat.getInstance();
+            }
 			int numberStyle = match(string, position, true, new String[] {
 					"currency", "percent", "integer" });
 			if (numberStyle == -1) {
@@ -719,10 +744,12 @@
 	 */
 	public void setFormats(Format[] formats) {
 		int min = this.formats.length;
-		if (formats.length < min)
-			min = formats.length;
-		for (int i=0; i<min; i++)
-			this.formats[i] = formats[i];
+		if (formats.length < min) {
+            min = formats.length;
+        }
+		for (int i=0; i<min; i++) {
+            this.formats[i] = formats[i];
+        }
 	}
 
 	/**
@@ -750,13 +777,13 @@
 		buffer.append(",number");
 		if (format.equals(NumberFormat.getNumberInstance(locale))) {
 			// Empty block
-		} else if (format.equals(NumberFormat.getIntegerInstance(locale)))
-			buffer.append(",integer");
-		else if (format.equals(NumberFormat.getCurrencyInstance(locale)))
-			buffer.append(",currency");
-		else if (format.equals(NumberFormat.getPercentInstance(locale)))
-			buffer.append(",percent");
-		else {
+		} else if (format.equals(NumberFormat.getIntegerInstance(locale))) {
+            buffer.append(",integer");
+        } else if (format.equals(NumberFormat.getCurrencyInstance(locale))) {
+            buffer.append(",currency");
+        } else if (format.equals(NumberFormat.getPercentInstance(locale))) {
+            buffer.append(",percent");
+        } else {
 			buffer.append(',');
 			return ((DecimalFormat) format).toPattern();
 		}
@@ -765,30 +792,30 @@
 
 	private String decodeSimpleDateFormat(StringBuffer buffer, Format format) {
 		if (format.equals(DateFormat
-				.getTimeInstance(DateFormat.DEFAULT, locale)))
-			buffer.append(",time");
-		else if (format.equals(DateFormat.getDateInstance(DateFormat.DEFAULT,
-				locale)))
-			buffer.append(",date");
-		else if (format.equals(DateFormat.getTimeInstance(DateFormat.SHORT,
-				locale)))
-			buffer.append(",time,short");
-		else if (format.equals(DateFormat.getDateInstance(DateFormat.SHORT,
-				locale)))
-			buffer.append(",date,short");
-		else if (format.equals(DateFormat.getTimeInstance(DateFormat.LONG,
-				locale)))
-			buffer.append(",time,long");
-		else if (format.equals(DateFormat.getDateInstance(DateFormat.LONG,
-				locale)))
-			buffer.append(",date,long");
-		else if (format.equals(DateFormat.getTimeInstance(DateFormat.FULL,
-				locale)))
-			buffer.append(",time,full");
-		else if (format.equals(DateFormat.getDateInstance(DateFormat.FULL,
-				locale)))
-			buffer.append(",date,full");
-		else {
+				.getTimeInstance(DateFormat.DEFAULT, locale))) {
+            buffer.append(",time");
+        } else if (format.equals(DateFormat.getDateInstance(DateFormat.DEFAULT,
+				locale))) {
+            buffer.append(",date");
+        } else if (format.equals(DateFormat.getTimeInstance(DateFormat.SHORT,
+				locale))) {
+            buffer.append(",time,short");
+        } else if (format.equals(DateFormat.getDateInstance(DateFormat.SHORT,
+				locale))) {
+            buffer.append(",date,short");
+        } else if (format.equals(DateFormat.getTimeInstance(DateFormat.LONG,
+				locale))) {
+            buffer.append(",time,long");
+        } else if (format.equals(DateFormat.getDateInstance(DateFormat.LONG,
+				locale))) {
+            buffer.append(",date,long");
+        } else if (format.equals(DateFormat.getTimeInstance(DateFormat.FULL,
+				locale))) {
+            buffer.append(",time,full");
+        } else if (format.equals(DateFormat.getDateInstance(DateFormat.FULL,
+				locale))) {
+            buffer.append(",date,full");
+        } else {
 			buffer.append(",date,");
 			return ((SimpleDateFormat) format).toPattern();
 		}
@@ -815,23 +842,26 @@
 				pattern = decodeDecimalFormat(buffer, format);
 			} else if (format instanceof SimpleDateFormat) {
 				pattern = decodeSimpleDateFormat(buffer, format);
-			} else if (format != null)
-				throw new IllegalArgumentException(Msg
+			} else if (format != null) {
+                throw new IllegalArgumentException(Msg
 						.getString("K0020"));
+            }
 			if (pattern != null) {
 				boolean quote = false;
 				int index = 0, length = pattern.length(), count = 0;
 				while (index < length) {
 					char ch = pattern.charAt(index++);
-					if (ch == '\'')
-						quote = !quote;
+					if (ch == '\'') {
+                        quote = !quote;
+                    }
 					if (!quote) {
-						if (ch == '{')
-							count++;
+						if (ch == '{') {
+                            count++;
+                        }
 						if (ch == '}') {
-							if (count > 0)
-								count--;
-							else {
+							if (count > 0) {
+                                count--;
+                            } else {
 								buffer.append("'}");
 								ch = '\'';
 							}
@@ -842,8 +872,9 @@
 			}
 			buffer.append('}');
 		}
-		if (maxOffset + 1 < strings.length)
-			appendQuoted(buffer, strings[maxOffset + 1]);
+		if (maxOffset + 1 < strings.length) {
+            appendQuoted(buffer, strings[maxOffset + 1]);
+        }
 		return buffer.toString();
 	}
 
@@ -855,8 +886,9 @@
 				buffer.append('\'');
 				buffer.append(ch);
 				buffer.append('\'');
-			} else
-				buffer.append(ch);
+			} else {
+                buffer.append(ch);
+            }
 		}
 	}
 
@@ -884,8 +916,9 @@
 			offsets[i] = offset;
 			pattern.append(strings[i]);
 		}
-		if (maxOffset + 1 < strings.length)
-			pattern.append(strings[maxOffset + 1]);
+		if (maxOffset + 1 < strings.length) {
+            pattern.append(strings[maxOffset + 1]);
+        }
 		fields.put("offsets", offsets);
 		fields.put("pattern", pattern.toString());
 		stream.writeFields();
@@ -901,20 +934,22 @@
 		int[] offsets = (int[]) fields.get("offsets", null);
 		String pattern = (String) fields.get("pattern", null);
 		int length;
-		if (maxOffset < 0)
-			length = pattern.length() > 0 ? 1 : 0;
-		else
-			length = maxOffset
+		if (maxOffset < 0) {
+            length = pattern.length() > 0 ? 1 : 0;
+        } else {
+            length = maxOffset
 					+ (offsets[maxOffset] == pattern.length() ? 1 : 2);
+        }
 		strings = new String[length];
 		int last = 0;
 		for (int i = 0; i <= maxOffset; i++) {
 			strings[i] = pattern.substring(last, offsets[i]);
 			last = offsets[i];
 		}
-		if (maxOffset + 1 < strings.length)
-			strings[strings.length - 1] = pattern.substring(last, pattern
+		if (maxOffset + 1 < strings.length) {
+            strings[strings.length - 1] = pattern.substring(last, pattern
 					.length());
+        }
 	}
 
 	/**
@@ -926,7 +961,9 @@
 	 * constants defined here.
 	 */
 	public static class Field extends Format.Field {
-
+        
+        private static final long serialVersionUID = 7899943957617360810L;
+        
 		public static final Field ARGUMENT = new Field("message argument field");
 
 		/**
@@ -943,13 +980,15 @@
 		 */
 		protected Object readResolve() throws InvalidObjectException {
 			String name = this.getName();
-			if (name == null)
-				// "Not a valid {0}, subclass should override readResolve()"
+			if (name == null) {
+                // "Not a valid {0}, subclass should override readResolve()"
 				throw new InvalidObjectException(
 						Msg.getString("K0344", "MessageFormat.Field"));
+            }
 
-			if (name.equals(ARGUMENT.getName()))
-				return ARGUMENT;
+			if (name.equals(ARGUMENT.getName())) {
+                return ARGUMENT;
+            }
 
 			throw new InvalidObjectException(
 					Msg.getString("K0344", "MessageFormat.Field"));



Mime
View raw message