|
||||||||||
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)
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 void |
editSection(Section section)
Edits a section. |
protected String |
getOutput(Section section)
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. |
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 |
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) throws IOException
LineEditor
editLine
in class LineEditor
line
- The line to edit or null
indicating the end of input.
line
with, or null
to replace line
with nothing.
IOException
- if editing fails.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 void editSection(Section section) throws IOException
This method does not change any content by default. Overriding classes may use this method for editing sections prior to rendering.
section
- The section to edit.
NullPointerException
- if section
is null
.
IOException
- if editing fails.protected String getOutput(Section section) throws IOException
This method calls method editSection()
for each section of the editor prior to rendering the sections
to produce the output of the editor.
section
- The section to start rendering the editor's output with.
NullPointerException
- if section
is null
.
IOException
- if editing or rendering fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |