|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<String>
com.puppycrawl.tools.checkstyle.api.FileText
public final class FileText
Represents the text contents of a file of arbitrary plain text type.
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.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
FileText(File aFile,
String aCharsetName)
Creates a new file text representation. |
Method Summary | |
---|---|
static FileText |
fromLines(File aFile,
List<String> aLines)
Compatibility conversion. |
String |
get(int aLineNo)
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 aPos)
Determine line and column numbers in full text. |
int |
size()
Counts the lines of the text. |
String[] |
toLinesArray()
Returns an array of all lines. |
Methods inherited from class java.util.AbstractList |
---|
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public FileText(File aFile, String aCharsetName) throws IOException
aFile
- the name of the fileaCharsetName
- the encoding to use when reading the file
NullPointerException
- if the text is null
IOException
- if the file could not be readMethod Detail |
---|
public static FileText fromLines(File aFile, List<String> aLines)
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.
aFile
- the name of the fileaLines
- the lines of the text, without terminators
public 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 aPos)
aPos
- the character position in the full text
public String get(int aLineNo)
get
in interface List<String>
get
in class AbstractList<String>
aLineNo
- the number of the line to get, starting at zero
public int size()
size
in interface Collection<String>
size
in interface List<String>
size
in class AbstractCollection<String>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |