JFlex

Class PackEmitter

public abstract class PackEmitter extends Object

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();
Field Summary
protected intchunks
number of existing string chunks
protected Stringname
name of the generated array (mixed case, no yy prefix)
protected StringBufferout
output buffer
Constructor Summary
PackEmitter(String name)
Create new emitter for an array.
Method Summary
voidbreaks()
Execute line/chunk break if necessary.
protected 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.
protected voidnl()
emit newline
protected voidprintln(String s)
StringtoString()
Return current output buffer.

Field Detail

chunks

protected int chunks
number of existing string chunks

name

protected String name
name of the generated array (mixed case, no yy prefix)

out

protected StringBuffer out
output buffer

Constructor Detail

PackEmitter

public PackEmitter(String name)
Create new emitter for an array.

Parameters: name the name of the generated array

Method Detail

breaks

public void breaks()
Execute line/chunk break if necessary. Leave space for at least two chars.

constName

protected String constName()
Convert array name into all uppercase internal scanner constant name.

Returns: name as a internal constant name.

See Also: name

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.

UNKNOWN: 0 <= i <= 0xFFFF

emitUnpack

public abstract void emitUnpack()
Emit the unpacking code.

nl

protected void nl()
emit newline

println

protected void println(String s)

toString

public String toString()
Return current output buffer.