4 package eu
.etaxonomy
.cdm
.strategy
.cache
;
6 import java
.util
.ArrayList
;
8 import java
.util
.SortedSet
;
9 import java
.util
.TreeSet
;
12 * Rules to define tagging for HTML tagged string output.
18 public class HTMLTagRules
{
20 private List
<TagRule
> rules
= new ArrayList
<HTMLTagRules
.TagRule
>();
22 private class TagRule
{
23 private TagRule(TagEnum type
, String htmlTag
){this.type
= type
; this.htmlTag
= htmlTag
;}
25 private String htmlTag
;
26 // public TagEnum getType(){return this.type;}
27 // public String getString(){return this.htmlTag;}
28 @Override public String
toString(){return type
.name() + "-><" + htmlTag
+ ">";}
32 public HTMLTagRules
addRule(TagEnum type
, String htmlTag
){
33 if (type
== null || htmlTag
== null){
34 throw new NullPointerException("Null tpye or htmlTag not allowed for HTMLTagRule");
36 rules
.add(new TagRule(type
, htmlTag
));
40 public SortedSet
<String
> getRule(TagEnum type
){
41 SortedSet
<String
> result
= new TreeSet
<String
>();
42 for (TagRule rule
: rules
){
43 if (rule
.type
.equals(type
)){
44 result
.add(rule
.htmlTag
);
50 public boolean hasRule(TagEnum type
, String htmlTag
){
51 for (TagRule rule
: rules
){
52 if (rule
.type
.equals(type
) && htmlTag
.equals(htmlTag
)){
60 public String
toString(){
61 String result
= "HTMLTagRules[";
62 for (TagRule rule
: rules
){
63 result
+= rule
.toString() + ";";
65 result
= result
.substring(0, result
.length() -1) + "]";