Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2005-2008 Whirlwind Match Limited. All rights reserved. This is open source software; you can use, redistribute and/or modify it under the terms of the Open Software Licence v 3.0 as published by the Open Source Initiative. You should have received a copy of the Open Software Licence along with this application. if not, contact the Open Source Initiative (www.opensource.org) /
package org.fuzzydb.attrs.byteencoding;
public class EnumCodec extends CompactAttrCodec {
	static final byte EXCLUSIVE_ENUM_SIZE =  + 2; // (note: not full header, no length byte) 1 for enumDefId, 1 for enum index
	private static final int ENUM_DEF_OFFSET = ;
	private static final int ENUM_DEF_LENGTH = 1; // byte
	private static final int ENUM_VALUE_OFFSET =  + ;
	static private EnumCodec instance;
	public static synchronized CompactAttrCodec getInstance() {
		if ( == null) {
			 = new EnumCodec();
		}
		return ;
	}
	public void encodeToByteArray(ByteArray bytesint attrIdObject value) {
		// Find if there's one to overwrite
		int i = findAttrInBuf(bytesattrId);
		// If not, allocate some space on the end
		if ( i < 0 ) {
		}
		// Write out the data that is needed.  
		// Note: enumDefId is sent to the server to allow the scorer to assert() that it is scoring against the right defs
		setAttrId(bytesiattrId);
		bytes.putByte(i + , (byteenumValue.getEnumDefId() );
		bytes.putByte(i + , (byteenumValue.getEnumIndex() );
	}
	public IAttribute getDecoded(ByteArray bytesint index) {
		int attrId = getAttrIdgetHeaderWordbytesindex) );
		byte val = bytes.getByte(index +  );
		byte defId = bytes.getByte(index +  );
		return new EnumExclusiveValueattrIddefIdval );
	}
	public static byte getValue(ByteArray bytesint index) {
		return bytes.getByte(index + );
	}
New to GrepCode? Check out our FAQ X