Package jflex.generator
Class PackEmitter
- java.lang.Object
-
- jflex.generator.PackEmitter
-
- Direct Known Subclasses:
CountEmitter,HiLowEmitter
public abstract class PackEmitter extends java.lang.ObjectEncodesintarrays 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
Fields Modifier and Type Field Description protected intchunksnumber of existing string chunksprivate static java.lang.Stringindentindent for string linesprivate intlineposposition in the current lineprivate static intmaxEntriesmax number of entries per lineprivate static intmaxSizemaximum size of chunksprotected java.lang.Stringnamename of the generated array (mixed case, no yy prefix)protected java.lang.StringBuilderoutoutput bufferprivate intUTF8Lengthcurrent UTF8 length of generated string in current chunk
-
Constructor Summary
Constructors Constructor Description PackEmitter(java.lang.String name)Create new emitter for an array.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbreaks()Execute line/chunk break if necessary.protected java.lang.StringconstName()Convert 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 voidemitUnpack()Emit the unpacking code.private voidnextChunk()emit next chunkprotected voidnl()emit newlineprotected voidprintln(java.lang.String s)println.private voidprintUC(char c)Append a unicode/octal escaped character tooutbuffer.java.lang.StringtoString()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 Detail
-
name
protected java.lang.String name
name of the generated array (mixed case, no yy prefix)
-
UTF8Length
private int UTF8Length
current UTF8 length of generated string in current chunk
-
linepos
private int linepos
position in the current line
-
maxEntries
private static final int maxEntries
max number of entries per line- See Also:
- Constant Field Values
-
out
protected java.lang.StringBuilder out
output buffer
-
chunks
protected int chunks
number of existing string chunks
-
maxSize
private static final int maxSize
maximum size of chunks- See Also:
- Constant Field Values
-
indent
private static final java.lang.String indent
indent for string lines- See Also:
- Constant Field Values
-
-
Method Detail
-
constName
protected java.lang.String constName()
Convert array name into all uppercase internal scanner constant name.- Returns:
nameas a internal constant name.- See Also:
name
-
toString
public java.lang.String toString()
Return current output buffer.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringobject.
-
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
protected void println(java.lang.String s)
println.- Parameters:
s- aStringobject.
-
-