|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.ByteArrayInputStream net.sf.farrago.type.runtime.BytePointer
public class BytePointer
BytePointer is instantiated during execution to refer to a contiguous subset of a byte array. It exists to avoid the need to instantiate a new object for each variable-width value read.
NOTE: BytePointer is not declared to implement NullableValue, although it actually provides the necessary method implementations. Instead, the NullableValue interface is declared by generated subclasses representing nullable types. This allows the presence of the NullableValue interface to be used in runtime contexts where we need to determine nullability but have lost explicit type information during code generation.
Field Summary | |
---|---|
static String |
CONCAT_METHOD_NAME
|
static byte[] |
emptyBytes
Read-only global for 0-length byte array |
static String |
ENFORCE_PRECISION_METHOD_NAME
|
static String |
GET_BYTE_COUNT_METHOD_NAME
|
static String |
INITCAP_METHOD_NAME
|
protected int |
L1
|
static String |
LOWER_METHOD_NAME
|
static String |
OVERLAY_METHOD_NAME
|
protected byte[] |
ownBytes
An allocate-on-demand array used when a new value must be created. |
static String |
POSITION_METHOD_NAME
|
protected int |
S1
two temp variables to store the substring pointers |
static String |
SET_POINTER_METHOD_NAME
|
static String |
SUBSTRING_METHOD_NAME
|
static String |
TRIM_METHOD_NAME
|
static String |
UPPER_METHOD_NAME
|
Fields inherited from class java.io.ByteArrayInputStream |
---|
buf, count, mark, pos |
Fields inherited from interface net.sf.farrago.type.runtime.AssignableValue |
---|
ASSIGNMENT_METHOD_NAME |
Constructor Summary | |
---|---|
BytePointer()
Creates a new BytePointer object. |
Method Summary | |
---|---|
protected void |
allocateOwnBytes(int n)
|
protected void |
allocateOwnBytesForPrecision(int n)
|
void |
assignFrom(Object obj)
Assigns value from an Object. |
long |
attemptFastAsciiByteToLong()
Attempts to convert this pointer's contents from a single-byte-ASCII-encoded integer string into a long. |
protected void |
calcSubstringPointers(int S,
int L,
int LC,
boolean useLength)
|
void |
cast(boolean b,
int precision)
|
void |
cast(double d,
int precision)
|
void |
cast(EncodedSqlDecimal d,
int precision)
|
void |
cast(float f,
int precision)
|
void |
cast(long l,
int precision)
|
private void |
castDecimal(long l,
int precision,
int scale)
Casts a decimal into a string. |
private void |
castNoChecking(double d,
int precision,
boolean isFloat)
|
char |
charAt(int index)
|
int |
compareBytes(BytePointer other)
Implementation for Comparable.compareTo() which assumes non-null and does byte-for-byte comparison. |
void |
concat(BytePointer bp1,
BytePointer bp2)
Assigns this pointer to the result of concatenating two input strings. |
protected void |
copyFrom(BytePointer bp1)
|
void |
enforceBytePrecision(int precision,
boolean needPad,
byte padByte)
Pads or truncates this value according to the given precision. |
protected void |
finishOverlay(BytePointer bp1,
BytePointer bp2,
int starting)
|
int |
getByteCount()
|
protected int |
getByteCountForPrecision(int n)
|
protected byte[] |
getBytesForString(String string)
Gets the byte representation of a string. |
protected String |
getCharsetName()
|
Object |
getNullableData()
|
void |
initcap(BytePointer bp1)
initcap the string. |
boolean |
isNull()
|
int |
length()
|
void |
lower(BytePointer bp1)
lower the case for each character of the string |
void |
overlay(BytePointer bp1,
BytePointer bp2,
int starting,
int length,
boolean useLength)
Assigns this value to the result of inserting bp2's value into bp1's value at a specified starting point, possibly deleting a prefix of the remainder of bp1 of a given length. |
int |
position(BytePointer bp1)
|
protected int |
positionImpl(BytePointer bp1,
int bytesPerChar)
|
protected void |
setCharAt(int index,
char c)
|
void |
setNull(boolean isNull)
|
void |
setPointer(byte[] buf,
int pos,
int end)
Sets the pointer to reference a buffer. |
CharSequence |
subSequence(int start,
int end)
|
void |
substring(int starting,
int length,
boolean useLength)
Reduces the value to a substring of the current value. |
String |
toString()
|
void |
trim(int trimOrdinal,
BytePointer bp1,
BytePointer bp2)
|
void |
upper(BytePointer bp1)
upper the case for each character of the string |
void |
writeToBuffer(ByteBuffer byteBuffer)
Writes the contents of this pointer to a ByteBuffer. |
void |
writeToBufferAbsolute(ByteBuffer byteBuffer,
int offset)
Writes the contents of this pointer to a ByteBuffer at a given offset without modifying the current position. |
Methods inherited from class java.io.ByteArrayInputStream |
---|
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.io.InputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ENFORCE_PRECISION_METHOD_NAME
public static final String SET_POINTER_METHOD_NAME
public static final String GET_BYTE_COUNT_METHOD_NAME
public static final String SUBSTRING_METHOD_NAME
public static final String OVERLAY_METHOD_NAME
public static final String INITCAP_METHOD_NAME
public static final String CONCAT_METHOD_NAME
public static final String UPPER_METHOD_NAME
public static final String LOWER_METHOD_NAME
public static final String TRIM_METHOD_NAME
public static final String POSITION_METHOD_NAME
public static final byte[] emptyBytes
protected byte[] ownBytes
protected int S1
protected int L1
Constructor Detail |
---|
public BytePointer()
Method Detail |
---|
public void setNull(boolean isNull)
public boolean isNull()
public Object getNullableData()
getNullableData
in interface DataValue
public void setPointer(byte[] buf, int pos, int end)
buf
- the buffer to point intopos
- position in buffer to point atend
- buffer position at which valid data endsprotected String getCharsetName()
public void assignFrom(Object obj)
AssignableValue
assignFrom
in interface AssignableValue
obj
- value to assign, or null to set nullpublic void enforceBytePrecision(int precision, boolean needPad, byte padByte)
precision
- desired precision, in characters for character data, or
bytes for binary dataneedPad
- true if short values should be paddedpadByte
- byte to pad withpublic void substring(int starting, int length, boolean useLength)
starting
- desired starting positionlength
- the length.useLength
- to indicate whether length parameter should be used.public void overlay(BytePointer bp1, BytePointer bp2, int starting, int length, boolean useLength)
bp1
- string1bp2
- string2starting
- starting pointlength
- lengthuseLength
- whether to use length parameterprotected void finishOverlay(BytePointer bp1, BytePointer bp2, int starting)
public void concat(BytePointer bp1, BytePointer bp2)
bp1
- string1bp2
- string2public int getByteCount()
public int length()
length
in interface CharSequence
protected void setCharAt(int index, char c)
public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public void upper(BytePointer bp1)
bp1
- string1public void lower(BytePointer bp1)
bp1
- string1public void initcap(BytePointer bp1)
bp1
- string1public void trim(int trimOrdinal, BytePointer bp1, BytePointer bp2)
public int position(BytePointer bp1)
protected int positionImpl(BytePointer bp1, int bytesPerChar)
protected void copyFrom(BytePointer bp1)
protected void calcSubstringPointers(int S, int L, int LC, boolean useLength)
protected void allocateOwnBytes(int n)
protected void allocateOwnBytesForPrecision(int n)
protected int getByteCountForPrecision(int n)
public final void writeToBuffer(ByteBuffer byteBuffer)
byteBuffer
- targetpublic final void writeToBufferAbsolute(ByteBuffer byteBuffer, int offset)
byteBuffer
- targetoffset
- starting byte offset within bufferprotected byte[] getBytesForString(String string)
string
- source
public int compareBytes(BytePointer other)
other
- another BytePointer to be compared
public String toString()
toString
in interface CharSequence
toString
in class Object
public void cast(float f, int precision)
public void cast(double d, int precision)
private void castNoChecking(double d, int precision, boolean isFloat)
public void cast(boolean b, int precision)
public void cast(long l, int precision)
public void cast(EncodedSqlDecimal d, int precision)
public long attemptFastAsciiByteToLong()
private void castDecimal(long l, int precision, int scale)
l
- long value of decimalprecision
- maximum length of stringscale
- scale of decimal
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |