/** * Instantiate and return a new DynaBean instance, associated * with this DynaClass. * @return A new <code>DynaBean</code> instance */ public DynaBean newInstance() { // Create a new instance of the Map Map<String, Object> newMap = null; try { @SuppressWarnings("unchecked") final // The new map is used as properties map Map<String, Object> temp = getMap().getClass().newInstance(); newMap = temp; } catch(final Exception ex) { newMap = newMap(); } // Crate new LazyDynaMap and initialize properties final LazyDynaMap lazyMap = new LazyDynaMap(newMap); final DynaProperty[] properties = this.getDynaProperties(); if (properties != null) { for (DynaProperty propertie : properties) { lazyMap.add(propertie); } } return lazyMap; }
/** * Add a new dynamic property with the specified data type, but with * no restrictions on readability or writeability. * * @param name Name of the new dynamic property * @param type Data type of the new dynamic property (null for no * restrictions) * * @throws IllegalArgumentException if name is null * @throws IllegalStateException if this DynaClass is currently * restricted, so no new properties can be added */ public void add(final String name, final Class<?> type) { if (name == null) { throw new IllegalArgumentException("Property name is missing."); } if (isRestricted()) { throw new IllegalStateException("DynaClass is currently restricted. No new properties can be added."); } final Object value = values.get(name); // Check if the property already exists if (value == null) { values.put(name, type == null ? null : createProperty(name, type)); } }
if (!values.containsKey(name) && isReturnNull()) { return null;
dynaBean = new LazyDynaMap((Map)object); this.elementDynaClass = dynaBean.getDynaClass(); } else if (DynaBean.class.isAssignableFrom(elementType)) { this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass(); } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType )) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();
this.wrapDynaClass = (WrapDynaClass)elementDynaClass; } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType)) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass(); this.elementDynaClass = elementDynaClass; } else {
/** * Add a new dynamic property with no restrictions on data type, * readability, or writeability. * * @param name Name of the new dynamic property * * @throws IllegalArgumentException if name is null */ public void add(final String name) { add(name, null); }
/** * Creates a new {@code LazyDynaMap} object for the given property value. * * @param value the property value * @return the newly created {@code LazyDynaMap} */ private LazyDynaMap createDynaBeanForMapProperty(final Object value) { @SuppressWarnings("unchecked") final // map properties are always stored as Map<String, Object> Map<String, Object> valueMap = (Map<String, Object>) value; return new LazyDynaMap(valueMap); }
/** * Set the value of a simple property with the specified name. * * @param name Name of the property whose value is to be set * @param value Value to which this property is to be set */ @Override public void set(final String name, final Object value) { if (isRestricted() && !values.containsKey(name)) { throw new IllegalArgumentException ("Invalid property name '" + name + "' (DynaClass is restricted)"); } values.put(name, value); }
/** * Construct a new <code>LazyDynaMap</code> with the specified name and <code>Map</code>. * * @param name Name of this DynaBean class * @param values The Map backing this <code>LazyDynaMap</code> */ public LazyDynaMap(final String name, final Map<String, Object> values) { this.name = name == null ? "LazyDynaMap" : name; this.values = values == null ? newMap() : values; this.dynaClass = this; }
public String toString() { StringBuilder sb = new StringBuilder(); Iterator keys = policyProperties.getMap().keySet().iterator(); String currentKey; while(keys.hasNext()) { currentKey = (String)keys.next(); sb.append(currentKey); sb.append("="); sb.append(policyProperties.get(currentKey)); if(keys.hasNext()) { sb.append(","); } } return sb.toString(); } }
dynaBean = new LazyDynaMap((Map)object); this.elementDynaClass = dynaBean.getDynaClass(); } else if (DynaBean.class.isAssignableFrom(elementType)) { this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass(); } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType )) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();
this.wrapDynaClass = (WrapDynaClass)elementDynaClass; } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType)) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass(); this.elementDynaClass = elementDynaClass; } else {
/** * Add a new dynamic property with no restrictions on data type, * readability, or writeability. * * @param name Name of the new dynamic property * * @throws IllegalArgumentException if name is null */ public void add(final String name) { add(name, null); }
/** * Creates a new {@code LazyDynaMap} object for the given property value. * * @param value the property value * @return the newly created {@code LazyDynaMap} */ private LazyDynaMap createDynaBeanForMapProperty(final Object value) { @SuppressWarnings("unchecked") final // map properties are always stored as Map<String, Object> Map<String, Object> valueMap = (Map<String, Object>) value; return new LazyDynaMap(valueMap); }
/** * Set the value of a simple property with the specified name. * * @param name Name of the property whose value is to be set * @param value Value to which this property is to be set */ @Override public void set(final String name, final Object value) { if (isRestricted() && !values.containsKey(name)) { throw new IllegalArgumentException ("Invalid property name '" + name + "' (DynaClass is restricted)"); } values.put(name, value); }
/** * Construct a new <code>LazyDynaMap</code> with the specified name and <code>Map</code>. * * @param name Name of this DynaBean class * @param values The Map backing this <code>LazyDynaMap</code> */ public LazyDynaMap(final String name, final Map<String, Object> values) { this.name = name == null ? "LazyDynaMap" : name; this.values = values == null ? newMap() : values; this.dynaClass = this; }
public String toString() { StringBuilder sb = new StringBuilder(); Iterator keys = policyProperties.getMap().keySet().iterator(); String currentKey; while(keys.hasNext()) { currentKey = (String)keys.next(); sb.append(currentKey); sb.append("="); sb.append(policyProperties.get(currentKey)); if(keys.hasNext()) { sb.append(","); } } return sb.toString(); } }
/** * Instantiate and return a new DynaBean instance, associated * with this DynaClass. * @return A new <code>DynaBean</code> instance */ public DynaBean newInstance() { // Create a new instance of the Map Map<String, Object> newMap = null; try { @SuppressWarnings("unchecked") final // The new map is used as properties map Map<String, Object> temp = getMap().getClass().newInstance(); newMap = temp; } catch(final Exception ex) { newMap = newMap(); } // Crate new LazyDynaMap and initialize properties final LazyDynaMap lazyMap = new LazyDynaMap(newMap); final DynaProperty[] properties = this.getDynaProperties(); if (properties != null) { for (DynaProperty propertie : properties) { lazyMap.add(propertie); } } return lazyMap; }
dynaBean = new LazyDynaMap((Map)object); this.elementDynaClass = dynaBean.getDynaClass(); } else if (DynaBean.class.isAssignableFrom(elementType)) { this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass(); } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType )) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();
this.elementType = ((WrapDynaBean)dynaBean).getInstance().getClass(); } else if (LazyDynaMap.class.isAssignableFrom(elementDynaBeanType )) { this.elementType = ((LazyDynaMap)dynaBean).getMap().getClass();