Java 类javax.imageio.metadata.IIOMetadataFormat 实例源码

项目:jdk8u-jdk    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:jdk8u-jdk    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:openjdk-jdk10    文件:ImageReaderWriterSpi.java   
private Class<?> getMetadataFormatClass(String formatClassName) {
    Module thisModule = ImageReaderWriterSpi.class.getModule();
    Module targetModule = this.getClass().getModule();
    Class<?> c = null;
    try {
        ClassLoader cl = this.getClass().getClassLoader();
        c = Class.forName(formatClassName, false, cl);
        if (!IIOMetadataFormat.class.isAssignableFrom(c)) {
            return null;
        }
    } catch (ClassNotFoundException e) {
    }
    if (thisModule.equals(targetModule) || c == null) {
        return c;
    }
    if (targetModule.isNamed()) {
        int i = formatClassName.lastIndexOf(".");
        String pn = i > 0 ? formatClassName.substring(0, i) : "";
        if (!targetModule.isExported(pn, thisModule)) {
            throw new IllegalStateException("Class " +  formatClassName +
              " in named module must be exported to java.desktop module.");
        }
    }
    return c;
}
项目:openjdk-jdk10    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:openjdk-jdk10    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:openjdk9    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:openjdk9    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:jdk8u_jdk    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:jdk8u_jdk    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:lookaside_java-1.8.0-openjdk    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:infobip-open-jdk-8    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:infobip-open-jdk-8    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:jdk8u-dev-jdk    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:jdk8u-dev-jdk    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:OLD-OpenJDK8    文件:RemoveElement.java   
public static void main(String[] args) {
    String elem = "elem2";
    int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
    MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
    fmt.addElement("elem1", "root", policy);
    fmt.addElement(elem, "root", policy);
    fmt.removeElement("elem1");

    boolean gotIAE = false;
    try {
        fmt.getChildPolicy("elem1");
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException("Element is still present!");
    }
    String[] chNames = fmt.getChildNames("root");
    if (chNames.length != 1) {
        throw new RuntimeException("Root still has more than 1 child!");
    }
    if (!elem.equals(chNames[0])) {
        throw new RuntimeException("Root's remaining child is incorrect!");
    }
}
项目:OLD-OpenJDK8    文件:IIOMetadataFormatImplTest.java   
public IIOMetadataFormatImpl440335x() {
    super("rootNode", 0, 1);
    addElement("anElement", "rootNode", 20, 200);
    addAttribute("anElement", "exclusiveAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "50", "500",
                 false, false);
    addAttribute("anElement", "minAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "60", "600",
                 true, false);
    addAttribute("anElement", "maxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "70", "700",
                 false, true);
    addAttribute("anElement", "minMaxAttr",
                 IIOMetadataFormat.DATATYPE_INTEGER,
                 true, null,
                 "80", "800",
                 true, true);
}
项目:OpenJSharp    文件:ImageReaderWriterSpi.java   
private IIOMetadataFormat getMetadataFormat(String formatName,
                                            boolean supportsStandard,
                                            String nativeName,
                                            String nativeClassName,
                                            String [] extraNames,
                                            String [] extraClassNames) {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (supportsStandard && formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {

        return IIOMetadataFormatImpl.getStandardFormatInstance();
    }
    String formatClassName = null;
    if (formatName.equals(nativeName)) {
        formatClassName = nativeClassName;
    } else if (extraNames != null) {
        for (int i = 0; i < extraNames.length; i++) {
            if (formatName.equals(extraNames[i])) {
                formatClassName = extraClassNames[i];
                break;  // out of for
            }
        }
    }
    if (formatClassName == null) {
        throw new IllegalArgumentException("Unsupported format name");
    }
    try {
        Class cls = Class.forName(formatClassName, true,
                                  ClassLoader.getSystemClassLoader());
        Method meth = cls.getMethod("getInstance");
        return (IIOMetadataFormat) meth.invoke(null);
    } catch (Exception e) {
        RuntimeException ex =
            new IllegalStateException ("Can't obtain format");
        ex.initCause(e);
        throw ex;
    }
}
项目:jdk8u-jdk    文件:ImageReaderWriterSpi.java   
private IIOMetadataFormat getMetadataFormat(String formatName,
                                            boolean supportsStandard,
                                            String nativeName,
                                            String nativeClassName,
                                            String [] extraNames,
                                            String [] extraClassNames) {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (supportsStandard && formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {

        return IIOMetadataFormatImpl.getStandardFormatInstance();
    }
    String formatClassName = null;
    if (formatName.equals(nativeName)) {
        formatClassName = nativeClassName;
    } else if (extraNames != null) {
        for (int i = 0; i < extraNames.length; i++) {
            if (formatName.equals(extraNames[i])) {
                formatClassName = extraClassNames[i];
                break;  // out of for
            }
        }
    }
    if (formatClassName == null) {
        throw new IllegalArgumentException("Unsupported format name");
    }
    try {
        Class cls = Class.forName(formatClassName, true,
                                  ClassLoader.getSystemClassLoader());
        Method meth = cls.getMethod("getInstance");
        return (IIOMetadataFormat) meth.invoke(null);
    } catch (Exception e) {
        RuntimeException ex =
            new IllegalStateException ("Can't obtain format");
        ex.initCause(e);
        throw ex;
    }
}
项目:jdk8u-jdk    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format) {
    String rootName = format.getRootName();
    println("<!DOCTYPE \"" +
                       rootName +
                       "\" [");
    ++indentLevel;
    print(format, rootName);
    --indentLevel;
    print("]>");
    println();
    println();
}
项目:jdk8u-jdk    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format,
                   String elementName) {
    // Don't print elements more than once
    if (printedElements.contains(elementName)) {
        return;
    }
    printedElements.add(elementName);

    // Add the unscheduled children of this node to a list,
    // and mark them as scheduled
    List children = new ArrayList();
    String[] childNames = format.getChildNames(elementName);
    if (childNames != null) {
        for (int i = 0; i < childNames.length; i++) {
            String childName = childNames[i];
            if (!scheduledElements.contains(childName)) {
                children.add(childName);
                scheduledElements.add(childName);
            }
        }
    }

    printElementInfo(format, elementName);
    printObjectInfo(format, elementName);

    ++indentLevel;
    String[] attrNames = format.getAttributeNames(elementName);
    for (int i = 0; i < attrNames.length; i++) {
        printAttributeInfo(format, elementName, attrNames[i]);
    }

    // Recurse on child nodes
    Iterator iter = children.iterator();
    while (iter.hasNext()) {
        print(format, (String)iter.next());
    }
    --indentLevel;
}
项目:jdk8u-jdk    文件:RegisteredFormatsTest.java   
private static void testMetadataFormat(IIOMetadataFormat fmt,
                                       String fmt_name) {
    System.out.print(fmt_name + "...");
    if (fmt != null) {
        fmts.put(fmt_name, Boolean.TRUE);
        System.out.println("Ok");
    } else {
        throw new RuntimeException("Test failed for " + fmt_name);
    }
}
项目:jdk8u-jdk    文件:ObjectArrayMaxLength.java   
public static void main(String[] args) {
    IIOMetadataFormat f = new MyIIOMetadataFormatImpl();
    if (f.getObjectArrayMaxLength("root") != 321) {
        throw new RuntimeException
            ("Bad value for getObjectArrayMaxLength!");
    }
}
项目:openjdk-jdk10    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format) {
    String rootName = format.getRootName();
    println("<!DOCTYPE \"" +
                       rootName +
                       "\" [");
    ++indentLevel;
    print(format, rootName);
    --indentLevel;
    print("]>");
    println();
    println();
}
项目:openjdk-jdk10    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format,
                   String elementName) {
    // Don't print elements more than once
    if (printedElements.contains(elementName)) {
        return;
    }
    printedElements.add(elementName);

    // Add the unscheduled children of this node to a list,
    // and mark them as scheduled
    List children = new ArrayList();
    String[] childNames = format.getChildNames(elementName);
    if (childNames != null) {
        for (int i = 0; i < childNames.length; i++) {
            String childName = childNames[i];
            if (!scheduledElements.contains(childName)) {
                children.add(childName);
                scheduledElements.add(childName);
            }
        }
    }

    printElementInfo(format, elementName);
    printObjectInfo(format, elementName);

    ++indentLevel;
    String[] attrNames = format.getAttributeNames(elementName);
    for (int i = 0; i < attrNames.length; i++) {
        printAttributeInfo(format, elementName, attrNames[i]);
    }

    // Recurse on child nodes
    Iterator iter = children.iterator();
    while (iter.hasNext()) {
        print(format, (String)iter.next());
    }
    --indentLevel;
}
项目:openjdk-jdk10    文件:RegisteredFormatsTest.java   
private static void testMetadataFormat(IIOMetadataFormat fmt,
                                       String fmt_name) {
    System.out.print(fmt_name + "...");
    if (fmt != null) {
        fmts.put(fmt_name, Boolean.TRUE);
        System.out.println("Ok");
    } else {
        throw new RuntimeException("Test failed for " + fmt_name);
    }
}
项目:openjdk-jdk10    文件:ObjectArrayMaxLength.java   
public static void main(String[] args) {
    IIOMetadataFormat f = new MyIIOMetadataFormatImpl();
    if (f.getObjectArrayMaxLength("root") != 321) {
        throw new RuntimeException
            ("Bad value for getObjectArrayMaxLength!");
    }
}
项目:openjdk-jdk10    文件:TestSIMPPlugin.java   
public static void main(String args[]) throws Exception {
    Iterator<ImageReader> readers = ImageIO.getImageReadersBySuffix("simp");
    ImageReader simpReader = null;
    if (readers.hasNext()) {
        simpReader = readers.next();
        System.out.println("reader="+simpReader);
    }
    if (simpReader == null) {
        throw new RuntimeException("Reader not found.");
    }

    ImageReaderSpi spi = simpReader.getOriginatingProvider();
    IIOMetadataFormat spiFmt =
        spi.getImageMetadataFormat("simp_metadata_1.0");
    System.out.println("fmt from SPI=" + spiFmt);

    ByteArrayInputStream bais = new ByteArrayInputStream(simpData);
    ImageInputStream iis = new MemoryCacheImageInputStream(bais);
    simpReader.setInput(iis);
    BufferedImage bi = simpReader.read(0);
    System.out.println(bi);
    IIOMetadata metadata = simpReader.getImageMetadata(0);
    System.out.println("Image metadata="+metadata);
    IIOMetadataFormat format =
        metadata.getMetadataFormat("simp_metadata_1.0");
    System.out.println("Image metadata format="+format);
    if (format == null) {
        throw new RuntimeException("MetadataFormat not found.");
    }
}
项目:openjdk9    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format) {
    String rootName = format.getRootName();
    println("<!DOCTYPE \"" +
                       rootName +
                       "\" [");
    ++indentLevel;
    print(format, rootName);
    --indentLevel;
    print("]>");
    println();
    println();
}
项目:openjdk9    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format,
                   String elementName) {
    // Don't print elements more than once
    if (printedElements.contains(elementName)) {
        return;
    }
    printedElements.add(elementName);

    // Add the unscheduled children of this node to a list,
    // and mark them as scheduled
    List children = new ArrayList();
    String[] childNames = format.getChildNames(elementName);
    if (childNames != null) {
        for (int i = 0; i < childNames.length; i++) {
            String childName = childNames[i];
            if (!scheduledElements.contains(childName)) {
                children.add(childName);
                scheduledElements.add(childName);
            }
        }
    }

    printElementInfo(format, elementName);
    printObjectInfo(format, elementName);

    ++indentLevel;
    String[] attrNames = format.getAttributeNames(elementName);
    for (int i = 0; i < attrNames.length; i++) {
        printAttributeInfo(format, elementName, attrNames[i]);
    }

    // Recurse on child nodes
    Iterator iter = children.iterator();
    while (iter.hasNext()) {
        print(format, (String)iter.next());
    }
    --indentLevel;
}
项目:openjdk9    文件:RegisteredFormatsTest.java   
private static void testMetadataFormat(IIOMetadataFormat fmt,
                                       String fmt_name) {
    System.out.print(fmt_name + "...");
    if (fmt != null) {
        fmts.put(fmt_name, Boolean.TRUE);
        System.out.println("Ok");
    } else {
        throw new RuntimeException("Test failed for " + fmt_name);
    }
}
项目:openjdk9    文件:ObjectArrayMaxLength.java   
public static void main(String[] args) {
    IIOMetadataFormat f = new MyIIOMetadataFormatImpl();
    if (f.getObjectArrayMaxLength("root") != 321) {
        throw new RuntimeException
            ("Bad value for getObjectArrayMaxLength!");
    }
}
项目:openjdk9    文件:TestSIMPPlugin.java   
public static void main(String args[]) throws Exception {
    Iterator<ImageReader> readers = ImageIO.getImageReadersBySuffix("simp");
    ImageReader simpReader = null;
    if (readers.hasNext()) {
        simpReader = readers.next();
        System.out.println("reader="+simpReader);
    }
    if (simpReader == null) {
        throw new RuntimeException("Reader not found.");
    }

    ImageReaderSpi spi = simpReader.getOriginatingProvider();
    IIOMetadataFormat spiFmt =
        spi.getImageMetadataFormat("simp_metadata_1.0");
    System.out.println("fmt from SPI=" + spiFmt);

    ByteArrayInputStream bais = new ByteArrayInputStream(simpData);
    ImageInputStream iis = new MemoryCacheImageInputStream(bais);
    simpReader.setInput(iis);
    BufferedImage bi = simpReader.read(0);
    System.out.println(bi);
    IIOMetadata metadata = simpReader.getImageMetadata(0);
    System.out.println("Image metadata="+metadata);
    IIOMetadataFormat format =
        metadata.getMetadataFormat("simp_metadata_1.0");
    System.out.println("Image metadata format="+format);
    if (format == null) {
        throw new RuntimeException("MetadataFormat not found.");
    }
}
项目:Java8CN    文件:ImageReaderWriterSpi.java   
private IIOMetadataFormat getMetadataFormat(String formatName,
                                            boolean supportsStandard,
                                            String nativeName,
                                            String nativeClassName,
                                            String [] extraNames,
                                            String [] extraClassNames) {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (supportsStandard && formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {

        return IIOMetadataFormatImpl.getStandardFormatInstance();
    }
    String formatClassName = null;
    if (formatName.equals(nativeName)) {
        formatClassName = nativeClassName;
    } else if (extraNames != null) {
        for (int i = 0; i < extraNames.length; i++) {
            if (formatName.equals(extraNames[i])) {
                formatClassName = extraClassNames[i];
                break;  // out of for
            }
        }
    }
    if (formatClassName == null) {
        throw new IllegalArgumentException("Unsupported format name");
    }
    try {
        Class cls = Class.forName(formatClassName, true,
                                  ClassLoader.getSystemClassLoader());
        Method meth = cls.getMethod("getInstance");
        return (IIOMetadataFormat) meth.invoke(null);
    } catch (Exception e) {
        RuntimeException ex =
            new IllegalStateException ("Can't obtain format");
        ex.initCause(e);
        throw ex;
    }
}
项目:jdk8u_jdk    文件:ImageReaderWriterSpi.java   
private IIOMetadataFormat getMetadataFormat(String formatName,
                                            boolean supportsStandard,
                                            String nativeName,
                                            String nativeClassName,
                                            String [] extraNames,
                                            String [] extraClassNames) {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (supportsStandard && formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {

        return IIOMetadataFormatImpl.getStandardFormatInstance();
    }
    String formatClassName = null;
    if (formatName.equals(nativeName)) {
        formatClassName = nativeClassName;
    } else if (extraNames != null) {
        for (int i = 0; i < extraNames.length; i++) {
            if (formatName.equals(extraNames[i])) {
                formatClassName = extraClassNames[i];
                break;  // out of for
            }
        }
    }
    if (formatClassName == null) {
        throw new IllegalArgumentException("Unsupported format name");
    }
    try {
        Class cls = Class.forName(formatClassName, true,
                                  ClassLoader.getSystemClassLoader());
        Method meth = cls.getMethod("getInstance");
        return (IIOMetadataFormat) meth.invoke(null);
    } catch (Exception e) {
        RuntimeException ex =
            new IllegalStateException ("Can't obtain format");
        ex.initCause(e);
        throw ex;
    }
}
项目:jdk8u_jdk    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format) {
    String rootName = format.getRootName();
    println("<!DOCTYPE \"" +
                       rootName +
                       "\" [");
    ++indentLevel;
    print(format, rootName);
    --indentLevel;
    print("]>");
    println();
    println();
}
项目:jdk8u_jdk    文件:MetadataFormatPrinter.java   
private void print(IIOMetadataFormat format,
                   String elementName) {
    // Don't print elements more than once
    if (printedElements.contains(elementName)) {
        return;
    }
    printedElements.add(elementName);

    // Add the unscheduled children of this node to a list,
    // and mark them as scheduled
    List children = new ArrayList();
    String[] childNames = format.getChildNames(elementName);
    if (childNames != null) {
        for (int i = 0; i < childNames.length; i++) {
            String childName = childNames[i];
            if (!scheduledElements.contains(childName)) {
                children.add(childName);
                scheduledElements.add(childName);
            }
        }
    }

    printElementInfo(format, elementName);
    printObjectInfo(format, elementName);

    ++indentLevel;
    String[] attrNames = format.getAttributeNames(elementName);
    for (int i = 0; i < attrNames.length; i++) {
        printAttributeInfo(format, elementName, attrNames[i]);
    }

    // Recurse on child nodes
    Iterator iter = children.iterator();
    while (iter.hasNext()) {
        print(format, (String)iter.next());
    }
    --indentLevel;
}
项目:jdk8u_jdk    文件:RegisteredFormatsTest.java   
private static void testMetadataFormat(IIOMetadataFormat fmt,
                                       String fmt_name) {
    System.out.print(fmt_name + "...");
    if (fmt != null) {
        fmts.put(fmt_name, Boolean.TRUE);
        System.out.println("Ok");
    } else {
        throw new RuntimeException("Test failed for " + fmt_name);
    }
}
项目:jdk8u_jdk    文件:ObjectArrayMaxLength.java   
public static void main(String[] args) {
    IIOMetadataFormat f = new MyIIOMetadataFormatImpl();
    if (f.getObjectArrayMaxLength("root") != 321) {
        throw new RuntimeException
            ("Bad value for getObjectArrayMaxLength!");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ImageReaderWriterSpi.java   
private IIOMetadataFormat getMetadataFormat(String formatName,
                                            boolean supportsStandard,
                                            String nativeName,
                                            String nativeClassName,
                                            String [] extraNames,
                                            String [] extraClassNames) {
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    if (supportsStandard && formatName.equals
            (IIOMetadataFormatImpl.standardMetadataFormatName)) {

        return IIOMetadataFormatImpl.getStandardFormatInstance();
    }
    String formatClassName = null;
    if (formatName.equals(nativeName)) {
        formatClassName = nativeClassName;
    } else if (extraNames != null) {
        for (int i = 0; i < extraNames.length; i++) {
            if (formatName.equals(extraNames[i])) {
                formatClassName = extraClassNames[i];
                break;  // out of for
            }
        }
    }
    if (formatClassName == null) {
        throw new IllegalArgumentException("Unsupported format name");
    }
    try {
        Class cls = Class.forName(formatClassName, true,
                                  ClassLoader.getSystemClassLoader());
        Method meth = cls.getMethod("getInstance");
        return (IIOMetadataFormat) meth.invoke(null);
    } catch (Exception e) {
        RuntimeException ex =
            new IllegalStateException ("Can't obtain format");
        ex.initCause(e);
        throw ex;
    }
}