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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
public class TIFFFieldNode extends IIOMetadataNode {
|
||||||
private static String getNodeName(TIFFField f) {
|
private static String getNodeName(TIFFField f) {
|
||||||
return f.getData() instanceof TIFFDirectory ?
|
return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ?
|
||||||
"TIFFIFD" : "TIFFField";
|
"TIFFIFD" : "TIFFField";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
|||||||
public TIFFFieldNode(TIFFField field) {
|
public TIFFFieldNode(TIFFField field) {
|
||||||
super(getNodeName(field));
|
super(getNodeName(field));
|
||||||
|
|
||||||
isIFD = field.getData() instanceof TIFFDirectory;
|
isIFD = field.hasDirectory() ||
|
||||||
|
field.getData() instanceof TIFFDirectory;
|
||||||
|
|
||||||
this.field = field;
|
this.field = field;
|
||||||
|
|
||||||
@ -68,7 +69,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
|||||||
setAttribute("parentTagName", tagName);
|
setAttribute("parentTagName", tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIFFDirectory dir = (TIFFDirectory)field.getData();
|
TIFFDirectory dir = field.hasDirectory() ?
|
||||||
|
field.getDirectory() : (TIFFDirectory)field.getData();
|
||||||
TIFFTagSet[] tagSets = dir.getTagSets();
|
TIFFTagSet[] tagSets = dir.getTagSets();
|
||||||
if(tagSets != null) {
|
if(tagSets != null) {
|
||||||
StringBuilder tagSetNames = new StringBuilder();
|
StringBuilder tagSetNames = new StringBuilder();
|
||||||
@ -90,7 +92,8 @@ public class TIFFFieldNode extends IIOMetadataNode {
|
|||||||
if(isInitialized) return;
|
if(isInitialized) return;
|
||||||
|
|
||||||
if(isIFD) {
|
if(isIFD) {
|
||||||
TIFFDirectory dir = (TIFFDirectory)field.getData();
|
TIFFDirectory dir = field.hasDirectory() ?
|
||||||
|
field.getDirectory() : (TIFFDirectory)field.getData();
|
||||||
TIFFField[] fields = dir.getTIFFFields();
|
TIFFField[] fields = dir.getTIFFFields();
|
||||||
if(fields != null) {
|
if(fields != null) {
|
||||||
TIFFTagSet[] tagSets = dir.getTagSets();
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
static class ExifVersion extends TIFFTag {
|
||||||
|
|
||||||
public ExifVersion() {
|
public ExifVersion() {
|
||||||
super("Exifversion",
|
super("ExifVersion",
|
||||||
TAG_EXIF_VERSION,
|
TAG_EXIF_VERSION,
|
||||||
1 << TIFFTag.TIFF_UNDEFINED,
|
1 << TIFFTag.TIFF_UNDEFINED,
|
||||||
4);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
static class GeoKeyDirectory extends TIFFTag {
|
||||||
public GeoKeyDirectory() {
|
public GeoKeyDirectory() {
|
||||||
super("GeoKeyDirectory",
|
super("GeoKeyDirectoryTag",
|
||||||
TAG_GEO_KEY_DIRECTORY,
|
TAG_GEO_KEY_DIRECTORY,
|
||||||
1 << TIFFTag.TIFF_SHORT);
|
1 << TIFFTag.TIFF_SHORT);
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
|
|||||||
|
|
||||||
static class GeoDoubleParams extends TIFFTag {
|
static class GeoDoubleParams extends TIFFTag {
|
||||||
public GeoDoubleParams() {
|
public GeoDoubleParams() {
|
||||||
super("GeoDoubleParams",
|
super("GeoDoubleParamsTag",
|
||||||
TAG_GEO_DOUBLE_PARAMS,
|
TAG_GEO_DOUBLE_PARAMS,
|
||||||
1 << TIFFTag.TIFF_DOUBLE);
|
1 << TIFFTag.TIFF_DOUBLE);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
|
|||||||
|
|
||||||
static class GeoAsciiParams extends TIFFTag {
|
static class GeoAsciiParams extends TIFFTag {
|
||||||
public GeoAsciiParams() {
|
public GeoAsciiParams() {
|
||||||
super("GeoAsciiParams",
|
super("GeoAsciiParamsTag",
|
||||||
TAG_GEO_ASCII_PARAMS,
|
TAG_GEO_ASCII_PARAMS,
|
||||||
1 << TIFFTag.TIFF_ASCII);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -219,12 +219,24 @@ public class TIFFDirectory implements Cloneable {
|
|||||||
TIFFField f = fields[i];
|
TIFFField f = fields[i];
|
||||||
TIFFTag tag = f.getTag();
|
TIFFTag tag = f.getTag();
|
||||||
if(tag.isIFDPointer()) {
|
if(tag.isIFDPointer()) {
|
||||||
TIFFDirectory subIFD =
|
TIFFDirectory subDir = null;
|
||||||
getDirectoryAsIFD((TIFFDirectory)f.getData());
|
if (f.hasDirectory()) {
|
||||||
f = new TIFFField(tag, f.getType(), (long)f.getCount(), subIFD);
|
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;
|
return ifd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user