Class Template

java.lang.Object
com.github.perdia.queries.Template

public class Template extends Object
Class for handling the creation, querying, deletion and saving of templates
  • Constructor Summary

    Constructors
    Constructor
    Description
    One of the constructors for the Template class.
    One of the constructors for the Template class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds all the entries contained in the given hashmap to the template.
    void
    addEntry(String name, DataEntry entry)
    Adds an entry with the given name and data entry (which includes a datatype and starting value) to the template.
    void
    addEntry(String name, DataType dt, Object starting)
    Adds an entry with the given name, datatype and starting value to the template.
    Returns a PANG query for deleting the respective template in the database, automatically deleting all instances utilising the deleted template at the same time.
    Returns a hashmap containing all the entries of the template.
    Returns the data entry with the given key of the template.
    Returns the name of the respective template.
    static String
    Returns a PANG query for querying all currently existing templates in the database
    static byte[]
    readPreset(String filename)
    Reads a .pang File from the /presets folder and returns the single characters of the template as a PANG query encoded in UTF-8
    void
    Sets the name of the respective template.
    Turns the current Template object in to a PANG query which creates the template in the database
    void
    toPreset(String filename)
    Saves a .pang File to the /presets folder which contains the current Template object as a PANG query encoded in UTF-8.
    Returns a PANG query for querying the respective template in the database
    static String
    Returns a PANG query for querying the given template based on its name in the database

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Template

      public Template(String name)
      One of the constructors for the Template class. This constructor creates a new empty template with only the name given.
      Parameters:
      name - The name of the template
    • Template

      public Template(String name, HashMap<String,DataEntry> entries)
      One of the constructors for the Template class. This constructor not only creates a new template with the given name, but also adds all the entries in the given Hashmap as entries of the template.
      Parameters:
      name - The name of the template
      entries - Hashmap of entries that will be added to the preset
  • Method Details

    • addEntry

      public void addEntry(String name, DataType dt, Object starting)
      Adds an entry with the given name, datatype and starting value to the template.
      Parameters:
      name - Name of the entry
      dt - Datatype of the entry
      starting - Starting value of the entry
    • addEntry

      public void addEntry(String name, DataEntry entry)
      Adds an entry with the given name and data entry (which includes a datatype and starting value) to the template.
      Parameters:
      name - Name of the entry
      entry - DataEntry containing the datatype and value of the entry
    • addEntries

      public void addEntries(HashMap<String,DataEntry> hm)
      Adds all the entries contained in the given hashmap to the template.
      Parameters:
      hm - Hashmap the values are supposed to be added from
    • toCreationQuery

      public String toCreationQuery()
      Turns the current Template object in to a PANG query which creates the template in the database
      Returns:
      String containing a PANG query for creating the template
    • toQuery

      public String toQuery()
      Returns a PANG query for querying the respective template in the database
      Returns:
      String containing PANG query for querying the respective template
    • toQuery

      public static String toQuery(String name)
      Returns a PANG query for querying the given template based on its name in the database
      Parameters:
      name - Name of the template to be queried from the database
      Returns:
      String containing PANG query for querying the given template based on its name
    • queryAll

      public static String queryAll()
      Returns a PANG query for querying all currently existing templates in the database
      Returns:
      String containing a PANG query for querying all existing templates
    • toPreset

      public void toPreset(String filename)
      Saves a .pang File to the /presets folder which contains the current Template object as a PANG query encoded in UTF-8. This preset file can then be read by the readPreset method.
      Parameters:
      filename - Name of the preset file to be saved to (not including the .pang file ending)
    • readPreset

      public static byte[] readPreset(String filename)
      Reads a .pang File from the /presets folder and returns the single characters of the template as a PANG query encoded in UTF-8
      Parameters:
      filename - Name of the preset file to be read from (not including the .pang file ending)
      Returns:
      Byte array containing the single characters of the query text encoded in UTF-8
    • getName

      public String getName()
      Returns the name of the respective template.
      Returns:
      The name of the template
    • setName

      public void setName(String name)
      Sets the name of the respective template.
      Parameters:
      name - The name of the template to be set
    • getData

      public HashMap<String,DataEntry> getData()
      Returns a hashmap containing all the entries of the template.
      Returns:
      Hashmap containing all the entries
    • getDataEntry

      public DataEntry getDataEntry(String key)
      Returns the data entry with the given key of the template.
      Parameters:
      key - Key of the DataEntry in the Template object to be returned
      Returns:
      DataEntry corresponding to the key in the data Hashmap
    • deleteQuery

      public String deleteQuery()
      Returns a PANG query for deleting the respective template in the database, automatically deleting all instances utilising the deleted template at the same time.
      Returns:
      String containing a PANG query for deleting the respective template (and its instances)