< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadataFormat.java

Print this page




 116         addAttribute("unknown",
 117                      "MarkerTag",
 118                      DATATYPE_INTEGER,
 119                      true,
 120                      null,
 121                      "0", "255",
 122                      true, true);
 123         addObjectValue("unknown", byte[].class, 1, MAX_JPEG_DATA_SIZE);
 124     }
 125 
 126     public boolean canNodeAppear(String elementName,
 127                                  ImageTypeSpecifier imageType) {
 128         // Just check if it appears in the format
 129         if (isInSubtree(elementName, getRootName())){
 130             return true;
 131         }
 132         return false;
 133     }
 134 
 135     /**
 136      * Returns <code>true</code> if the named element occurs in the
 137      * subtree of the format starting with the node named by
 138      * <code>subtreeName</code>, including the node
 139      * itself.  <code>subtreeName</code> may be any node in
 140      * the format.  If it is not, an
 141      * <code>IllegalArgumentException</code> is thrown.
 142      */
 143     protected boolean isInSubtree(String elementName,
 144                                   String subtreeName) {
 145         if (elementName.equals(subtreeName)) {
 146             return true;
 147         }
 148         String [] children = getChildNames(elementName);
 149         for (int i=0; i < children.length; i++) {
 150             if (isInSubtree(elementName, children[i])) {
 151                 return true;
 152             }
 153         }
 154         return false;
 155     }
 156 
 157 }


 116         addAttribute("unknown",
 117                      "MarkerTag",
 118                      DATATYPE_INTEGER,
 119                      true,
 120                      null,
 121                      "0", "255",
 122                      true, true);
 123         addObjectValue("unknown", byte[].class, 1, MAX_JPEG_DATA_SIZE);
 124     }
 125 
 126     public boolean canNodeAppear(String elementName,
 127                                  ImageTypeSpecifier imageType) {
 128         // Just check if it appears in the format
 129         if (isInSubtree(elementName, getRootName())){
 130             return true;
 131         }
 132         return false;
 133     }
 134 
 135     /**
 136      * Returns {@code true} if the named element occurs in the
 137      * subtree of the format starting with the node named by
 138      * {@code subtreeName}, including the node
 139      * itself.  {@code subtreeName} may be any node in
 140      * the format.  If it is not, an
 141      * {@code IllegalArgumentException} is thrown.
 142      */
 143     protected boolean isInSubtree(String elementName,
 144                                   String subtreeName) {
 145         if (elementName.equals(subtreeName)) {
 146             return true;
 147         }
 148         String [] children = getChildNames(elementName);
 149         for (int i=0; i < children.length; i++) {
 150             if (isInSubtree(elementName, children[i])) {
 151                 return true;
 152             }
 153         }
 154         return false;
 155     }
 156 
 157 }
< prev index next >