mockattributeset.java

来自「java1.6众多例子参考」· Java 代码 · 共 109 行

JAVA
109
字号
/* * @(#)MockAttributeSet.java	1.12 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.text.rtf;import java.util.Dictionary;import java.util.Enumeration;import javax.swing.text.AttributeSet;import javax.swing.text.MutableAttributeSet;/* This AttributeSet is made entirely out of tofu and Ritz Crackers   and yet has a remarkably attribute-set-like interface! */class MockAttributeSet    implements AttributeSet, MutableAttributeSet{    public Dictionary backing;    public boolean isEmpty()    {         return backing.isEmpty();    }        public int getAttributeCount()    {         return backing.size();    }    public boolean isDefined(Object name)    {         return ( backing.get(name) ) != null;    }    public boolean isEqual(AttributeSet attr)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }    public AttributeSet copyAttributes()    {         throw new InternalError("MockAttributeSet: charade revealed!");    }        public Object getAttribute(Object name)    {        return backing.get(name);    }    public void addAttribute(Object name, Object value)    {        backing.put(name, value);    }        public void addAttributes(AttributeSet attr)    {        Enumeration as = attr.getAttributeNames();	while(as.hasMoreElements()) {	    Object el = as.nextElement();	    backing.put(el, attr.getAttribute(el));	}    }    public void removeAttribute(Object name)    {        backing.remove(name);    }    public void removeAttributes(AttributeSet attr)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }    public void removeAttributes(Enumeration<?> en)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }    public void setResolveParent(AttributeSet pp)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }        public Enumeration getAttributeNames()    {         return backing.keys();    }        public boolean containsAttribute(Object name, Object value)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }    public boolean containsAttributes(AttributeSet attr)    {         throw new InternalError("MockAttributeSet: charade revealed!");    }    public AttributeSet getResolveParent()    {         throw new InternalError("MockAttributeSet: charade revealed!");    }}        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?