private String[] formatRow(CompositeData row, List<String> header) { String[] text = new String[header.size()]; for(int i = 0; i != text.length; ++i) { String attr = header.get(i); text[i] = formatLine(row.get(attr), row.getCompositeType().getType(attr).getClassName()); } return text; }
throws Exception if ( openType.isArray()) Class.forName(arrayType.getElementOpenType().getClassName()), itemValueArray.size()); int i = 0; itemValueArray.toString(), openType.getTypeName()); throw new Exception(errMsg);
attrKeys.add(attrName); for(String key : type.keySet()) { String typ = type.getType(key).getTypeName(); Object valu = composite.get(key); processBeanValue( String typ = type.getType(valueIdx).getTypeName(); String name = valueIdx; if (valueIdx.toLowerCase().equals("value")) {
String className = openType.getClassName(); itemStrValue, openType.getTypeName()); throw new Exception(errMsg);
if ( type.isArray() ) if ( type.getClassName().equals(CompositeData.class.getName()) )
if ( itemType.isArray())
private static OpenMBeanOperationInfo findOperation(String name, Type[] parameterTypes, MBeanOperationInfo[] operations) { OpenType[] signature = getSignature(parameterTypes); for (int i = 0; i < operations.length; ++i) { if (operations[i].getName().equals(name) == false) continue; MBeanParameterInfo[] parameters = operations[i].getSignature(); boolean match = true; for (int p = 0; p < parameters.length && match; ++p) { OpenMBeanParameterInfo openMBeanParameterInfo = (OpenMBeanParameterInfo) parameters[p]; if (signature[p].equals(openMBeanParameterInfo.getOpenType()) == false) match = false; } if (match) return (OpenMBeanOperationInfo) operations[i]; } return null; }
buf.append(idt).append(nvp("OpenType", open.getOpenType().toString())).append(NL); buf.append(idt).append(nvp("hasLegalValues", open.hasLegalValues())).append(NL); buf.append(idt).append(nvp("hasDefaultValue", open.hasDefaultValue())).append(NL);
static Object getJavaTypeArray(ArrayType<?> atype, ClassLoader classLoader, int dimension) throws OpenDataException { Class<?> compType; OpenType<?> elementType = atype.getElementOpenType(); try { if (atype.isPrimitiveArray()) { compType = Class.forName(atype.getTypeName()).getComponentType(); } else { compType = classLoader.loadClass(elementType.getTypeName()); } } catch (ClassNotFoundException ex) { OpenDataException odex = new OpenDataException("Cannot load array type: " + atype); odex.initCause(ex); throw odex; } return Array.newInstance(compType, dimension); }
OpenType<?> openType = (OpenType<?>)d.getFieldValue("openType"); if(openType.isArray()){ Object[] valarray = (Object[])val; val = Integer.toString(valarray.length);
private static OpenMBeanOperationInfo findOperation(String name, Type[] parameterTypes, MBeanOperationInfo[] operations) { OpenType[] signature = getSignature(parameterTypes); for (int i = 0; i < operations.length; ++i) { if (operations[i].getName().equals(name) == false) continue; MBeanParameterInfo[] parameters = operations[i].getSignature(); boolean match = true; for (int p = 0; p < parameters.length && match; ++p) { OpenMBeanParameterInfo openMBeanParameterInfo = (OpenMBeanParameterInfo) parameters[p]; if (signature[p].equals(openMBeanParameterInfo.getOpenType()) == false) match = false; } if (match) return (OpenMBeanOperationInfo) operations[i]; } return null; }
buf.append(idt + nvp("OpenType", open.getOpenType().toString()) + NL); buf.append(idt + nvp("hasLegalValues", open.hasLegalValues()) + NL); buf.append(idt + nvp("hasDefaultValue", open.hasDefaultValue()) + NL);
for(String attr: cdata.getCompositeType().keySet()) { sb.append(attr).append("="); sb.append(formatLine(cdata.get(attr), cdata.getCompositeType().getType(attr).getClassName())); sb.append(',');
static Object getJavaTypeArray(ArrayType<?> atype, ClassLoader classLoader, int dimension) throws OpenDataException { Class<?> compType; OpenType<?> elementType = atype.getElementOpenType(); try { if (atype.isPrimitiveArray()) { compType = Class.forName(atype.getTypeName()).getComponentType(); } else { compType = classLoader.loadClass(elementType.getTypeName()); } } catch (ClassNotFoundException ex) { OpenDataException odex = new OpenDataException("Cannot load array type: " + atype); odex.initCause(ex); throw odex; } return Array.newInstance(compType, dimension); }
/** * Reconstruct a type from an object * * @param openType the open type * @param type the type * @param value the value * @param context for error reporting * @return the object * @throws Exception for any error */ public static Object reconstruct(OpenType openType, Type type, Object value, Object context) throws Exception { if (openType instanceof SimpleType) return reconstructSimpleData(type, value, context); if (openType.isArray()) return reconstructArrayData(openType, type, value, context); if (openType instanceof TabularType) return reconstructTabularData(openType, type, value, context); return reconstructCompositeData(openType, type, value, context); }
List<String[]> content = new ArrayList<String[]>(); for(String field: cd.getCompositeType().keySet()) { String val = formatLine(cd.get(field), cd.getCompositeType().getType(field).getClassName()); content.add(new String[]{field + ": ", val});
static Object getOpenTypeArray(ArrayType<?> atype, ClassLoader classLoader, int dimension) throws OpenDataException { Class<?> compType; OpenType<?> elementType = atype.getElementOpenType(); try { if (atype.isPrimitiveArray()) { compType = Class.forName(atype.getTypeName()).getComponentType(); } else if (elementType instanceof CompositeType) { compType = CompositeData.class; } else if (elementType instanceof TabularType) { compType = TabularData.class; } else { compType = classLoader.loadClass(elementType.getTypeName()); } } catch (ClassNotFoundException ex) { OpenDataException odex = new OpenDataException("Cannot load array type: " + atype); odex.initCause(ex); throw odex; } return Array.newInstance(compType, dimension); }
/** * Construct some open data * * @param openType the open type * @param value the value * @param context the context * @return the open data * @throws Exception for any error */ public static Object construct(OpenType openType, Object value, Object context) throws Exception { if (openType instanceof SimpleType) return constructSimpleData(value); if (openType.isArray()) return constructArrayData(openType, value, context); if (openType instanceof TabularType) return constructTabularData(openType, value, context); return constructCompositeData(openType, value, context); }
private Object[] createTargetArray(OpenType pElementType, int pLength) { if (pElementType instanceof SimpleType) { try { SimpleType simpleType = (SimpleType) pElementType; Class elementClass = Class.forName(simpleType.getClassName()); return (Object[]) Array.newInstance(elementClass, pLength); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Can't find class " + pElementType.getClassName() + " for instantiating array: " + e.getMessage(),e); } } else if (pElementType instanceof CompositeType) { return new CompositeData[pLength]; } else { throw new UnsupportedOperationException("Unsupported array element type: " + pElementType); } } }
static Object getOpenTypeArray(ArrayType<?> atype, ClassLoader classLoader, int dimension) throws OpenDataException { Class<?> compType; OpenType<?> elementType = atype.getElementOpenType(); try { if (atype.isPrimitiveArray()) { compType = Class.forName(atype.getTypeName()).getComponentType(); } else if (elementType instanceof CompositeType) { compType = CompositeData.class; } else if (elementType instanceof TabularType) { compType = TabularData.class; } else { compType = classLoader.loadClass(elementType.getTypeName()); } } catch (ClassNotFoundException ex) { OpenDataException odex = new OpenDataException("Cannot load array type: " + atype); odex.initCause(ex); throw odex; } return Array.newInstance(compType, dimension); }