Class PackEmitter

java.lang.Object
jflex.generator.PackEmitter
Direct Known Subclasses:
CountEmitter, HiLowEmitter

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();

Version:
JFlex 1.8.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    number of existing string chunks
    private static final String
    indent for string lines
    private int
    position in the current line
    private static final int
    max number of entries per line
    private static final int
    maximum size of chunks
    protected String
    name of the generated array (mixed case, no yy prefix)
    protected StringBuilder
    output buffer
    private int
    current UTF8 length of generated string in current chunk
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create new emitter for an array.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Execute line/chunk break if necessary.
    protected String
    Convert array name into all uppercase internal scanner constant name.
    void
    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 chunk
    protected void
    nl()
    emit newline
    protected void
    println.
    private void
    printUC(char c)
    Append a unicode/octal escaped character to out buffer.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      protected 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:
    • out

      protected 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:
    • indent

      private static final String indent
      indent for string lines
      See Also:
  • Constructor Details

    • PackEmitter

      public PackEmitter(String name)
      Create new emitter for an array.
      Parameters:
      name - the name of the generated array
  • Method Details

    • constName

      protected String constName()
      Convert array name into all uppercase internal scanner constant name.
      Returns:
      name as a internal constant name.
      See Also:
    • toString

      public String toString()
      Return current output buffer.
      Overrides:
      toString in class Object
      Returns:
      a String object.
    • 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 to out 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

      protected void println(String s)
      println.
      Parameters:
      s - a String object.