From: Sergey Vladimirov Date: Thu, 28 Jul 2011 11:34:16 +0000 (+0000) Subject: fix generics compiler warnings X-Git-Tag: REL_3_8_BETA4~60 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=614f365d648ed34c3144679fdd91253f71f6e2de;p=poi.git fix generics compiler warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151798 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ddf/EscherOptRecord.java b/src/java/org/apache/poi/ddf/EscherOptRecord.java index cf6985aecf..d833d86504 100644 --- a/src/java/org/apache/poi/ddf/EscherOptRecord.java +++ b/src/java/org/apache/poi/ddf/EscherOptRecord.java @@ -21,7 +21,6 @@ package org.apache.poi.ddf; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import org.apache.poi.util.HexDump; @@ -59,15 +58,13 @@ public class EscherOptRecord LittleEndian.putShort( data, offset + 2, getRecordId() ); LittleEndian.putInt( data, offset + 4, getPropertiesSize() ); int pos = offset + 8; - for ( Iterator iterator = properties.iterator(); iterator.hasNext(); ) + for ( EscherProperty property : properties ) { - EscherProperty escherProperty = (EscherProperty) iterator.next(); - pos += escherProperty.serializeSimplePart( data, pos ); + pos += property.serializeSimplePart( data, pos ); } - for ( Iterator iterator = properties.iterator(); iterator.hasNext(); ) + for ( EscherProperty property : properties ) { - EscherProperty escherProperty = (EscherProperty) iterator.next(); - pos += escherProperty.serializeComplexPart( data, pos ); + pos += property.serializeComplexPart( data, pos ); } listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); return pos - offset; @@ -94,11 +91,11 @@ public class EscherOptRecord private int getPropertiesSize() { int totalSize = 0; - for ( Iterator iterator = properties.iterator(); iterator.hasNext(); ) + for ( EscherProperty property : properties ) { - EscherProperty escherProperty = (EscherProperty) iterator.next(); - totalSize += escherProperty.getPropertySize(); + totalSize += property.getPropertySize(); } + return totalSize; } @@ -109,10 +106,10 @@ public class EscherOptRecord { String nl = System.getProperty( "line.separator" ); StringBuffer propertiesBuf = new StringBuffer(); - for ( Iterator iterator = properties.iterator(); iterator.hasNext(); ) - propertiesBuf.append( " " - + iterator.next().toString() - + nl ); + for ( EscherProperty property : properties ) + { + propertiesBuf.append( " " + property.toString() + nl ); + } return "org.apache.poi.ddf.EscherOptRecord:" + nl + " isContainer: " + isContainerRecord() + nl + @@ -152,13 +149,13 @@ public class EscherOptRecord */ public void sortProperties() { - Collections.sort( properties, new Comparator() + Collections.sort( properties, new Comparator() { - public int compare( Object o1, Object o2 ) + public int compare( EscherProperty p1, EscherProperty p2 ) { - EscherProperty p1 = (EscherProperty) o1; - EscherProperty p2 = (EscherProperty) o2; - return Short.valueOf( p1.getPropertyNumber() ).compareTo( Short.valueOf( p2.getPropertyNumber() ) ); + short s1 = p1.getPropertyNumber(); + short s2 = p2.getPropertyNumber(); + return s1 < s2 ? -1 : s1 == s2 ? 0 : 1; } } ); }