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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAfterLast(String str) Add String after the end of the block.voidaddBeforeFirst(String str) Add String before the start of the block.voidaddPrefixToAll(String prefix) Add the prefix to each string in the block.voidAdd a tag to the block.contents()Get the contents of the block.booleanReplace tabs with spaces, assuming tab stops are located as usual at n*8 + 1private StringexpandTabs(String src) Return the first string in the block that contains the search string.inthashCode()booleanReturn whether or not a block has a particular tag.booleanReturn 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()voidwrite(FileWrapper fw) Write block to FileWrapper.
-
Field Details
-
data
-
tags
-
-
Constructor Details
-
Block
-
Block
-
Block
Create a new Block which is a copy of block.
-
-
Method Details
-
toString
-
equals
-
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
-
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
-
write
Write block to FileWrapper. FileWrapper must be open for writing.- Throws:
IOException
-
instantiateTemplate
-
expandTabs
-
expandTabs
Replace tabs with spaces, assuming tab stops are located as usual at n*8 + 1 -
substitute
-
splitFirst
-