public abstract class

CodeDocumentPart

extends Object
implements ICodeDocument ITextDocumentPart
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.output.code.CodeDocumentPart
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A document part specific to code outputs. Use with CodeDocument Remember to call registerAnchor(String) before generating content at a given anchor point.

The type of ILine used is CodeLine. The type of IAnchor used is CodeAnchor.

Clients must extend this class.

Summary

Fields
protected String indentString
protected String paddingString
Public Constructors
CodeDocumentPart(long baseAnchorId)
Create a new code document part, attached to the given anchor.
Public Methods
void append(String str, ItemClassIdentifiers classId)
void append(String s)
void append(String s, int[] aActualInsertionIndex)
Append a chunk of text to the current line.
void appendAndRecord(String s, ItemClassIdentifiers classId, long itemId, int flags)
Append a chunk of text to the current line.
void appendAndRecord(String s, ItemClassIdentifiers classId, long itemId)
Append a chunk of text to the current line.
void appendAndRecord(String s, ItemClassIdentifiers classId)
Append a chunk of text to the current line.
void appendComment(String text, boolean auto)
void appendComment(String text)
void appendCommentAuto(String text)
void appendKeyword(String keyword)
Convenience method.
void appendKeyword(String keyword, long itemId)
void appendMulti(String s)
void appendParameterSeparator()
Append a parameter separator to the current line.
void brace()
void braceClose()
void bracket()
void bracketClose()
void decrementIndentationLevel()
void disablePadding()
void enablePadding()
static boolean enableTokenFlattening(boolean enabled)
Enable or disable token flattening.
void eol()
End the current line.
void eol(ICodeCoordinates lineCoord)
End the current line.
String format()
List<CodeAnchor> getAnchors()
Get the anchors within that part.
CodeAnchor getCurrentAnchor()
Get the currently active anchor.
ICodeCoordinates getCurrentCoordinates()
CodeLine getCurrentLine()
Get the last (unfinished) line
ICodeCoordinates getCurrentLineCoordinates()
int getCurrentLineIndex()
int getCurrentLineLength()
int getCurrentMarginLength()
ICodeCoordinates getCurrentMostPreciseCodeCoordinates()
int getIndentationLevel()
String getIndentationString()
int getLastLineIndex()
Get the index of the last finished line.
CodeLine getLine(int index)
int getLineCount()
Get the number of finished (EOL-terminated) lines in this part.
List<CodeLine> getLines()
Get the lines within that part.
List<ObjectLocation> getObjectLocations()
Retrieve the list of objects represented in the part, as well as their locations (line start/end, column start/end).
void incrementIndentationLevel()
void indentReset()
boolean isCurrentLineEmpty()
void markCurrentPosition(String name, Object object)
boolean moveLastLine(int newIndex)
boolean moveLine(int index, int newIndex)
void paren()
void parenClose()
void prependCodePart(CodeDocumentPart part)
void recordCurrentCoordinates(ICodeCoordinates coordinates)
void recordLineCoordinates(ICodeCoordinates coordinates)
void recordObjectLocation(Object object, boolean begin, int depth)
boolean registerAnchor(String name)
Create an anchor using the current (next) anchor id, and register it at the current last line.
boolean registerAnchor(long anchorId, String name)
Create an anchor with the provided anchor id, and register it at the current last line.
void resetPaddingString()
void setIndentationLevel(int level)
void setIndentationString(String indentString)
void setPaddingString(String paddingString)
void setParameterSeparator(String parameterSeparator)
Set the parameter separator.
void space()
Append a space to the current line.
void space(int cnt)
Append one or more spaces to the current line.
String toString()
void unrecordCurrentCoordinates()
void unrecordLineCoordinates()
void validate()
Protected Methods
void appendKeyword(int id)
int registerKeyword(String keyword)
Register a keyword for future fast appending.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.output.code.ICodeDocument
From interface com.pnfsoftware.jeb.core.output.text.ITextDocumentPart

Fields

protected String indentString

protected String paddingString

Public Constructors

public CodeDocumentPart (long baseAnchorId)

Create a new code document part, attached to the given anchor. An 8-space padding and a 4-space indentation is selected by default.

Parameters
baseAnchorId the base anchor identifier

Public Methods

public void append (String str, ItemClassIdentifiers classId)

public void append (String s)

public void append (String s, int[] aActualInsertionIndex)

Append a chunk of text to the current line. The line should not contain CR/LF characters.

Parameters
s chunk of text, should not contain CR or LF characters. If found, they are replaced by slash ('/') characters
aActualInsertionIndex optional: set the index of the inserted string (can be different from current index because of padding) at 0-index

public void appendAndRecord (String s, ItemClassIdentifiers classId, long itemId, int flags)

Append a chunk of text to the current line.

