21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package com.sun.imageio.plugins.tiff; 26 27 import java.util.Arrays; 28 import java.util.List; 29 import javax.imageio.metadata.IIOMetadataNode; 30 import org.w3c.dom.Node; 31 import javax.imageio.plugins.tiff.TIFFDirectory; 32 import javax.imageio.plugins.tiff.TIFFField; 33 import javax.imageio.plugins.tiff.TIFFTag; 34 import javax.imageio.plugins.tiff.TIFFTagSet; 35 36 /** 37 * The {@code Node} representation of a {@code TIFFField} 38 * wherein the child node is procedural rather than buffered. 39 */ 40 public class TIFFFieldNode extends IIOMetadataNode { 41 private static String getNodeName(TIFFField f) { 42 return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ? 43 "TIFFIFD" : "TIFFField"; 44 } 45 46 private boolean isIFD; 47 48 private Boolean isInitialized = Boolean.FALSE; 49 50 private TIFFField field; 51 52 public TIFFFieldNode(TIFFField field) { 53 super(getNodeName(field)); 54 55 isIFD = field.hasDirectory() || 56 field.getData() instanceof TIFFDirectory; 57 58 this.field = field; 59 60 TIFFTag tag = field.getTag(); 61 int tagNumber = tag.getNumber(); 62 String tagName = tag.getName(); 63 64 if(isIFD) { 65 if(tagNumber != 0) { 66 setAttribute("parentTagNumber", Integer.toString(tagNumber)); 67 } 68 if(tagName != null) { 69 setAttribute("parentTagName", tagName); 70 } 71 72 TIFFDirectory dir = field.hasDirectory() ? 73 field.getDirectory() : (TIFFDirectory)field.getData(); 74 TIFFTagSet[] tagSets = dir.getTagSets(); 75 if(tagSets != null) { 76 StringBuilder tagSetNames = new StringBuilder(); | 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package com.sun.imageio.plugins.tiff; 26 27 import java.util.Arrays; 28 import java.util.List; 29 import javax.imageio.metadata.IIOMetadataNode; 30 import org.w3c.dom.Node; 31 import javax.imageio.plugins.tiff.TIFFDirectory; 32 import javax.imageio.plugins.tiff.TIFFField; 33 import javax.imageio.plugins.tiff.TIFFTag; 34 import javax.imageio.plugins.tiff.TIFFTagSet; 35 36 /** 37 * The {@code Node} representation of a {@code TIFFField} 38 * wherein the child node is procedural rather than buffered. 39 */ 40 public class TIFFFieldNode extends IIOMetadataNode { 41 private static boolean isIFD(TIFFField f) { 42 int type = f.getType(); 43 return f.hasDirectory() && 44 (type == TIFFTag.TIFF_LONG || type == TIFFTag.TIFF_IFD_POINTER); 45 } 46 47 private static String getNodeName(TIFFField f) { 48 return isIFD(f) ? "TIFFIFD" : "TIFFField"; 49 } 50 51 private boolean isIFD; 52 53 private Boolean isInitialized = Boolean.FALSE; 54 55 private TIFFField field; 56 57 public TIFFFieldNode(TIFFField field) { 58 super(getNodeName(field)); 59 60 isIFD = isIFD(field); 61 62 this.field = field; 63 64 TIFFTag tag = field.getTag(); 65 int tagNumber = tag.getNumber(); 66 String tagName = tag.getName(); 67 68 if(isIFD) { 69 if(tagNumber != 0) { 70 setAttribute("parentTagNumber", Integer.toString(tagNumber)); 71 } 72 if(tagName != null) { 73 setAttribute("parentTagName", tagName); 74 } 75 76 TIFFDirectory dir = field.hasDirectory() ? 77 field.getDirectory() : (TIFFDirectory)field.getData(); 78 TIFFTagSet[] tagSets = dir.getTagSets(); 79 if(tagSets != null) { 80 StringBuilder tagSetNames = new StringBuilder(); |