|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.jomc.util.LineEditor
org.jomc.util.SectionEditor
public class SectionEditor
Interface to section based editing.
Section based editing is a two phase process of parsing the editor's input into a corresponding hierarchy of
Section instances, followed by rendering the parsed sections to produce the output of the editor. Method
editLine returns null during parsing and the output of the editor on end of input, rendered by
calling method getOutput. Parsing is backed by methods getSection and isSectionFinished.
LineEditor.edit(java.lang.String)| Field Summary | |
|---|---|
private static String |
DEFAULT_SECTION_END
Marker indicating the end of a section. |
private static String |
DEFAULT_SECTION_START
Marker indicating the start of a section. |
private Stack<Section> |
stack
Stack of sections. |
| Constructor Summary | |
|---|---|
SectionEditor()
Creates a new SectionEditor instance. |
|
SectionEditor(LineEditor editor)
Creates a new SectionEditor instance taking an editor to chain. |
|
SectionEditor(LineEditor editor,
String lineSeparator)
Creates a new SectionEditor instance taking an editor to chain and a string to use for separating lines. |
|
SectionEditor(String lineSeparator)
Creates a new SectionEditor instance taking a string to use for separating lines. |
|
| Method Summary | |
|---|---|
protected String |
editLine(String line)
Edits a line. |
protected String |
getOutput(Section root)
Gets the output of the editor. |
protected Section |
getSection(String line)
Parses the given line to mark the start of a new section. |
protected boolean |
isSectionFinished(String line)
Parses the given line to mark the end of a section. |
private StringBuilder |
renderSections(Section section,
StringBuilder buffer)
Appends the content of a given section to a given buffer. |
| Methods inherited from class org.jomc.util.LineEditor |
|---|
edit, getLineSeparator |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final String DEFAULT_SECTION_START
private static final String DEFAULT_SECTION_END
private Stack<Section> stack
| Constructor Detail |
|---|
public SectionEditor()
SectionEditor instance.
public SectionEditor(String lineSeparator)
SectionEditor instance taking a string to use for separating lines.
lineSeparator - String to use for separating lines.public SectionEditor(LineEditor editor)
SectionEditor instance taking an editor to chain.
editor - The editor to chain.
public SectionEditor(LineEditor editor,
String lineSeparator)
SectionEditor instance taking an editor to chain and a string to use for separating lines.
editor - The editor to chain.lineSeparator - String to use for separating lines.| Method Detail |
|---|
protected final String editLine(String line)
LineEditor
editLine in class LineEditorline - The line to edit or null indicating the end of input.
line with, or null to replace line with nothing.protected Section getSection(String line)
line - The line to parse.
line or null if line does not mark the start of a
section.protected boolean isSectionFinished(String line)
line - The line to parse.
true if line marks the end of a section; false if line does not mark the
end of a section.protected String getOutput(Section root)
This method returns the unchanged input by rendering the given sections. Overwriting classes may call this method after having updated the given sections for rendering edited content.
root - The root of the parsed sections to render the editor's output with.
NullPointerException - if root is null.Section.getSections()
private StringBuilder renderSections(Section section,
StringBuilder buffer)
section - The section to render.buffer - The buffer to append the content of section to.
buffer with content of section appended.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||