Package adams.core.option
Class NestedFormatHelper
- java.lang.Object
-
- adams.core.option.NestedFormatHelper
-
public class NestedFormatHelper extends Object
A helper class for the nested option format.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NestedFormatHelper.Line
Container class for wrapping a line from the nested format.
-
Constructor Summary
Constructors Constructor Description NestedFormatHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
checkModules(List<String> modules)
Checks whether there are any modules missing in the current environment compared to the provided list of module names.protected static String
getIndentation(int level)
Returns the indentation string for the given level.protected static int
getIndentationLevel(String s, char indentChar)
Determines the indentation level of the given string.static List<String>
getModules(List<String> lines)
Extracts the modules from the comments, if available.static ArrayList
linesToNested(List<String> lines, char indentChar)
Turns the nested lines into a nested structure to be used by option handlers.protected static ArrayList
linesToNested(List<String> lines, int[] index, int[] levels, int offset)
Turns the nested lines into a nested structure to be used by option handlers.static ArrayList
linesToNested(List<String> lines, int offset, char indentChar)
Turns the nested lines into a nested structure to be used by option handlers.static List<String>
nestedToLines(List nested)
Turns the nested options from an option handler into indentated lines.static List<String>
nestedToLines(List nested, boolean lineNo)
Turns the nested options from an option handler into indentated lines.protected static void
nestedToLines(List nested, boolean lineNo, List<String> lines, int level)
Turns the nested options from an option handler into indentated lines.static int
removeComments(List<String> lines)
Removes all comments from the start of the list of (raw) lines.static void
renumber(List nested)
Updates the line numbering.protected static int
renumber(List nested, int offset)
Updates the line numbering.
-
-
-
Method Detail
-
removeComments
public static int removeComments(List<String> lines)
Removes all comments from the start of the list of (raw) lines.- Parameters:
lines
- the raw lines- Returns:
- the number of comment lines
-
getIndentationLevel
protected static int getIndentationLevel(String s, char indentChar)
Determines the indentation level of the given string.- Parameters:
s
- the string to analyzeindentChar
- the character used for indentation- Returns:
- the level
-
linesToNested
protected static ArrayList linesToNested(List<String> lines, int[] index, int[] levels, int offset)
Turns the nested lines into a nested structure to be used by option handlers.- Parameters:
lines
- the lines to turn into a nested structureindex
- the index in the lineslevels
- all the indentation levels in the linesoffset
- the offset in lines, i.e., the number of comments removed- Returns:
- the nested structure
-
linesToNested
public static ArrayList linesToNested(List<String> lines, char indentChar)
Turns the nested lines into a nested structure to be used by option handlers.- Parameters:
lines
- the lines to turn into a nested structureindentChar
- the character used for indentation- Returns:
- the nested structure
-
linesToNested
public static ArrayList linesToNested(List<String> lines, int offset, char indentChar)
Turns the nested lines into a nested structure to be used by option handlers.- Parameters:
lines
- the lines to turn into a nested structureoffset
- the offset in lines, i.e., the number of comments removedindentChar
- the character used for indentation- Returns:
- the nested structure
-
getIndentation
protected static String getIndentation(int level)
Returns the indentation string for the given level.- Parameters:
level
- the level to generate the indentation string for- Returns:
- the generated string
-
nestedToLines
protected static void nestedToLines(List nested, boolean lineNo, List<String> lines, int level)
Turns the nested options from an option handler into indentated lines.- Parameters:
nested
- the nested structure to turn into indentated lineslineNo
- whether to add the line numberslines
- the lines so farlevel
- the current level of indentation
-
nestedToLines
public static List<String> nestedToLines(List nested)
Turns the nested options from an option handler into indentated lines.- Parameters:
nested
- the nested structure to turn into indentated lines- Returns:
- the indentated lines
-
nestedToLines
public static List<String> nestedToLines(List nested, boolean lineNo)
Turns the nested options from an option handler into indentated lines.- Parameters:
nested
- the nested structure to turn into indentated lineslineNo
- whether to add the line numbers- Returns:
- the indentated lines
-
renumber
protected static int renumber(List nested, int offset)
Updates the line numbering.- Parameters:
nested
- the nested lines to updatedoffset
- the current offset- Returns:
- the last line number updated
-
renumber
public static void renumber(List nested)
Updates the line numbering.- Parameters:
nested
- the nested lines to updated
-
getModules
public static List<String> getModules(List<String> lines)
Extracts the modules from the comments, if available.- Parameters:
lines
- the raw lines of the flow- Returns:
- the modules, if any
-
-