/** * Create a new empty <code>AttributeTable</code>. * * @deprecated Use constructor that takes the name of the table. */ public AttributeTable() { _attr = new SortedTable(); }
/** * Returns the <code>Attribute</code> which matches name. * * @param clearname the name of the <code>Attribute</code> to return. * @return the <code>Attribute</code> with the specified name, or null * if there is no matching <code>Attribute</code>. * @see Attribute */ public final Attribute getAttribute(String clearname) { //throws NoSuchAttributeException { Attribute a = (Attribute) _attr.get(clearname); return (a); }
/** * Returns an <code>Enumeration</code> of the attribute names in this * <code>AttributeTable</code>. * Use the <code>getAttribute</code> method to get the * <code>Attribute</code> for a given name. * * @return an <code>Enumeration</code> of <code>String</code>. * @see AttributeTable#getAttribute(String) */ public final Enumeration getNames() { return _attr.keys(); }
/** * Returns a clone of this <code>AttributeTable</code>. * See DAPNode.cloneDag() * * @param map track previously cloned nodes * @return a clone of this <code>Attribute</code>. */ public DAPNode cloneDAG(CloneMap map) throws CloneNotSupportedException { AttributeTable at = (AttributeTable) super.cloneDAG(map); at._attr = new SortedTable(); for (int i = 0; i < _attr.size(); i++) { String key = (String) _attr.getKey(i); Attribute element = (Attribute) _attr.elementAt(i); // clone element (don't clone key because it's a read-only String) at._attr.put(key, (Attribute)cloneDAG(map,element)); } return at; }
/** * Create and append an attribute container to the table. * A container is another <code>AttributeTable</code> object. * * @param name the name of the container to add. * @return A pointer to the new <code>AttributeTable</code> object, or null * if a container by that name already exists. */ public final AttributeTable appendContainer(String name) { // return null if name already exists // FIXME! THIS SHOULD RETURN AN EXCEPTION! if (_attr.get(name) != null) return null; AttributeTable at = new AttributeTable(name); Attribute a = new Attribute(name, at); _attr.put(name, a); return at; }
/** * Delete the attribute named <code>name</code>. If the attribute has a * vector value, delete the <code>i</code>'th element of the vector. * * @param name The name of the attribute to delete. This can be an * attribute of any type, including containers. * @param i If the named attribute is a vector, and <code>i</code> is * non-negative, the <code>i</code>'th entry in the vector is deleted. * If <code>i</code> equals -1, the entire attribute is deleted. * @see AttributeTable#delAttribute(String) */ public final void delAttribute(String name, int i) throws DASException { if (i == -1) { // delete the whole attribute _attr.remove(name); } else { Attribute a = (Attribute) _attr.get(name); if (a != null) { if (a.isContainer()) { _attr.remove(name); // delete the entire container } else { a.deleteValueAt(i); } } } }
/** * Delete the attribute named <code>name</code>. * * @param clearname The name of the attribute to delete. This can be an * attribute of any type, including containers. */ public final void delAttribute(String clearname) { _attr.remove(clearname); }
/** * * @return the # of contained attributes */ public int size() { return (_attr == null ? 0 : _attr.size()); }
/** * Returns a clone of this <code>AttributeTable</code>. * See DAPNode.cloneDag() * * @param map track previously cloned nodes * @return a clone of this <code>Attribute</code>. */ public DAPNode cloneDAG(CloneMap map) throws CloneNotSupportedException { AttributeTable at = (AttributeTable) super.cloneDAG(map); at._attr = new SortedTable(); for (int i = 0; i < _attr.size(); i++) { String key = (String) _attr.getKey(i); Attribute element = (Attribute) _attr.elementAt(i); // clone element (don't clone key because it's a read-only String) at._attr.put(key, (Attribute)cloneDAG(map,element)); } return at; }
/** * Create and append an attribute container to the table. * A container is another <code>AttributeTable</code> object. * * @param clearname the name of the container to add. * @return A pointer to the new <code>AttributeTable</code> object, or null * if a container by that name already exists. */ public final AttributeTable appendContainer(String clearname) { // return null if clearname already exists // FIXME! THIS SHOULD RETURN AN EXCEPTION! if (_attr.get(clearname) != null) return null; AttributeTable at = new AttributeTable(clearname); Attribute a = new Attribute(clearname, at); _attr.put(clearname, a); return at; }
/** * Delete the attribute named <code>name</code>. If the attribute has a * vector value, delete the <code>i</code>'th element of the vector. * * @param clearname The name of the attribute to delete. This can be an * attribute of any type, including containers. * @param i If the named attribute is a vector, and <code>i</code> is * non-negative, the <code>i</code>'th entry in the vector is deleted. * If <code>i</code> equals -1, the entire attribute is deleted. * @see AttributeTable#delAttribute(String) */ public final void delAttribute(String clearname, int i) throws DASException { if (i == -1) { // delete the whole attribute _attr.remove(clearname); } else { Attribute a = (Attribute) _attr.get(clearname); if (a != null) { if (a.isContainer()) { _attr.remove(clearname); // delete the entire container } else { a.deleteValueAt(i); } } } }
/** * Delete the attribute named <code>name</code>. * * @param name The name of the attribute to delete. This can be an * attribute of any type, including containers. */ public final void delAttribute(String name) { _attr.remove(name); }
/** * Create and append an attribute container to the table. * A container is another <code>AttributeTable</code> object. * * @param clearname the name of the container to add. * if a container by that name already exists. */ public final void addContainer(String clearname, AttributeTable at) throws AttributeExistsException { // return null if name already exists if (_attr.get(clearname) != null) { throw new AttributeExistsException("The Attribute '" + clearname + "' already exists in the container '" + getEncodedName() + "'"); } Attribute a = new Attribute(clearname, at); _attr.put(clearname, a); }
/** * Create a new empty <code>AttributeTable</code>. */ public AttributeTable(String clearname) { super(clearname); _attr = new SortedTable(); }
/** * Returns the <code>Attribute</code> which matches name. * * @param name the name of the <code>Attribute</code> to return. * @return True if an Attribute with named 'name' exists, False otherwise. * @see Attribute */ public final boolean hasAttribute(String name) { Attribute a = (Attribute) _attr.get(name); if (a == null) { return (false); } return (true); }
/** * Returns an <code>Enumeration</code> of the attribute names in this * <code>AttributeTable</code>. * Use the <code>getAttribute</code> method to get the * <code>Attribute</code> for a given name. * * @return an <code>Enumeration</code> of <code>String</code>. * @see AttributeTable#getAttribute(String) */ public final Enumeration getNames() { return _attr.keys(); }
/** * Create and append an attribute container to the table. * A container is another <code>AttributeTable</code> object. * * @param name the name of the container to add. * if a container by that name already exists. */ public final void addContainer(String name, AttributeTable at) throws AttributeExistsException { // return null if name already exists if (_attr.get(name) != null) { throw new AttributeExistsException("The Attribute '" + name + "' already exists in the container '" + getName() + "'"); } Attribute a = new Attribute(name, at); _attr.put(name, a); }
/** * Create a new empty <code>AttributeTable</code>. * * @deprecated Use constructor that takes the name of the table. */ public AttributeTable() { _attr = new SortedTable(); }
/** * Returns the <code>Attribute</code> which matches name. * * @param clearname the name of the <code>Attribute</code> to return. * @return True if an Attribute with named 'name' exists, False otherwise. * @see Attribute */ public final boolean hasAttribute(String clearname) { Attribute a = (Attribute) _attr.get(clearname); if (a == null) { return (false); } return (true); }