# HG changeset patch # User bpb # Date 1476825059 25200 # Tue Oct 18 14:10:59 2016 -0700 # Node ID b6afe1ae2f05034ac0294e5d1972cc0909f10dfa # Parent d7944c75be9cd99aa312a4d6a3b32743c9df17df 8165981: Consider making some classes in javax.imageio.plugins.tiff final Summary: Make the classes TIFFField and TIFFImageReadParam final. Reviewed-by: XXX diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java @@ -233,7 +233,7 @@ * @return The {@code TIFFTagSet}s associated with this * {@code TIFFDirectory}. */ - public TIFFTagSet[] getTagSets() { + public final TIFFTagSet[] getTagSets() { return tagSets.toArray(new TIFFTagSet[tagSets.size()]); } @@ -280,7 +280,7 @@ * @return The parent {@code TIFFTag} of this * {@code TIFFDiectory} or {@code null}. */ - public TIFFTag getParentTag() { + public final TIFFTag getParentTag() { return parentTag; } @@ -293,7 +293,7 @@ * @param tagNumber The tag number of interest. * @return The corresponding {@code TIFFTag} or {@code null}. */ - public TIFFTag getTag(int tagNumber) { + public final TIFFTag getTag(int tagNumber) { return TIFFIFD.getTag(tagNumber, tagSets); } @@ -303,7 +303,7 @@ * @return The number of {@code TIFFField}s in this * {@code TIFFDirectory}. */ - public int getNumTIFFFields() { + public final int getNumTIFFFields() { return numLowFields + highFields.size(); } @@ -315,7 +315,7 @@ * @return Whether a {@link TIFFTag} with tag number equal to * {@code tagNumber} is present in this {@code TIFFDirectory}. */ - public boolean containsTIFFField(int tagNumber) { + public final boolean containsTIFFField(int tagNumber) { return (tagNumber >= 0 && tagNumber <= MAX_LOW_FIELD_TAG_NUM && lowFields[tagNumber] != null) || highFields.containsKey(Integer.valueOf(tagNumber)); @@ -349,7 +349,7 @@ * @return A {@code TIFFField} with the requested tag number of * {@code null} if no such field is present. */ - public TIFFField getTIFFField(int tagNumber) { + public final TIFFField getTIFFField(int tagNumber) { TIFFField f; if(tagNumber >= 0 && tagNumber <= MAX_LOW_FIELD_TAG_NUM) { f = lowFields[tagNumber]; @@ -381,7 +381,7 @@ * @return An array of all TIFF fields in order of numerically increasing * tag number. */ - public TIFFField[] getTIFFFields() { + public final TIFFField[] getTIFFFields() { // Allocate return value. TIFFField[] fields = new TIFFField[numLowFields + highFields.size()]; @@ -420,7 +420,7 @@ * @return A metadata instance initialized from the contents of this * {@code TIFFDirectory}. */ - public IIOMetadata getAsMetadata() { + public final IIOMetadata getAsMetadata() { return new TIFFImageMetadata(TIFFIFD.getDirectoryAsIFD(this)); } diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -261,7 +261,7 @@ * @see TIFFDirectory * @see TIFFTag */ -public class TIFFField implements Cloneable { +public final class TIFFField implements Cloneable { private static final String[] typeNames = { null, diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java @@ -48,7 +48,7 @@ * * @since 9 */ -public class TIFFImageReadParam extends ImageReadParam { +public final class TIFFImageReadParam extends ImageReadParam { private List allowedTagSets = new ArrayList(4); diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java @@ -240,7 +240,7 @@ * less than {@code MIN_DATATYPE} or greater than * {@code MAX_DATATYPE}. */ - public static int getSizeOfType(int dataType) { + public static final int getSizeOfType(int dataType) { if (dataType < MIN_DATATYPE ||dataType > MAX_DATATYPE) { throw new IllegalArgumentException("dataType out of range!"); } @@ -253,7 +253,7 @@ * * @return the tag name, as a {@code String}. */ - public String getName() { + public final String getName() { return name; } @@ -262,7 +262,7 @@ * * @return the tag number, as an {@code int}. */ - public int getNumber() { + public final int getNumber() { return number; } @@ -279,7 +279,7 @@ * @return an {@code int} containing a bitmask encoding the * set of valid data types. */ - public int getDataTypes() { + public final int getDataTypes() { return dataTypes; } @@ -294,7 +294,7 @@ * * @return the value count of this tag. */ - public int getCount() { + public final int getCount() { return count; } @@ -312,7 +312,7 @@ * less than {@code MIN_DATATYPE} or greater than * {@code MAX_DATATYPE}. */ - public boolean isDataTypeOK(int dataType) { + public final boolean isDataTypeOK(int dataType) { if (dataType < MIN_DATATYPE || dataType > MAX_DATATYPE) { throw new IllegalArgumentException("datatype not in range!"); } @@ -324,7 +324,7 @@ * * @return the containing {@code TIFFTagSet}. */ - public TIFFTagSet getTagSet() { + public final TIFFTagSet getTagSet() { return tagSet; } @@ -342,7 +342,7 @@ * * @return {@code true} if this tag points to an IFD. */ - public boolean isIFDPointer() { + public final boolean isIFDPointer() { return tagSet != null || isDataTypeOK(TIFF_IFD_POINTER); } @@ -353,7 +353,7 @@ * * @return {@code true} if mnemonic value names are available. */ - public boolean hasValueNames() { + public final boolean hasValueNames() { return valueNames != null; } @@ -382,7 +382,7 @@ * @return the mnemonic name associated with the value, as a * {@code String}. */ - public String getValueName(int value) { + public final String getValueName(int value) { if (valueNames == null) { return null; } @@ -397,7 +397,7 @@ * * @return the values for which there is a mnemonic name. */ - public int[] getNamedValues() { + public final int[] getNamedValues() { int[] intValues = null; if (valueNames != null) { Set values = valueNames.keySet(); diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java @@ -95,7 +95,7 @@ * * @return the numbered {@code TIFFTag}, or {@code null}. */ - public TIFFTag getTag(int tagNumber) { + public final TIFFTag getTag(int tagNumber) { return allowedTagsByNumber.get(Integer.valueOf(tagNumber)); } @@ -111,7 +111,7 @@ * @throws IllegalArgumentException if {@code tagName} is * {@code null}. */ - public TIFFTag getTag(String tagName) { + public final TIFFTag getTag(String tagName) { if (tagName == null) { throw new IllegalArgumentException("tagName == null!"); } @@ -128,7 +128,7 @@ * * @return All tag numbers in this set. */ - public SortedSet getTagNumbers() { + public final SortedSet getTagNumbers() { Set tagNumbers = allowedTagsByNumber.keySet(); SortedSet sortedTagNumbers; if(tagNumbers instanceof SortedSet) { @@ -150,7 +150,7 @@ * * @return All tag names in this set. */ - public SortedSet getTagNames() { + public final SortedSet getTagNames() { Set tagNames = allowedTagsByName.keySet(); SortedSet sortedTagNames; if(tagNames instanceof SortedSet) {