/** * Returns a String representing this SBase with all the * attributes that are defined. * * @return a String representing this SBase with all its * attributes */ @Override public String toString() { Map<String, String> attMap = writeXMLAttributes(); StringBuilder sb = new StringBuilder(""); sb.append(getElementName()).append(" ["); if (attMap != null) { // print id, name and metaid first sb.append(extractAttribute(attMap, "id")); sb.append(extractAttribute(attMap, "name")); sb.append(extractAttribute(attMap, "metaid")); for (String attributeName : attMap.keySet()) { sb.append(" ").append(attributeName).append("=\""); sb.append(attMap.get(attributeName)).append("\""); } } sb.append("]"); return sb.toString(); }
/** * Checks if the sID is a valid identifier. * * @param sID * the identifier to be checked. If null or an invalid * identifier, an exception will be thrown. * @return {@code true} only if the sID is a valid identifier. * Otherwise this method throws an {@link IllegalArgumentException}. * This is an intended behavior. * @throws IllegalArgumentException * if the given id is not valid in this model. */ protected boolean checkIdentifier(String sID) { if ((sID == null) || !SyntaxChecker.isValidId(sID, getLevel(), getVersion())) { throw new IllegalArgumentException(format( resourceBundle.getString("AbstractNamedSBase.checkIdentifier"), sID, getElementName())); } return true; }
? format( resourceBundle.getString("IndexExceedsBoundsException2"), getElementName()) : format( resourceBundle.getString("IndexExceedsBoundsException"), childIndex,
@Override public List<Object> getListOfSBMLElementsToWrite(Object treeNode) { if (logger.isDebugEnabled()) { logger.debug("getListOfSBMLElementsToWrite: " + treeNode.getClass().getCanonicalName()); } List<Object> listOfElementsToWrite = new ArrayList<Object>(); // test if this treeNode is an extended SBase. if (treeNode instanceof SBase && ((SBase) treeNode).getExtension(shortLabel) != null) { SBasePlugin sbasePlugin = ((Model) treeNode).getExtension(shortLabel); if (sbasePlugin != null) { listOfElementsToWrite = super.getListOfSBMLElementsToWrite(sbasePlugin); logger.debug("getListOfSBMLElementsToWrite: nb children = " + sbasePlugin.getChildCount()); } } else { listOfElementsToWrite = super.getListOfSBMLElementsToWrite(treeNode); } // IntraSpeciesReaction children if (treeNode instanceof IntraSpeciesReaction) { String sbmlNamespace = JSBML.getNamespaceFrom(((IntraSpeciesReaction) treeNode).getLevel(), ((IntraSpeciesReaction) treeNode).getVersion()); for (Object child : listOfElementsToWrite) { if (child instanceof AbstractSBase && ((AbstractSBase) child).getNamespace() == null) { AbstractSBase sbase = (AbstractSBase) child; logger.debug("Found one suspect Model child: " + sbase.getElementName() + ". Setting the SBML namespace to it."); sbase.setNamespace(sbmlNamespace); } } } return listOfElementsToWrite; }
@Override public List<Object> getListOfSBMLElementsToWrite(Object treeNode) { if (logger.isDebugEnabled()) { logger.debug("getListOfSBMLElementsToWrite: " + treeNode.getClass().getCanonicalName()); } List<Object> listOfElementsToWrite = new ArrayList<Object>(); // test if this treeNode is an extended SBase. if (treeNode instanceof SBase && (! (treeNode instanceof Model)) && ((SBase) treeNode).getExtension(getNamespaceURI()) != null) { SBasePlugin sbasePlugin = ((SBase) treeNode).getExtension(getNamespaceURI()); if (sbasePlugin != null) { listOfElementsToWrite = super.getListOfSBMLElementsToWrite(sbasePlugin); logger.debug("getListOfSBMLElementsToWrite: nb children = " + sbasePlugin.getChildCount()); } } else { listOfElementsToWrite = super.getListOfSBMLElementsToWrite(treeNode); } if (treeNode instanceof Model && listOfElementsToWrite != null) { String sbmlNamespace = JSBML.getNamespaceFrom(((Model) treeNode).getLevel(), ((Model) treeNode).getVersion()); for (Object child : listOfElementsToWrite) { if (child instanceof AbstractSBase && ((AbstractSBase) child).getNamespace() == null) { AbstractSBase sbase = (AbstractSBase) child; logger.debug("Found one suspect Model child: " + sbase.getElementName() + ". Setting the SBML namespace to it."); sbase.setNamespace(sbmlNamespace); } } } return listOfElementsToWrite; }
logger.debug(format( "Some annotations would get lost because there was no metaid defined on {0}. To avoid this, an automatic metaid ''{0}'' has been generated.", getElementName(), getMetaId())); logger.warn(format( "Some annotations can get lost because no metaid is defined on {0}.", getElementName()));
logger.warn(format( resourceBundle.getString("AbstractSBase.registerChild1"), sbase.getElementName(), sbase, getElementName(), this)); } else { logger.warn(format(
throw new IllegalArgumentException(format( resourceBundle.getString("AbstractSBase.setMetaId"), metaId, getElementName()));