@Override public ObjectName unwrapMetaValue(MetaValue metaValue) { CompositeValue compositeValue = (CompositeValue) metaValue; SimpleValue domain = (SimpleValue) compositeValue.get("domain"); String domainUnwrap = (String) domain.getValue(); MetaValue keys = compositeValue.get("keyPropertyList"); Hashtable keysUnwrap = null; if(keys instanceof PropertiesMetaValue) keysUnwrap = (PropertiesMetaValue) keys; try { ObjectName name = new ObjectName(domainUnwrap, keysUnwrap); return name; } catch(Exception e) { throw new IllegalArgumentException(e); } }
protected Map unwrapCompositeMap(CompositeValue compositeValue) { HashMap map = new HashMap(); CompositeMetaType metaType = compositeValue.getMetaType(); for(String key : metaType.itemSet()) { MetaValue mv = compositeValue.get(key); Object value = unwrap(mv); map.put(key, value); } return map; }
@Override public ObjectName unwrapMetaValue(MetaValue metaValue) { CompositeValue cv = (CompositeValue) metaValue; String domain = null; Hashtable<String, String> props = new Hashtable<String, String>(); for(String key : cv.getMetaType().itemSet()) { SimpleValue svalue = (SimpleValue) cv.get(key); String value = (String) svalue.getValue(); if(key.equalsIgnoreCase("domain")) domain = value; else props.put(key, value); } try { ObjectName name = new ObjectName(domain, props); return name; } catch(Exception e) { throw new IllegalArgumentException("Failed to build ObjectName from MetaValue: "+metaValue, e); } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class.equals(method.getDeclaringClass())) return handleObjectInvocation(method.getName(), args); MetaValue value = compositeValue.get(getCompositeDataKey(method)); Type returnType = method.getGenericReturnType(); return factory.unwrap(value, returnType); }
String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue(); String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue(); CompositeValue paramsValue = (CompositeValue) protocolValue.get("protocolParameters"); Set<String> paramNames = paramsValue.getMetaType().keySet(); List<ProtocolParameter> protParams = new ArrayList<ProtocolParameter>(paramNames.size()); for (String paramName : paramNames) CompositeValue paramValue = (CompositeValue) paramsValue.get(paramName); String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue(); protParams.add(new ProtocolParameter(paramName, paramVal));
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Class<?> declaringClass = method.getDeclaringClass(); if (Object.class.equals(declaringClass)) return handleObjectInvocation(method.getName(), args); Type returnType = method.getGenericReturnType(); // size if(method.getName().equals("size")) return compositeValue.values().size(); MetaValue value = compositeValue.get(getCompositeDataKey(method)); return factory.unwrap(value, returnType); }
for (String stack : topCompValue.getMetaType().keySet()) CompositeValue stackValue = (CompositeValue) topCompValue.get(stack); String name = (String) ((SimpleValue) stackValue.get("name")).getValue(); String description = (String) ((SimpleValue) stackValue.get("description")).getValue(); CollectionValue protocolsValue = (CollectionValue) stackValue.get("configuration"); ProtocolData[] protocolData = CONFIG_MAPPER.unwrapMetaValue(protocolsValue);
/** * Create a map * * @param tableValue the table value * @param keyType the key type * @param valueType the value type * @return the map */ protected Map createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType) { if (tableValue == null) return null; Map<Object, Object> result = new HashMap<Object, Object>(); Collection<CompositeValue> values = tableValue.values(); for (CompositeValue entry : values) { Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType); Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType); result.put(key, val); } return result; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CompositeValue == false) return false; CompositeValue other = (CompositeValue) obj; if (getMetaType().equals(other.getMetaType()) == false) return false; for (String key : getMetaType().keySet()) { Object thisValue = this.get(key); Object otherValue = other.get(key); if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false) return false; } return true; }
/** * Create a map * * @param tableValue the table value * @param keyType the key type * @param valueType the value type * @return the map */ protected Map<?,?> createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType) { if (tableValue == null) return null; Map<Object, Object> result = new HashMap<Object, Object>(); Collection<CompositeValue> values = tableValue.values(); for (CompositeValue entry : values) { Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType); Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType); result.put(key, val); } return result; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CompositeValue == false) return false; CompositeValue other = (CompositeValue) obj; if (getMetaType().equals(other.getMetaType()) == false) return false; for (String key : getMetaType().keySet()) { Object thisValue = this.get(key); Object otherValue = other.get(key); if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false) return false; } return true; }
SimpleValue v = (SimpleValue) row.get(attribute); if(v != null && v.getValue() != null)
MetaValue domain = compositeValue.get("domain"); String domainUnwrap = (String) unwrap(domain, String.class); MetaValue keys = compositeValue.get("keyPropertyList"); Hashtable keysUnwrap = null; if(keys instanceof PropertiesMetaValue) for (String name : compositeMetaType.itemSet()) MetaValue itemValue = compositeValue.get(name); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object value = unwrap(itemValue, propertyInfo.getType());
for (String name : compositeMetaType.keySet()) MetaValue itemValue = compositeValue.get(name); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object value = unwrap(itemValue, propertyInfo.getType());
MetaValue itemValue = value.get(item);