All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codetaco.funnel.orderby.ByteKey Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package com.codetaco.funnel.orderby;

import java.util.Arrays;

/**
 * 

* ByteKey class. *

* * @author Chris DeGreef [email protected] */ public class ByteKey extends KeyPart { byte[] contents; /** *

* Constructor for ByteKey. *

*/ public ByteKey() { super(); } private void formatObjectIntoKey(final KeyContext context, final byte[] rawBytes) { int lengthThisTime = length; if (rawBytes.length < length) lengthThisTime = rawBytes.length; System.arraycopy(rawBytes, 0, context.key, context.keyLength, lengthThisTime); context.keyLength += lengthThisTime; if (direction == KeyDirection.DESC || direction == KeyDirection.ADESC) { for (int b = context.keyLength - lengthThisTime; b < context.keyLength; b++) { context.key[b] = (byte) (context.key[b] ^ 0xff); } } } /** {@inheritDoc} */ @Override public Object getContents() { return contents; } /** {@inheritDoc} */ @Override public byte[] getContentsAsByteArray() { return contents; } /** {@inheritDoc} */ @Override public double getContentsAsDouble() { return 0; } /** {@inheritDoc} */ @Override public boolean isNumeric() { return false; } /** {@inheritDoc} */ @Override public void pack(final KeyContext context) throws Exception { parseObject(context); formatObjectIntoKey(context, contents); if (nextPart != null) nextPart.pack(context); } /** {@inheritDoc} */ @Override public void parseObjectFromRawData(final byte[] rawBytes) throws Exception { contents = Arrays.copyOfRange(rawBytes, this.offset, this.offset + this.length); unformattedContents = contents; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy