Java Code Examples for javax.imageio.metadata.IIOMetadataFormat#CHILD_POLICY_CHOICE

The following examples show how to use javax.imageio.metadata.IIOMetadataFormat#CHILD_POLICY_CHOICE . 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 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 2
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 3
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 4
Source File: MetadataFormatPrinter.java    From openjdk-jdk8u 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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 +
                    " -->");
        }
    }
}