Parameters
s a string
classId a class identifier
itemId an item identifier
flags flags

public void appendAndRecord (String s, ItemClassIdentifiers classId, long itemId)

Append a chunk of text to the current line.

Parameters
s a string
classId a class identifier
itemId an item identifier

public void appendAndRecord (String s, ItemClassIdentifiers classId)

Append a chunk of text to the current line.

Parameters
s a string
classId a class identifier

public void appendComment (String text, boolean auto)

public void appendComment (String text)

public void appendCommentAuto (String text)

public void appendKeyword (String keyword)

Convenience method.

public void appendKeyword (String keyword, long itemId)

public void appendMulti (String s)

public void appendParameterSeparator ()

Append a parameter separator to the current line. Use setParameterSeparator(String) to override default.

public void brace ()

public void braceClose ()

public void bracket ()

public void bracketClose ()

public void decrementIndentationLevel ()

public void disablePadding ()

public void enablePadding ()

public static boolean enableTokenFlattening (boolean enabled)

Enable or disable token flattening. This method is reserved for internal use. Refer to the Engines property FlattenStringsInCodeDocuments if you wish to modify whether tokens should be flattened when they are appended to a text document.

Returns
  • the previous setting

public void eol ()

End the current line.

public void eol (ICodeCoordinates lineCoord)

End the current line.

Parameters
lineCoord optional chunk coordinates

public String format ()

public List<CodeAnchor> getAnchors ()

Get the anchors within that part. The last anchor object may be used to specify the first anchor id of the next, contiguous part. It is especially useful in cases where a line spans multiple anchor ids.

Returns
  • the list of anchors

public CodeAnchor getCurrentAnchor ()

Get the currently active anchor.

public ICodeCoordinates getCurrentCoordinates ()

public CodeLine getCurrentLine ()

Get the last (unfinished) line

Returns
  • the last line

public ICodeCoordinates getCurrentLineCoordinates ()

public int getCurrentLineIndex ()

Returns
  • the line count

public int getCurrentLineLength ()

public int getCurrentMarginLength ()

public ICodeCoordinates getCurrentMostPreciseCodeCoordinates ()

public int getIndentationLevel ()

public String getIndentationString ()

public int getLastLineIndex ()

Get the index of the last finished line.

Returns
  • the last finished line index

public CodeLine getLine (int index)

public int getLineCount ()

Get the number of finished (EOL-terminated) lines in this part. A line is finished by calling eol().

Returns
  • the number of lines, excluding the last (unfinished) line

public List<CodeLine> getLines ()

Get the lines within that part. The lines may span over one or more anchors.

Returns
  • the list of lines

public List<ObjectLocation> getObjectLocations ()

Retrieve the list of objects represented in the part, as well as their locations (line start/end, column start/end). A given coordinates within the part may host multiple objects.

Implementation of this method is optional; to ensure backward compatibility with existing documents, the default implementation returns an empty collection.

Returns
  • a collection of objects; the type of objects is specific to the document (and in the common case, the unit that generated the document)

public void incrementIndentationLevel ()

public void indentReset ()

public boolean isCurrentLineEmpty ()

public void markCurrentPosition (String name, Object object)

public boolean moveLastLine (int newIndex)

public boolean moveLine (int index, int newIndex)

public void paren ()

public void parenClose ()

public void prependCodePart (CodeDocumentPart part)

public void recordCurrentCoordinates (ICodeCoordinates coordinates)

public void recordLineCoordinates (ICodeCoordinates coordinates)

public void recordObjectLocation (Object object, boolean begin, int depth)

public boolean registerAnchor (String name)

Create an anchor using the current (next) anchor id, and register it at the current last line.

Parameters
name the anchor name
Returns
  • true if the anchor was successfully registered

public boolean registerAnchor (long anchorId, String name)

Create an anchor with the provided anchor id, and register it at the current last line.

Returns
  • true if the anchor was successfully registered

public void resetPaddingString ()

public void setIndentationLevel (int level)

public void setIndentationString (String indentString)

public void setPaddingString (String paddingString)

public void setParameterSeparator (String parameterSeparator)

Set the parameter separator. Default is ", ".

Parameters
parameterSeparator new parameter separator

public void space ()

Append a space to the current line.

public void space (int cnt)

Append one or more spaces to the current line.

Parameters
cnt the number of spaces to be appended; may be <= 0, in which case, this method will do nothing

public String toString ()

public void unrecordCurrentCoordinates ()

public void unrecordLineCoordinates ()

public void validate ()

Protected Methods

protected void appendKeyword (int id)

protected int registerKeyword (String keyword)

Register a keyword for future fast appending. Use for frequent keywords to bypass some internal checks.

Parameters
keyword a keyword ".", ";" for example...
Returns
  • the id of the keyword;