Package jflex.generator
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.8.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
number of existing string chunksprivate static final String
indent for string linesprivate int
position in the current lineprivate static final int
max number of entries per lineprivate static final int
maximum size of chunksprotected String
name of the generated array (mixed case, no yy prefix)protected StringBuilder
output bufferprivate int
current UTF8 length of generated string in current chunk -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
breaks()
Execute line/chunk break if necessary.protected String
Convert array name into all uppercase internal scanner constant name.void
emitInit()
Emit declaration of decoded member and open first chunk.void
emitUC
(int i) Emit single unicode character.abstract void
Emit the unpacking code.private void
emit next chunkprotected void
nl()
emit newlineprotected void
println.private void
printUC
(char c) Append a unicode/octal escaped character toout
buffer.toString()
Return current output buffer.private static int
Utf8Length
(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
indent for string lines- See Also:
-
-
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:
name
as a internal constant name.- See Also:
-
toString
Return current output buffer. -
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 toout
buffer.- 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
println.- Parameters:
s
- aString
object.
-