public float getFloat(String name) { FloatAttribute attr = (FloatAttribute) attributes.get(name); return attr.getValue(); }
public void put(String name, float f) { attributes.put(name, new FloatAttribute(name, f)); }
public FloatValue convertToInternal(int attrid, Attribute<?> object) { if (object instanceof UnspecifiedTypeAttribute) { return new FloatValue(attrid, ((UnspecifiedTypeAttribute)object).asFloat() ); } FloatAttribute attr = (FloatAttribute) object; return new FloatValue(attrid, attr.getValue() ); } }
public FloatAttribute convert(String name, IAttribute attribute) { return new FloatAttribute( name, ((FloatValue)attribute).getValue() ); }
@Override public void encodeToByteArray(ByteArray bytes, int attrId, Object value) { // Find if there's one to overwrite int i = findAttrInBuf(bytes, attrId); // If not, allocate some space on the end if ( i < 0 ) { i = bytes.getIndexForWrite(FLOAT_SIZE); } setAttrId(bytes, i, attrId); if (value instanceof FloatAttribute) { bytes.putFloat(i + FLOAT_VALUE_OFFSET, ((FloatAttribute)value).getValue()); } else if (value instanceof FloatValue) { bytes.putFloat(i + FLOAT_VALUE_OFFSET, ((FloatValue) value).getValue()); } else { // assume Float bytes.putFloat(i + FLOAT_VALUE_OFFSET, ((Float)value) ); } }
@Override public Attribute<?> getAttribute() { return new FloatAttribute( getName(), getValue() ); } }
public void put(Attribute attr1) { // FIXME: This is a big mess, and we don't use StringAttributeMap... int attrId = getAttrDefinitions().getAttrId( attr1.getName(), attr1.getClass() ); if (attr1 instanceof BooleanAttribute){ IAttribute attr = new BooleanValue( attrId, ((BooleanAttribute) attr1).getValue()); putAttr( attr ); } else if ( attr1 instanceof FloatAttribute) { IAttribute attr = new FloatValue( attrId, ((FloatAttribute) attr1).getValue()); putAttr( attr ); } else if ( attr1 instanceof EnumAttribute) { // If supplied our existing attributes, then just set the attrId, allowing Jason to supply zero EnumAttribute enumAttribute = (EnumAttribute) attr1; EnumDefinition def = getAttrDefinitions().getEnumDefinition( enumAttribute.getEnumName()); EnumExclusiveValue attr = def.getEnumValue(enumAttribute.getEnumName(), attrId); attr.setAttrId(attrId); putAttr( attr ); } else { throw new UnsupportedOperationException(); } }