001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package java.text;
019:
020: import java.io.InvalidObjectException;
021: import java.io.Serializable;
022: import java.util.Map;
023: import java.util.Set;
024:
025: import org.apache.harmony.text.internal.nls.Messages;
026:
027: /**
028: * AttributedCharacterIterator
029: */
030: public interface AttributedCharacterIterator extends CharacterIterator {
031:
032: public static class Attribute implements Serializable {
033:
034: private static final long serialVersionUID = -9142742483513960612L;
035:
036: public static final Attribute INPUT_METHOD_SEGMENT = new Attribute(
037: "input_method_segment"); //$NON-NLS-1$
038:
039: public static final Attribute LANGUAGE = new Attribute(
040: "language"); //$NON-NLS-1$
041:
042: public static final Attribute READING = new Attribute("reading"); //$NON-NLS-1$
043:
044: private String name;
045:
046: protected Attribute(String name) {
047: this .name = name;
048: }
049:
050: @Override
051: public final boolean equals(Object object) {
052: if (object == null
053: || !(object.getClass().equals(this .getClass()))) {
054: return false;
055: }
056: return name.equals(((Attribute) object).name);
057: }
058:
059: protected String getName() {
060: return name;
061: }
062:
063: @Override
064: public final int hashCode() {
065: return name.hashCode();
066: }
067:
068: protected Object readResolve() throws InvalidObjectException {
069: if (this .getClass() != Attribute.class) {
070: // text.0C=cannot resolve subclasses
071: throw new InvalidObjectException(Messages
072: .getString("text.0C")); //$NON-NLS-1$
073: }
074: if (this .equals(INPUT_METHOD_SEGMENT)) {
075: return INPUT_METHOD_SEGMENT;
076: }
077: if (this .equals(LANGUAGE)) {
078: return LANGUAGE;
079: }
080: if (this .equals(READING)) {
081: return READING;
082: }
083: // text.02=Unknown attribute
084: throw new InvalidObjectException(Messages
085: .getString("text.02")); //$NON-NLS-1$
086: }
087:
088: @Override
089: public String toString() {
090: return getClass().getName() + '(' + getName() + ')';
091: }
092: }
093:
094: public Set<Attribute> getAllAttributeKeys();
095:
096: public Object getAttribute(Attribute attribute);
097:
098: public Map<Attribute, Object> getAttributes();
099:
100: public int getRunLimit();
101:
102: public int getRunLimit(Attribute attribute);
103:
104: public int getRunLimit(Set<? extends Attribute> attributes);
105:
106: public int getRunStart();
107:
108: public int getRunStart(Attribute attribute);
109:
110: public int getRunStart(Set<? extends Attribute> attributes);
111: }
|