forked from stdcs/21-ip-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(collection): add assignmen 6.1 placeholder file
Assignment description: 1. Template Parser at stdcs#147
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ip.syssrc.collection; | ||
|
||
/** | ||
* TemplateParse | ||
* | ||
* Assignment 6.1 | ||
* | ||
* @author H071171512 - Fitrah Muhammad <fitrahm17h@student.unhas.ac.id> | ||
* | ||
*/ | ||
public class TemplateParse { | ||
|
||
public static void main(String[] args) { | ||
String template = new String("The {alpha} {do} over the {animal}\n") | ||
.concat("and feels as if {who} where in {where}\n") | ||
.concat("of typography together with {with}.\n"); | ||
|
||
Map<String, String> data = new HashMap<>(); | ||
data.put("with", "Hermann Zapf"); | ||
data.put("do", "jumps"); | ||
data.put("alpha", "quick brown fox"); | ||
data.put("animal", "lazy dog"); | ||
data.put("where", "the seventh heaven"); | ||
data.put("who", "he"); | ||
|
||
render(parse(template, data)); | ||
} | ||
|
||
/** | ||
* Replace all the placeholders in the template with the coreesponding values in | ||
* the data | ||
* | ||
* @param template the string with placeholder, placeholder is a word inside | ||
* curly braces e.g. {name}, a placeholder with "name" as key | ||
* @param data the map of key-value, value is the data that will replace the | ||
* placeholder in the template, key is a placeholder without | ||
* curly braces. | ||
* @return list of strings with parsed placeholder | ||
*/ | ||
public static List<String> parse(String template, Map<String, String> data) { | ||
return new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Print each element of template with new line | ||
* | ||
* @param template the list to be printed | ||
**/ | ||
public static void render(List<String> template) {} | ||
} |