@Override public void setSBOTerm(int term) { if ((getLevelAndVersion().compareTo(Integer.valueOf(2), Integer.valueOf(2)) < 0) && (!isReadingInProgress())) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.sboTerm, this); } if ((term != -1) && !SBO.checkTerm(term) && !isReadingInProgress()) { throw new IllegalArgumentException(format( resourceBundle.getString("AbstractSBase.setSBOTerm"), term)); } Integer oldTerm = Integer.valueOf(sboTerm); sboTerm = term; firePropertyChange(TreeNodeChangeEvent.sboTerm, oldTerm, sboTerm); }
/** * Creates an {@link AbstractSBase} instance with the given SBML Level and * Version. * <p> * By default, the sboTerm is -1, the metaid, notes, * {@link #parent}, {@link #annotation}, and notes are {@code null}. The * {@link #declaredNamespaces} list and the {@link #extensions} {@link Map} * are * empty. * * @param level * the SBML level * @param version * the SBML version */ public AbstractSBase(int level, int version) { this(); lv.setL(level); lv.setV(version); if (!hasValidLevelVersionNamespaceCombination()) { if (!isReadingInProgress()) { throw new LevelVersionError(this); } else { logger.error(format(LevelVersionError.UNDEFINED_LEVEL_VERSION_COMBINATION_MSG, level, version)); } } }
/** * Checks if the attribute conforms to the SBML specifications of the level * and version of this object. The final values of {@link TreeNodeChangeEvent} * could be used as attribute name. * * <p>WARNING: this is a placeholder method, most classes have no attribute * validations implemented. * * @param attributeName - the attribute name * @return {@code true} if the attribute conforms the the SBML specifications. */ protected boolean checkAttribute(String attributeName) { // do not do the checks if we are reading a model or in the process of cloning any TreeNode if (! (isReadingInProgress() || isCloningInProgress())) { AbstractSBase.attributeValidator.setLevelAndVersion(getLevel(), getVersion()); Class<?> clazz = this.getClass(); attributeValidator.loadConstraintsForAttribute(clazz, attributeName); boolean valid = attributeValidator.validate(this); if (!valid) { logger.error("Invalid value for attribute " + attributeName + " on " + clazz.getSimpleName() + " with id = " + metaId + "!"); } return valid; } return true; }
throw new PropertyNotAvailableException(TreeNodeChangeEvent.metaId, this); } else if (!SyntaxChecker.isValidMetaId(metaId) && !isReadingInProgress()) { throw new IllegalArgumentException(format( resourceBundle.getString("AbstractSBase.setMetaId"), metaId, if (!doc.registerMetaId(this, true) && !isReadingInProgress()) {