01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexey A. Ivanov
19: * @version $Revision$
20: */package javax.swing.text;
21:
22: import java.io.Serializable;
23: import java.util.Enumeration;
24: import java.util.NoSuchElementException;
25:
26: import org.apache.harmony.x.swing.internal.nls.Messages;
27:
28: /**
29: * Implementation of empty attribute set.
30: *
31: */
32: final class EmptyAttributeSet implements AttributeSet, Serializable {
33:
34: public static final AttributeSet EMPTY = new EmptyAttributeSet();
35:
36: private EmptyAttributeSet() {
37: }
38:
39: public boolean containsAttribute(final Object name,
40: final Object value) {
41: return false;
42: }
43:
44: public boolean containsAttributes(final AttributeSet attr) {
45: return attr.getAttributeCount() == 0;
46: }
47:
48: public AttributeSet copyAttributes() {
49: return this ;
50: }
51:
52: public boolean equals(final Object obj) {
53: return obj instanceof AttributeSet
54: && isEqual((AttributeSet) obj);
55: }
56:
57: public Object getAttribute(final Object name) {
58: return null;
59: }
60:
61: public int getAttributeCount() {
62: return 0;
63: }
64:
65: public Enumeration getAttributeNames() {
66: return new Enumeration() {
67: public boolean hasMoreElements() {
68: return false;
69: }
70:
71: public Object nextElement() {
72: throw new NoSuchElementException(Messages
73: .getString("swing.8A")); //$NON-NLS-1$
74: }
75: };
76: }
77:
78: public AttributeSet getResolveParent() {
79: return null;
80: }
81:
82: public int hashCode() {
83: return 0;
84: }
85:
86: public boolean isDefined(final Object name) {
87: return false;
88: }
89:
90: public boolean isEqual(final AttributeSet attr) {
91: return attr.getAttributeCount() == 0;
92: }
93: }
|