public class CharacterUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CharacterUtil.LineCount
Number of lines and line separator (break character) in one box.
|
Constructor and Description |
---|
CharacterUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
countLinebreaks(char[] buffer,
int offset,
int length)
Returns the number of line breaks (\n, \r or combination thereof)
found in the specified buffer.
|
static CharacterUtil.LineCount |
countLinebreaks(java.io.InputStream instream)
Returns the number of lines (\n, \r or combination thereof)
found in the specified input and its type.
|
static java.lang.String |
flatWhiteSpace(java.lang.String raw)
Replaces every sequence of whitespace characters
with a single blank (" ").
|
static java.nio.charset.Charset[] |
getCharsetList(java.util.List<java.nio.charset.Charset> availableCharsets,
java.nio.charset.Charset actualCharset)
Returns the supplied List as an array, and guarantees that the specified actual Charset is contained.
|
static boolean |
isLineBreakChar(char c)
Returns true if the specified character is
a linefeed (LF) or a carriage return (CR).
|
static void |
reportIllegalCharacter(char[] text,
int offset,
int length,
java.nio.charset.CharsetEncoder encoder,
int firstLine,
MessageBox messageBox,
Localizer localizer)
Find the position of the first illegal character for the present
encoding (if any) and write a suitable message to the message sink.
|
public static int countLinebreaks(char[] buffer, int offset, int length)
buffer
- where to lookoffset
- where to start lookinglength
- how many characters to testpublic static CharacterUtil.LineCount countLinebreaks(java.io.InputStream instream) throws java.io.IOException
instream
- where to lookjava.io.IOException
- if the stream throws onepublic static void reportIllegalCharacter(char[] text, int offset, int length, java.nio.charset.CharsetEncoder encoder, int firstLine, MessageBox messageBox, Localizer localizer)
text
- to be scanned for illegal charactersoffset
- where to start scanninglength
- how many characters to scanencoder
- encoder to be used for testingfirstLine
- number of first linemessageBox
- where to write the message tolocalizer
- to be used for translationspublic static java.lang.String flatWhiteSpace(java.lang.String raw)
raw
- to be flattendpublic static boolean isLineBreakChar(char c)
c
- to be testedpublic static java.nio.charset.Charset[] getCharsetList(java.util.List<java.nio.charset.Charset> availableCharsets, java.nio.charset.Charset actualCharset)
availableCharsets
- list to be returned as array, actual Charset includedactualCharset
- the one charset that must be included in the list