net.sf.farrago.type.runtime
Class Ucs2CharPointer

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.ByteArrayInputStream
          extended by net.sf.farrago.type.runtime.BytePointer
              extended by net.sf.farrago.type.runtime.EncodedCharPointer
                  extended by net.sf.farrago.type.runtime.Ucs2CharPointer
All Implemented Interfaces:
Closeable, CharSequence, AssignableValue, DataValue

public class Ucs2CharPointer
extends EncodedCharPointer

Ucs2CharPointer specializes EncodedCharPointer to interpret its bytes as characters encoded via a UCS-2 charset.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/type/runtime/Ucs2CharPointer.java#4 $
Author:
John Sichi

Field Summary
 
Fields inherited from class net.sf.farrago.type.runtime.BytePointer
CONCAT_METHOD_NAME, emptyBytes, ENFORCE_PRECISION_METHOD_NAME, GET_BYTE_COUNT_METHOD_NAME, INITCAP_METHOD_NAME, L1, LOWER_METHOD_NAME, OVERLAY_METHOD_NAME, ownBytes, POSITION_METHOD_NAME, S1, SET_POINTER_METHOD_NAME, SUBSTRING_METHOD_NAME, TRIM_METHOD_NAME, 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
Ucs2CharPointer()
           
 
Method Summary
protected  void allocateOwnBytesForPrecision(int n)
           
 long attemptFastAsciiByteToLong()
          Attempts to convert this pointer's contents from a single-byte-ASCII-encoded integer string into a long.
 char charAt(int index)
           
 void enforceBytePrecision(int precision, boolean needPad, byte padByte)
          Pads or truncates this value according to the given precision.
protected  int getByteCountForPrecision(int n)
           
protected  String getCharsetName()
           
 void initcap(BytePointer bp1)
          initcap the string.
 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  void setCharAt(int index, char c)
           
 CharSequence subSequence(int start, int end)
           
 void substring(int starting, int length, boolean useLength)
          Reduces the value to a substring of the current value.
 void trim(int trimOrdinal, BytePointer bp1, BytePointer bp2)
           
 void upper(BytePointer bp1)
          upper the case for each character of the string
 
Methods inherited from class net.sf.farrago.type.runtime.EncodedCharPointer
getBytesForString, getNullableData, toString
 
Methods inherited from class net.sf.farrago.type.runtime.BytePointer
allocateOwnBytes, assignFrom, calcSubstringPointers, cast, cast, cast, cast, cast, compareBytes, concat, copyFrom, finishOverlay, getByteCount, isNull, positionImpl, setNull, setPointer, writeToBuffer, writeToBufferAbsolute
 
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
 

Constructor Detail

Ucs2CharPointer

public Ucs2CharPointer()
Method Detail

length

public int length()
Specified by:
length in interface CharSequence
Overrides:
length in class BytePointer

allocateOwnBytesForPrecision

protected void allocateOwnBytesForPrecision(int n)
Overrides:
allocateOwnBytesForPrecision in class BytePointer

getByteCountForPrecision

protected int getByteCountForPrecision(int n)
Overrides:
getByteCountForPrecision in class BytePointer

enforceBytePrecision

public void enforceBytePrecision(int precision,
                                 boolean needPad,
                                 byte padByte)
Description copied from class: BytePointer
Pads or truncates this value according to the given precision.

Overrides:
enforceBytePrecision in class BytePointer
Parameters:
precision - desired precision, in characters for character data, or bytes for binary data
needPad - true if short values should be padded
padByte - byte to pad with

substring

public void substring(int starting,
                      int length,
                      boolean useLength)
Description copied from class: BytePointer
Reduces the value to a substring of the current value.

Overrides:
substring in class BytePointer
Parameters:
starting - desired starting position
length - the length.
useLength - to indicate whether length parameter should be used.

overlay

public void overlay(BytePointer bp1,
                    BytePointer bp2,
                    int starting,
                    int length,
                    boolean useLength)
Description copied from class: BytePointer
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. Implements the SQL string OVERLAY function.

Overrides:
overlay in class BytePointer
Parameters:
bp1 - string1
bp2 - string2
starting - starting point
length - length
useLength - whether to use length parameter

position

public int position(BytePointer bp1)
Overrides:
position in class BytePointer

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence
Overrides:
charAt in class BytePointer

setCharAt

protected void setCharAt(int index,
                         char c)
Overrides:
setCharAt in class BytePointer

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence
Overrides:
subSequence in class BytePointer

getCharsetName

protected String getCharsetName()
Specified by:
getCharsetName in class EncodedCharPointer
Returns:
the charset used for this pointer's encoding, or BINARY if no character data is encoded

trim

public void trim(int trimOrdinal,
                 BytePointer bp1,
                 BytePointer bp2)
Overrides:
trim in class BytePointer

upper

public void upper(BytePointer bp1)
Description copied from class: BytePointer
upper the case for each character of the string

Overrides:
upper in class BytePointer
Parameters:
bp1 - string1

lower

public void lower(BytePointer bp1)
Description copied from class: BytePointer
lower the case for each character of the string

Overrides:
lower in class BytePointer
Parameters:
bp1 - string1

initcap

public void initcap(BytePointer bp1)
Description copied from class: BytePointer
initcap the string.

Overrides:
initcap in class BytePointer
Parameters:
bp1 - string1

attemptFastAsciiByteToLong

public long attemptFastAsciiByteToLong()
Description copied from class: BytePointer
Attempts to convert this pointer's contents from a single-byte-ASCII-encoded integer string into a long.

Overrides:
attemptFastAsciiByteToLong in class BytePointer
Returns:
converted value if successful, or Long.MAX_VALUE if unsuccessful (does not necessarily indicate that cast fails, just that this fast path can't handle it, e.g. negative/decimal/floating)