Home » openjdk-7 » javax » swing » text » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     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    */
   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, final Object value) {
   40           return false;
   41       }
   42   
   43       public boolean containsAttributes(final AttributeSet attr) {
   44           return attr.getAttributeCount() == 0;
   45       }
   46   
   47       public AttributeSet copyAttributes() {
   48           return this;
   49       }
   50   
   51       public boolean equals(final Object obj) {
   52           return obj instanceof AttributeSet && isEqual((AttributeSet)obj);
   53       }
   54   
   55       public Object getAttribute(final Object name) {
   56           return null;
   57       }
   58   
   59       public int getAttributeCount() {
   60           return 0;
   61       }
   62   
   63       public Enumeration getAttributeNames() {
   64           return new Enumeration() {
   65               public boolean hasMoreElements() {
   66                   return false;
   67               }
   68               public Object nextElement() {
   69                   throw new NoSuchElementException(Messages.getString("swing.8A")); //$NON-NLS-1$
   70               }
   71           };
   72       }
   73   
   74       public AttributeSet getResolveParent() {
   75           return null;
   76       }
   77   
   78       public int hashCode() {
   79           return 0;
   80       }
   81   
   82       public boolean isDefined(final Object name) {
   83           return false;
   84       }
   85   
   86       public boolean isEqual(final AttributeSet attr) {
   87           return attr.getAttributeCount() == 0;
   88       }
   89   }

Home » openjdk-7 » javax » swing » text » [javadoc | source]