1 16 package org.outerj.daisy.htmlcleaner; 17 18 import java.util.Set ; 19 import java.util.HashSet ; 20 21 class ElementDescriptor { 22 23 private Set attributes = new HashSet (); 24 private String [] attributeNames; 25 26 private Set children = new HashSet (); 27 private String name; 28 29 public ElementDescriptor(String name) { 30 this.name = name; 31 } 32 33 public void addAttribute(String name) { 34 attributes.add(name); 35 attributeNames = null; 36 } 37 38 public void addChild(String name) { 39 children.add(name); 40 } 41 42 public Set getAttributes() { 43 return attributes; 44 } 45 46 public void setAttributes(Set attributes) { 47 this.attributes = attributes; 48 this.attributeNames = null; 49 } 50 51 public Set getChildren() { 52 return children; 53 } 54 55 public void setChildren(Set children) { 56 this.children = children; 57 } 58 59 public String getName() { 60 return name; 61 } 62 63 public String [] getAttributeNames() { 64 if (attributeNames == null) 65 attributeNames = (String [])attributes.toArray(new String [attributes.size()]); 66 return attributeNames; 67 } 68 69 public boolean childAllowed(String name) { 70 return children.contains(name); 71 } 72 73 public boolean attributeAllowed(String name) { 74 return attributes.contains(name); 75 } 76 } 77 | Popular Tags |