You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2012/02/04 11:34:47 UTC
svn commit: r1240483 - in
/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg:
iptc/JpegIptcRewriter.java xmp/JpegRewriter.java
Author: damjan
Date: Sat Feb 4 10:34:46 2012
New Revision: 1240483
URL: http://svn.apache.org/viewvc?rev=1240483&view=rev
Log:
More conversion to generic types for IPTC classes.
Modified:
commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java
commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java?rev=1240483&r1=1240482&r2=1240483&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java Sat Feb 4 10:34:46 2012
@@ -117,13 +117,13 @@ public class JpegIptcRewriter extends Jp
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 @@ public class JpegIptcRewriter extends Jp
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());
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java?rev=1240483&r1=1240482&r2=1240483&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java Sat Feb 4 10:34:46 2012
@@ -52,10 +52,10 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
}
};
- 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 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
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 @@ public class JpegRewriter extends Binary
for (int i = 0; i < segments.size(); i++)
{
- JFIFPiece piece = (JFIFPiece) segments.get(i);
+ JFIFPiece piece = segments.get(i);
piece.write(os);
}
os.close();