1 18 package org.apache.batik.transcoder; 19 20 import java.util.HashMap ; 21 import java.util.Iterator ; 22 import java.util.Map ; 23 24 31 public class TranscodingHints extends HashMap { 32 33 36 public TranscodingHints() { 37 this(null); 38 } 39 40 47 public TranscodingHints(Map init) { 48 super(7); 49 if (init != null) { 50 putAll(init); 51 } 52 } 53 54 63 public boolean containsKey(Object key) { 64 return super.containsKey(key); 65 } 66 67 74 public Object get(Object key) { 75 return super.get(key); 76 } 77 78 89 public Object put(Object key, Object value) { 90 if (!((Key) key).isCompatibleValue(value)) { 91 throw new IllegalArgumentException (value+ 92 " incompatible with "+ 93 key); 94 } 95 return super.put(key, value); 96 } 97 98 106 public Object remove(Object key) { 107 return super.remove(key); 108 } 109 110 115 public void putAll(TranscodingHints hints) { 116 super.putAll(hints); 117 } 118 119 127 public void putAll(Map m) { 128 if (m instanceof TranscodingHints) { 129 putAll(((TranscodingHints) m)); 130 } else { 131 Iterator iter = m.entrySet().iterator(); 132 while (iter.hasNext()) { 133 Map.Entry entry = (Map.Entry ) iter.next(); 134 put(entry.getKey(), entry.getValue()); 135 } 136 } 137 } 138 139 143 public abstract static class Key { 144 145 148 protected Key() { } 149 150 154 public abstract boolean isCompatibleValue(Object val); 155 } 156 } 157 | Popular Tags |