Package com.github.perdia.queries
Class Template
java.lang.Object
com.github.perdia.queries.Template
Class for handling the creation, querying, deletion and saving of templates
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntries(HashMap<String, DataEntry> hm) Adds all the entries contained in the given hashmap to the template.voidAdds an entry with the given name and data entry (which includes a datatype and starting value) to the template.voidAdds 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.getData()Returns a hashmap containing all the entries of the template.getDataEntry(String key) Returns the data entry with the given key of the template.getName()Returns the name of the respective template.static StringqueryAll()Returns a PANG query for querying all currently existing templates in the databasestatic 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-8voidSets the name of the respective template.Turns the current Template object in to a PANG query which creates the template in the databasevoidSaves a .pang File to the /presets folder which contains the current Template object as a PANG query encoded in UTF-8.toQuery()Returns a PANG query for querying the respective template in the databasestatic StringReturns a PANG query for querying the given template based on its name in the database
-
Constructor Details
-
Template
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
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 templateentries- Hashmap of entries that will be added to the preset
-
-
Method Details
-
addEntry
Adds an entry with the given name, datatype and starting value to the template.- Parameters:
name- Name of the entrydt- Datatype of the entrystarting- Starting value of the entry
-
addEntry
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 entryentry- DataEntry containing the datatype and value of the entry
-
addEntries
Adds all the entries contained in the given hashmap to the template.- Parameters:
hm- Hashmap the values are supposed to be added from
-
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
Returns a PANG query for querying the respective template in the database- Returns:
- String containing PANG query for querying the respective template
-
toQuery
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
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
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
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
Returns the name of the respective template.- Returns:
- The name of the template
-
setName
Sets the name of the respective template.- Parameters:
name- The name of the template to be set
-
getData
Returns a hashmap containing all the entries of the template.- Returns:
- Hashmap containing all the entries
-
getDataEntry
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
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)
-