1 47 48 package com.lowagie.text.html.simpleparser; 49 50 import java.util.HashMap ; 51 52 public class StyleSheet { 53 54 public HashMap classMap = new HashMap (); 55 public HashMap tagMap = new HashMap (); 56 57 58 public StyleSheet() { 59 } 60 61 public void applyStyle(String tag, HashMap props) { 62 HashMap map = (HashMap )tagMap.get(tag.toLowerCase()); 63 if (map != null) { 64 HashMap temp = new HashMap (map); 65 temp.putAll(props); 66 props.putAll(temp); 67 } 68 String cm = (String )props.get("class"); 69 if (cm == null) 70 return; 71 map = (HashMap )classMap.get(cm.toLowerCase()); 72 if (map == null) 73 return; 74 props.remove("class"); 75 HashMap temp = new HashMap (map); 76 temp.putAll(props); 77 props.putAll(temp); 78 } 79 80 public void loadStyle(String style, HashMap props) { 81 classMap.put(style.toLowerCase(), props); 82 } 83 84 public void loadStyle(String style, String key, String value) { 85 style = style.toLowerCase(); 86 HashMap props = (HashMap )classMap.get(style); 87 if (props == null) { 88 props = new HashMap (); 89 classMap.put(style, props); 90 } 91 props.put(key, value); 92 } 93 94 public void loadTagStyle(String tag, HashMap props) { 95 tagMap.put(tag.toLowerCase(), props); 96 } 97 98 public void loadTagStyle(String tag, String key, String value) { 99 tag = tag.toLowerCase(); 100 HashMap props = (HashMap )tagMap.get(tag); 101 if (props == null) { 102 props = new HashMap (); 103 tagMap.put(tag, props); 104 } 105 props.put(key, value); 106 } 107 108 } | Popular Tags |