Class Section
- Direct Known Subclasses:
Section0,Section1,Section10,Section2,Section3,Section4,Section5Or6,Section7,Section8Or11
A class to encapsulate an SCP-ECG section.
Though not abstract, in order to support unrecognized sections, this class is usually extended
by more specific classes; there is a factory method makeSection
that is used to create specific sub-classes once the section
number is known (i.e. has been read).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected SectionHeaderprotected longprotected SCPTreeRecord -
Constructor Summary
ConstructorsConstructorDescriptionSection(SectionHeader header) Construct an empty section with the specified header. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidaddNodeOfDecimalAndHex(SCPTreeRecord parent, String name, int value) Add a tree node with a numeric value as decimal and hexadecimal strings.protected static voidaddNodeOfDecimalWithMissingValues(SCPTreeRecord parent, String name, int value) Add a tree node with a numeric value as decimal string, with potentially missing values.protected voidaddSectionHeaderToTree(SCPTreeRecord parent) Get section header information to the section node in a tree for display.static StringdescribeMissingValues(int i) Get a description of measurement values that may have missing values.Get a string name for this section.getTree()Get the contents of the section as a tree for display.getTree(SCPTreeRecord parent) Get the contents of the section as a tree for display, constructing it if not already done.protected StringGet the value to use as the value section of the section node in a tree for display.static SectionmakeSection(SectionHeader sectionHeader, TreeMap sections) A factory method to construct specific sub-classes of section.static StringmakeStringFromByteArrayRemovingAnyNulls(byte[] bytes) Convert an array of bytes to aStringremoving any embedded nulls.longRead the remainder of the section from a stream.protected longSkip to the end of the section, if not already there.toString()Dump the section as aString.validate()Validate the section against the standard.
-
Field Details
-
header
-
bytesRead
protected long bytesRead -
sectionBytesRemaining
protected long sectionBytesRemaining -
tree
-
-
Constructor Details
-
Section
Construct an empty section with the specified header.
- Parameters:
header- the header (which has already been read)
-
-
Method Details
-
getSectionHeader
-
read
Read the remainder of the section from a stream.
- Parameters:
i- the input stream- Returns:
- the number of bytes read
- Throws:
IOException
-
skipToEndOfSectionIfNotAlreadyThere
Skip to the end of the section, if not already there.
Used either for unrecognized sections, or when there is an encoding error within a section and parsing of the section has to be abandoned.
- Parameters:
i- the input stream- Returns:
- the number of bytes skipped
- Throws:
IOException
-
toString
Dump the section as a
String. -
validate
Validate the section against the standard.
- Returns:
- the validation results as a
String
-
getSectionName
Get a string name for this section.
- Returns:
- a string name for this section
-
makeSection
A factory method to construct specific sub-classes of section.
- Parameters:
sectionHeader- the section header already read from the stream, containing the section numbersections- the sections that have already been read, in case values are needed for making new sections- Returns:
- a section of the appropriate sub-class.
-
getValueForSectionNodeInTree
Get the value to use as the value section of the section node in a tree for display.
- Returns:
- the value of just this node (not its contents)
-
addSectionHeaderToTree
Get section header information to the section node in a tree for display.
-
getTree
Get the contents of the section as a tree for display.
- Returns:
- the section as a tree, or null if not constructed
-
getTree
Get the contents of the section as a tree for display, constructing it if not already done.
- Parameters:
parent- the node to which this section is to be added if it needs to be created de novo- Returns:
- the section as a tree
-
describeMissingValues
Get a description of measurement values that may have missing values.
Described in Section 5.10.2 as being defined in the CSE Project.
- Parameters:
i- the numeric value that may be missing- Returns:
- a description of the type of missing value
-
addNodeOfDecimalAndHex
Add a tree node with a numeric value as decimal and hexadecimal strings.
- Parameters:
parent- the node to which to add this new node as a childname- the name of the new nodevalue- the numeric value of the new node
-
addNodeOfDecimalWithMissingValues
protected static void addNodeOfDecimalWithMissingValues(SCPTreeRecord parent, String name, int value) Add a tree node with a numeric value as decimal string, with potentially missing values.
- Parameters:
parent- the node to which to add this new node as a childname- the name of the new nodevalue- the numeric value of the new node
-
makeStringFromByteArrayRemovingAnyNulls
Convert an array of bytes to a
Stringremoving any embedded nulls.Nulls may be embedded, and are simply ignored; they do not terminate the string.
The default character encoding is used; ISO 2022 escapes are not yet supported.
- Parameters:
bytes- the array of bytes, possibly with embedded nulls- Returns:
- the
Stringvalue
-