|
From: <lh...@us...> - 2008-09-04 11:36:15
|
Revision: 152
http://tinytim.svn.sourceforge.net/tinytim/?rev=152&view=rev
Author: lheuer
Date: 2008-09-04 11:36:23 +0000 (Thu, 04 Sep 2008)
Log Message:
-----------
- More docs
- Added LiteralNormalizer which normalizes a few datatypes
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java
tinytim/trunk/src/main/java/org/tinytim/core/IScope.java
tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java
tinytim/trunk/src/main/java/org/tinytim/core/Literal.java
tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java
tinytim/trunk/src/main/java/org/tinytim/voc/Vocabulary.java
tinytim/trunk/src/main/java/org/tinytim/voc/XSD.java
tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java
tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java
tinytim/trunk/src/test/java/org/tinytim/core/TestItemIdentifierConstraint.java
tinytim/trunk/src/test/java/org/tinytim/core/TestLiteral.java
tinytim/trunk/src/test/java/org/tinytim/core/TestScope.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java
tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java
Modified: tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -47,10 +47,6 @@
*/
final class CopyUtils {
- private CopyUtils() {
- // noop.
- }
-
/**
* Copies the topics and associations from the <tt>source</tt> to the
* <tt>target</tt> topic map.
Modified: tinytim/trunk/src/main/java/org/tinytim/core/IScope.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -51,6 +51,15 @@
public boolean contains(Topic theme);
/**
+ * Returns <tt>true</tt> if all themes of the other <tt>scope</tt> are part
+ * of this scope.
+ *
+ * @param scope A collection of themes.
+ * @return <tt>true</tt> if all themes are part of this scope, otherwise <tt>false</tt>.
+ */
+ public boolean containsAll(Collection<Topic> scope);
+
+ /**
* Returns a <tt>IScope</tt> consisting of all themes contained in this
* scope and the <tt>theme</tt>.
*
@@ -84,6 +93,4 @@
*/
public int size();
- public boolean containsAll(Collection<Topic> scope);
-
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -34,10 +34,6 @@
private static final AtomicLong _COUNTER = new AtomicLong();
- private IdGenerator() {
- // noop.
- }
-
/**
* Returns the next identifier.
*
Modified: tinytim/trunk/src/main/java/org/tinytim/core/Literal.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -48,14 +48,20 @@
if (value == null) {
throw new IllegalArgumentException("The value must not be null");
}
- _value = value;
+ _value = LiteralNormalizer.normalize(value, datatype);
_datatype = datatype;
}
+ /* (non-Javadoc)
+ * @see org.tinytim.core.ILiteral#getDatatype()
+ */
public Locator getDatatype() {
return _datatype;
}
+ /* (non-Javadoc)
+ * @see org.tinytim.core.ILiteral#getValue()
+ */
public String getValue() {
return _value;
}
Added: tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -0,0 +1,164 @@
+/*
+ * This is tinyTiM, a tiny Topic Maps engine.
+ *
+ * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+package org.tinytim.core;
+
+import org.tinytim.voc.XSD;
+import org.tmapi.core.Locator;
+
+/**
+ * Normalizes literal values.
+ *
+ * This class is not meant to be used outside of the tinyTiM package.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+final class LiteralNormalizer {
+
+ private LiteralNormalizer() {
+ // noop.
+ }
+
+ /**
+ * Normalizes the <tt>value</tt> dependent on the <tt>datatype</tt>.
+ *
+ * @param value The value to normalize.
+ * @param datatype The datatype.
+ * @return A normalized value.
+ */
+ public static String normalize(final String value, final Locator datatype) {
+ if (XSD.BOOLEAN.equals(datatype)) {
+ return normalizeBoolean(value);
+ }
+ else if (XSD.INTEGER.equals(datatype)) {
+ return normalizeInteger(value);
+ }
+ else if (XSD.DECIMAL.equals(datatype)) {
+ return normalizeDecimal(value);
+ }
+ return value;
+ }
+
+ public static String normalizeBoolean(final String value) {
+ if ("0".equals(value) || "false".equals(value)) {
+ return "false";
+ }
+ else if ("1".equals(value) || "true".equals(value)) {
+ return "true";
+ }
+ throw new IllegalArgumentException("Illegal boolean value: " + value);
+ }
+
+ public static String normalizeInteger(final String value) {
+ final String val = value.trim();
+ int len = value.length();
+ if (len == 0) {
+ throw new IllegalArgumentException();
+ }
+ int idx = 0;
+ boolean negative = false;
+ switch (val.charAt(idx)) {
+ case '-':
+ idx++;
+ negative = true;
+ break;
+ case '+':
+ idx++;
+ break;
+ }
+ // Skip leading zeros if any
+ while (idx < len && val.charAt(idx) == '0') {
+ idx++;
+ }
+ if (idx == len) {
+ return "0";
+ }
+ final String normalized = val.substring(idx);
+ len = normalized.length();
+ // Check if everything is a digit
+ for (int i = 0; i < len; i++) {
+ if (!Character.isDigit(normalized.charAt(i))) {
+ throw new IllegalArgumentException();
+ }
+ }
+ return negative && normalized.charAt(0) != 0 ? '-' + normalized : normalized;
+ }
+
+ public static String normalizeDecimal(final String value) {
+ final String val = value.trim();
+ int len = value.length();
+ if (len == 0) {
+ throw new IllegalArgumentException();
+ }
+ int idx = 0;
+ boolean negative = false;
+ switch (val.charAt(idx)) {
+ case '-':
+ idx++;
+ negative = true;
+ break;
+ case '+':
+ idx++;
+ break;
+ }
+ // Skip leading zeros if any
+ while (idx < len && val.charAt(idx) == '0') {
+ idx++;
+ }
+ if (idx == len) {
+ return "0.0";
+ }
+ StringBuilder normalized = new StringBuilder(len);
+ if (val.charAt(idx) == '.') {
+ normalized.append('0');
+ }
+ else {
+ while (idx < len && val.charAt(idx) != '.') {
+ char c = val.charAt(idx);
+ if (!Character.isDigit(c)) {
+ throw new IllegalArgumentException("Illegal decimal value: " + value);
+ }
+ normalized.append(c);
+ idx++;
+ }
+ }
+ normalized.append('.');
+ len--;
+ while (len >= idx && val.charAt(len) == '0') {
+ len--;
+ }
+ if (len == idx || len < idx) {
+ normalized.append('0');
+ }
+ else {
+ while (idx < len) {
+ char c = val.charAt(idx);
+ if (!Character.isDigit(c)) {
+ throw new IllegalArgumentException("Illegal decimal value: " + value);
+ }
+ normalized.append(c);
+ idx++;
+ }
+ }
+ return negative && normalized.charAt(0) != '0' ? '-' + normalized.toString() : normalized.toString();
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -30,8 +30,8 @@
import org.tmapi.core.Topic;
/**
+ * {@link IScope} implementation.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
Modified: tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -28,87 +28,78 @@
import org.tmapi.core.Topic;
/**
- * Utility class to check arguments and to throw
- * {@link org.tmapi.core.ModelConstraintException}s if the arg violates a
- * constraint.
+ * Provides various argument constraint checks.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
public final class Check {
- private Check() {
- // noop.
- }
-
- /**
- * Throws a {@link ModelConstraintException} with the specified <tt>sender</tt>
- * and <tt>msg</tt>
- *
- * @param sender The sender
- * @param msg The error message
- */
- private static void _reportError(final Construct sender, final String msg) {
+ private static void _reportError(Construct sender, String msg) {
throw new ModelConstraintException(sender, msg);
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>scope</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>scope</tt> is
+ * <tt>null</tt>.
*
- * @param sender The sender
- * @param scope The scope array.
+ * @param sender The sender.
+ * @param scope The scope.
*/
- public static void scopeNotNull(final Construct sender, final Topic[] scope) {
+ public static void scopeNotNull(Construct sender, Topic[] scope) {
if (scope == null) {
_reportError(sender, "The scope must not be null");
}
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>scope</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>scope</tt> is
+ * <tt>null</tt>.
*
- * @param sender The sender
- * @param scope A collection.
+ * @param sender The sender.
+ * @param scope The scope.
*/
- public static void scopeNotNull(final Construct sender, final Collection<Topic> scope) {
+ public static void scopeNotNull(Construct sender, Collection<Topic> scope) {
if (scope == null) {
_reportError(sender, "The scope must not be null");
}
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>type</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>type</tt> is
+ * <tt>null</tt>.
*
- * @param sender The sender
- * @param type The topic to check.
+ * @param sender The sender.
+ * @param type The type.
*/
- public static void typeNotNull(final Construct sender, final Topic type) {
+ public static void typeNotNull(Construct sender, Topic type) {
if (type == null) {
_reportError(sender, "The type must not be null");
}
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>value</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>value</tt> is
+ * <tt>null</tt>.
*
- * @param sender The sender
+ * @param sender The sender.
* @param value The value.
*/
- public static void valueNotNull(final Construct sender, final Object value) {
+ public static void valueNotNull(Construct sender, Object value) {
if (value == null) {
_reportError(sender, "The value must not be null");
}
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>value</tt> or
- * <tt>datatype</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>value</tt> or
+ * the <tt>datatype</tt> is <tt>null</tt>.
*
- * @param sender The sender
+ * @param sender The sender.
* @param value The value.
- * @param datatype The locator indicating the datatype.
+ * @param datatype The datatype.
*/
- public static void valueNotNull(final Construct sender, final Object value, Locator datatype) {
+ public static void valueNotNull(Construct sender, Object value, Locator datatype) {
valueNotNull(sender, value);
if (datatype == null) {
_reportError(sender, "The datatype must not be null");
@@ -116,12 +107,13 @@
}
/**
- * Throws a {@link ModelConstraintException} if the <tt>player</tt> is <tt>null</tt>.
+ * Throws a {@link ModelConstraintException} iff the <tt>player</tt> is
+ * <tt>null</tt>.
*
- * @param sender The sender
- * @param player The topic to check.
+ * @param sender The sender.
+ * @param player The player.
*/
- public static void playerNotNull(final Construct sender, final Topic player) {
+ public static void playerNotNull(Construct sender, Topic player) {
if (player == null) {
_reportError(sender, "The role player must not be null");
}
Modified: tinytim/trunk/src/main/java/org/tinytim/voc/Vocabulary.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/voc/Vocabulary.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/voc/Vocabulary.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -24,13 +24,19 @@
import org.tmapi.core.Locator;
/**
+ * Base for classes which provide PSIs.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
abstract class Vocabulary {
+ /**
+ * Returns a locator with the specified <tt>reference</tt>.
+ *
+ * @param reference The address of the locator.
+ * @return A locator.
+ */
protected final static Locator _createLocator(String reference) {
return Literal.createIRI(reference);
}
Modified: tinytim/trunk/src/main/java/org/tinytim/voc/XSD.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/voc/XSD.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/main/java/org/tinytim/voc/XSD.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -23,8 +23,8 @@
import org.tmapi.core.Locator;
/**
+ * Provides PSIs for the XML Schema Datatypes.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
@@ -50,4 +50,6 @@
public final static Locator LONG = _createLocator(_BASE + "long");
+ public static final Locator BOOLEAN = _createLocator(_BASE + "boolean");
+
}
Modified: tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -22,7 +22,6 @@
import org.tinytim.utils.TestDuplicateRemovalUtils;
import org.tinytim.utils.TestTopicUtils;
-import org.tinytim.utils.TestTypeInstanceConverter;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -46,13 +45,13 @@
suite.addTestSuite(TestIConstruct.class);
suite.addTestSuite(TestScope.class);
suite.addTestSuite(TestLiteral.class);
+ suite.addTestSuite(TestLiteralNormalizer.class);
suite.addTestSuite(TestItemIdentifierConstraint.class);
suite.addTestSuite(TestSignatureGenerator.class);
suite.addTest(TestTMAPICore.suite());
suite.addTest(TestTMAPIIndex.suite());
suite.addTestSuite(TestTopicMapSystemFactoryImpl.class);
suite.addTestSuite(TestTopicUtils.class);
- suite.addTestSuite(TestTypeInstanceConverter.class);
return suite;
}
}
Modified: tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -30,8 +30,8 @@
import org.tmapi.core.Variant;
/**
+ * Tests against {@link IConstruct}.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev:$ - $Date:$
*/
Modified: tinytim/trunk/src/test/java/org/tinytim/core/TestItemIdentifierConstraint.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestItemIdentifierConstraint.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestItemIdentifierConstraint.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -40,11 +40,11 @@
*
* @param tmo The Topic Maps construct to test.
*/
- private void _testConstraint(final Construct tmo) {
+ private void _testConstraint(Construct tmo) throws Exception {
assertTrue(tmo.getItemIdentifiers().isEmpty());
- final Locator iid = createLocator("http://sf.net/projects/tinytim");
- final Locator iid2 = createLocator("http://sf.net/projects/tinytim2");
- final Association assoc = createAssociation();
+ Locator iid = createLocator("http://sf.net/projects/tinytim");
+ Locator iid2 = createLocator("http://sf.net/projects/tinytim2");
+ Association assoc = createAssociation();
assoc.addItemIdentifier(iid);
assertFalse(tmo.getItemIdentifiers().contains(iid));
try {
@@ -72,16 +72,16 @@
/**
* Tests against a topic map.
*/
- public void testTopicMap() {
+ public void testTopicMap() throws Exception {
_testConstraint(_tm);
}
/**
* Tests againts a topic.
*/
- public void testTopic() {
- final Topic topic = createTopic();
- final Locator iid = createLocator("http://sf.net/projects/tinytim");
+ public void testTopic() throws Exception {
+ Topic topic = createTopic();
+ Locator iid = createLocator("http://sf.net/projects/tinytim");
topic.addItemIdentifier(iid);
assertTrue(topic.getItemIdentifiers().contains(iid));
Topic topic2 = createTopic();
@@ -107,35 +107,35 @@
/**
* Tests against an association.
*/
- public void testAssociation() {
+ public void testAssociation() throws Exception {
_testConstraint(createAssociation());
}
/**
* Tests against a role.
*/
- public void testRole() {
+ public void testRole() throws Exception {
_testConstraint(createRole());
}
/**
* Tests against an occurrence.
*/
- public void testOccurrence() {
+ public void testOccurrence() throws Exception {
_testConstraint(createOccurrence());
}
/**
* Tests against a name.
*/
- public void testName() {
+ public void testName() throws Exception {
_testConstraint(createName());
}
/**
* Tests against a variant.
*/
- public void testVariant() {
+ public void testVariant() throws Exception {
_testConstraint(createVariant());
}
Modified: tinytim/trunk/src/test/java/org/tinytim/core/TestLiteral.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestLiteral.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestLiteral.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -24,8 +24,8 @@
import org.tmapi.core.Locator;
/**
+ * Tests against {@link Literal}.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
Added: tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -0,0 +1,79 @@
+/*
+ * This is tinyTiM, a tiny Topic Maps engine.
+ *
+ * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+package org.tinytim.core;
+
+/**
+ * Tests against the {@link LiteralNormalizer}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestLiteralNormalizer extends TinyTimTestCase {
+
+ public void testNormalizeBoolean() {
+ assertEquals("true", LiteralNormalizer.normalizeBoolean("1"));
+ assertEquals("true", LiteralNormalizer.normalizeBoolean("true"));
+ assertEquals("false", LiteralNormalizer.normalizeBoolean("0"));
+ assertEquals("false", LiteralNormalizer.normalizeBoolean("false"));
+ try {
+ LiteralNormalizer.normalizeBoolean("invalid");
+ fail("Expected an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex) {
+ // noop.
+ }
+ }
+
+ public void testNormalizeInteger() {
+ assertEquals("0", LiteralNormalizer.normalizeInteger("0"));
+ assertEquals("0", LiteralNormalizer.normalizeInteger("-0"));
+ assertEquals("1", LiteralNormalizer.normalizeInteger("+1"));
+ assertEquals("1", LiteralNormalizer.normalizeInteger("00001"));
+ assertEquals("-1", LiteralNormalizer.normalizeInteger("-1"));
+ assertEquals("-1", LiteralNormalizer.normalizeInteger("-00001"));
+ try {
+ LiteralNormalizer.normalizeInteger("invalid");
+ fail("Expected an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex) {
+ // noop.
+ }
+ }
+
+ public void testNormalizeDecimal() {
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("0"));
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("-0"));
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("-0.0"));
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("+0.0"));
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("+00000.0000000"));
+ assertEquals("0.0", LiteralNormalizer.normalizeDecimal("-00000.0000000"));
+ assertEquals("10.0", LiteralNormalizer.normalizeDecimal("10"));
+ assertEquals("-10.0", LiteralNormalizer.normalizeDecimal("-10.00"));
+ assertEquals("10.0", LiteralNormalizer.normalizeDecimal("+10.00"));
+ try {
+ LiteralNormalizer.normalizeDecimal("invalid");
+ fail("Expected an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException ex) {
+ // noop.
+ }
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
Modified: tinytim/trunk/src/test/java/org/tinytim/core/TestScope.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestScope.java 2008-08-26 16:57:58 UTC (rev 151)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestScope.java 2008-09-04 11:36:23 UTC (rev 152)
@@ -25,8 +25,8 @@
import org.tmapi.core.Topic;
/**
+ * Tests against {@link Scope}.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
@@ -38,11 +38,11 @@
}
public void testEquals() {
- Topic theme1 = createTopic();
- Topic theme2 = createTopic();
- IScope scope1 = Scope.create(Arrays.asList(theme1, theme2));
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final IScope scope1 = Scope.create(Arrays.asList(theme1, theme2));
assertEquals(2, scope1.size());
- IScope scope2 = Scope.create(Arrays.asList(theme2, theme1));
+ final IScope scope2 = Scope.create(Arrays.asList(theme2, theme1));
assertSame(scope1, scope2);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|