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 indentation
    static int getEndTagIndex​(java.lang.String line, int indentation)
    Method that fetches the end index value of the starter tag
    static char getFirstChar​(java.lang.String line)
    Method that get first character
    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()
    static java.lang.String makeEndTag​(java.lang.String tag)
    Method that makes EndTag
    static java.util.ArrayList<java.lang.String> makeIgnoreList()
    Method with tags without an end tag or that close at another time
    static java.util.ArrayList<java.lang.String> makeLists​(java.lang.String filepath)
    Method that makes a Arraylist out 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 child
    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)
    Method that prints the converted lines to the html file

    Methods 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.IOException
      Method that makes a Arraylist out 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 end
      indentation - - 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 document
      parentTag - - 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.IOException
      Recursive method that will check if a child has another child
      Parameters:
      childLine - The current child being processed
      parentLine - Parent line of current child
      linecounter - Current line index
      Jhaml - 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.IOException
      Method that prints the converted lines to the html file
      Parameters:
      indentation - - integer value of the indentation of current line
      tag - - tag of the current line without '>'
      rest - - 'elements' of the current tag
      txt - - 'values' of the current tag
      writer - - Filewriter that will write the lines to the html file
      Throws:
      java.io.IOException