Java Code Examples for javax.management.openmbean.ArrayType#getArrayType()

The following examples show how to use javax.management.openmbean.ArrayType#getArrayType() . 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: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 2
Source File: DefaultMXBeanMappingFactory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 3
Source File: DefaultMXBeanMappingFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 4
Source File: DefaultMXBeanMappingFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 5
Source File: TypeConverters.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public OpenType<?> getOpenType() {
    try {
        return ArrayType.getArrayType(getConverter(valueTypeNode, null).getOpenType());
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
 
Example 6
Source File: DefaultMXBeanMappingFactory.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 7
Source File: DefaultMXBeanMappingFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 8
Source File: DefaultMXBeanMappingFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 9
Source File: DefaultMXBeanMappingFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 10
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 11
Source File: DefaultMXBeanMappingFactory.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
 
Example 12
Source File: CompositeDataStringTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 13
Source File: CompositeDataStringTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 14
Source File: StreamServiceTest.java    From cassandra-reaper with Apache License 2.0 4 votes vote down vote up
private CompositeType makeSessionsType4_0() throws OpenDataException {
  String typeName = "org.apache.cassandra.streaming.SessionInfo";
  String description = "SessionInfo";
  String[] itemNames = {
      "connecting",
      "connecting_port",
      "peer",
      "peer_port",
      "planId",
      "receivingFiles",
      "receivingSummaries",
      "sendingFiles",
      "sendingSummaries",
      "sessionIndex",
      "state"
  };
  String[] itemDescriptions = {
      "connecting",
      "connecting_port",
      "peer",
      "peer_port",
      "planId",
      "receivingFiles",
      "receivingSummaries",
      "sendingFiles",
      "sendingSummaries",
      "sessionIndex",
      "state"
  };
  OpenType[] itemTypes = {
      SimpleType.STRING,
      SimpleType.INTEGER,
      SimpleType.STRING,
      SimpleType.INTEGER,
      SimpleType.STRING,
      ArrayType.getArrayType(makeFilesType_4_0_0()),
      ArrayType.getArrayType(makeSummariesType_4_0_0()),
      ArrayType.getArrayType(makeFilesType_4_0_0()),
      ArrayType.getArrayType(makeSummariesType_4_0_0()),
      SimpleType.INTEGER,
      SimpleType.STRING,
  };

  return new CompositeType(typeName, description, itemNames, itemDescriptions, itemTypes);
}
 
Example 15
Source File: CompositeDataStringTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 16
Source File: CompositeDataStringTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 17
Source File: CompositeDataStringTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 18
Source File: CompositeDataStringTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 19
Source File: CompositeDataStringTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
 
Example 20
Source File: CompositeDataStringTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType(
            "basicCT", "basic CompositeType",
            new String[] {"name", "value"},
            new String[] {"name", "value"},
            new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
    CompositeType ct = new CompositeType(
            "noddy", "descr",
            new String[] {"strings", "ints", "cds"},
            new String[] {"string array", "int array", "composite data array"},
            new OpenType<?>[] {
                ArrayType.getArrayType(SimpleType.STRING),
                ArrayType.getPrimitiveArrayType(int[].class),
                ArrayType.getArrayType(basicCT)
            });
    CompositeData basicCD1 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
    CompositeData basicCD2 = new CompositeDataSupport(
            basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
    CompositeData cd = new CompositeDataSupport(
            ct,
            new String[] {"strings", "ints", "cds"},
            new Object[] {
                new String[] {"fred", "jim", "sheila"},
                new int[] {2, 3, 5, 7},
                new CompositeData[] {basicCD1, basicCD2}
            });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = {
        "fred, jim, sheila",
        "2, 3, 5, 7",
        "ceathar",
        "naoi",
    };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" +
                    expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}