From: <and...@us...> - 2015-04-22 15:11:31
|
Revision: 2218 http://sourceforge.net/p/jsbml/code/2218 Author: andreas-draeger Date: 2015-04-22 15:11:23 +0000 (Wed, 22 Apr 2015) Log Message: ----------- * Started to extract user messages from AbstractSBase to an XML file. * Implemented a new method to set the non-RDF annotation on SBase for libSBML compliance. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/AbstractSBase.java trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java trunk/core/src/org/sbml/jsbml/SBase.java Added Paths: ----------- trunk/core/resources/org/sbml/jsbml/resources/Messages.xml Added: trunk/core/resources/org/sbml/jsbml/resources/Messages.xml =================================================================== --- trunk/core/resources/org/sbml/jsbml/resources/Messages.xml (rev 0) +++ trunk/core/resources/org/sbml/jsbml/resources/Messages.xml 2015-04-22 15:11:23 UTC (rev 2218) @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment> + $Id$ + $URL$ + ---------------------------------------------------------------------------- + This file is part of JSBML. Please visit http://sbml.org/Software/JSBML + for the latest version of JSBML and more information about SBML. + + Copyright (C) 2009-2015 jointly by the following organizations: + 1. The University of Tuebingen, Germany + 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK + 3. The California Institute of Technology, Pasadena, CA, USA + 4. The University of California, San Diego, La Jolla, CA, USA + 5. The Babraham Institute, Cambridge, UK + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation. A copy of the license agreement is provided + in the file named "LICENSE.txt" included with this software distribution + and also available online as http://sbml.org/Software/JSBML/License. + ---------------------------------------------------------------------------- + + A collection of text messages to be presented to uses upon certain events. + + Author: Andreas Dräger + Version: $Rev$ + Since: 1.1 + </comment> + + <entry key="IndexExceedsBoundsException">Index {0,number,integer} >= {1,number,integer}</entry> + + <entry key="AbstractSBase.addDeclaredNamespace">The only allowed prefix for a namespace is 'xmlns:'.</entry> + <entry key="AbstractSBase.addExtensionExc">The package namespace or name ''{0}'' is unknown!</entry> + <entry key="AbstractSBase.setNamespaceExc">An SBase element cannot belong to two different namespaces! Current namespace = ''{0}'', new namespace = ''{1}''</entry> + <entry key="AbstractSBase.emptyNotes">The notes to append are empty!</entry> + <entry key="AbstractSBase.invalidNotesStructure">The given 'notes' String does not have the proper structure, excepting the children 'head' and 'body' to the 'html' element.</entry> + <entry key="AbstractSBase.problemAddingXMLNode">There was a problem adding the given XMLNode: ''{0}'' to the ''body'' XMLNode.</entry> + +</properties> \ No newline at end of file Property changes on: trunk/core/resources/org/sbml/jsbml/resources/Messages.xml ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id URL Rev \ No newline at end of property Modified: trunk/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2015-04-22 15:01:44 UTC (rev 2217) +++ trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2015-04-22 15:11:23 UTC (rev 2218) @@ -318,10 +318,9 @@ */ @Override public void addDeclaredNamespace(String prefix, String namespace) { - if ((!prefix.startsWith("xmlns:")) && (!prefix.equals("xmlns"))) { if (prefix.indexOf(":") != -1) { - throw new IllegalArgumentException("The only allowed prefix for a namespace is 'xmlns:'."); + throw new IllegalArgumentException(resourceBundle.getString("AbstractSBase.addDeclaredNamespace")); } prefix = "xmlns:" + prefix; } @@ -360,7 +359,7 @@ firePropertyChange(TreeNodeChangeEvent.addExtension, null, sbasePlugin); } else { throw new IllegalArgumentException(MessageFormat.format( - "The package namespace or name ''{0}'' is unknown!", nameOrUri)); + resourceBundle.getString("AbstractSBase.addExtensionExc"), nameOrUri)); } } @@ -384,12 +383,12 @@ * @param namespace the XML namespace to which this {@link SBase} belong. */ public void setNamespace(String namespace) { - if ((elementNamespace != null) && (!elementNamespace.equals(namespace))) { // if we implement proper conversion some days, we need to unset the namespace before changing it. - logger.error(MessageFormat.format("An SBase element cannot belong to two different namespaces! Current namespace = ''{0}'', new namespace = ''{1}''", elementNamespace, namespace)); - // throw new IllegalArgumentException(MessageFormat.format("An SBase element cannot belong to two different namespaces ! " - // + "Current namespace = '{0}', new namespace = '{1}' ", elementNamespace, namespace)); + logger.error(MessageFormat.format( + resourceBundle.getString("AbstractSBase.setNamespaceExc"), + elementNamespace, namespace)); + // throw new IllegalArgumentException(MessageFormat.format(resourceBundle.getString("AbstractSBase.setNamespaceExc"), elementNamespace, namespace)); } String old = elementNamespace; elementNamespace = namespace; @@ -496,7 +495,7 @@ else { // the given notes is empty - logger.info("The notes to append are empty !!"); + logger.info(resourceBundle.getString("AbstractSBase.emptyNotes")); return; } } @@ -533,7 +532,7 @@ // The given notes node needs to be added to a parent node // if the node is neither "html" nor "body" element because the // children of addedNotes will be added to the current notes later if the - // node is neither "html" nor "body" (i.e. any XHTML element that + // node is neither "html" nor "body" (i.e., any XHTML element that // would be permitted within a "body" element) addedNotes.addChild(notes); addedNotesType = NOTES_TYPE.NotesAny; @@ -569,7 +568,7 @@ if (!headFound || !bodyFound || otherElementFound) { // TODO - throw an exception as well - logger.warn("The given 'notes' String does not have the proper structure, excepting the children 'head' and 'body' to the 'html' element."); + logger.warn(resourceBundle.getString("AbstractSBase.invalidNotesStructure")); return; } } @@ -639,7 +638,9 @@ for (i=0; i < addedBody.getChildCount(); i++) { if (curBody.addChild(addedBody.getChildAt(i)) < 0) { - logger.warn("There was a problem adding the given XMLNode: '" + SBMLtools.toXML(addedBody.getChildAt(i)) + "' to the 'body' XMLNode."); + logger.warn(MessageFormat.format( + resourceBundle.getString("AbstractSBase.problemAddingXMLNode"), + SBMLtools.toXML(addedBody.getChildAt(i)))); return; } } @@ -650,10 +651,12 @@ // adds the given body or other tag (permitted in the body) to the current // html tag - for (i=0; i < addedNotes.getChildCount(); i++) + for (i = 0; i < addedNotes.getChildCount(); i++) { if (curBody.addChild(addedNotes.getChildAt(i)) < 0) { - logger.warn("There was a problem adding the given XMLNode: '" + SBMLtools.toXML(addedNotes.getChildAt(i)) + "' to the 'body' XMLNode."); + logger.warn(MessageFormat.format( + resourceBundle.getString("AbstractSBase.problemAddingXMLNode"), + SBMLtools.toXML(addedNotes.getChildAt(i)))); return; } } @@ -1775,7 +1778,7 @@ // Could/Should be used by the method #firePropertyChange // TODO - set package version and namespace if needed - + int childCount = sbasePlugin.getChildCount(); if (childCount > 0) { @@ -1828,6 +1831,14 @@ } /* (non-Javadoc) + * @see org.sbml.jsbml.SBase#setAnnotation(org.sbml.jsbml.xml.XMLNode) + */ + @Override + public void setAnnotation(XMLNode nonRDFAnnotation) { + getAnnotation().setNonRDFAnnotation(nonRDFAnnotation); + } + + /* (non-Javadoc) * @see org.sbml.jsbml.SBase#setHistory(org.sbml.jsbml.History) */ @Override @@ -2204,7 +2215,7 @@ return; } - throw new IllegalArgumentException(MessageFormat.format("The package namespace or name ''{0}'' is unknown!!", nameOrUri)); + throw new IllegalArgumentException(MessageFormat.format("The package namespace or name ''{0}'' is unknown!", nameOrUri)); } @Override Modified: trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java 2015-04-22 15:01:44 UTC (rev 2217) +++ trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java 2015-04-22 15:11:23 UTC (rev 2218) @@ -32,11 +32,13 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.ResourceBundle; import java.util.Set; import javax.swing.tree.TreeNode; import org.apache.log4j.Logger; +import org.sbml.jsbml.util.ResourceManager; import org.sbml.jsbml.util.StringTools; import org.sbml.jsbml.util.TreeNodeChangeEvent; import org.sbml.jsbml.util.TreeNodeChangeListener; @@ -60,6 +62,11 @@ private static final long serialVersionUID = 8629109724566600238L; /** + * Localization support. + */ + protected static final transient ResourceBundle resourceBundle = ResourceManager.getBundle("org.sbml.jsbml.resources.Messages"); + + /** * */ public static final String UNKNOWN_ATTRIBUTES = "unknown.attributes"; //$NON-NLS-1$ Modified: trunk/core/src/org/sbml/jsbml/SBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBase.java 2015-04-22 15:01:44 UTC (rev 2217) +++ trunk/core/src/org/sbml/jsbml/SBase.java 2015-04-22 15:11:23 UTC (rev 2218) @@ -503,15 +503,15 @@ public int getCVTermCount(); /** - * Returns the name of the SBML Level 3 package in which this element is defined, as + * Returns the name of the SBML Level 3 package in which this element is defined, as * defined in <a href="http://sbml.org/Community/Wiki"> the sbml.org community wiki</a>. * - * <p> For example, the string "core" will be returned if this element is defined in SBML Level 3 Core. + * <p> For example, the string "core" will be returned if this element is defined in SBML Level 3 Core. * * @return the name of the SBML Level 3 package in which this element is defined. */ public String getPackageName(); - + /** * Returns the version of the SBML Level 3 package to which this element belongs. * @@ -522,7 +522,7 @@ * @return the version of the SBML Level 3 package to which this element belongs. */ public int getPackageVersion(); - + /** * Returns the parent of this {@link SBase}. * @@ -584,16 +584,16 @@ /** * Returns the namespace to which this {@link SBase} belong to. Same as {@link #getNamespace()}. * - * <p>For example, all elements that belong to Layout Extension Version 1 for SBML Level 3 Version 1 Core + * <p>For example, all elements that belong to Layout Extension Version 1 for SBML Level 3 Version 1 Core * must have the URI 'http://www.sbml.org/sbml/level3/version1/layout/version1'. * <p>The elements that belong to SBML core might return null. * * @return the namespace to which this {@link SBase} belong to. * @see SBase#getNamespace() - * @libsbml.deprecated + * @libsbml.deprecated */ public String getURI(); - + /** * Returns the Version within the SBML Level of the overall SBML document. * Return -1 if it is not set. @@ -858,6 +858,12 @@ public void setAnnotation(Annotation annotation); /** + * + * @param nonRDFAnnotation + */ + public void setAnnotation(XMLNode nonRDFAnnotation); + + /** * Sets the history. * * @param history the history of this {@link SBase} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |