/** * Puts the property's value. * @param name the name of the property * @param value the value */ public void putValue(String name, Object value) { PreviewProperty property = getProperty(name); if (property != null) { property.setValue(value); } else { simpleValues.put(name, value); } }
/** * Sets all preset's property values to this properties. * @param previewPreset the preset to get values from */ public void applyPreset(PreviewPreset previewPreset) { for (Entry<String, Object> entry : previewPreset.getProperties().entrySet()) { PreviewProperty prop = getProperty(entry.getKey()); if (prop != null) { prop.setValue(entry.getValue()); } else { simpleValues.put(entry.getKey(), entry.getValue()); } } }
/** * Returns the property value and cast it to the <code>T</code> type. * @param <T> the type to cast the property value to * @param property the property's name * @param defaultValue the default value if not found * @return the property's value or <code>defaultValue</code> if not found * @throws ClassCastException if the property can't be cast to <code>T</code> */ public <T> T getValue(String property, T defaultValue) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null) { T value = (T) p.getValue(); return value; } else if (simpleValues.containsKey(property)) { return (T) simpleValues.get(property); } return defaultValue; }
/** * Returns the property value and cast it to the <code>T</code> type. * @param <T> the type to cast the property value to * @param property the property's name * @return the property's value or <code>null</code> if not found * @throws ClassCastException if the property can't be cast to <code>T</code> */ public <T> T getValue(String property) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null) { T value = (T) p.getValue(); return value; } else if (simpleValues.containsKey(property)) { return (T) simpleValues.get(property); } return null; }
/** * Returns the property value as a <code>Number</code>. * @param property the property's name * @param defaultValue the default value if not found * @return the property's value or <code>defaultValue</code> if not found * @throws ClassCastException if the property can't be cast to <code>Number</code> */ public Number getNumberValue(String property, Number defaultValue) { PreviewProperty p = getProperty(property); if (p != null && p.getValue() != null && p.getValue() instanceof Number) { Number value = (Number) p.getValue(); return value; } else if (simpleValues.containsKey(property) && simpleValues.get(property) instanceof Number) { return (Number) simpleValues.get(property); } return defaultValue; }
if (propName != null) { if (!isSimpleValue) {//Read PreviewProperty: PreviewProperty p = props.getProperty(propName); if (p != null) { Object value = Serialization.readValueFromText(reader.getText(), p.getType());