4 package eu
.etaxonomy
.cdm
.strategy
.cache
;
6 import java
.util
.ArrayList
;
7 import java
.util
.HashSet
;
10 import java
.util
.SortedSet
;
11 import java
.util
.TreeSet
;
14 * Rules to define tagging for HTML tagged string output.
20 public class HTMLTagRules
{
22 private List
<TagRule
> rules
= new ArrayList
<HTMLTagRules
.TagRule
>();
24 private class TagRule
{
25 private TagRule(TagEnum type
, String htmlTag
){this.type
= type
; this.htmlTag
= htmlTag
;}
27 private String htmlTag
;
28 // public TagEnum getType(){return this.type;}
29 // public String getString(){return this.htmlTag;}
30 @Override public String
toString(){return type
.name() + "-><" + htmlTag
+ ">";}
34 public HTMLTagRules
addRule(TagEnum type
, String htmlTag
){
35 if (type
== null || htmlTag
== null){
36 throw new NullPointerException("Null tpye or htmlTag not allowed for HTMLTagRule");
38 rules
.add(new TagRule(type
, htmlTag
));
42 public SortedSet
<String
> getRule(TagEnum type
){
43 SortedSet
<String
> result
= new TreeSet
<String
>();
44 for (TagRule rule
: rules
){
45 if (rule
.type
.equals(type
)){
46 result
.add(rule
.htmlTag
);
52 public boolean hasRule(TagEnum type
, String htmlTag
){
53 for (TagRule rule
: rules
){
54 if (rule
.type
.equals(type
) && htmlTag
.equals(htmlTag
)){
62 public String
toString(){
63 String result
= "HTMLTagRules[";
64 for (TagRule rule
: rules
){
65 result
+= rule
.toString() + ";";
67 result
= result
.substring(0, result
.length() -1) + "]";