FileDocCategorySizeDatePackage
AttributeSet.javaAPI DocExample3492Thu Nov 08 00:22:50 GMT 2001com.ora.rmibook.chapter15

AttributeSet

public class AttributeSet extends Object implements Serializable, Comparable

Fields Summary
private TreeMap
_underlyingMap
Constructors Summary
public AttributeSet()

        _underlyingMap = new TreeMap();
    
Methods Summary
public synchronized voidadd(java.lang.String name, java.lang.String value)

        if (null == name) {
            return;
        }
        if (null == value) {
            _underlyingMap.remove(name);
        } else {
            _underlyingMap.put(name, value);
        }
    
public synchronized intcompareTo(java.lang.Object object)

        if (null == object) {
            return -1;
        }
        AttributeSet otherAttributeSet = (AttributeSet) object;
        int sizeDifferential = _underlyingMap.size() - otherAttributeSet.getSize();

        if (0 != sizeDifferential) {
            return (sizeDifferential > 0) ? -1 : 1;   //doesn't matter as long as we're consistent.
        }
        Iterator otherIterator = otherAttributeSet.getNames();
        Iterator internalIterator = getNames();

        while (otherIterator.hasNext()) {
            String foreignName = (String) otherIterator.next();
            String internalName = (String) internalIterator.next();
            int firstComparison = internalName.compareTo(foreignName);

            if (0 != firstComparison) {
                return firstComparison;
            }
            String foreignValue = otherAttributeSet.getValue(foreignName);
            String internalValue = getValue(foreignName);
            int secondComparison = internalValue.compareTo(foreignValue);

            if (0 != secondComparison) {
                return secondComparison;
            }
        }
        return 0;
    
public synchronized booleancontains(java.lang.String name)

        return (null != _underlyingMap.get(name));
    
public synchronized booleancontains(java.lang.String name, java.lang.String value)

        String internalValue = (String) _underlyingMap.get(name);

        if (null != internalValue) {
            return internalValue.equals(value);
        }
        return null == value;
    
public synchronized booleanequals(java.lang.Object object)

        if (null == object) {
            return false;
        }
        if (false == (object instanceof AttributeSet)) {
            return false;
        }
        return (0 == compareTo(object));
    
public synchronized java.util.IteratorgetNames()

        return _underlyingMap.keySet().iterator();
    
public synchronized intgetSize()

        return _underlyingMap.size();
    
public synchronized java.lang.StringgetValue(java.lang.String name)

        return (String) _underlyingMap.get(name);
    
public synchronized voidremove(java.lang.String name)

        _underlyingMap.remove(name);
    
public synchronized booleansubsetOf(com.ora.rmibook.chapter15.AttributeSet otherAttributeSet)

        if (null == otherAttributeSet) {
            return false;
        }
        Iterator i = getNames();

        while (i.hasNext()) {
            String name = (String) i.next();
            String value = getValue(name);

            if (false == otherAttributeSet.contains(name, value)) {
                return false;
            }
        }
        return true;