More conversion to generic types for IPTC classes.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/sanselan/trunk@1240483 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java
index 364840a..152e7cd 100644
--- a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java
+++ b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java
@@ -117,13 +117,13 @@
throws ImageReadException, IOException, ImageWriteException
{
JFIFPieces jfifPieces = analyzeJFIF(byteSource);
- List oldPieces = jfifPieces.pieces;
- List photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);
+ List<JFIFPiece> oldPieces = jfifPieces.pieces;
+ List<JFIFPiece> photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);
if (photoshopApp13Segments.size() > 1)
throw new ImageReadException(
"Image contains more than one Photoshop App13 segment.");
- List newPieces = removePhotoshopApp13Segments(oldPieces);
+ List<JFIFPiece> newPieces = removePhotoshopApp13Segments(oldPieces);
if (photoshopApp13Segments.size() == 1)
{
JFIFPieceSegment oldSegment = (JFIFPieceSegment) photoshopApp13Segments
@@ -220,17 +220,17 @@
ImageWriteException
{
JFIFPieces jfifPieces = analyzeJFIF(byteSource);
- List oldPieces = jfifPieces.pieces;
- List photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);
+ List<JFIFPiece> oldPieces = jfifPieces.pieces;
+ List<JFIFPiece> photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);
if (photoshopApp13Segments.size() > 1)
throw new ImageReadException(
"Image contains more than one Photoshop App13 segment.");
- List newPieces = removePhotoshopApp13Segments(oldPieces);
+ List<JFIFPiece> newPieces = removePhotoshopApp13Segments(oldPieces);
{
// discard old iptc blocks.
- List newBlocks = newData.getNonIptcBlocks();
+ List<IptcBlock> newBlocks = newData.getNonIptcBlocks();
byte[] newBlockBytes = new IptcParser().writeIPTCBlock(newData
.getRecords());
diff --git a/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java b/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
index 10db048..0c142df 100644
--- a/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
+++ b/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
@@ -52,10 +52,10 @@
protected static class JFIFPieces
{
- public final List pieces;
+ public final List<JFIFPiece> pieces;
public final List<JFIFPiece> segmentPieces;
- public JFIFPieces(final List pieces, final List<JFIFPiece> segmentPieces)
+ public JFIFPieces(final List<JFIFPiece> pieces, final List<JFIFPiece> segmentPieces)
{
this.pieces = pieces;
this.segmentPieces = segmentPieces;
@@ -171,7 +171,7 @@
throws ImageReadException, IOException
// , ImageWriteException
{
- final List pieces = new ArrayList();
+ final List<JFIFPiece> pieces = new ArrayList<JFIFPiece>();
final List<JFIFPiece> segmentPieces = new ArrayList<JFIFPiece>();
JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
@@ -232,39 +232,41 @@
}
};
- protected List removeXmpSegments(List segments)
+ protected List<JFIFPiece> removeXmpSegments(List<? extends JFIFPiece> segments)
{
return filterSegments(segments, XMP_SEGMENT_FILTER);
}
- protected List removePhotoshopApp13Segments(List segments)
+ protected List<JFIFPiece> removePhotoshopApp13Segments(List<? extends JFIFPiece> segments)
{
return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER);
}
- protected List findPhotoshopApp13Segments(List segments)
+ protected List<JFIFPiece> findPhotoshopApp13Segments(List<? extends JFIFPiece> segments)
{
return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER, true);
}
- protected List removeExifSegments(List segments)
+ protected List<JFIFPiece> removeExifSegments(List<? extends JFIFPiece> segments)
{
return filterSegments(segments, EXIF_SEGMENT_FILTER);
}
- protected List filterSegments(List segments, SegmentFilter filter)
+ protected List<JFIFPiece> filterSegments(List<? extends JFIFPiece> segments, SegmentFilter filter)
{
return filterSegments(segments, filter, false);
}
- protected List filterSegments(List segments, SegmentFilter filter,
+ protected List<JFIFPiece> filterSegments(
+ List<? extends JFIFPiece> segments,
+ SegmentFilter filter,
boolean reverse)
{
- List result = new ArrayList();
+ List<JFIFPiece> result = new ArrayList<JFIFPiece>();
for (int i = 0; i < segments.size(); i++)
{
- JFIFPiece piece = (JFIFPiece) segments.get(i);
+ JFIFPiece piece = segments.get(i);
if (piece instanceof JFIFPieceSegment)
{
if (filter.filter((JFIFPieceSegment) piece) ^ !reverse)
@@ -276,8 +278,10 @@
return result;
}
- protected List<JFIFPiece> insertBeforeFirstAppSegments(List<JFIFPiece> segments, List<JFIFPiece> newSegments)
- throws ImageWriteException
+ protected List<JFIFPiece> insertBeforeFirstAppSegments(
+ List<? extends JFIFPiece> segments,
+ List<? extends JFIFPiece> newSegments)
+ throws ImageWriteException
{
int firstAppIndex = -1;
for (int i = 0; i < segments.size(); i++)
@@ -301,13 +305,15 @@
return result;
}
- protected List insertAfterLastAppSegments(List segments, List newSegments)
- throws ImageWriteException
+ protected List<JFIFPiece> insertAfterLastAppSegments(
+ List<? extends JFIFPiece> segments,
+ List<? extends JFIFPiece> newSegments)
+ throws ImageWriteException
{
int lastAppIndex = -1;
for (int i = 0; i < segments.size(); i++)
{
- JFIFPiece piece = (JFIFPiece) segments.get(i);
+ JFIFPiece piece = segments.get(i);
if (!(piece instanceof JFIFPieceSegment))
continue;
@@ -316,7 +322,7 @@
lastAppIndex = i;
}
- List result = new ArrayList(segments);
+ List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
if (lastAppIndex == -1)
{
if(segments.size()<1)
@@ -324,13 +330,15 @@
result.addAll(1, newSegments);
}
else
- result.addAll(lastAppIndex + 1, newSegments);
+ result.addAll(lastAppIndex + 1, newSegments);
return result;
}
- protected void writeSegments(OutputStream os, List segments)
- throws IOException
+ protected void writeSegments(
+ OutputStream os,
+ List<? extends JFIFPiece> segments)
+ throws IOException
{
try
{
@@ -338,7 +346,7 @@
for (int i = 0; i < segments.size(); i++)
{
- JFIFPiece piece = (JFIFPiece) segments.get(i);
+ JFIFPiece piece = segments.get(i);
piece.write(os);
}
os.close();