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

The following examples show how to use javax.imageio.metadata.IIOMetadataFormat#CHILD_POLICY_SOME . 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: RemoveElement.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 2
Source File: RemoveElement.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 3
Source File: RemoveElement.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 4
Source File: RemoveElement.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 5
Source File: RemoveElement.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 6
Source File: RemoveElement.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 7
Source File: RemoveElement.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 8
Source File: RemoveElement.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 9
Source File: RemoveElement.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 10
Source File: RemoveElement.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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!");
    }
}
 
Example 11
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 12
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 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 +
                    " -->");
        }
    }
}
 
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 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 16
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 17
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 18
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 19
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 20
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 +
                    " -->");
        }
    }
}