org.netbeans.modules.editor.util/1 1.26

org.netbeans.lib.editor.util
Class CharacterConversions

java.lang.Object
  extended by org.netbeans.lib.editor.util.CharacterConversions

public final class CharacterConversions
extends Object

Provides some useful methods for character conversions.

Since:
1.21

Field Summary
static char CR
          Unicode carriage return (0x000D).
static char LF
          Unicode line feed (0x000A).
static char LS
          Unicode line separator (0x2028).
static char PS
          Unicode paragraph separator (0x2029).
 
Method Summary
static String lineFeedToLineSeparator(CharSequence text)
          Converts line feed characters (0x0A) to a system default line separator.
static String lineFeedToLineSeparator(CharSequence text, CharSequence lineSeparator)
          Converts line feed characters (0x0A) to the specified line separator.
static String lineSeparatorToLineFeed(CharSequence text)
          Converts line separators in text to line feed (0x0A) character.
static String lineSeparatorToLineFeed(CharSequence text, CharSequence lineSeparator)
          Converts line separators in text to line feed (0x0A) character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LF

public static final char LF
Unicode line feed (0x000A).

See Also:
Constant Field Values

CR

public static final char CR
Unicode carriage return (0x000D).

See Also:
Constant Field Values

LS

public static final char LS
Unicode line separator (0x2028).

See Also:
Constant Field Values

PS

public static final char PS
Unicode paragraph separator (0x2029).

See Also:
Constant Field Values
Method Detail

lineSeparatorToLineFeed

public static String lineSeparatorToLineFeed(CharSequence text)
Converts line separators in text to line feed (0x0A) character. It automatically detects all sorts of line separators such as CRLF, LF, LS and PS. The text can even contain a mixture of those separators.

Parameters:
text - The text to convert line seprators in. This can be null, in which case an empty string is returned.
Returns:
The text with line separators replaced by the line feed character.

lineSeparatorToLineFeed

public static String lineSeparatorToLineFeed(CharSequence text,
                                             CharSequence lineSeparator)
Converts line separators in text to line feed (0x0A) character. This method will only look for the lineSeparator characters and will ignore all other characters that could possibly be used for separating lines in the text. If you want automatic detection of all possible line separators use lineSeparatorToLineFeed(CharSequence).

Parameters:
text - The text to convert line seprators in. This can be null, in which case an empty string is returned.
lineSeparator - The line separator to look for and replace.
Returns:
The text with lineSeparators replaced by the line feed character.

lineFeedToLineSeparator

public static String lineFeedToLineSeparator(CharSequence text)
Converts line feed characters (0x0A) to a system default line separator. The line separator for your system is determined by looking at the "line.separator" system property of your JVM.

Parameters:
text - The text to convert line feed characters in. Can be null, in which case an empty string is returned.
Returns:
The text with line feed characters replaced by a line separator used on your system.

lineFeedToLineSeparator

public static String lineFeedToLineSeparator(CharSequence text,
                                             CharSequence lineSeparator)
Converts line feed characters (0x0A) to the specified line separator.

Parameters:
text - The text to convert line feed characters in. Can be null, in which case an empty string is returned.
lineSeparator - The line separator to use as a replacement.
Returns:
The text with line feed characters replaced by the lineSeparator.

org.netbeans.modules.editor.util/1 1.26

Built on December 3 2008.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.