Java Code Examples for javax.imageio.metadata.IIOMetadataFormat#getElementMaxChildren()

The following examples show how to use javax.imageio.metadata.IIOMetadataFormat#getElementMaxChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataFormatPrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 2
Source File: IIOMetadataFormatImplTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 3
Source File: MetadataFormatPrinter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 4
Source File: IIOMetadataFormatImplTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 5
Source File: MetadataFormatPrinter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 6
Source File: IIOMetadataFormatImplTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 7
Source File: MetadataFormatPrinter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 8
Source File: MetadataFormatPrinter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 9
Source File: MetadataFormatPrinter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 10
Source File: IIOMetadataFormatImplTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 11
Source File: MetadataFormatPrinter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 12
Source File: IIOMetadataFormatImplTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 13
Source File: MetadataFormatPrinter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 14
Source File: MetadataFormatPrinter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 15
Source File: MetadataFormatPrinter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 16
Source File: IIOMetadataFormatImplTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 17
Source File: MetadataFormatPrinter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 18
Source File: IIOMetadataFormatImplTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}
 
Example 19
Source File: MetadataFormatPrinter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void printElementInfo(IIOMetadataFormat format,
                              String elementName) {
    println();
    indent();
    print("<!ELEMENT \"" +
          elementName +
          "\"");

    String[] childNames = format.getChildNames(elementName);
    boolean hasChildren = true;
    String separator = " "; // symbol to place between children
    String terminator = ""; // symbol to follow last child
    String repeater = ""; // "*" if repeating

    switch (format.getChildPolicy(elementName)) {
    case IIOMetadataFormat.CHILD_POLICY_EMPTY:
        hasChildren = false;
        break;
    case IIOMetadataFormat.CHILD_POLICY_ALL:
        separator = ", ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SOME:
        separator = "?, ";
        terminator = "?";
        break;
    case IIOMetadataFormat.CHILD_POLICY_CHOICE:
        separator = " | ";
        break;
    case IIOMetadataFormat.CHILD_POLICY_SEQUENCE:
        separator = " | ";
        repeater = "*";
        break;
    case IIOMetadataFormat.CHILD_POLICY_REPEAT:
        repeater = "*";
        break;
    default:
        break;
    }

    if (hasChildren) {
        print(" (");
        for (int i = 0; i < childNames.length - 1; i++) {
            print(childNames[i] + separator);
        }
        print(childNames[childNames.length - 1] + terminator);
        print(")" + repeater + ">");
    } else {
        print(" EMPTY>");
    }
    println();

    String description = format.getElementDescription(elementName, null);
    if (description != null) {
        ++indentLevel;
        indent();
        printWrapped("<!-- " + description + " -->", 5);
        println();
        --indentLevel;
    }
    if (format.getChildPolicy(elementName) ==
        IIOMetadataFormat.CHILD_POLICY_REPEAT) {
        int minChildren = format.getElementMinChildren(elementName);
        if (minChildren != 0) {
            indent();
            println("  <!-- Min children: " +
                    minChildren +
                    " -->");
        }
        int maxChildren = format.getElementMaxChildren(elementName);
        if (maxChildren != Integer.MAX_VALUE) {
            indent();
            println("  <!-- Max children: " +
                    maxChildren +
                    " -->");
        }
    }
}
 
Example 20
Source File: IIOMetadataFormatImplTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test440335x() {
    IIOMetadataFormat format = new IIOMetadataFormatImpl440335x();

    // Check that correct value is returned
    if (format.getElementMinChildren("anElement") != 20) {
        throw new RuntimeException("Error on getElementMinChildren!");
    }
    if (format.getElementMaxChildren("anElement") != 200) {
        throw new RuntimeException("Error on getElementMaxChildren!");
    }

    // Check that correct value is returned and no exception is thrown
    try {
        if (!format.getAttributeMinValue("anElement",
                                         "exclusiveAttr").equals("50")) {
            throw new RuntimeException("Error on exclusiveAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "exclusiveAttr").equals("500")) {
            throw new RuntimeException("Error on exclusiveAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minAttr").equals("60")) {
            throw new RuntimeException("Error on minAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minAttr").equals("600")) {
            throw new RuntimeException("Error on minAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "maxAttr").equals("70")) {
            throw new RuntimeException("Error on maxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "maxAttr").equals("700")) {
            throw new RuntimeException("Error on maxAttr max!");
        }
        if (!format.getAttributeMinValue("anElement",
                                         "minMaxAttr").equals("80")) {
            throw new RuntimeException("Error on minMaxAttr min!");
        }
        if (!format.getAttributeMaxValue("anElement",
                                         "minMaxAttr").equals("800")) {
            throw new RuntimeException("Error on minMaxAttr max!");
        }
    } catch (IllegalStateException e) {
        throw new RuntimeException("Got IllegalStateException!");
    }
}