src/share/classes/com/sun/imageio/plugins/common/StandardMetadataFormat.java

Print this page
rev 9343 : 8033716: Fix raw and unchecked lint warnings in com.sun.imageio
Reviewed-by: darcy, prr, bae


  25 
  26 package com.sun.imageio.plugins.common;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 import javax.imageio.ImageTypeSpecifier;
  31 import javax.imageio.metadata.IIOMetadataFormatImpl;
  32 
  33 public class StandardMetadataFormat extends IIOMetadataFormatImpl {
  34 
  35     // Utility method for nodes with a single attribute named "value"
  36     private void addSingleAttributeElement(String elementName,
  37                                            String parentName,
  38                                            int dataType) {
  39         addElement(elementName, parentName, CHILD_POLICY_EMPTY);
  40         addAttribute(elementName, "value", dataType, true, null);
  41     }
  42 
  43     public StandardMetadataFormat() {
  44         super(standardMetadataFormatName, CHILD_POLICY_SOME);
  45         List values;
  46 
  47         // root -> Chroma
  48         addElement("Chroma", standardMetadataFormatName,
  49                    CHILD_POLICY_SOME);
  50 
  51         // root -> Chroma -> ColorSpaceType
  52         addElement("ColorSpaceType", "Chroma",
  53                    CHILD_POLICY_EMPTY);
  54 
  55         values = new ArrayList();
  56         values.add("XYZ");
  57         values.add("Lab");
  58         values.add("Luv");
  59         values.add("YCbCr");
  60         values.add("Yxy");
  61         values.add("YCCK");
  62         values.add("PhotoYCC");
  63         values.add("RGB");
  64         values.add("GRAY");
  65         values.add("HSV");
  66         values.add("HLS");
  67         values.add("CMYK");
  68         values.add("CMY");
  69         values.add("2CLR");
  70         values.add("3CLR");
  71         values.add("4CLR");
  72         values.add("5CLR");
  73         values.add("6CLR");
  74         values.add("7CLR");
  75         values.add("8CLR");


 147         addElement("Lossless", "Compression", CHILD_POLICY_EMPTY);
 148         addBooleanAttribute("Lossless", "value", true, true);
 149 
 150         // root -> Compression -> NumProgressiveScans
 151         addSingleAttributeElement("NumProgressiveScans",
 152                                   "Compression",
 153                                   DATATYPE_INTEGER);
 154 
 155         // root -> Compression -> BitRate
 156         addSingleAttributeElement("BitRate",
 157                                   "Compression",
 158                                   DATATYPE_FLOAT);
 159 
 160         // root -> Data
 161         addElement("Data", standardMetadataFormatName,
 162                    CHILD_POLICY_SOME);
 163 
 164         // root -> Data -> PlanarConfiguration
 165         addElement("PlanarConfiguration", "Data", CHILD_POLICY_EMPTY);
 166 
 167         values = new ArrayList();
 168         values.add("PixelInterleaved");
 169         values.add("PlaneInterleaved");
 170         values.add("LineInterleaved");
 171         values.add("TileInterleaved");
 172         addAttribute("PlanarConfiguration", "value",
 173                      DATATYPE_STRING,
 174                      true,
 175                      null,
 176                      values);
 177 
 178         // root -> Data -> SampleFormat
 179         addElement("SampleFormat", "Data", CHILD_POLICY_EMPTY);
 180 
 181         values = new ArrayList();
 182         values.add("SignedIntegral");
 183         values.add("UnsignedIntegral");
 184         values.add("Real");
 185         values.add("Index");
 186         addAttribute("SampleFormat", "value",
 187                      DATATYPE_STRING,
 188                      true,
 189                      null,
 190                      values);
 191 
 192         // root -> Data -> BitsPerSample
 193         addElement("BitsPerSample", "Data",
 194                    CHILD_POLICY_EMPTY);
 195         addAttribute("BitsPerSample", "value",
 196                      DATATYPE_INTEGER,
 197                      true,
 198                      1, Integer.MAX_VALUE);
 199 
 200         // root -> Data -> SignificantBitsPerSample
 201         addElement("SignificantBitsPerSample", "Data", CHILD_POLICY_EMPTY);


 208         addElement("SampleMSB", "Data",
 209                    CHILD_POLICY_EMPTY);
 210         addAttribute("SampleMSB", "value",
 211                      DATATYPE_INTEGER,
 212                      true,
 213                      1, Integer.MAX_VALUE);
 214 
 215         // root -> Dimension
 216         addElement("Dimension", standardMetadataFormatName,
 217                    CHILD_POLICY_SOME);
 218 
 219         // root -> Dimension -> PixelAspectRatio
 220         addSingleAttributeElement("PixelAspectRatio",
 221                                   "Dimension",
 222                                   DATATYPE_FLOAT);
 223 
 224         // root -> Dimension -> ImageOrientation
 225         addElement("ImageOrientation", "Dimension",
 226                    CHILD_POLICY_EMPTY);
 227 
 228         values = new ArrayList();
 229         values.add("Normal");
 230         values.add("Rotate90");
 231         values.add("Rotate180");
 232         values.add("Rotate270");
 233         values.add("FlipH");
 234         values.add("FlipV");
 235         values.add("FlipHRotate90");
 236         values.add("FlipVRotate90");
 237         addAttribute("ImageOrientation", "value",
 238                      DATATYPE_STRING,
 239                      true,
 240                      null,
 241                      values);
 242 
 243         // root -> Dimension -> HorizontalPixelSize
 244         addSingleAttributeElement("HorizontalPixelSize",
 245                                   "Dimension",
 246                                   DATATYPE_FLOAT);
 247 
 248         // root -> Dimension -> VerticalPixelSize


 289         addSingleAttributeElement("VerticalScreenSize",
 290                                   "Dimension",
 291                                   DATATYPE_INTEGER);
 292 
 293 
 294         // root -> Document
 295         addElement("Document", standardMetadataFormatName,
 296                    CHILD_POLICY_SOME);
 297 
 298         // root -> Document -> FormatVersion
 299         addElement("FormatVersion", "Document",
 300                    CHILD_POLICY_EMPTY);
 301         addAttribute("FormatVersion", "value",
 302                      DATATYPE_STRING,
 303                      true,
 304                      null);
 305 
 306         // root -> Document -> SubimageInterpretation
 307         addElement("SubimageInterpretation", "Document",
 308                    CHILD_POLICY_EMPTY);
 309         values = new ArrayList();
 310         values.add("Standalone");
 311         values.add("SinglePage");
 312         values.add("FullResolution");
 313         values.add("ReducedResolution");
 314         values.add("PyramidLayer");
 315         values.add("Preview");
 316         values.add("VolumeSlice");
 317         values.add("ObjectView");
 318         values.add("Panorama");
 319         values.add("AnimationFrame");
 320         values.add("TransparencyMask");
 321         values.add("CompositingLayer");
 322         values.add("SpectralSlice");
 323         values.add("Unknown");
 324         addAttribute("SubimageInterpretation", "value",
 325                      DATATYPE_STRING,
 326                      true,
 327                      null,
 328                      values);
 329 


 401 
 402         // root -> Text -> TextEntry
 403         addElement("TextEntry", "Text", CHILD_POLICY_EMPTY);
 404         addAttribute("TextEntry", "keyword",
 405                      DATATYPE_STRING,
 406                      false,
 407                      null);
 408         addAttribute("TextEntry", "value",
 409                      DATATYPE_STRING,
 410                      true,
 411                      null);
 412         addAttribute("TextEntry", "language",
 413                      DATATYPE_STRING,
 414                      false,
 415                      null);
 416         addAttribute("TextEntry", "encoding",
 417                      DATATYPE_STRING,
 418                      false,
 419                      null);
 420 
 421         values = new ArrayList();
 422         values.add("none");
 423         values.add("lzw");
 424         values.add("zip");
 425         values.add("bzip");
 426         values.add("other");
 427         addAttribute("TextEntry", "compression",
 428                      DATATYPE_STRING,
 429                      false,
 430                      "none",
 431                      values);
 432 
 433         // root -> Transparency
 434         addElement("Transparency", standardMetadataFormatName,
 435                    CHILD_POLICY_SOME);
 436 
 437         // root -> Transparency -> Alpha
 438         addElement("Alpha", "Transparency", CHILD_POLICY_EMPTY);
 439 
 440         values = new ArrayList();
 441         values.add("none");
 442         values.add("premultiplied");
 443         values.add("nonpremultiplied");
 444         addAttribute("Alpha", "value",
 445                      DATATYPE_STRING,
 446                      false,
 447                      "none",
 448                      values);
 449 
 450         // root -> Transparency -> TransparentIndex
 451         addSingleAttributeElement("TransparentIndex", "Transparency",
 452                                   DATATYPE_INTEGER);
 453 
 454         // root -> Transparency -> TransparentColor
 455         addElement("TransparentColor", "Transparency",
 456                    CHILD_POLICY_EMPTY);
 457         addAttribute("TransparentColor", "value",
 458                      DATATYPE_INTEGER,
 459                      true,
 460                      0, Integer.MAX_VALUE);




  25 
  26 package com.sun.imageio.plugins.common;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 import javax.imageio.ImageTypeSpecifier;
  31 import javax.imageio.metadata.IIOMetadataFormatImpl;
  32 
  33 public class StandardMetadataFormat extends IIOMetadataFormatImpl {
  34 
  35     // Utility method for nodes with a single attribute named "value"
  36     private void addSingleAttributeElement(String elementName,
  37                                            String parentName,
  38                                            int dataType) {
  39         addElement(elementName, parentName, CHILD_POLICY_EMPTY);
  40         addAttribute(elementName, "value", dataType, true, null);
  41     }
  42 
  43     public StandardMetadataFormat() {
  44         super(standardMetadataFormatName, CHILD_POLICY_SOME);
  45         List<String> values;
  46 
  47         // root -> Chroma
  48         addElement("Chroma", standardMetadataFormatName,
  49                    CHILD_POLICY_SOME);
  50 
  51         // root -> Chroma -> ColorSpaceType
  52         addElement("ColorSpaceType", "Chroma",
  53                    CHILD_POLICY_EMPTY);
  54 
  55         values = new ArrayList<>();
  56         values.add("XYZ");
  57         values.add("Lab");
  58         values.add("Luv");
  59         values.add("YCbCr");
  60         values.add("Yxy");
  61         values.add("YCCK");
  62         values.add("PhotoYCC");
  63         values.add("RGB");
  64         values.add("GRAY");
  65         values.add("HSV");
  66         values.add("HLS");
  67         values.add("CMYK");
  68         values.add("CMY");
  69         values.add("2CLR");
  70         values.add("3CLR");
  71         values.add("4CLR");
  72         values.add("5CLR");
  73         values.add("6CLR");
  74         values.add("7CLR");
  75         values.add("8CLR");


 147         addElement("Lossless", "Compression", CHILD_POLICY_EMPTY);
 148         addBooleanAttribute("Lossless", "value", true, true);
 149 
 150         // root -> Compression -> NumProgressiveScans
 151         addSingleAttributeElement("NumProgressiveScans",
 152                                   "Compression",
 153                                   DATATYPE_INTEGER);
 154 
 155         // root -> Compression -> BitRate
 156         addSingleAttributeElement("BitRate",
 157                                   "Compression",
 158                                   DATATYPE_FLOAT);
 159 
 160         // root -> Data
 161         addElement("Data", standardMetadataFormatName,
 162                    CHILD_POLICY_SOME);
 163 
 164         // root -> Data -> PlanarConfiguration
 165         addElement("PlanarConfiguration", "Data", CHILD_POLICY_EMPTY);
 166 
 167         values = new ArrayList<>();
 168         values.add("PixelInterleaved");
 169         values.add("PlaneInterleaved");
 170         values.add("LineInterleaved");
 171         values.add("TileInterleaved");
 172         addAttribute("PlanarConfiguration", "value",
 173                      DATATYPE_STRING,
 174                      true,
 175                      null,
 176                      values);
 177 
 178         // root -> Data -> SampleFormat
 179         addElement("SampleFormat", "Data", CHILD_POLICY_EMPTY);
 180 
 181         values = new ArrayList<>();
 182         values.add("SignedIntegral");
 183         values.add("UnsignedIntegral");
 184         values.add("Real");
 185         values.add("Index");
 186         addAttribute("SampleFormat", "value",
 187                      DATATYPE_STRING,
 188                      true,
 189                      null,
 190                      values);
 191 
 192         // root -> Data -> BitsPerSample
 193         addElement("BitsPerSample", "Data",
 194                    CHILD_POLICY_EMPTY);
 195         addAttribute("BitsPerSample", "value",
 196                      DATATYPE_INTEGER,
 197                      true,
 198                      1, Integer.MAX_VALUE);
 199 
 200         // root -> Data -> SignificantBitsPerSample
 201         addElement("SignificantBitsPerSample", "Data", CHILD_POLICY_EMPTY);


 208         addElement("SampleMSB", "Data",
 209                    CHILD_POLICY_EMPTY);
 210         addAttribute("SampleMSB", "value",
 211                      DATATYPE_INTEGER,
 212                      true,
 213                      1, Integer.MAX_VALUE);
 214 
 215         // root -> Dimension
 216         addElement("Dimension", standardMetadataFormatName,
 217                    CHILD_POLICY_SOME);
 218 
 219         // root -> Dimension -> PixelAspectRatio
 220         addSingleAttributeElement("PixelAspectRatio",
 221                                   "Dimension",
 222                                   DATATYPE_FLOAT);
 223 
 224         // root -> Dimension -> ImageOrientation
 225         addElement("ImageOrientation", "Dimension",
 226                    CHILD_POLICY_EMPTY);
 227 
 228         values = new ArrayList<>();
 229         values.add("Normal");
 230         values.add("Rotate90");
 231         values.add("Rotate180");
 232         values.add("Rotate270");
 233         values.add("FlipH");
 234         values.add("FlipV");
 235         values.add("FlipHRotate90");
 236         values.add("FlipVRotate90");
 237         addAttribute("ImageOrientation", "value",
 238                      DATATYPE_STRING,
 239                      true,
 240                      null,
 241                      values);
 242 
 243         // root -> Dimension -> HorizontalPixelSize
 244         addSingleAttributeElement("HorizontalPixelSize",
 245                                   "Dimension",
 246                                   DATATYPE_FLOAT);
 247 
 248         // root -> Dimension -> VerticalPixelSize


 289         addSingleAttributeElement("VerticalScreenSize",
 290                                   "Dimension",
 291                                   DATATYPE_INTEGER);
 292 
 293 
 294         // root -> Document
 295         addElement("Document", standardMetadataFormatName,
 296                    CHILD_POLICY_SOME);
 297 
 298         // root -> Document -> FormatVersion
 299         addElement("FormatVersion", "Document",
 300                    CHILD_POLICY_EMPTY);
 301         addAttribute("FormatVersion", "value",
 302                      DATATYPE_STRING,
 303                      true,
 304                      null);
 305 
 306         // root -> Document -> SubimageInterpretation
 307         addElement("SubimageInterpretation", "Document",
 308                    CHILD_POLICY_EMPTY);
 309         values = new ArrayList<>();
 310         values.add("Standalone");
 311         values.add("SinglePage");
 312         values.add("FullResolution");
 313         values.add("ReducedResolution");
 314         values.add("PyramidLayer");
 315         values.add("Preview");
 316         values.add("VolumeSlice");
 317         values.add("ObjectView");
 318         values.add("Panorama");
 319         values.add("AnimationFrame");
 320         values.add("TransparencyMask");
 321         values.add("CompositingLayer");
 322         values.add("SpectralSlice");
 323         values.add("Unknown");
 324         addAttribute("SubimageInterpretation", "value",
 325                      DATATYPE_STRING,
 326                      true,
 327                      null,
 328                      values);
 329 


 401 
 402         // root -> Text -> TextEntry
 403         addElement("TextEntry", "Text", CHILD_POLICY_EMPTY);
 404         addAttribute("TextEntry", "keyword",
 405                      DATATYPE_STRING,
 406                      false,
 407                      null);
 408         addAttribute("TextEntry", "value",
 409                      DATATYPE_STRING,
 410                      true,
 411                      null);
 412         addAttribute("TextEntry", "language",
 413                      DATATYPE_STRING,
 414                      false,
 415                      null);
 416         addAttribute("TextEntry", "encoding",
 417                      DATATYPE_STRING,
 418                      false,
 419                      null);
 420 
 421         values = new ArrayList<>();
 422         values.add("none");
 423         values.add("lzw");
 424         values.add("zip");
 425         values.add("bzip");
 426         values.add("other");
 427         addAttribute("TextEntry", "compression",
 428                      DATATYPE_STRING,
 429                      false,
 430                      "none",
 431                      values);
 432 
 433         // root -> Transparency
 434         addElement("Transparency", standardMetadataFormatName,
 435                    CHILD_POLICY_SOME);
 436 
 437         // root -> Transparency -> Alpha
 438         addElement("Alpha", "Transparency", CHILD_POLICY_EMPTY);
 439 
 440         values = new ArrayList<>();
 441         values.add("none");
 442         values.add("premultiplied");
 443         values.add("nonpremultiplied");
 444         addAttribute("Alpha", "value",
 445                      DATATYPE_STRING,
 446                      false,
 447                      "none",
 448                      values);
 449 
 450         // root -> Transparency -> TransparentIndex
 451         addSingleAttributeElement("TransparentIndex", "Transparency",
 452                                   DATATYPE_INTEGER);
 453 
 454         // root -> Transparency -> TransparentColor
 455         addElement("TransparentColor", "Transparency",
 456                    CHILD_POLICY_EMPTY);
 457         addAttribute("TransparentColor", "value",
 458                      DATATYPE_INTEGER,
 459                      true,
 460                      0, Integer.MAX_VALUE);