harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r409689 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text: AttributedCharacterIterator.java AttributedString.java SimpleDateFormat.java
Date Fri, 26 May 2006 16:12:17 GMT
Author: tellison
Date: Fri May 26 09:12:17 2006
New Revision: 409689

URL: http://svn.apache.org/viewvc?rev=409689&view=rev
Log:
Generics uplift in java.text

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedCharacterIterator.java
    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/SimpleDateFormat.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedCharacterIterator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedCharacterIterator.java?rev=409689&r1=409688&r2=409689&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedCharacterIterator.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/AttributedCharacterIterator.java
Fri May 26 09:12:17 2006
@@ -76,21 +76,21 @@
 		}
 	}
 
-	public Set getAllAttributeKeys();
+	public Set<Attribute> getAllAttributeKeys();
 
 	public Object getAttribute(Attribute attribute);
 
-	public Map getAttributes();
+	public Map<Attribute, Object> getAttributes();
 
 	public int getRunLimit();
 
 	public int getRunLimit(Attribute attribute);
 
-	public int getRunLimit(Set attributes);
+	public int getRunLimit(Set<? extends Attribute> attributes);
 
 	public int getRunStart();
 
 	public int getRunStart(Attribute attribute);
 
-	public int getRunStart(Set attributes);
+	public int getRunStart(Set<? extends Attribute> attributes);
 }

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=409689&r1=409688&r2=409689&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
Fri May 26 09:12:17 2006
@@ -34,7 +34,7 @@
 
 	String text;
 
-	Map attributeMap;
+	Map<AttributedCharacterIterator.Attribute, ArrayList> attributeMap;
 
 	static class Range {
 		int start, end;
@@ -174,12 +174,12 @@
 			return false;
 		}
 
-		public Set getAllAttributeKeys() {
+		public Set<AttributedIterator.Attribute> getAllAttributeKeys() {
 			if (begin == 0 && end == attrString.text.length()
 					&& attributesAllowed == null)
 				return attrString.attributeMap.keySet();
 
-			HashSet result = new HashSet(
+            Set<AttributedIterator.Attribute> result = new HashSet(
 					(attrString.attributeMap.size() * 4 / 3) + 1);
 			Iterator it = attrString.attributeMap.entrySet().iterator();
 			while (it.hasNext()) {
@@ -188,7 +188,7 @@
 						|| attributesAllowed.contains(entry.getKey())) {
 					ArrayList ranges = (ArrayList) entry.getValue();
 					if (inRange(ranges))
-						result.add(entry.getKey());
+						result.add((AttributedIterator.Attribute)entry.getKey());
 				}
 			}
 			return result;
@@ -217,7 +217,7 @@
 		}
 
 		public Map getAttributes() {
-			HashMap result = new HashMap(
+			Map result = new HashMap(
 					(attrString.attributeMap.size() * 4 / 3) + 1);
 			Iterator it = attrString.attributeMap.entrySet().iterator();
 			while (it.hasNext()) {
@@ -382,30 +382,31 @@
 	}
 
 	public AttributedString(AttributedCharacterIterator iterator) {
-		StringBuffer buffer = new StringBuffer();
-		while (iterator.current() != CharacterIterator.DONE) {
-			buffer.append(iterator.current());
-			iterator.next();
-		}
-		text = buffer.toString();
-		Set attributes = iterator.getAllAttributeKeys();
-		attributeMap = new HashMap((attributes.size() * 4 / 3) + 1);
-
-		Iterator it = attributes.iterator();
-		while (it.hasNext()) {
-			AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.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)
-					addAttribute(attribute, value, start, limit);
-				iterator.setIndex(limit);
-			}
-		}
-	}
+        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);
+
+        Iterator it = attributes.iterator();
+        while (it.hasNext()) {
+            AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.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)
+                    addAttribute(attribute, value, start, limit);
+                iterator.setIndex(limit);
+            }
+        }
+    }
 
 	private AttributedString(AttributedCharacterIterator iterator, int start,
 			int end, Set attributes) {
@@ -459,30 +460,32 @@
 		attributeMap = new HashMap(11);
 	}
 
-	public AttributedString(String value, Map attributes) {
-		if (value == null)
-			throw new NullPointerException();
-		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();
-		while (it.hasNext()) {
-			Map.Entry entry = (Map.Entry) it.next();
-			ArrayList ranges = new ArrayList(1);
-			ranges.add(new Range(0, text.length(), entry.getValue()));
-			attributeMap.put(entry.getKey(), ranges);
-		}
-	}
+	public AttributedString(String value,
+            Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) {
+        if (value == null)
+            throw new NullPointerException();
+        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();
+        while (it.hasNext()) {
+            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);
+        }
+    }
 
 	public void addAttribute(AttributedCharacterIterator.Attribute attribute,
 			Object value) {
 		if (text.length() == 0)
 			throw new IllegalArgumentException();
 
-		ArrayList ranges = (ArrayList) attributeMap.get(attribute);
+		ArrayList<Range> ranges = attributeMap.get(attribute);
 		if (ranges == null) {
-			ranges = new ArrayList(1);
+			ranges = new ArrayList<Range>(1);
 			attributeMap.put(attribute, ranges);
 		} else {
 			ranges.clear();
@@ -495,14 +498,14 @@
 		if (start < 0 || end > text.length() || start >= end)
 			throw new IllegalArgumentException();
 
-		ArrayList ranges = (ArrayList) attributeMap.get(attribute);
+		ArrayList<Range> ranges = attributeMap.get(attribute);
 		if (ranges == null) {
-			ranges = new ArrayList(1);
+			ranges = new ArrayList<Range>(1);
 			ranges.add(new Range(start, end, value));
 			attributeMap.put(attribute, ranges);
 			return;
 		}
-		ListIterator it = ranges.listIterator();
+		ListIterator<Range> it = ranges.listIterator();
 		while (it.hasNext()) {
 			Range range = (Range) it.next();
 			if (end <= range.start) {
@@ -562,15 +565,17 @@
 		it.add(new Range(start, end, value));
 	}
 
-	public void addAttributes(Map 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);
-		}
-	}
+	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);
+        }
+    }
 
 	public AttributedCharacterIterator getIterator() {
 		return new AttributedIterator(this);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java?rev=409689&r1=409688&r2=409689&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
Fri May 26 09:12:17 2006
@@ -132,7 +132,7 @@
 	}
 
 	private void append(StringBuffer buffer, FieldPosition position,
-			Vector fields, char format, int count) {
+			Vector<FieldPosition> fields, char format, int count) {
 		int field = -1;
 		int index = patternChars.indexOf(format);
 		if (index == -1)
@@ -421,7 +421,7 @@
 
 	private AttributedCharacterIterator formatToCharacterIteratorImpl(Date date) {
 		StringBuffer buffer = new StringBuffer();
-		Vector fields = new Vector();
+		Vector<FieldPosition> fields = new Vector<FieldPosition>();
 
 		// format the date, and find fields
 		formatImpl(date, buffer, null, fields);
@@ -565,7 +565,7 @@
 	 *                when the object cannot be formatted by this Format
 	 */
 	private StringBuffer formatImpl(Date date, StringBuffer buffer,
-			FieldPosition field, Vector fields) {
+			FieldPosition field, Vector<FieldPosition> fields) {
 
 		boolean quote = false;
 		int next, last = -1, count = 0;



Mime
View raw message