/** * Sets the id of this field. Don't do this unless you know what you are doing * * @param newId the id - if this is less than 100 it will cause document to serialize * using just one byte for this field id. 100-127 are reserved values * @param owner the owning document, this is checked for collisions and notified * of the id change. It can not be null */ public void setId(int newId, DocumentType owner) { if (owner == null) { throw new NullPointerException("Can not assign an id of " + this + " without knowing the owner"); } validateId(newId, owner, Document.SERIALIZED_VERSION); owner.removeField(getName()); this.fieldId = newId; this.fieldIdV6 = newId; this.forcedId = true; owner.addField(this); }
/** * Removes an field from the DocumentType. * * @param name The name of the field. * @return The field that was removed or null if it did not exist. */ public Field removeField(String name) { if (isRegistered()) { throw new IllegalStateException("You cannot remove fields from a document type that is already registered."); } Field field = headerType.removeField(name); if (field == null) { field = bodyType.removeField(name); } if (field == null) { for (DocumentType inheritedType : inherits) { field = inheritedType.removeField(name); if (field != null) break; } } return field; }