Package JHamlConverter
Class HelperMethods
java.lang.Object
JHamlConverter.HelperMethods
public class HelperMethods
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description HelperMethods()
-
Method Summary
Modifier and Type Method Description static java.lang.String
createSpace(int amountOfSpace)
Method that creates correct indentationstatic int
getEndTagIndex(java.lang.String line, int indentation)
Method that fetches the end index value of the starter tagstatic char
getFirstChar(java.lang.String line)
Method that get first characterstatic int
getParentLine(java.util.ArrayList<java.lang.String> lines, java.lang.String parentTag)
Method that gets the index of the current headParent to use in getChildrenElements()static java.lang.String
makeEndTag(java.lang.String tag)
Method that makes EndTagstatic java.util.ArrayList<java.lang.String>
makeIgnoreList()
Method with tags without an end tag or that close at another timestatic java.util.ArrayList<java.lang.String>
makeLists(java.lang.String filepath)
Method that makes a Arraylistout of a file static int
parseTags(java.lang.String childLine, java.lang.String parentLine, int linecounter, java.util.ArrayList<java.lang.String> Jhaml, java.io.FileWriter writer)
Recursive method that will check if a child has another childstatic void
writeToFile(int indentation, java.lang.String tag, java.lang.String rest, java.lang.String txt, java.io.FileWriter writer, java.lang.String type)
Method that prints the converted lines to the html fileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
HelperMethods
public HelperMethods()
-
-
Method Details
-
makeLists
public static java.util.ArrayList<java.lang.String> makeLists(java.lang.String filepath) throws java.io.IOExceptionMethod that makes a Arraylistout of a file - Parameters:
filepath
- - a string with the filepath- Returns:
- list - Arraylist
- Throws:
java.io.IOException
-
getEndTagIndex
public static int getEndTagIndex(java.lang.String line, int indentation)Method that fetches the end index value of the starter tag- Parameters:
line
- - a string where we need to find the correct index of where the tag should endindentation
- - integer value of the indentation of current line- Returns:
- endTagIndex - integer value that represents the end index of the begining-tag
-
getParentLine
public static int getParentLine(java.util.ArrayList<java.lang.String> lines, java.lang.String parentTag)Method that gets the index of the current headParent to use in getChildrenElements()- Parameters:
lines
- - filepath to read a specific documentparentTag
- - filepath to read a specific document- Returns:
- parentLine - integer value representing index number of the current headParent
-
parseTags
public static int parseTags(java.lang.String childLine, java.lang.String parentLine, int linecounter, java.util.ArrayList<java.lang.String> Jhaml, java.io.FileWriter writer) throws java.io.IOExceptionRecursive method that will check if a child has another child- Parameters:
childLine
- The current child being processedparentLine
- Parent line of current childlinecounter
- Current line indexJhaml
- The to be converted document represented by lines (each index = 1 line (Arraylist)) writer
- Filewriter that will write the lines to the html file- Returns:
- update linecounter
- Throws:
java.io.IOException
-
createSpace
public static java.lang.String createSpace(int amountOfSpace)Method that creates correct indentation- Parameters:
amountOfSpace
- - integer value that represents the amountOfSpace that needs to be created for indentation- Returns:
- space - String with indentation
-
getFirstChar
public static char getFirstChar(java.lang.String line)Method that get first character- Parameters:
line
-- Returns:
- indentation
-
makeEndTag
public static java.lang.String makeEndTag(java.lang.String tag)Method that makes EndTag- Parameters:
tag
- belongs to some substrings- Returns:
- the endtag
-
makeIgnoreList
public static java.util.ArrayList<java.lang.String> makeIgnoreList()Method with tags without an end tag or that close at another time- Returns:
- ignoreList
-
writeToFile
public static void writeToFile(int indentation, java.lang.String tag, java.lang.String rest, java.lang.String txt, java.io.FileWriter writer, java.lang.String type) throws java.io.IOExceptionMethod that prints the converted lines to the html file- Parameters:
indentation
- - integer value of the indentation of current linetag
- - tag of the current line without '>'rest
- - 'elements' of the current tagtxt
- - 'values' of the current tagwriter
- - Filewriter that will write the lines to the html file- Throws:
java.io.IOException
-