Package net.sourceforge.pmd.document
Class DocumentFile
- java.lang.Object
-
- net.sourceforge.pmd.document.DocumentFile
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Document
public class DocumentFile extends Object implements Document, Closeable
Implementation that handles a Document as a file in the filesystem and receives operations in a sorted manner (i.e. the regions are sorted). This improves the efficiency of reading the file by only scanning it once while operations are applied, until an instance of this document is closed.
-
-
Constructor Summary
Constructors Constructor Description DocumentFile(File file, Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
delete(RegionByLine regionByOffset)
Delete a region in the document, removing all text which contains it.void
insert(int beginLine, int beginColumn, String textToInsert)
Insert a text at a line at the position/column specified.void
replace(RegionByLine regionByLine, String textToReplace)
Replace a specific region in the document which contains text by another text, which not necessarily is the same length as the region's one.
-
-
-
Constructor Detail
-
DocumentFile
public DocumentFile(File file, Charset charset) throws IOException
- Throws:
IOException
-
-
Method Detail
-
insert
public void insert(int beginLine, int beginColumn, String textToInsert)
Description copied from interface:Document
Insert a text at a line at the position/column specified. If there is any text to the right of the insertion, that text is shifted by the length of the text to insert, which means that it is not replaced.
-
replace
public void replace(RegionByLine regionByLine, String textToReplace)
Description copied from interface:Document
Replace a specific region in the document which contains text by another text, which not necessarily is the same length as the region's one.
-
delete
public void delete(RegionByLine regionByOffset)
Description copied from interface:Document
Delete a region in the document, removing all text which contains it. If there is any text to the right of this region, it will be shifted to the left by the length of the region to delete.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-