8149815: Misleading TIFFField#getAsNativeNode spec about native node name "TIFFIFD"

Change the specification verbiage of TIFFField.getAsNativeNode() to reflect the actual behavior.

Reviewed-by: prr
This commit is contained in:
Brian Burkhalter 2016-05-25 15:48:57 -07:00
parent 3e726f00ed
commit 08121fbd51
2 changed files with 11 additions and 8 deletions

View File

@ -38,9 +38,14 @@ import javax.imageio.plugins.tiff.TIFFTagSet;
* wherein the child node is procedural rather than buffered.
*/
public class TIFFFieldNode extends IIOMetadataNode {
private static boolean isIFD(TIFFField f) {
int type = f.getType();
return f.hasDirectory() &&
(type == TIFFTag.TIFF_LONG || type == TIFFTag.TIFF_IFD_POINTER);
}
private static String getNodeName(TIFFField f) {
return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ?
"TIFFIFD" : "TIFFField";
return isIFD(f) ? "TIFFIFD" : "TIFFField";
}
private boolean isIFD;
@ -52,8 +57,7 @@ public class TIFFFieldNode extends IIOMetadataNode {
public TIFFFieldNode(TIFFField field) {
super(getNodeName(field));
isIFD = field.hasDirectory() ||
field.getData() instanceof TIFFDirectory;
isIFD = isIFD(field);
this.field = field;

View File

@ -843,10 +843,9 @@ public class TIFFField implements Cloneable {
* Returns the {@code TIFFField} as a node named either
* <tt>"TIFFField"</tt> or <tt>"TIFFIFD"</tt> as described in the
* TIFF native image metadata specification. The node will be named
* <tt>"TIFFIFD"</tt> if and only if the field's data object is an
* instance of {@link TIFFDirectory} or equivalently
* {@link TIFFTag#isIFDPointer getTag.isIFDPointer()} returns
* {@code true}.
* <tt>"TIFFIFD"</tt> if and only if {@link #hasDirectory()} returns
* {@code true} and the field's type is either {@link TIFFTag#TIFF_LONG}
* or {@link TIFFTag#TIFF_IFD_POINTER}.
*
* @return a {@code Node} named <tt>"TIFFField"</tt> or
* <tt>"TIFFIFD"</tt>.