/** * Deregister an attribute as having a type of ID. * * @param attributeName the QName of the ID attribute to be de-registered */ public void deregisterID(QName attributeName) { if (idAttribNames.contains(attributeName)) { idAttribNames.remove(attributeName); } // In case attribute already has a value, // deregister the current value mapping with the XMLObject owner. if (containsKey(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(get(attributeName)); } }
/** * Deregister an attribute as having a type of ID. * * @param attributeName the QName of the ID attribute to be de-registered */ public void deregisterID(QName attributeName) { if (idAttribNames.contains(attributeName)) { idAttribNames.remove(attributeName); } // In case attribute already has a value, // deregister the current value mapping with the XMLObject owner. if (containsKey(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(get(attributeName)); } }
/** * Deregister an ID-to-XMLObject mapping for one of this object's owner's children. * * @param id the ID attribute value of the XMLObject child to deregister */ public void deregisterIDMapping(String id) { if (id == null) { return; } idMappings.remove(id); if (owner.hasParent()) { owner.getParent().getIDIndex().deregisterIDMapping(id); } }
/** * Deregister an ID-to-XMLObject mapping for one of this object's owner's children. * * @param id the ID attribute value of the XMLObject child to deregister */ public void deregisterIDMapping(String id) { if (id == null) { return; } idMappings.remove(id); if (owner.hasParent()) { owner.getParent().getIDIndex().deregisterIDMapping(id); } }
/** * A helper function for derived classes. The mutator/setter method for any ID-typed attributes should call this * method in order to handle getting the old value removed from the ID-to-XMLObject mapping, and the new value added * to the mapping. * * @param oldID the old value of the ID-typed attribute * @param newID the new value of the ID-typed attribute */ protected void registerOwnID(String oldID, String newID) { String newString = DatatypeHelper.safeTrimOrNullString(newID); if (!DatatypeHelper.safeEquals(oldID, newString)) { if (oldID != null) { idIndex.deregisterIDMapping(oldID); } if (newString != null) { idIndex.registerIDMapping(newString, this); } } }
/** * A helper function for derived classes. The mutator/setter method for any ID-typed attributes should call this * method in order to handle getting the old value removed from the ID-to-XMLObject mapping, and the new value added * to the mapping. * * @param oldID the old value of the ID-typed attribute * @param newID the new value of the ID-typed attribute */ protected void registerOwnID(String oldID, String newID) { String newString = DatatypeHelper.safeTrimOrNullString(newID); if (!DatatypeHelper.safeEquals(oldID, newString)) { if (oldID != null) { idIndex.deregisterIDMapping(oldID); } if (newString != null) { idIndex.registerIDMapping(newString, this); } } }
/** {@inheritDoc} */ public String remove(Object key) { String removedValue = attributes.remove(key); if (removedValue != null) { releaseDOM(); QName attributeName = (QName) key; if (isIDAttribute(attributeName) || Configuration.isIDAttribute(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(removedValue); } attributeOwner.getNamespaceManager().deregisterAttributeName(attributeName); checkAndDeregisterQNameValue(attributeName, removedValue); } return removedValue; }
/** {@inheritDoc} */ public String remove(Object key) { String removedValue = attributes.remove(key); if (removedValue != null) { releaseDOM(); QName attributeName = (QName) key; if (isIDAttribute(attributeName) || Configuration.isIDAttribute(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(removedValue); } attributeOwner.getNamespaceManager().deregisterAttributeName(attributeName); checkAndDeregisterQNameValue(attributeName, removedValue); } return removedValue; }
/** {@inheritDoc} */ public String put(QName attributeName, String value) { String oldValue = get(attributeName); if (!DatatypeHelper.safeEquals(value, oldValue)) { releaseDOM(); attributes.put(attributeName, value); if (isIDAttribute(attributeName) || Configuration.isIDAttribute(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(oldValue); attributeOwner.getIDIndex().registerIDMapping(value, attributeOwner); } if (!DatatypeHelper.isEmpty(attributeName.getNamespaceURI())) { if (value == null) { attributeOwner.getNamespaceManager().deregisterAttributeName(attributeName); } else { attributeOwner.getNamespaceManager().registerAttributeName(attributeName); } } checkAndDeregisterQNameValue(attributeName, oldValue); checkAndRegisterQNameValue(attributeName, value); } return oldValue; }
/** {@inheritDoc} */ public String put(QName attributeName, String value) { String oldValue = get(attributeName); if (!DatatypeHelper.safeEquals(value, oldValue)) { releaseDOM(); attributes.put(attributeName, value); if (isIDAttribute(attributeName) || Configuration.isIDAttribute(attributeName)) { attributeOwner.getIDIndex().deregisterIDMapping(oldValue); attributeOwner.getIDIndex().registerIDMapping(value, attributeOwner); } if (!DatatypeHelper.isEmpty(attributeName.getNamespaceURI())) { if (value == null) { attributeOwner.getNamespaceManager().deregisterAttributeName(attributeName); } else { attributeOwner.getNamespaceManager().registerAttributeName(attributeName); } } checkAndDeregisterQNameValue(attributeName, oldValue); checkAndRegisterQNameValue(attributeName, value); } return oldValue; }