public boolean getBoolean(String name) { BooleanAttribute attr = (BooleanAttribute) attributes.get(name); return attr.getValue(); }
public BooleanValue convertToInternal(int attrid, Attribute<?> object) { if (object instanceof UnspecifiedTypeAttribute){ return new BooleanValue(attrid, ((UnspecifiedTypeAttribute) object).asBoolean()); } BooleanAttribute attr = (BooleanAttribute)object; return new BooleanValue(attrid, attr.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(BOOLEAN_SIZE); } setAttrId(bytes, i, attrId); // override this so that true/false/includesnotspecified gets included in attrId encoding if (value instanceof BooleanValue){ bytes.putBoolean(i + BOOLEAN_FLAG_OFFSET, ((BooleanValue) value).isTrue()); } else if (value instanceof BooleanAttribute) { bytes.putBoolean(i + BOOLEAN_FLAG_OFFSET, ((BooleanAttribute) value).getValue()); } else { bytes.putBoolean(i + BOOLEAN_FLAG_OFFSET, (Boolean)value); } }
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(); } }