|
10 | 10 |
|
11 | 11 | package cbit.vcell.model; |
12 | 12 |
|
| 13 | +import org.vcell.util.xml.XmlChars; |
| 14 | + |
13 | 15 | import java.beans.PropertyChangeEvent; |
14 | 16 | import java.beans.PropertyChangeListener; |
15 | 17 | import java.beans.PropertyVetoException; |
@@ -299,10 +301,23 @@ public static String fixSbmlName(String newString) { |
299 | 301 | String newValue = sb.toString(); |
300 | 302 | return newValue; |
301 | 303 | } |
| 304 | + |
| 305 | +public static String fixAndValidateSbmlName(String newString, Object source) throws PropertyVetoException { |
| 306 | + String newValue = fixSbmlName(newString); |
| 307 | + if (newValue == null) return null; |
| 308 | + try { |
| 309 | + XmlChars.requireValidAttributeContent(newValue, "sbmlName"); |
| 310 | + } catch (IllegalArgumentException ex) { |
| 311 | + throw new PropertyVetoException(ex.getMessage(), |
| 312 | + new PropertyChangeEvent(source, "sbmlName", null, newValue)); |
| 313 | + } |
| 314 | + return newValue; |
| 315 | +} |
| 316 | + |
302 | 317 | public void setSbmlName(String newString) throws PropertyVetoException { |
303 | 318 | String oldValue = this.sbmlName; |
304 | | - String newValue = fixSbmlName(newString); |
305 | | - |
| 319 | + String newValue = fixAndValidateSbmlName(newString, this); |
| 320 | + |
306 | 321 | fireVetoableChange("sbmlName", oldValue, newValue); |
307 | 322 | this.sbmlName = newValue; |
308 | 323 | firePropertyChange("sbmlName", oldValue, newValue); |
|
0 commit comments