|
From: <lh...@us...> - 2009-02-06 16:25:42
|
Revision: 97
http://tmapi.svn.sourceforge.net/tmapi/?rev=97&view=rev
Author: lheuer
Date: 2009-02-06 16:25:36 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
- Added MalformedIRIException (acc. to vote November 2008)
- Changed ModelConstraintException and IdentityConstraintException: getSender() -> getReporter(), disallow null
- Updated test cases
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
trunk/src/main/java/org/tmapi/core/TopicInUseException.java
trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestItemIdentifierConstraint.java
trunk/src/test/java/org/tmapi/core/TestReifiable.java
trunk/src/test/java/org/tmapi/core/TestTopicRemovableConstraint.java
Added Paths:
-----------
trunk/src/main/java/org/tmapi/core/MalformedIRIException.java
Modified: trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -34,21 +34,23 @@
* Creates a new <tt>IdentityConstraintException</tt> with the specified
* message.
*
- * @param sender The construct to which the identity should have been assigned to.
+ * @param reporter The construct to which the identity should have been
+ * assigned to. In case a factory method has thrown this
+ * exception, the construct which provides the factory method.
* @param existing The construct which has the same identity.
* @param locator The locator representing the identity.
* @param msg The detail message.
*/
- public IdentityConstraintException(Construct sender, Construct existing,
+ public IdentityConstraintException(Construct reporter, Construct existing,
Locator locator, String msg) {
- super(sender, msg);
+ super(reporter, msg);
_existing = existing;
_locator = locator;
}
/**
- * Returns the {@link Construct} which existed already with the
- * same identity.
+ * Returns the {@link Construct} which already has the identity represented
+ * by the locator {@link #getLocator()}.
*
* @return The existing construct.
*/
@@ -57,9 +59,9 @@
}
/**
- * Returns the locator that caused the exception.
+ * Returns the locator representing the identity that caused the exception.
*
- * @return The locator.
+ * @return A locator representing the identity which has caused the exception.
*/
public Locator getLocator() {
return _locator;
Added: trunk/src/main/java/org/tmapi/core/MalformedIRIException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/MalformedIRIException.java (rev 0)
+++ trunk/src/main/java/org/tmapi/core/MalformedIRIException.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -0,0 +1,36 @@
+/*
+ * The Topic Maps API (TMAPI) was created collectively by
+ * the membership of the tmapi-discuss mailing list
+ * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>,
+ * is hereby released into the public domain; and comes with
+ * NO WARRANTY.
+ *
+ * No one owns TMAPI: you may use it freely in both commercial and
+ * non-commercial applications, bundle it with your software
+ * distribution, include it on a CD-ROM, list the source code in a
+ * book, mirror the documentation at your own web site, or use it in
+ * any other way you see fit.
+ */
+package org.tmapi.core;
+
+/**
+ * Thrown to indicate that a malformed IRI has occurred.
+ *
+ * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class MalformedIRIException extends TMAPIRuntimeException {
+
+ private static final long serialVersionUID = 2126925008251115110L;
+
+ /**
+ * Constructs a <tt>MalformedIRIException</tt> with the specified detail
+ * message.
+ *
+ * @param message The detail message.
+ */
+ public MalformedIRIException(String message) {
+ super(message);
+ }
+
+}
Property changes on: trunk/src/main/java/org/tmapi/core/MalformedIRIException.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -23,31 +23,29 @@
*/
public class ModelConstraintException extends TMAPIRuntimeException {
- private static final long serialVersionUID = -7515653646384503071L;
+ private static final long serialVersionUID = 7038106692343162395L;
- private final Construct _sender;
+ private final Construct _reporter;
/**
* Creates a new <tt>ModelConstraintException</tt> with the specified
* message.
*
- * @param sender The construct which should have been modified.
+ * @param reporter The construct which has thrown this exception.
* @param msg The detail message.
*/
- public ModelConstraintException(Construct sender, String msg) {
+ public ModelConstraintException(Construct reporter, String msg) {
super(msg);
- _sender = sender;
+ _reporter = reporter;
}
/**
* Returns the {@link Construct} which has thrown the exception.
*
- * @return The construct which has thrown the exception or <tt>null</tt>
- * if no appropriate construct is available (i.e. in the factory
- * methods).
+ * @return The construct which has thrown the exception.
*/
- public Construct getSender() {
- return _sender;
+ public Construct getReporter() {
+ return _reporter;
}
}
Modified: trunk/src/main/java/org/tmapi/core/TopicInUseException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -22,26 +22,25 @@
*/
public class TopicInUseException extends ModelConstraintException {
- private static final long serialVersionUID = 6118893892630188394L;
+ private static final long serialVersionUID = 486617548358575845L;
-
/**
* Creates a new <tt>TopicInUseException</tt> with the specified
* message.
*
- * @param sender The topic which is not removable.
+ * @param topic The topic which is not removable.
* @param msg The detail message.
*/
- public TopicInUseException(Topic sender, String msg) {
- super(sender, msg);
+ public TopicInUseException(Topic topic, String msg) {
+ super(topic, msg);
}
/* (non-Javadoc)
- * @see org.tmapi.core.ModelConstraintException#getSender()
+ * @see org.tmapi.core.ModelConstraintException#getReporter()
*/
@Override
- public Topic getSender() {
- return (Topic) super.getSender();
+ public Topic getReporter() {
+ return (Topic) super.getReporter();
}
}
Modified: trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -155,9 +155,8 @@
final DatatypeAware dt = getDatatypeAware();
dt.setValue(value);
final String val = dt.getValue();
- if (!"10".equals(val) && !"10.0".equals(val)) {
- fail("Expected either '10' or the canonical representation '10.0'");
- }
+ assertTrue("Expected either '10' or the canonical representation '10.0'",
+ "10".equals(val) || "10.0".equals(val));
assertEquals(_xsdDecimal, dt.getDatatype());
assertEquals(value, dt.decimalValue());
assertEquals(BigInteger.TEN, dt.integerValue());
@@ -171,9 +170,8 @@
final DatatypeAware dt = getDatatypeAware();
dt.setValue(value.toString(), _xsdDecimal);
final String val = dt.getValue();
- if (!"10".equals(val) && !"10.0".equals(val)) {
- fail("Expected either '10' or the canonical representation '10.0'");
- }
+ assertTrue("Expected either '10' or the canonical representation '10.0'",
+ "10".equals(val) || "10.0".equals(val));
assertEquals(_xsdDecimal, dt.getDatatype());
if (!value.equals(dt.decimalValue()) &&
!new BigDecimal("10.0").equals(dt.decimalValue())) {
Modified: trunk/src/test/java/org/tmapi/core/TestItemIdentifierConstraint.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestItemIdentifierConstraint.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/test/java/org/tmapi/core/TestItemIdentifierConstraint.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -25,7 +25,7 @@
*
* @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestItemIdentifierConstraint extends TMAPITestCase {
@@ -50,7 +50,9 @@
fail("Topic Maps constructs with the same item identifier are not allowed");
}
catch (IdentityConstraintException ex) {
- // noop
+ assertEquals(tmo, ex.getReporter());
+ assertEquals(assoc, ex.getExisting());
+ assertEquals(iid, ex.getLocator());
}
tmo.addItemIdentifier(iid2);
assertTrue(tmo.getItemIdentifiers().contains(iid2));
@@ -87,7 +89,9 @@
topic2.addItemIdentifier(iid);
}
catch (IdentityConstraintException ex) {
- // noop.
+ assertEquals(topic2, ex.getReporter());
+ assertEquals(topic, ex.getExisting());
+ assertEquals(iid, ex.getLocator());
}
topic.removeItemIdentifier(iid);
assertFalse(topic.getItemIdentifiers().contains(iid));
Modified: trunk/src/test/java/org/tmapi/core/TestReifiable.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestReifiable.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/test/java/org/tmapi/core/TestReifiable.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -73,7 +73,7 @@
fail("The reifier reifies already another construct");
}
catch (ModelConstraintException ex) {
- assertEquals(reifiable, ex.getSender());
+ assertEquals(reifiable, ex.getReporter());
}
otherReifiable.setReifier(null);
assertNull("Reifier property should be null", otherReifiable.getReifier());
Modified: trunk/src/test/java/org/tmapi/core/TestTopicRemovableConstraint.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicRemovableConstraint.java 2009-01-11 20:30:19 UTC (rev 96)
+++ trunk/src/test/java/org/tmapi/core/TestTopicRemovableConstraint.java 2009-02-06 16:25:36 UTC (rev 97)
@@ -45,7 +45,7 @@
fail("The topic is used as type");
}
catch (TopicInUseException ex) {
- assertEquals(topic, ex.getSender());
+ assertEquals(topic, ex.getReporter());
}
assertEquals(topicCount+1, _tm.getTopics().size());
typed.setType(oldType);
@@ -69,7 +69,7 @@
fail("The topic is used as theme");
}
catch (TopicInUseException ex) {
- assertEquals(topic, ex.getSender());
+ assertEquals(topic, ex.getReporter());
}
assertEquals(topicCount+1, _tm.getTopics().size());
scoped.removeTheme(topic);
@@ -94,7 +94,7 @@
fail("The topic is used as reifier");
}
catch (TopicInUseException ex) {
- assertEquals(topic, ex.getSender());
+ assertEquals(topic, ex.getReporter());
}
assertEquals(topicCount+1, _tm.getTopics().size());
reifiable.setReifier(null);
@@ -214,7 +214,7 @@
fail("The topic is used as topic type");
}
catch (TopicInUseException ex) {
- assertEquals(topic, ex.getSender());
+ assertEquals(topic, ex.getReporter());
}
assertEquals(2, _tm.getTopics().size());
topic2.removeType(topic);
@@ -242,7 +242,7 @@
fail("The topic is used as player");
}
catch (TopicInUseException ex) {
- assertEquals(topic, ex.getSender());
+ assertEquals(topic, ex.getReporter());
}
role.setPlayer(createTopic());
assertEquals(4, _tm.getTopics().size());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|