Class PackEmitter
java.lang.Object
jflex.generator.PackEmitter
- Direct Known Subclasses:
CountEmitter, HiLowEmitter
Encodes
int arrays as strings.
Also splits up strings when longer than 64K in UTF8 encoding. Subclasses emit unpacking code.
Usage protocol: p.emitInit();
for each data: p.emitData(data);
p.emitUnpack();
- Version:
- JFlex 1.9.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intnumber of existing string chunksprivate static final Stringindent for string linesprivate intposition in the current lineprivate static final intmax number of entries per lineprivate static final intmaximum size of chunksprotected Stringname of the generated array (mixed case, no yy prefix)protected StringBuilderoutput bufferprivate intcurrent UTF8 length of generated string in current chunk -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbreaks()Execute line/chunk break if necessary.protected StringConvert array name into all uppercase internal scanner constant name.voidemitInit()Emit declaration of decoded member and open first chunk.voidemitUC(int i) Emit single unicode character.abstract voidEmit the unpacking code.private voidemit next chunkprotected voidnl()emit newlineprotected voidprintln.private voidprintUC(char c) Append a unicode/octal escaped character tooutbuffer.toString()Return current output buffer.private static intUtf8Length(int value) Calculates the number of bytes a Unicode character would have in UTF8 representation in a class file.
-
Field Details
-
name
name of the generated array (mixed case, no yy prefix) -
UTF8Length
private int UTF8Lengthcurrent UTF8 length of generated string in current chunk -
linepos
private int lineposposition in the current line -
maxEntries
private static final int maxEntriesmax number of entries per line- See Also:
-
out
output buffer -
chunks
protected int chunksnumber of existing string chunks -
maxSize
private static final int maxSizemaximum size of chunks- See Also:
-
indent
-
-
Constructor Details
-
PackEmitter
Create new emitter for an array.- Parameters:
name- the name of the generated array
-
-
Method Details
-
constName
Convert array name into all uppercase internal scanner constant name.- Returns:
nameas a internal constant name.- See Also:
-
toString
-
emitInit
public void emitInit()Emit declaration of decoded member and open first chunk. -
emitUC
public void emitUC(int i) Emit single unicode character.Updates length, position, etc.
- Parameters:
i- the character to emit.
-
breaks
public void breaks()Execute line/chunk break if necessary. Leave space for at least two chars. -
emitUnpack
public abstract void emitUnpack()Emit the unpacking code. -
nextChunk
private void nextChunk()emit next chunk -
nl
protected void nl()emit newline -
printUC
private void printUC(char c) Append a unicode/octal escaped character tooutbuffer.- Parameters:
c- the character to append
-
Utf8Length
private static int Utf8Length(int value) Calculates the number of bytes a Unicode character would have in UTF8 representation in a class file.- Parameters:
value- the char code of the Unicode character- Returns:
- length of UTF8 representation.
-
println
-