Class Block
java.lang.Object
org.glassfish.pfl.basic.tools.file.Block
Represents a range of Strings, typically read from a file, that are in some sense
related and contiguous. Blocks may also be tagged as an aid in transforming
a series of blocks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAfterLast
(String str) Add String after the end of the block.void
addBeforeFirst
(String str) Add String before the start of the block.void
addPrefixToAll
(String prefix) Add the prefix to each string in the block.void
Add a tag to the block.contents()
Get the contents of the block.boolean
Replace tabs with spaces, assuming tab stops are located as usual at n*8 + 1Return the first string in the block that contains the search string.int
hashCode()
boolean
Return whether or not a block has a particular tag.boolean
Return whether or not a block has ALL of the listed tags.instantiateTemplate
(Map<String, String> parameters) replace all occurrences of @KEY@ with parameters.get( KEY ).Split block into two blocks, with only the first line of the original Block in result.first().substitute
(List<? extends Pair<String, String>> substitutions) toString()
void
write
(FileWrapper fw) Write block to FileWrapper.
-
Constructor Details
-
Block
Create a new Block from a list of strings. -
Block
Create a new Block which is a copy of block.
-
-
Method Details
-
toString
-
equals
-
hashCode
public int hashCode() -
addTag
Add a tag to the block. Useful for classifying blocks. -
hasTag
Return whether or not a block has a particular tag. -
hasTags
Return whether or not a block has ALL of the listed tags. -
contents
Get the contents of the block. -
addBeforeFirst
Add String before the start of the block. -
addAfterLast
Add String after the end of the block. -
addPrefixToAll
Add the prefix to each string in the block. -
find
Return the first string in the block that contains the search string. -
write
Write block to FileWrapper. FileWrapper must be open for writing.- Throws:
IOException
-
instantiateTemplate
replace all occurrences of @KEY@ with parameters.get( KEY ). This is very simple: only one scan is made, so @...@ patterns in the parameters values are ignored. -
expandTabs
Replace tabs with spaces, assuming tab stops are located as usual at n*8 + 1 -
substitute
-
splitFirst
Split block into two blocks, with only the first line of the original Block in result.first().
-