8148628: TIFFDirectory(getAsMetaData) created with one TIFFField having a IFD pointer tag throws ClassCastException & other naming differences (JEP 262)
Clean up some handling of TIFFDirectory instances contained in TIFFFields and make a couple of minor changes to Exif and GeoTIFF tag names. Reviewed-by: prr
This commit is contained in:
parent
c43521be07
commit
71681ac4cb
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,7 +39,7 @@ import javax.imageio.plugins.tiff.TIFFTagSet;
|
||||
*/
|
||||
public class TIFFFieldNode extends IIOMetadataNode {
|
||||
private static String getNodeName(TIFFField f) {
|
||||
return f.getData() instanceof TIFFDirectory ?
|
||||
return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ?
|
||||
"TIFFIFD" : "TIFFField";
|
||||
}
|
||||
|
||||
@ -52,7 +52,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
||||
public TIFFFieldNode(TIFFField field) {
|
||||
super(getNodeName(field));
|
||||
|
||||
isIFD = field.getData() instanceof TIFFDirectory;
|
||||
isIFD = field.hasDirectory() ||
|
||||
field.getData() instanceof TIFFDirectory;
|
||||
|
||||
this.field = field;
|
||||
|
||||
@ -68,7 +69,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
||||
setAttribute("parentTagName", tagName);
|
||||
}
|
||||
|
||||
TIFFDirectory dir = (TIFFDirectory)field.getData();
|
||||
TIFFDirectory dir = field.hasDirectory() ?
|
||||
field.getDirectory() : (TIFFDirectory)field.getData();
|
||||
TIFFTagSet[] tagSets = dir.getTagSets();
|
||||
if(tagSets != null) {
|
||||
StringBuilder tagSetNames = new StringBuilder();
|
||||
@ -90,7 +92,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
||||
if(isInitialized) return;
|
||||
|
||||
if(isIFD) {
|
||||
TIFFDirectory dir = (TIFFDirectory)field.getData();
|
||||
TIFFDirectory dir = field.hasDirectory() ?
|
||||
field.getDirectory() : (TIFFDirectory)field.getData();
|
||||
TIFFField[] fields = dir.getTIFFFields();
|
||||
if(fields != null) {
|
||||
TIFFTagSet[] tagSets = dir.getTagSets();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1256,7 +1256,7 @@ public class ExifTIFFTagSet extends TIFFTagSet {
|
||||
static class ExifVersion extends TIFFTag {
|
||||
|
||||
public ExifVersion() {
|
||||
super("Exifversion",
|
||||
super("ExifVersion",
|
||||
TAG_EXIF_VERSION,
|
||||
1 << TIFFTag.TIFF_UNDEFINED,
|
||||
4);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -97,7 +97,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
|
||||
|
||||
static class GeoKeyDirectory extends TIFFTag {
|
||||
public GeoKeyDirectory() {
|
||||
super("GeoKeyDirectory",
|
||||
super("GeoKeyDirectoryTag",
|
||||
TAG_GEO_KEY_DIRECTORY,
|
||||
1 << TIFFTag.TIFF_SHORT);
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
|
||||
|
||||
static class GeoDoubleParams extends TIFFTag {
|
||||
public GeoDoubleParams() {
|
||||
super("GeoDoubleParams",
|
||||
super("GeoDoubleParamsTag",
|
||||
TAG_GEO_DOUBLE_PARAMS,
|
||||
1 << TIFFTag.TIFF_DOUBLE);
|
||||
}
|
||||
@ -113,7 +113,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
|
||||
|
||||
static class GeoAsciiParams extends TIFFTag {
|
||||
public GeoAsciiParams() {
|
||||
super("GeoAsciiParams",
|
||||
super("GeoAsciiParamsTag",
|
||||
TAG_GEO_ASCII_PARAMS,
|
||||
1 << TIFFTag.TIFF_ASCII);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -219,11 +219,23 @@ public class TIFFDirectory implements Cloneable {
|
||||
TIFFField f = fields[i];
|
||||
TIFFTag tag = f.getTag();
|
||||
if(tag.isIFDPointer()) {
|
||||
TIFFDirectory subIFD =
|
||||
getDirectoryAsIFD((TIFFDirectory)f.getData());
|
||||
f = new TIFFField(tag, f.getType(), (long)f.getCount(), subIFD);
|
||||
TIFFDirectory subDir = null;
|
||||
if (f.hasDirectory()) {
|
||||
subDir = f.getDirectory();
|
||||
} else if (f.getData() instanceof TIFFDirectory) {
|
||||
subDir = (TIFFDirectory)f.getData();
|
||||
}
|
||||
if (subDir != null) {
|
||||
TIFFDirectory subIFD = getDirectoryAsIFD(subDir);
|
||||
f = new TIFFField(tag, f.getType(), (long)f.getCount(),
|
||||
subIFD);
|
||||
} else {
|
||||
f = null;
|
||||
}
|
||||
}
|
||||
if (f != null) {
|
||||
ifd.addTIFFField(f);
|
||||
}
|
||||
ifd.addTIFFField(f);
|
||||
}
|
||||
|
||||
return ifd;
|
||||
|
Loading…
Reference in New Issue
Block a user