1 7 8 package java.text; 9 10 import java.io.InvalidObjectException ; 11 import java.io.Serializable ; 12 import java.util.HashMap ; 13 import java.util.Map ; 14 import java.util.Set ; 15 16 54 55 public interface AttributedCharacterIterator extends CharacterIterator { 56 57 64 65 public static class Attribute implements Serializable { 66 67 73 private String name; 74 75 private static final Map instanceMap = new HashMap (7); 77 78 81 protected Attribute(String name) { 82 this.name = name; 83 if (this.getClass() == Attribute.class) { 84 instanceMap.put(name, this); 85 } 86 } 87 88 93 public final boolean equals(Object obj) { 94 return super.equals(obj); 95 } 96 97 101 public final int hashCode() { 102 return super.hashCode(); 103 } 104 105 109 public String toString() { 110 return getClass().getName() + "(" + name + ")"; 111 } 112 113 116 protected String getName() { 117 return name; 118 } 119 120 123 protected Object readResolve() throws InvalidObjectException { 124 if (this.getClass() != Attribute.class) { 125 throw new InvalidObjectException ("subclass didn't correctly implement readResolve"); 126 } 127 128 Attribute instance = (Attribute) instanceMap.get(getName()); 129 if (instance != null) { 130 return instance; 131 } else { 132 throw new InvalidObjectException ("unknown attribute name"); 133 } 134 } 135 136 141 public static final Attribute LANGUAGE = new Attribute("language"); 142 143 152 public static final Attribute READING = new Attribute("reading"); 153 154 160 public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment"); 161 162 private static final long serialVersionUID = -9142742483513960612L; 164 165 }; 166 167 171 public int getRunStart(); 172 173 177 public int getRunStart(Attribute attribute); 178 179 183 public int getRunStart(Set <? extends Attribute> attributes); 184 185 189 public int getRunLimit(); 190 191 195 public int getRunLimit(Attribute attribute); 196 197 201 public int getRunLimit(Set <? extends Attribute> attributes); 202 203 207 public Map <Attribute,Object > getAttributes(); 208 209 214 public Object getAttribute(Attribute attribute); 215 216 221 public Set <Attribute> getAllAttributeKeys(); 222 }; 223 | Popular Tags |