org.jcodings
Class SingleByteEncoding

java.lang.Object
  extended by org.jcodings.Encoding
      extended by org.jcodings.SingleByteEncoding
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ASCIIEncoding, CaseFoldMapEncoding, USASCIIEncoding

public abstract class SingleByteEncoding
extends Encoding


Field Summary
protected static CaseFoldCodeItem[] EMPTY_FOLD_CODES
           
protected  byte[] LowerCaseTable
           
 
Fields inherited from class org.jcodings.Encoding
CHAR_INVALID, hashCode, isAsciiCompatible, isDummy, isFixedWidth, isSingleByte, maxLength, minLength, name, NEW_LINE
 
Constructor Summary
protected SingleByteEncoding(String name, short[] CTypeTable, byte[] LowerCaseTable)
           
protected SingleByteEncoding(String name, short[] CTypeTable, byte[] LowerCaseTable, boolean isDummy)
           
 
Method Summary
 void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
          onigenc_ascii_apply_all_case_fold / used also by multibyte encodings
protected  void asciiApplyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
           
protected  CaseFoldCodeItem[] asciiCaseFoldCodesByString(int flag, byte[] bytes, int p, int end)
           
protected  int asciiMbcCaseFold(int flag, byte[] bytes, IntHolder pp, int end, byte[] lower)
           
 CaseFoldCodeItem[] caseFoldCodesByString(int flag, byte[] bytes, int p, int end)
          onigenc_ascii_get_case_fold_codes_by_str / used also by multibyte encodings
 int codeToMbc(int code, byte[] bytes, int p)
          onigenc_single_byte_code_to_mbc
 int codeToMbcLength(int code)
          onigenc_single_byte_code_to_mbclen
 int[] ctypeCodeRange(int ctype, IntHolder sbOut)
          onigenc_not_support_get_ctype_code_range
protected  boolean isCodeCTypeInternal(int code, int ctype)
          ONIGENC_IS_XXXXXX_CODE_CTYPE
 boolean isNewLine(byte[] bytes, int p, int end)
          onigenc_is_mbc_newline_0x0a / used also by multibyte encodings
 boolean isReverseMatchAllowed(byte[] bytes, int p, int end)
          onigenc_always_true_is_allowed_reverse_match
 int leftAdjustCharHead(byte[] bytes, int p, int s, int end)
          onigenc_single_byte_left_adjust_char_head
 int length(byte c)
          onigenc_single_byte_mbc_enc_len
 int length(byte[] bytes, int p, int end)
          Returns character length given stream, character position and stream end returns 1 for singlebyte encodings or performs sanity validations for multibyte ones and returns the character length, missing characters in the stream otherwise
 int mbcCaseFold(int flag, byte[] bytes, IntHolder pp, int end, byte[] lower)
          onigenc_ascii_mbc_case_fold
 int mbcToCode(byte[] bytes, int p, int end)
          onigenc_single_byte_mbc_to_code
 int propertyNameToCType(byte[] bytes, int p, int end)
          onigenc_minimum_property_name_to_ctype notably overridden by unicode encodings
 int strCodeAt(byte[] bytes, int p, int end, int index)
           
 int strLength(byte[] bytes, int p, int end)
           
 
Methods inherited from class org.jcodings.Encoding
asciiToLower, asciiToUpper, digitVal, equals, getIndex, getName, hashCode, isAlnum, isAlpha, isAscii, isAscii, isAsciiCompatible, isBlank, isCntrl, isCodeCType, isDigit, isDummy, isFixedWidth, isGraph, isLower, isMbcAscii, isMbcCrnl, isMbcHead, isMbcWord, isNewLine, isPrint, isPunct, isSbWord, isSingleByte, isSpace, isUpper, isWord, isWordGraphPrint, isXDigit, load, maxLength, maxLengthDistance, mbcodeStartPosition, minLength, odigitVal, prevCharHead, replicate, rightAdjustCharHead, rightAdjustCharHeadWithPrev, setName, setName, step, stepBack, strByteLengthNull, strLengthNull, strNCmp, toLowerCaseTable, toString, xdigitVal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LowerCaseTable

protected final byte[] LowerCaseTable

EMPTY_FOLD_CODES

protected static final CaseFoldCodeItem[] EMPTY_FOLD_CODES
Constructor Detail

SingleByteEncoding

protected SingleByteEncoding(String name,
                             short[] CTypeTable,
                             byte[] LowerCaseTable)

SingleByteEncoding

protected SingleByteEncoding(String name,
                             short[] CTypeTable,
                             byte[] LowerCaseTable,
                             boolean isDummy)
Method Detail

length

public int length(byte c)
onigenc_single_byte_mbc_enc_len

