org.jomc.util
Class LineEditor

Package class diagram package LineEditor
java.lang.Object
  extended by org.jomc.util.LineEditor
Direct Known Subclasses:
SectionEditor, TrailingWhitespaceEditor

public class LineEditor
extends Object

Interface to line based editing.

Version:
$JOMC: LineEditor.java 3875 2011-10-19 09:17:25Z schulte2005 $
Author:
Christian Schulte
See Also:
edit(java.lang.String)

Constructor Summary
LineEditor()
          Creates a new LineEditor instance.
LineEditor(LineEditor editor)
          Creates a new LineEditor instance taking an editor to chain.
LineEditor(LineEditor editor, String lineSeparator)
          Creates a new LineEditor instance taking an editor to chain and a string to use for separating lines.
LineEditor(String lineSeparator)
          Creates a new LineEditor instance taking a string to use for separating lines.
 
Method Summary
 String edit(String text)
          Edits text.
protected  String editLine(String line)
          Edits a line.
 long getLineNumber()
          Gets the current line number.
 String getLineSeparator()
          Gets the line separator of the editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineEditor

public LineEditor()
Creates a new LineEditor instance.


LineEditor

public LineEditor(String lineSeparator)
Creates a new LineEditor instance taking a string to use for separating lines.

Parameters:
lineSeparator - String to use for separating lines.

LineEditor

public LineEditor(LineEditor editor)
Creates a new LineEditor instance taking an editor to chain.

Parameters:
editor - The editor to chain.

LineEditor

public LineEditor(LineEditor editor,
                  String lineSeparator)
Creates a new LineEditor instance taking an editor to chain and a string to use for separating lines.

Parameters:
editor - The editor to chain.
lineSeparator - String to use for separating lines.
Method Detail

getLineSeparator

public final String getLineSeparator()
Gets the line separator of the editor.

Returns:
The line separator of the editor.

getLineNumber

public final long getLineNumber()
Gets the current line number.

Returns:
The current line number.
Since:
1.2

edit

public final String edit(String text)
                  throws IOException
Edits text.

This method splits the given string into lines and passes every line to method editLine in order of occurrence. On end of input, method editLine is called with a null argument.

Parameters:
text - The text to edit or null.
Returns:
The edited text or null.
Throws:
IOException - if editing fails.

editLine

protected String editLine(String line)
                   throws IOException
Edits a line.

Parameters:
line - The line to edit or null, indicating the end of input.
Returns:
The string to replace line with or null, to replace line with nothing.
Throws:
IOException - if editing fails.


Copyright © 2005-2012 The JOMC Project. All Rights Reserved.Get JOMC at SourceForge.net. Fast, secure and Free Open Source software downloads
Please note that this documentation is maintained by non-native english speaking authors. As such, you may encounter phrases or wordings which seem imprecise or may even have a totally different meaning to native english speaking readers than what the individual author was trying to express. If you are a native english speaking reader and find any such phrases or wordings we kindly ask you to send an email to the corresponding author and help us improve this documentation in order to avoid misunderstandings. You will find the authors' email addresses at the top of each class. Please accept our apologies for any inconvenience caused.