Package nom.tam.fits.utilities
Class FitsLineAppender
- java.lang.Object
-
- nom.tam.fits.utilities.FitsLineAppender
-
public class FitsLineAppender extends java.lang.ObjectThis class handles the writing of a card line. It keeps track of the position in the line and will limit it to 80 characters. A write will never cross the line border but a write when the line is at position 80 will start a new line.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilderbufferthe underlying StringBuilder to which the writing of fits lines happens.private intcharCountthe char current position in the line.private static java.lang.StringFULL_CARD_AS_SPACESA String of 80 spaces to fill up fits card space.
-
Constructor Summary
Constructors Constructor Description FitsLineAppender()create a new FitsLineAppender that will have space allocated for one line.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char character)append a character to the fits line.voidappend(java.lang.String string)append a string to the fits line, but limit the append to the line length.voidappend(java.lang.String key, int start, int end)voidappend(FitsSubString stringValue)Append a sub-string to this line.voidappendReplacing(java.lang.String key, char toReplace, char with)append a string to the buffer, replacing all occurrences of a character with an other.voidappendSpacesTo(int count)append a number of spaces to the line, limited to the line length! This will only be done if the line is already started, so attention when a line is still empty this method will have no effect on empty lines.voidcompleteLine()fill the rest of current line with spaces and start a new fits line.intlength()intspaceLeftInLine()java.lang.StringtoString()
-
-
-
Field Detail
-
FULL_CARD_AS_SPACES
private static final java.lang.String FULL_CARD_AS_SPACES
A String of 80 spaces to fill up fits card space.
-
buffer
private final java.lang.StringBuilder buffer
the underlying StringBuilder to which the writing of fits lines happens.
-
charCount
private int charCount
the char current position in the line.
-
-
Method Detail
-
append
public void append(char character)
append a character to the fits line.- Parameters:
character- the character to append to the line.
-
append
public void append(FitsSubString stringValue)
Append a sub-string to this line.- Parameters:
stringValue- the sub string to append.
-
append
public void append(java.lang.String string)
append a string to the fits line, but limit the append to the line length. rest of the string will be silently truncated.- Parameters:
string- the string to append
-
appendReplacing
public void appendReplacing(java.lang.String key, char toReplace, char with)append a string to the buffer, replacing all occurrences of a character with an other.- Parameters:
key- the string to writetoReplace- the character to replacewith- the character to replace the toReplace character with.
-
appendSpacesTo
public void appendSpacesTo(int count)
append a number of spaces to the line, limited to the line length! This will only be done if the line is already started, so attention when a line is still empty this method will have no effect on empty lines.- Parameters:
count- the number of spaces to write.
-
completeLine
public void completeLine()
fill the rest of current line with spaces and start a new fits line.
-
length
public int length()
- Returns:
- the character position in the current line.
-
spaceLeftInLine
public int spaceLeftInLine()
- Returns:
- the number of characters still available in the current fits line.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
append
public void append(java.lang.String key, int start, int end)
-
-