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 ( /
package org.fuzzydb.attrs.layout;
// FIXME: This is not at all complete
public class BooleanCodec extends LayoutAttrCodec<IAttribute> {
	private static final int ENCODED_LENGTH = 1;
	private static BooleanCodec instance = null;
	public static synchronized BooleanCodec getInstance() {
		if ( == null) {
		return ;
	public void encode(LayoutAttrMap<IAttributemapint attrIdObject value) {
		// FIXME: For now, we don't bother with any bit shifting, thus meaning that we encode it as an int (how wasteful!)
		int index = map.getIndexForIntsWrite(attrId);
		Boolean bv = (Boolean)value;
		map.getInts()[index] = bv.booleanValue() ? 1 : 0;
	public IAttribute getDecoded(LayoutAttrMap<IAttributemapint attrId) {
		int index = map.getIndexQuick(attrId);
		boolean isTrue = map.getInts()[index] == 1;
		return BooleanValue.valueOf(attrIdisTrue);
	protected boolean consistentForInternal(LayoutAttrMap<IAttributemapint attrIdIAttributeConstraint constraint) {
		int index = map.getIndexQuick(attrId);
		boolean isTrue = map.getInts()[index] == 1;
		return bc.consistentisTrue );
New to GrepCode? Check out our FAQ X