Specified by:
length in class Encoding
Parameters:
c - Character head Oniguruma equivalent: mbc_enc_len To be deprecated very soon (use length(byte[]bytes, int p, int end) version)

length

public int length(byte[] bytes,
                  int p,
                  int end)
Description copied from class: Encoding
Returns character length given stream, character position and stream end returns 1 for singlebyte encodings or performs sanity validations for multibyte ones and returns the character length, missing characters in the stream otherwise

Specified by:
length in class Encoding
Returns:
0 Never > 0 Valid character, length returned -1 Illegal/malformed character < -1 (-1 - n) Number of missing bytes for character in p...end range Oniguruma equivalent: mbc_enc_len modified for 1.9 purposes,

strLength

public final int strLength(byte[] bytes,
                           int p,
                           int end)
Specified by:
strLength in class Encoding

strCodeAt

public int strCodeAt(byte[] bytes,
                     int p,
                     int end,
                     int index)
Specified by:
strCodeAt in class Encoding

mbcToCode

public int mbcToCode(byte[] bytes,
                     int p,
                     int end)
onigenc_single_byte_mbc_to_code

Specified by:
mbcToCode in class Encoding

codeToMbcLength

public final int codeToMbcLength(int code)
onigenc_single_byte_code_to_mbclen

Specified by:
codeToMbcLength in class Encoding

codeToMbc

public final int codeToMbc(int code,
                           byte[] bytes,
                           int p)
onigenc_single_byte_code_to_mbc

Specified by:
codeToMbc in class Encoding
Returns:
character length for the given code point Oniguruma equivalent: code_to_mbc

ctypeCodeRange

public final int[] ctypeCodeRange(int ctype,
                                  IntHolder sbOut)
onigenc_not_support_get_ctype_code_range

Specified by:
ctypeCodeRange in class Encoding

leftAdjustCharHead

public final int leftAdjustCharHead(byte[] bytes,
                                    int p,
                                    int s,
                                    int end)
onigenc_single_byte_left_adjust_char_head

Specified by:
leftAdjustCharHead in class Encoding
Parameters:
bytes - byte stream
p - position
s - stop
end - end

isReverseMatchAllowed

public final boolean isReverseMatchAllowed(byte[] bytes,
                                           int p,
                                           int end)
onigenc_always_true_is_allowed_reverse_match

Specified by:
isReverseMatchAllowed in class Encoding

isCodeCTypeInternal

protected final boolean isCodeCTypeInternal(int code,
                                            int ctype)
ONIGENC_IS_XXXXXX_CODE_CTYPE


isNewLine

public boolean isNewLine(byte[] bytes,
                         int p,
                         int end)
onigenc_is_mbc_newline_0x0a / used also by multibyte encodings

Specified by:
isNewLine in class Encoding

asciiMbcCaseFold

protected final int asciiMbcCaseFold(int flag,
                                     byte[] bytes,
                                     IntHolder pp,
                                     int end,
                                     byte[] lower)

mbcCaseFold

public int mbcCaseFold(int flag,
                       byte[] bytes,
                       IntHolder pp,
                       int end,
                       byte[] lower)
onigenc_ascii_mbc_case_fold

Specified by:
mbcCaseFold in class Encoding
Parameters:
flag - case fold flag
pp - an IntHolder that points at character head
lower - a buffer where to extract case folded character Oniguruma equivalent: mbc_case_fold

asciiApplyAllCaseFold

protected final void asciiApplyAllCaseFold(int flag,
                                           ApplyAllCaseFoldFunction fun,
                                           Object arg)

applyAllCaseFold

public void applyAllCaseFold(int flag,
                             ApplyAllCaseFoldFunction fun,
                             Object arg)
onigenc_ascii_apply_all_case_fold / used also by multibyte encodings

Specified by:
applyAllCaseFold in class Encoding
Parameters:
flag - case fold flag
fun - case folding functor (look at: ApplyCaseFold)
arg - case folding functor argument (look at: ApplyCaseFoldArg) Oniguruma equivalent: apply_all_case_fold

asciiCaseFoldCodesByString

protected final CaseFoldCodeItem[] asciiCaseFoldCodesByString(int flag,
                                                              byte[] bytes,
                                                              int p,
                                                              int end)

caseFoldCodesByString

public CaseFoldCodeItem[] caseFoldCodesByString(int flag,
                                                byte[] bytes,
                                                int p,
                                                int end)
onigenc_ascii_get_case_fold_codes_by_str / used also by multibyte encodings

Specified by:
caseFoldCodesByString in class Encoding

propertyNameToCType

public int propertyNameToCType(byte[] bytes,
                               int p,
                               int end)
onigenc_minimum_property_name_to_ctype notably overridden by unicode encodings

Specified by:
propertyNameToCType in class Encoding


Copyright © 2011. All Rights Reserved.