public void addProperty(String name, Class type, Object value) { if (type.isAssignableFrom(value.getClass())) { list.add(new GlyphProperty(name, type, value)); names.add(name); } else { throw new RuntimeException( "Wrong class for setting variable " + name + ". Expected a " + type + " but received a " + value.getClass() + "."); } }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and * property 1. */ public String getPropertyName(int i) { return ((GlyphProperty) list.get(i)).getName(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and * property 1. */ public Class getPropertyType(int i) { return ((GlyphProperty) list.get(i)).getType(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and * property 1. */ public Object getPropertyValue(int i) { return ((GlyphProperty) list.get(i)).getValue(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public Class getPropertyType(int i){ return ((GlyphProperty) list.get(i)).getType(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public Object getPropertyValue(int i){ return ((GlyphProperty) list.get(i)).getValue(); }
public void setPropertyValue(String name, Object value){ int index = names.indexOf(name); if (index != -1){ GlyphProperty prop = (GlyphProperty) list.get(index); if (value instanceof String){ value = stringToLiteral((String) value); } if (value instanceof Integer){ value = numberToLiteral((Integer) value); } if (value instanceof Double){ value = numberToLiteral((Double) value); } if (prop.getType().isAssignableFrom(value.getClass())){ prop.setValue(value); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + prop.getType() + " but received a " + value.getClass() + "."); } } else { throw new RuntimeException("Tried to set the value of a non-existent property: " + name); } } }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public String getPropertyName(int i){ return ((GlyphProperty) list.get(i)).getName(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public Class getPropertyType(int i){ return ((GlyphProperty) list.get(i)).getType(); }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public Object getPropertyValue(int i){ return ((GlyphProperty) list.get(i)).getValue(); }
public void addProperty(String name, Class type, Object value){ if (type.isAssignableFrom(value.getClass())){ list.add(new GlyphProperty(name, type, value)); names.add(name); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + type + " but received a " + value.getClass() + "."); } }
public void setPropertyValue(String name, Object value){ int index = names.indexOf(name); if (index != -1){ GlyphProperty prop = (GlyphProperty) list.get(index); if (value instanceof String){ value = stringToLiteral((String) value); } if (value instanceof Integer){ value = numberToLiteral((Integer) value); } if (value instanceof Double){ value = numberToLiteral((Double) value); } if (prop.getType().isAssignableFrom(value.getClass())){ prop.setValue(value); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + prop.getType() + " but received a " + value.getClass() + "."); } } else { throw new RuntimeException("Tried to set the value of a non-existent property: " + name); } } }
/** * the index i starts counting at 0, not 1. A list with two properties has property 0 and property 1. */ public String getPropertyName(int i){ return ((GlyphProperty) list.get(i)).getName(); }
public void addProperty(String name, Class type, Object value){ if (type.isAssignableFrom(value.getClass())){ list.add(new GlyphProperty(name, type, value)); names.add(name); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + type + " but received a " + value.getClass() + "."); } }