public abstract class PackEmitter
extends java.lang.Object
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();
Modifier and Type | Field and Description |
---|---|
protected int |
chunks
number of existing string chunks
|
private static java.lang.String |
indent
indent for string lines
|
private int |
linepos
position in the current line
|
private static int |
maxEntries
max number of entries per line
|
private static int |
maxSize
maximum size of chunks
|
protected java.lang.String |
name
name of the generated array (mixed case, no yy prefix)
|
protected java.lang.StringBuilder |
out
output buffer
|
private int |
UTF8Length
current UTF8 length of generated string in current chunk
|
Constructor and Description |
---|
PackEmitter(java.lang.String name)
Create new emitter for an array.
|
Modifier and Type | Method and Description |
---|---|
void |
breaks()
Execute line/chunk break if necessary.
|
protected java.lang.String |
constName()
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 |
emitUnpack()
Emit the unpacking code.
|
private void |
nextChunk()
emit next chunk
|
protected void |
nl()
emit newline
|
protected void |
println(java.lang.String s) |
private void |
printUC(char c)
Append a unicode/octal escaped character
to
out buffer. |
java.lang.String |
toString()
Return current output buffer.
|
private int |
UTF8Length(int value)
Calculates the number of bytes a Unicode character
would have in UTF8 representation in a class file.
|
protected java.lang.String name
private int UTF8Length
private int linepos
private static final int maxEntries
protected java.lang.StringBuilder out
protected int chunks
private static final int maxSize
private static final java.lang.String indent
public PackEmitter(java.lang.String name)
name
- the name of the generated arrayprotected java.lang.String constName()
name
as a internal constant name.name
public java.lang.String toString()
toString
in class java.lang.Object
public void emitInit()
public void emitUC(int i)
i
- the character to emit.public void breaks()
public abstract void emitUnpack()
private void nextChunk()
protected void nl()
private void printUC(char c)
out
buffer.c
- the character to appendprivate int UTF8Length(int value)
value
- the char code of the Unicode characterprotected void println(java.lang.String s)