public final class FileText extends AbstractList<String>
This class will be passed to instances of class FileSetCheck by Checker. It implements a string list to ensure backwards compatibility, but can be extended in the future to allow more flexible, more powerful or more efficient handling of certain situations.
modCount| Constructor and Description |
|---|
FileText(File file,
String charsetName)
Creates a new file text representation.
|
| Modifier and Type | Method and Description |
|---|---|
static FileText |
fromLines(File file,
List<String> lines)
Compatibility conversion.
|
String |
get(int lineNo)
Retrieves a line of the text by its number.
|
ByteBuffer |
getBytes()
Get the binary contents of the file.
|
Charset |
getCharset()
Get the character set which was used to read the file.
|
File |
getFile()
Get the name of the file.
|
CharSequence |
getFullText()
Retrieve the full text of the file.
|
LineColumn |
lineColumn(int pos)
Determine line and column numbers in full text.
|
int |
size()
Counts the lines of the text.
|
String[] |
toLinesArray()
Returns an array of all lines.
|
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringpublic FileText(File file, String charsetName) throws IOException
file - the name of the filecharsetName - the encoding to use when reading the fileNullPointerException - if the text is nullIOException - if the file could not be readpublic static FileText fromLines(File file, List<String> lines)
FileSetCheck.process(File,List) to a FileText
object. If the list of lines already is a FileText, it is
returned as is. Otherwise, a new FileText is constructed by
joining the lines using line feed characters.file - the name of the filelines - the lines of the text, without terminatorspublic File getFile()
public Charset getCharset()
null for a file reconstructed from its lines.public ByteBuffer getBytes() throws IOException
IOException - if the bytes could not be read from the filepublic CharSequence getFullText()
public String[] toLinesArray()
text.toLinesArray() is equivalent to
text.toArray(new String[text.size()]).public LineColumn lineColumn(int pos)
pos - the character position in the full textpublic String get(int lineNo)
public int size()
size in interface Collection<String>size in interface List<String>size in class AbstractCollection<String>Copyright © 2001–2015. All rights reserved.