public void addField(Field field) { verifyInheritance(field); for (Iterator<Field> i = docType.fieldIteratorThisTypeOnly(); i.hasNext(); ) { if (field.getName().equalsIgnoreCase((i.next()).getName())) { throw new IllegalArgumentException("Duplicate (case insensitively) " + field + " in " + this); } } docType.addField(field); }
public TestDocMan() { DocumentType docType = new DocumentType("testdoctype1"); docType.addHeaderField("headerval", DataType.INT); docType.addField("content", DataType.STRING); registerDocumentType(docType); }
/** * 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); }