You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(48) |
May
(21) |
Jun
(3) |
Jul
(10) |
Aug
(66) |
Sep
(11) |
Oct
(7) |
Nov
(73) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(3) |
Feb
(17) |
Mar
(19) |
Apr
(1) |
May
(4) |
Jun
|
Jul
(43) |
Aug
(18) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
|
| 2010 |
Jan
(3) |
Feb
(7) |
Mar
(21) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(6) |
Aug
(6) |
Sep
(7) |
Oct
|
Nov
(1) |
Dec
|
| 2011 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <lh...@us...> - 2008-04-27 13:17:45
|
Revision: 44
http://tinytim.svn.sourceforge.net/tinytim/?rev=44&view=rev
Author: lheuer
Date: 2008-04-27 06:17:48 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Project layout for the CXTM subpackage
Added Paths:
-----------
tinytim-cxtm/
tinytim-cxtm/branches/
tinytim-cxtm/tags/
tinytim-cxtm/trunk/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-26 14:36:29
|
Revision: 43
http://tinytim.svn.sourceforge.net/tinytim/?rev=43&view=rev
Author: lheuer
Date: 2008-04-26 07:36:30 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
- Construct accesses the _id now directly
- Removed unnecessary Generics from the IdentityManager
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/Construct.java
tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
Modified: tinytim/trunk/src/main/java/org/tinytim/Construct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-26 09:51:39 UTC (rev 42)
+++ tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-26 14:36:30 UTC (rev 43)
@@ -26,7 +26,6 @@
import org.tmapi.core.DuplicateSourceLocatorException;
import org.tmapi.core.Locator;
import org.tmapi.core.TopicMap;
-import org.tmapi.core.TopicMapObject;
/**
* Base class for all Topic Maps constructs.
@@ -34,7 +33,7 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-abstract class Construct implements TopicMapObject, IConstruct {
+abstract class Construct implements IConstruct {
protected String _id;
protected TopicMapImpl _tm;
@@ -129,7 +128,7 @@
if (this == obj) {
return true;
}
- return (obj instanceof Construct) && _id.equals(((Construct) obj).getObjectId());
+ return (obj instanceof Construct) && _id.equals(((Construct) obj)._id);
}
/* (non-Javadoc)
Modified: tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-26 09:51:39 UTC (rev 42)
+++ tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-26 14:36:30 UTC (rev 43)
@@ -45,10 +45,10 @@
IdentityManager(TopicMapImpl tm) {
ICollectionFactory collFactory = tm.getCollectionFactory();
- _id2Construct = collFactory.<String, IConstruct>createMap();
- _sid2Topic = collFactory.<Locator, Topic>createMap();
- _slo2Topic = collFactory.<Locator, Topic>createMap();
- _iid2Construct = collFactory.<Locator, IConstruct>createMap();
+ _id2Construct = collFactory.createMap();
+ _sid2Topic = collFactory.createMap();
+ _slo2Topic = collFactory.createMap();
+ _iid2Construct = collFactory.createMap();
_subscribe(tm);
_register(tm);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-26 09:51:35
|
Revision: 42
http://tinytim.svn.sourceforge.net/tinytim/?rev=42&view=rev
Author: lheuer
Date: 2008-04-26 02:51:39 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
- Moved the IDatatypeAwareConstruct constants to the abstract class
- DatatypeAwareConstruct sends now the correct SET_LOCATOR event if the resource is set
- Minor Java Doc tweaks
- TopicMapImpl cleans up the cached HelperObjects
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/SignatureGenerator.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
tinytim/trunk/src/main/java/org/tinytim/Typed.java
tinytim/trunk/src/test/java/org/tinytim/AllTests.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
Modified: tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -34,6 +34,10 @@
abstract class DatatypeAwareConstruct extends Scoped implements
IDatatypeAwareConstruct {
+ private static final String _XSD_BASE = "http://www.w3.org/2001/XMLSchema#";
+ private static final Locator STRING = new IRI(_XSD_BASE + "string");
+ private static final Locator ANY_URI = new IRI(_XSD_BASE + "anyURI");
+
private String _value;
private Locator _resource;
@@ -96,7 +100,7 @@
* @param value The locator.
*/
public void setResource(Locator value) {
- _fireEvent(Event.SET_VALUE, _value, value);
+ _fireEvent(Event.SET_LOCATOR, _resource, value);
_value = null;
_resource = value;
}
Modified: tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -25,15 +25,13 @@
/**
* Indicates that a Topic Maps construct has a value and a datatype.
*
+ * This interface 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$
*/
interface IDatatypeAwareConstruct extends IConstruct {
- static final String _XSD_BASE = "http://www.w3.org/2001/XMLSchema#";
- static final Locator STRING = new IRI(_XSD_BASE + "string");
- static final Locator ANY_URI = new IRI(_XSD_BASE + "anyURI");
-
/**
* The value of this Topic Maps construct.
*
Modified: tinytim/trunk/src/main/java/org/tinytim/SignatureGenerator.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/SignatureGenerator.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/SignatureGenerator.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -34,7 +34,7 @@
* Generates signatures for Topic Maps constructs.
*
* This class can be used to detect duplicates: If two Topic Maps constructs
- * have the same signature, they should be merged (if they belong to the same
+ * have the same signature, they should be merged (if they belong to the same
* parent).
*
* Neither the topic map, the parent, the reifier, nor item identifiers
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -243,7 +243,7 @@
}
/**
- * Returns a toic by its subject identifier.
+ * Returns a topic by its subject identifier.
*
* @param subjectIdentifier The subject identifier.
* @return A topic or <code>null</code> if no topic with the specified
@@ -254,7 +254,7 @@
}
/**
- * Returns a toic by its subject locator.
+ * Returns a topic by its subject locator.
*
* @param subjectLocator The subject locator.
* @return A topic or <code>null</code> if no topic with the specified
@@ -335,6 +335,8 @@
_identityManager.close();
_identityManager = null;
_eventMultiplier = null;
+ _helperObjects.clear();
+ _helperObjects = null;
super.dispose();
}
@@ -362,7 +364,7 @@
_helperObjects.put(interfaceName, instance);
}
catch (Exception ex) {
- throw new HelperObjectInstantiationException("");
+ throw new HelperObjectInstantiationException("Failed to initialize the helper object");
}
}
return instance;
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -80,7 +80,7 @@
}
/**
- * Creates a collection factory based according to the
+ * Creates a collection factory according to the
* {@link Property#COLLECTION_FACTORY} value. If the collection factory
* is not available, a default collection factory implementation is returned.
*
Modified: tinytim/trunk/src/main/java/org/tinytim/Typed.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -23,9 +23,9 @@
import org.tmapi.core.Topic;
/**
- * Class that provides a "type" property and fires an event if that type
- * property changes. Additionally, this class provides
- * a {@link IReifiable} implementation.
+ * Class that provides a "type" property and fires an event if that property
+ * changes. Additionally, this class provides a {@link IReifiable}
+ * implementation.
*
* @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/AllTests.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -30,7 +30,7 @@
* Runs all tests.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class AllTests extends TestSuite {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-25 20:24:19 UTC (rev 41)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-26 09:51:39 UTC (rev 42)
@@ -60,6 +60,7 @@
assertFalse(TopicUtils.isRemovable(topic, true));
((IReifiable) assoc).setReifier(null);
assertTrue(TopicUtils.isRemovable(topic));
+ assertTrue(TopicUtils.isRemovable(topic, true));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-25 20:25:00
|
Revision: 41
http://tinytim.svn.sourceforge.net/tinytim/?rev=41&view=rev
Author: lheuer
Date: 2008-04-25 13:24:19 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
- More tests
- Added class which excutes all tests
Added Paths:
-----------
tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java
tinytim/trunk/src/test/java/org/tinytim/AllTests.java
tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java
Added: tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java 2008-04-25 20:24:19 UTC (rev 41)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import junit.framework.TestSuite;
+
+/**
+ * Base class for all TMAPI-related test cases.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev$ - $Date$
+ */
+public abstract class AbstractTMAPITestSuite extends TestSuite {
+
+ static {
+ System.setProperty("org.tmapi.core.TopicMapSystemFactory", "org.tinytim.TopicMapSystemFactoryImpl");
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/test/java/org/tinytim/AllTests.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/AllTests.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-04-25 20:24:19 UTC (rev 41)
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.tinytim.index.TestScopedIndex;
+import org.tinytim.index.TestTypeInstanceIndex;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Runs all tests.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class AllTests extends TestSuite {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(TestConstruct.class);
+ suite.addTestSuite(TestItemIdentifierConstraint.class);
+ suite.addTestSuite(TestReifiable.class);
+ suite.addTestSuite(TestScoped.class);
+ suite.addTestSuite(TestSignatureGenerator.class);
+ suite.addTest(TestTMAPICore.suite());
+ suite.addTest(TestTMAPIIndex.suite());
+ suite.addTestSuite(TestTopicMapMerge.class);
+ suite.addTestSuite(TestTopicMapSystemFactoryImpl.class);
+ suite.addTestSuite(TestTopicMerge.class);
+ suite.addTestSuite(TestTopicMergeDetection.class);
+ suite.addTestSuite(TestTopicUtils.class);
+ suite.addTestSuite(TestTyped.class);
+ suite.addTestSuite(TestScopedIndex.class);
+ suite.addTestSuite(TestTypeInstanceIndex.class);
+ return suite;
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/AllTests.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java 2008-04-25 20:24:19 UTC (rev 41)
@@ -0,0 +1,171 @@
+/*
+ * 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.index;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.tinytim.TinyTimTestCase;
+import org.tmapi.core.Association;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicName;
+
+/**
+ * Tests against {@link IScopedIndex}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestScopedIndex extends TinyTimTestCase {
+
+ private IScopedIndex _scopedIdx;
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ _scopedIdx = _tm.getIndexManager().getScopedIndex();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ _scopedIdx = null;
+ }
+
+ private void _updateIndex() {
+ if (!_scopedIdx.isAutoUpdated()) {
+ _scopedIdx.reindex();
+ }
+ }
+
+ public void testAssociation() throws Exception {
+ Topic theme = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getAssociationsByTheme(null).isEmpty());
+ assertTrue(_scopedIdx.getAssociationsByTheme(theme).isEmpty());
+ assertTrue(_scopedIdx.getAssociationThemes().isEmpty());
+ Association scoped = _tm.createAssociation();
+ assertEquals(0, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(1, _scopedIdx.getAssociationsByTheme(null).size());
+ assertTrue(_scopedIdx.getAssociationsByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getAssociationThemes().contains(theme));
+ scoped.addScopingTopic(theme);
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getAssociationsByTheme(null).size());
+ assertFalse(_scopedIdx.getAssociationsByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getAssociationThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getAssociationThemes().size());
+ assertTrue(_scopedIdx.getAssociationsByTheme(theme).contains(scoped));
+ assertTrue(_scopedIdx.getAssociationThemes().contains(theme));
+ scoped.remove();
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getAssociationsByTheme(null).size());
+ assertFalse(_scopedIdx.getAssociationsByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getAssociationThemes().contains(theme));
+ }
+
+ public void testOccurrence() throws Exception {
+ Topic theme = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getOccurrencesByTheme(null).isEmpty());
+ assertTrue(_scopedIdx.getOccurrencesByTheme(theme).isEmpty());
+ assertTrue(_scopedIdx.getOccurrenceThemes().isEmpty());
+ Occurrence scoped = _tm.createTopic().createOccurrence("tinyTiM", null, null);
+ assertEquals(0, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(1, _scopedIdx.getOccurrencesByTheme(null).size());
+ assertTrue(_scopedIdx.getOccurrencesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme));
+ scoped.addScopingTopic(theme);
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getOccurrencesByTheme(null).size());
+ assertFalse(_scopedIdx.getOccurrencesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getOccurrenceThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getOccurrenceThemes().size());
+ assertTrue(_scopedIdx.getOccurrencesByTheme(theme).contains(scoped));
+ assertTrue(_scopedIdx.getOccurrenceThemes().contains(theme));
+ scoped.remove();
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getOccurrencesByTheme(null).size());
+ assertFalse(_scopedIdx.getOccurrencesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme));
+ }
+
+ public void testName() throws Exception {
+ Topic theme = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getNamesByTheme(null).isEmpty());
+ assertTrue(_scopedIdx.getNamesByTheme(theme).isEmpty());
+ assertTrue(_scopedIdx.getNameThemes().isEmpty());
+ TopicName scoped = _tm.createTopic().createTopicName("tinyTiM", null, null);
+ assertEquals(0, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(1, _scopedIdx.getNamesByTheme(null).size());
+ assertTrue(_scopedIdx.getNamesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getNameThemes().contains(theme));
+ scoped.addScopingTopic(theme);
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getNamesByTheme(null).size());
+ assertFalse(_scopedIdx.getNamesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getNameThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getNameThemes().size());
+ assertTrue(_scopedIdx.getNamesByTheme(theme).contains(scoped));
+ assertTrue(_scopedIdx.getNameThemes().contains(theme));
+ scoped.remove();
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getNamesByTheme(null).size());
+ assertFalse(_scopedIdx.getNamesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getNameThemes().contains(theme));
+ }
+
+ public void testName2() throws Exception {
+ Topic theme = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getNamesByTheme(null).isEmpty());
+ assertTrue(_scopedIdx.getNamesByTheme(theme).isEmpty());
+ assertTrue(_scopedIdx.getNameThemes().isEmpty());
+ Collection<Topic> scope = Collections.singleton(theme);
+ TopicName scoped = _tm.createTopic().createTopicName("tinyTiM", null, scope);
+ assertEquals(1, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getNamesByTheme(null).size());
+ assertFalse(_scopedIdx.getNamesByTheme(null).contains(scoped));
+ assertFalse(_scopedIdx.getNameThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getNameThemes().size());
+ assertTrue(_scopedIdx.getNamesByTheme(theme).contains(scoped));
+ assertTrue(_scopedIdx.getNameThemes().contains(theme));
+ scoped.remove();
+ _updateIndex();
+ assertEquals(0, _scopedIdx.getNamesByTheme(null).size());
+ assertFalse(_scopedIdx.getNamesByTheme(null).contains(scoped));
+ assertEquals(0, _scopedIdx.getNamesByTheme(theme).size());
+ assertFalse(_scopedIdx.getNameThemes().contains(theme));
+ }
+
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-25 20:22:31
|
Revision: 40
http://tinytim.svn.sourceforge.net/tinytim/?rev=40&view=rev
Author: lheuer
Date: 2008-04-25 13:22:36 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Removed in favour of the AbstractTMAPITestSuite
Removed Paths:
-------------
tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java
Deleted: tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java 2008-04-25 20:20:01 UTC (rev 39)
+++ tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java 2008-04-25 20:22:36 UTC (rev 40)
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-import junit.framework.TestCase;
-
-/**
- * Base class for all TMAPI-related test cases.
- *
- * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev$ - $Date$
- */
-public class TMAPITestCase extends TestCase {
-
- static {
- System.setProperty("org.tmapi.core.TopicMapSystemFactory", "org.tinytim.TopicMapSystemFactoryImpl");
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-25 20:19:56
|
Revision: 39
http://tinytim.svn.sourceforge.net/tinytim/?rev=39&view=rev
Author: lheuer
Date: 2008-04-25 13:20:01 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
- Added Ant build files, changes, and readme
- License is added
Added Paths:
-----------
tinytim/trunk/CHANGES.txt
tinytim/trunk/LICENSE.txt
tinytim/trunk/README.txt
tinytim/trunk/build.properties
tinytim/trunk/build.xml
Added: tinytim/trunk/CHANGES.txt
===================================================================
--- tinytim/trunk/CHANGES.txt (rev 0)
+++ tinytim/trunk/CHANGES.txt 2008-04-25 20:20:01 UTC (rev 39)
@@ -0,0 +1,10 @@
+===========
+Changes Log
+===========
+
+
+1.5.0 alpha1 (25.04.2008)
+-------------------------
+- Initial 1.5.x release
+- New code base
+- Java 1.5
Added: tinytim/trunk/LICENSE.txt
===================================================================
--- tinytim/trunk/LICENSE.txt (rev 0)
+++ tinytim/trunk/LICENSE.txt 2008-04-25 20:20:01 UTC (rev 39)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Added: tinytim/trunk/README.txt
===================================================================
--- tinytim/trunk/README.txt (rev 0)
+++ tinytim/trunk/README.txt 2008-04-25 20:20:01 UTC (rev 39)
@@ -0,0 +1,29 @@
+====================================
+tinyTiM - The tiny Topic Maps engine
+====================================
+
+What is tinyTiM?
+----------------
+tinyTiM is a tiny Topic Maps engine which keeps topic maps in-memory.
+This Topic Maps engine is meant to be used together with the TMAPI interfaces,
+see <http://www.tmapi.org/> for details.
+
+
+Installation
+------------
+No real installation needed, simply put the ``tinytim-<VERSION>.jar`` and
+``tmapi-1_0SP1.jar`` into your classpath. That's all. :)
+Optionally, you can put the ``trove-<VERSION>.jar`` into your classpath which
+makes tinyTiM slightly more memory efficient and faster.
+
+
+Latest Version
+--------------
+Visit tinyTiM's homepage <http://sourceforge.net/projects/tinytim> for the
+latest version.
+
+
+License
+-------
+tinyTiM is licensed under the GNU Lesser General Public License (LGPL)
+Version 2.1, see LICENSE.txt for details.
Added: tinytim/trunk/build.properties
===================================================================
--- tinytim/trunk/build.properties (rev 0)
+++ tinytim/trunk/build.properties 2008-04-25 20:20:01 UTC (rev 39)
@@ -0,0 +1,4 @@
+version=1.5.0
+version_suffix=alpha1
+debug=off
+optimize=on
Added: tinytim/trunk/build.xml
===================================================================
--- tinytim/trunk/build.xml (rev 0)
+++ tinytim/trunk/build.xml 2008-04-25 20:20:01 UTC (rev 39)
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ====================================================================
+ This is tinyTiM, a tiny Topic Maps engine.
+
+ 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.
+ ====================================================================
+
+ $Rev:$ - $Date:$
+-->
+<project name="tinyTiM" default="jar" basedir=".">
+ <property file="build.properties"/>
+
+ <property name="dir.src" value="${basedir}/src/main/java"/>
+ <property name="dir.test" value="${basedir}/src/test/java"/>
+ <property name="dir.lib" value="${basedir}/lib"/>
+ <property name="dir.res" value="${basedir}/src/main/resources"/>
+
+ <property name="lib.junit" value="${dir.lib}/junit-4.4.jar"/>
+ <property name="lib.trove" value="${dir.lib}/trove-2.0.3.jar"/>
+ <property name="lib.tmapi" value="${dir.lib}/tmapi-1_0SP1.jar"/>
+ <property name="lib.tmapi.tests" value="${dir.lib}/tmapi-test-1_0SP1.jar"/>
+
+ <target name="help">
+ <echo message="--------------------"/>
+ <echo message="tinyTiM - Build file"/>
+ <echo message="--------------------"/>
+ <echo message=""/>
+ <echo message="Available targets:"/>
+ <echo message=""/>
+ <echo message=" jar Creates the jar"/>
+ <echo message=" release Creates the jar and a distributable file"/>
+ </target>
+
+ <target name="init">
+ <property name="dist.version" value="${version}${version_suffix}"/>
+ <property name="dist.name" value="tinytim-${dist.version}"/>
+
+ <property name="tinytim.jar" value="${dist.name}.jar"/>
+ <property name="tinytim.tar" value="${dist.name}.tar"/>
+ <property name="tinytim.tar.gz" value="${tinytim.tar}.gz"/>
+ <property name="tinytim.zip" value="${dist.name}.zip"/>
+
+ <property name="dir.build" value="${basedir}/build"/>
+ <property name="dir.dist.root" value="${dir.build}/dist"/>
+ <property name="dir.dist" value="${dir.dist.root}/${dist.name}"/>
+ <property name="dir.build.classes" value="${dir.build}/classes"/>
+ <property name="dir.build.tests" value="${dir.build}/tests"/>
+ <property name="dir.javadocs" value="${basedir}/javadocs"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Clean targets -->
+ <!-- =================================================================== -->
+ <target name="clean" depends="init">
+ <delete dir="${dir.build}"/>
+ <delete dir="${dir.javadocs}"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares the build directory -->
+ <!-- =================================================================== -->
+ <target name="prepare" depends="init">
+ <mkdir dir="${dir.build}"/>
+ <mkdir dir="${dir.build.classes}"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Tests -->
+ <!-- =================================================================== -->
+ <target name="test" depends="compile">
+ <mkdir dir="${dir.build.tests}"/>
+ <javac destdir="${dir.build.tests}"
+ debug="${debug}"
+ optimize="${optimize}"
+ target="1.5">
+ <classpath>
+ <pathelement location="${dir.build.classes}"/>
+ <pathelement location="${lib.junit}"/>
+ <pathelement location="${lib.tmapi}"/>
+ <pathelement location="${lib.tmapi.tests}"/>
+ <pathelement location="${lib.trove}"/>
+ </classpath>
+ <src path="${dir.test}"/>
+ </javac>
+ <junit printsummary="true" showoutput="false"
+ errorProperty="test.failed" failureProperty="test.failed">
+ <classpath>
+ <pathelement location="${dir.build.classes}"/>
+ <pathelement location="${dir.build.tests}"/>
+ <pathelement location="${lib.junit}"/>
+ <pathelement location="${lib.tmapi}"/>
+ <pathelement location="${lib.tmapi.tests}"/>
+ <pathelement location="${lib.trove}"/>
+ </classpath>
+ <formatter type="brief" usefile="false"/>
+ <batchtest fork="no" todir="${dir.build}">
+ <fileset dir="${dir.build.tests}/">
+ <include name="**/Test**.class"/>
+ <exclude name="**/Test*$**.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <fail message="Tests failed. Check test output." if="test.failed"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Compile source files -->
+ <!-- =================================================================== -->
+ <target name="compile" depends="clean, prepare">
+ <javac destdir="${dir.build.classes}"
+ debug="${debug}"
+ target="1.5">
+ <classpath>
+ <pathelement location="${lib.tmapi}"/>
+ <pathelement location="${lib.trove}"/>
+ </classpath>
+ <src path="${dir.src}"/>
+ </javac>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Creates the jar -->
+ <!-- =================================================================== -->
+ <target name="jar" depends="compile">
+ <jar destfile="${dir.build}/${tinytim.jar}">
+ <fileset dir="${dir.build.classes}">
+ <include name="**/*.*"/>
+ </fileset>
+ <fileset dir="${dir.res}">
+ <include name="**/*.*"/>
+ </fileset>
+ <manifest>
+ <attribute name="Implementation-Title" value="tinyTiM"/>
+ <attribute name="Implementation-Version" value="${dist.version}"/>
+ <attribute name="Implementation-URL" value="http://sourceforge.net/projects/tinytim"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares a distribution -->
+ <!-- =================================================================== -->
+ <target name="dist" depends="jar">
+ <mkdir dir="${dir.dist}"/>
+
+ <copy todir="${dir.dist}" file="${dir.build}/${tinytim.jar}"/>
+
+ <copy todir="${dir.dist}/src">
+ <fileset dir="${dir.src}"/>
+ </copy>
+ <copy todir="${dir.dist}/test">
+ <fileset dir="${dir.test}"/>
+ </copy>
+ <copy todir="${dir.dist}/lib">
+ <fileset dir="${dir.lib}"/>
+ </copy>
+
+ <copy todir="${dir.dist}" file="CHANGES.txt"/>
+ <copy todir="${dir.dist}" file="LICENSE.txt"/>
+ <copy todir="${dir.dist}" file="README.txt"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Creates the distribution files (.zip and .tar.gz) -->
+ <!-- -->
+ <!-- Won't create the distribution files if a test fails -->
+ <!-- =================================================================== -->
+ <target name="release" depends="jar, test, dist">
+ <tar destfile="${dir.dist.root}/${tinytim.tar}"
+ basedir="${dir.dist.root}"/>
+ <gzip src="${dir.dist.root}/${tinytim.tar}"
+ destfile="${dir.build}/${tinytim.tar.gz}" />
+ <delete file="${dir.dist.root}/${tinytim.tar}" />
+ <zip destfile="${dir.build}/${tinytim.zip}" basedir="${dir.dist.root}"/>
+ </target>
+</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-25 20:17:41
|
Revision: 38
http://tinytim.svn.sourceforge.net/tinytim/?rev=38&view=rev
Author: lheuer
Date: 2008-04-25 13:17:41 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Removed LICENSE (a replacement is in the trunk, same lic, other layout ;))
Removed Paths:
-------------
tinytim/trunk/src/LICENSE.txt
Deleted: tinytim/trunk/src/LICENSE.txt
===================================================================
--- tinytim/trunk/src/LICENSE.txt 2008-04-25 20:09:10 UTC (rev 37)
+++ tinytim/trunk/src/LICENSE.txt 2008-04-25 20:17:41 UTC (rev 38)
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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; either
- version 2.1 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-25 20:11:44
|
Revision: 37
http://tinytim.svn.sourceforge.net/tinytim/?rev=37&view=rev
Author: lheuer
Date: 2008-04-25 13:09:10 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
- Small modifications
- Event system simplified
- Bugs in ScopedIndex fixed
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/Construct.java
tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/Property.java
tinytim/trunk/src/main/java/org/tinytim/Scoped.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java
tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java
Modified: tinytim/trunk/src/main/java/org/tinytim/Construct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -125,18 +125,18 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
+ public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
- return (obj instanceof Construct) && _id.equals(((Construct) obj)._id);
+ return (obj instanceof Construct) && _id.equals(((Construct) obj).getObjectId());
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
- public int hashCode() {
+ public final int hashCode() {
return _id.hashCode();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -53,6 +53,11 @@
_register(tm);
}
+ /**
+ * Subscribes itself to the specified event publisher.
+ *
+ * @param publisher The publisher to subscribe to.
+ */
private void _subscribe(IEventPublisher publisher) {
IEventHandler handler = new TopicMapsConstructAddHandler();
publisher.subscribe(Event.ADD_TOPIC, handler);
@@ -84,32 +89,66 @@
publisher.subscribe(Event.SET_REIFIER, handler);
}
+ /**
+ * Registeres a Topic Maps construct and, if necessary, gives it an id.
+ *
+ * @param construct The construct to register.
+ */
private void _register(IConstruct construct) {
Construct c = (Construct) construct;
if (c._id == null) {
c._id = "" + _nextId++;
}
- if (!_id2Construct.containsKey(c)) {
+ if (!_id2Construct.containsKey(c._id)) {
_id2Construct.put(c._id, c);
}
}
+ /**
+ * Unregisteres the specified <code>construct</code>.
+ *
+ * @param construct The Topic Maps construct to unregister.
+ */
private void _unregister(IConstruct construct) {
_id2Construct.remove(((Construct) construct)._id);
}
+ /**
+ * Returns a Topic Maps construct by its identifier.
+ *
+ * @param id The identifier.
+ * @return A Topic Maps construct with the <code>id</code> or <code>null</code>.
+ */
public IConstruct getConstructById(String id) {
return _id2Construct.get(id);
}
+ /**
+ * Returns a topic by its subject identifier.
+ *
+ * @param sid The subject identifier.
+ * @return A topic with the <code>sid</code> or <code>null</code>.
+ */
public Topic getTopicBySubjectIdentifier(Locator sid) {
return _sid2Topic.get(sid);
}
+ /**
+ * Returns a topic by its subject locator.
+ *
+ * @param slo The subject locator.
+ * @return A topic with the <code>slo</code> or <code>null</code>.
+ */
public Topic getTopicBySubjectLocator(Locator slo) {
return _slo2Topic.get(slo);
}
+ /**
+ * Returns a Topic Maps construct by its item identifier.
+ *
+ * @param iid The item identifier.
+ * @return A Topic Maps construct with the <code>iid</code> or <code>null</code>.
+ */
public IConstruct getConstructByItemIdentifier(Locator iid) {
return _iid2Construct.get(iid);
}
@@ -199,8 +238,7 @@
private class RemoveSubjectIdentifierHandler implements IEventHandler {
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
- Locator slo = (Locator) oldValue;
- _sid2Topic.remove(slo);
+ _sid2Topic.remove(oldValue);
}
}
@@ -227,8 +265,7 @@
private class RemoveSubjectLocatorHandler implements IEventHandler {
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
- Locator slo = (Locator) oldValue;
- _slo2Topic.remove(slo);
+ _slo2Topic.remove(oldValue);
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -41,7 +41,7 @@
import org.tmapi.core.Variant;
/**
- * This class does provides functions to merge topic maps and topics.
+ * This class provides functions to merge topic maps and topics.
*
* This class relies on the implementation of tinyTiM, if the implementation
* changes, check the <code>==</code> comparisons.
Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -43,16 +43,16 @@
public static final String COLLECTION_FACTORY = "org.tinytim.CollectionFactory";
/**
- * Property which indicates if the "old" XTM 1.0 reification mechansm should
- * be used.
+ * Property which indicates if the "old" XTM 1.0 reification mechanism
+ * should be used.
*
* For backwards compatibilty and to support TMAPI 1.0 this property is
* set to "true" by default.
*
* Note, that this property is likely to be removed in a future version and
* that only the TMDM way of reification will be supported.
- * Maybe you'll be able to use {@link org.tinytim.ReificationUtils} to support
- * the XTM 1.0 reification mechanism.
+ * Maybe you'll be able to use {@link org.tinytim.ReificationUtils} to
+ * support the XTM 1.0 reification mechanism.
*/
public static final String XTM10_REIFICATION = "org.tinytim.XTM10Reification";
Modified: tinytim/trunk/src/main/java/org/tinytim/Scoped.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -27,8 +27,8 @@
import org.tmapi.core.Topic;
/**
- * Class that provides a "scope" property and sends events if that
- * scope property changes.
+ * Class that provides a "scope" property and sends events if that property
+ * changes.
*
* @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/TopicMapImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -422,16 +422,16 @@
switch (evt) {
case ADD_TOPIC: _topicAdd((TopicImpl)newValue); break;
case ADD_ASSOCIATION: _associationAdd((AssociationImpl)newValue); break;
- case ADD_ROLE: _roleAdd((AssociationRoleImpl)newValue); break;
- case ADD_OCCURRENCE: _occurrenceAdd((OccurrenceImpl)newValue); break;
case ADD_NAME: _nameAdd((TopicNameImpl)newValue); break;
- case ADD_VARIANT: _variantAdd((VariantImpl)newValue); break;
+ case ADD_ROLE:
+ case ADD_OCCURRENCE:
+ case ADD_VARIANT: _constructAdd((IConstruct)newValue); break;
case REMOVE_TOPIC: _topicRemove((TopicImpl) oldValue); break;
case REMOVE_ASSOCIATION: _associationRemove((AssociationImpl) oldValue); break;
- case REMOVE_ROLE: _roleRemove((AssociationRoleImpl) oldValue); break;
- case REMOVE_OCCURRENCE: _occurrenceRemove((OccurrenceImpl) oldValue); break;
- case REMOVE_NAME: _nameRemove((TopicNameImpl) oldValue); break;
- case REMOVE_VARIANT: _variantRemove((VariantImpl) oldValue); break;
+ case REMOVE_NAME: _nameRemove((TopicNameImpl)oldValue); break;
+ case REMOVE_ROLE:
+ case REMOVE_OCCURRENCE:
+ case REMOVE_VARIANT: _constructRemove((IConstruct) oldValue); break;
}
}
@@ -456,62 +456,18 @@
private void _associationAdd(AssociationImpl sender) {
_constructAdd(sender);
- _typedAdd(sender);
- _scopedAdd(sender);
for (AssociationRole role: sender.getAssociationRoles()) {
_handler.handleEvent(Event.ADD_ROLE, sender, null, role);
}
}
- private void _roleAdd(AssociationRoleImpl sender) {
- _constructAdd(sender);
- _typedAdd(sender);
- _handler.handleEvent(Event.SET_PLAYER, sender, null, sender.getPlayer());
- }
-
- private void _occurrenceAdd(OccurrenceImpl sender) {
- _constructAdd(sender);
- _typedAdd(sender);
- _scopedAdd(sender);
- if (sender.getValue() != null) {
- _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
- }
- else if (sender.getResource() != null) {
- _handler.handleEvent(Event.SET_LOCATOR, sender, null, sender.getResource());
- }
- }
-
private void _nameAdd(TopicNameImpl sender) {
_constructAdd(sender);
- _typedAdd(sender);
- _scopedAdd(sender);
- _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
for (Variant variant: sender.getVariants()) {
_handler.handleEvent(Event.ADD_VARIANT, sender, null, variant);
}
}
- private void _variantAdd(VariantImpl sender) {
- _constructAdd(sender);
- _scopedAdd(sender);
- if (sender.getValue() != null) {
- _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
- }
- else if (sender.getResource() != null) {
- _handler.handleEvent(Event.SET_LOCATOR, sender, null, sender.getResource());
- }
- }
-
- private void _typedAdd(ITyped typed) {
- _handler.handleEvent(Event.SET_TYPE, typed, null, typed.getType());
- }
-
- private void _scopedAdd(IScoped scoped) {
- for (Topic theme: scoped.getScope()) {
- _handler.handleEvent(Event.ADD_THEME, scoped, null, theme);
- }
- }
-
private void _constructAdd(IConstruct construct) {
for (Locator iid: construct.getItemIdentifiers()) {
_handler.handleEvent(Event.ADD_IID, construct, null, iid);
@@ -550,14 +506,6 @@
}
}
- private void _roleRemove(AssociationRoleImpl sender) {
- _constructRemove(sender);
- }
-
- private void _occurrenceRemove(OccurrenceImpl sender) {
- _constructRemove(sender);
- }
-
private void _nameRemove(TopicNameImpl sender) {
_constructRemove(sender);
for (Variant variant: sender.getVariants()) {
@@ -565,8 +513,5 @@
}
}
- private void _variantRemove(VariantImpl sender) {
- _constructRemove(sender);
- }
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -70,7 +70,7 @@
* otherwise.
*/
public static boolean isRemovable(Topic topic, boolean includeReified) {
- if (includeReified && ((TopicImpl) topic)._reified != null) {
+ if (includeReified && ((TopicImpl) topic).getReifiedConstruct() != null) {
return false;
}
if (!topic.getRolesPlayed().isEmpty()) {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -69,6 +69,11 @@
publisher.subscribe(Event.REMOVE_TOPIC, handler);
handler = new TypeHandler();
publisher.subscribe(Event.SET_TYPE, handler);
+ handler = new AddTypedHandler();
+ publisher.subscribe(Event.ADD_ASSOCIATION, handler);
+ publisher.subscribe(Event.ADD_ROLE, handler);
+ publisher.subscribe(Event.ADD_OCCURRENCE, handler);
+ publisher.subscribe(Event.ADD_NAME, handler);
handler = new RemoveTypedHandler();
publisher.subscribe(Event.REMOVE_ASSOCIATION, handler);
publisher.subscribe(Event.REMOVE_ROLE, handler);
@@ -192,14 +197,26 @@
}
}
- private boolean _unindex(List<ITyped> objects, Object obj) {
- if (objects == null) {
- return false;
+ private void _index(Map<Topic, List<ITyped>> type2Typed, Topic type, ITyped typed) {
+ List<ITyped> list = type2Typed.get(type);
+ if (list == null) {
+ list = new ArrayList<ITyped>();
+ type2Typed.put(type, list);
}
- objects.remove(obj);
- return objects.isEmpty();
+ list.add(typed);
}
+ private void _unindex(Map<Topic, List<ITyped>> type2Typed, Topic type, ITyped typed) {
+ List<ITyped> list = type2Typed.get(type);
+ if (list == null) {
+ return;
+ }
+ list.remove(typed);
+ if (list.isEmpty()) {
+ type2Typed.remove(type);
+ }
+ }
+
/* (non-Javadoc)
* @see org.tinytim.index.IIndex#close()
*/
@@ -308,64 +325,57 @@
}
}
- private final class TypeHandler implements IEventHandler {
+ private abstract class _EvtHandler implements IEventHandler {
@SuppressWarnings("unchecked")
- public void handleEvent(Event evt, IConstruct sender, Object oldValue,
- Object newValue) {
+ Map<Topic, List<ITyped>> getMap(ITyped typed) {
Map<Topic, ?> type2Typed = null;
- if (sender instanceof AssociationImpl) {
+ if (typed instanceof AssociationImpl) {
type2Typed = _type2Assocs;
}
- else if (sender instanceof AssociationRoleImpl) {
+ else if (typed instanceof AssociationRoleImpl) {
type2Typed = _type2Roles;
}
- else if (sender instanceof OccurrenceImpl) {
+ else if (typed instanceof OccurrenceImpl) {
type2Typed = _type2Occs;
}
- else if (sender instanceof TopicNameImpl) {
+ else if (typed instanceof TopicNameImpl) {
type2Typed = _type2Names;
}
- if (_unindex((List<ITyped>)type2Typed.get((Topic)oldValue), sender)) {
- type2Typed.remove(oldValue);
- }
- _index((Map<Topic, List<ITyped>>) type2Typed, (Topic) newValue, (ITyped) sender);
+ return (Map<Topic, List<ITyped>>) type2Typed;
}
+ }
- private void _index(Map<Topic, List<ITyped>> type2Typed,
- Topic newValue, ITyped sender) {
- List<ITyped> typedConstructs = type2Typed.get(newValue);
- if (typedConstructs == null) {
- typedConstructs = new ArrayList<ITyped>();
- type2Typed.put(newValue, typedConstructs);
- }
- typedConstructs.add(sender);
+ private final class TypeHandler extends _EvtHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ ITyped typed = (ITyped) sender;
+ Map<Topic, List<ITyped>> map = getMap(typed);
+ _unindex(map, (Topic) oldValue, typed);
+ _index(map, (Topic) newValue, typed);
}
}
- private final class RemoveTypedHandler implements IEventHandler {
+ private final class AddTypedHandler extends _EvtHandler {
@SuppressWarnings("unchecked")
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
- Map<Topic, ?> type2Typed = null;
- if (oldValue instanceof AssociationImpl) {
- type2Typed = _type2Assocs;
- }
- else if (oldValue instanceof AssociationRoleImpl) {
- type2Typed = _type2Roles;
- }
- else if (oldValue instanceof OccurrenceImpl) {
- type2Typed = _type2Occs;
- }
- else if (oldValue instanceof TopicNameImpl) {
- type2Typed = _type2Names;
- }
- Topic type = ((ITyped) oldValue).getType();
- if (_unindex((List<ITyped>)type2Typed.get(type), oldValue)) {
- type2Typed.remove(type);
- }
+ ITyped typed = (ITyped) newValue;
+ Map<Topic, List<ITyped>> map = getMap(typed);
+ _index(map, typed.getType(), typed);
}
}
+ private final class RemoveTypedHandler extends _EvtHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ ITyped typed = (ITyped) oldValue;
+ Map<Topic, List<ITyped>> map = getMap(typed);
+ _unindex(map, typed.getType(), typed);
+ }
+ }
+
void clear() {
_type2Topics.clear();
_type2Topics = null;
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -23,7 +23,6 @@
import org.tmapi.core.test.AllTMAPITests;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* Runs the TMAPI core test suite against tinyTiM.
@@ -31,15 +30,13 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-public class TestTMAPICore extends TMAPITestCase {
+public class TestTMAPICore extends AbstractTMAPITestSuite {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(AllTMAPITests.suite());
- return suite;
+ return AllTMAPITests.suite();
}
}
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -23,7 +23,6 @@
import org.tmapi.index.core.test.AllTMAPIIndexTests;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* Runs the TMAPI index test suite against tinyTiM.
@@ -31,15 +30,13 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-public class TestTMAPIIndex extends TMAPITestCase {
+public class TestTMAPIIndex extends AbstractTMAPITestSuite {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(AllTMAPIIndexTests.suite());
- return suite;
+ return AllTMAPIIndexTests.suite();
}
}
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java 2008-04-24 13:43:47 UTC (rev 36)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java 2008-04-25 20:09:10 UTC (rev 37)
@@ -28,7 +28,7 @@
* Tests merging of topic maps.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTopicMapMerge extends TinyTimTestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-24 13:43:51
|
Revision: 36
http://tinytim.svn.sourceforge.net/tinytim/?rev=36&view=rev
Author: lheuer
Date: 2008-04-24 06:43:47 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Initial import of the TopicMapMerge test. More tests needed, though
Added Paths:
-----------
tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java
Added: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java 2008-04-24 13:43:47 UTC (rev 36)
@@ -0,0 +1,157 @@
+/*
+ * 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;
+
+import org.tmapi.core.Locator;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+
+/**
+ * Tests merging of topic maps.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestTopicMapMerge extends TinyTimTestCase {
+
+ private static final String _TM2_BASE = "http://www.sf.net/projects/tinytim/tm-2";
+
+ private TopicMap _tm2;
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ _tm2 = _sys.createTopicMap(_TM2_BASE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ _tm2 = null;
+ }
+
+ /**
+ * Tests merging of topics by equal item identifiers.
+ */
+ public void testMergeSimple1() {
+ final String ref = "http://sf.net/projects/tinytim/loc";
+ Topic topicA = _tm.createTopic();
+ Locator iidA = _tm.createLocator(ref);
+ topicA.addSourceLocator(iidA);
+ Topic topicB = _tm2.createTopic();
+ Locator iidB = _tm2.createLocator(ref);
+ topicB.addSourceLocator(iidB);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(1, _tm2.getTopics().size());
+
+ _tm.mergeIn(_tm2);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(topicA, _tm.getObjectByItemIdentifier(iidA));
+ }
+
+ /**
+ * Tests merging of topics by equal subject identifiers.
+ */
+ public void testMergeSimple2() {
+ final String ref = "http://sf.net/projects/tinytim/loc";
+ Topic topicA = _tm.createTopic();
+ Locator sidA = _tm.createLocator(ref);
+ topicA.addSubjectIdentifier(sidA);
+ Topic topicB = _tm2.createTopic();
+ Locator sidB = _tm2.createLocator(ref);
+ topicB.addSubjectIdentifier(sidB);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(1, _tm2.getTopics().size());
+
+ _tm.mergeIn(_tm2);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(topicA, _tm.getTopicBySubjectIdentifier(sidA));
+ }
+
+ /**
+ * Tests merging of topics by equal subject locators.
+ */
+ public void testMergeSimple3() {
+ final String ref = "http://sf.net/projects/tinytim/loc";
+ Topic topicA = _tm.createTopic();
+ Locator sloA = _tm.createLocator(ref);
+ topicA.addSubjectLocator(sloA);
+ Topic topicB = _tm2.createTopic();
+ Locator sloB = _tm2.createLocator(ref);
+ topicB.addSubjectLocator(sloB);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(1, _tm2.getTopics().size());
+
+ _tm.mergeIn(_tm2);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(topicA, _tm.getTopicBySubjectLocator(sloA));
+ }
+
+ /**
+ * Tests merging of topics by existing topic with item identifier equals
+ * to a topic's subject identifier from the other map.
+ */
+ public void testMergeSimple4() {
+ final String ref = "http://sf.net/projects/tinytim/loc";
+ Topic topicA = _tm.createTopic();
+ Locator loc = _tm.createLocator(ref);
+ topicA.addSourceLocator(loc);
+ Topic topicB = _tm2.createTopic();
+ Locator locB = _tm2.createLocator(ref);
+ topicB.addSubjectIdentifier(locB);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(1, _tm2.getTopics().size());
+ assertEquals(topicA, _tm.getObjectByItemIdentifier(loc));
+ assertNull(_tm.getTopicBySubjectIdentifier(loc));
+ _tm.mergeIn(_tm2);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(topicA, _tm.getObjectByItemIdentifier(loc));
+ assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc));
+ }
+
+ /**
+ * Tests merging of topics by existing topic with subject identifier equals
+ * to a topic's item identifier from the other map.
+ */
+ public void testMergeSimple5() {
+ final String ref = "http://sf.net/projects/tinytim/loc";
+ Topic topicA = _tm.createTopic();
+ Locator loc = _tm.createLocator(ref);
+ topicA.addSubjectIdentifier(loc);
+ Topic topicB = _tm2.createTopic();
+ Locator locB = _tm2.createLocator(ref);
+ topicB.addSourceLocator(locB);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(1, _tm2.getTopics().size());
+ assertNull(_tm.getObjectByItemIdentifier(loc));
+ assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc));
+ _tm.mergeIn(_tm2);
+ assertEquals(1, _tm.getTopics().size());
+ assertEquals(topicA, _tm.getObjectByItemIdentifier(loc));
+ assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc));
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-24 12:13:25
|
Revision: 35
http://tinytim.svn.sourceforge.net/tinytim/?rev=35&view=rev
Author: lheuer
Date: 2008-04-24 05:04:37 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
- More tests
- CopyUtils finished (needs testing, though)
- Added getReifiedConstruct() to the TopicImpl to avoid direct access to that field in most cases
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
tinytim/trunk/src/main/java/org/tinytim/IMovable.java
tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java
tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory
tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java
tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
Modified: tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -22,12 +22,17 @@
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
import org.tmapi.core.Locator;
import org.tmapi.core.Occurrence;
import org.tmapi.core.Topic;
import org.tmapi.core.TopicMap;
import org.tmapi.core.TopicMapObject;
+import org.tmapi.core.TopicName;
+import org.tmapi.core.Variant;
/**
* This class provides methods to copy Topic Maps constructs from one
@@ -107,8 +112,17 @@
_copyTypes(topic, targetTopic, mergeMap);
_copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap);
}
+ _copyAssociations(source, target, mergeMap);
}
+ /**
+ * Copies the <code>topic</code> to the <code>target</code> topic map.
+ *
+ * @param topic The topic to copy.
+ * @param target The target topic map.
+ * @param mergeMap The map which holds the merge mappings.
+ * @return The newly created topic in the target topic map.
+ */
private static Topic _copyTopic(Topic topic, TopicMap target,
Map<Topic, Topic> mergeMap) {
Topic targetTopic = target.createTopic();
@@ -118,6 +132,13 @@
return targetTopic;
}
+ /**
+ * Copies the identities (item identifiers, subject identifiers and subject
+ * locators) from the <code>source/code> to the <code>targetTopic</code>.
+ *
+ * @param topic The topic to take the identities from.
+ * @param targetTopic The topic which gets the identities.
+ */
@SuppressWarnings("unchecked")
private static void _copyIdentities(Topic topic, Topic targetTopic) {
for(Iterator<Locator> iter = topic.getSubjectIdentifiers().iterator(); iter.hasNext();) {
@@ -129,6 +150,13 @@
_copyItemIdentifiers((IConstruct)topic, (IConstruct)targetTopic);
}
+ /**
+ * Copies the types from the <code>topic</code> to the <code>targetTopic</code>.
+ *
+ * @param topic The topic to take the types from.
+ * @param targetTopic The topic which receives the types.
+ * @param mergeMap The map which holds the merge mappings.
+ */
@SuppressWarnings("unchecked")
private static void _copyTypes(Topic topic, Topic targetTopic,
Map<Topic, Topic> mergeMap) {
@@ -142,20 +170,206 @@
}
}
+ /**
+ * Copies the occurrences and names from <code>topic</code> to the
+ * <code>targetTopic</code>.
+ *
+ * @param topic The topic to take the characteristics from.
+ * @param targetTopic The target topic which gets the charateristics.
+ * @param mergeMap The map which holds the merge mappings.
+ */
private static void _copyCharacteristics(Topic topic, TopicImpl targetTopic,
Map<Topic, Topic> mergeMap) {
Map<String, IReifiable> sigs = ((TopicMapImpl) targetTopic.getTopicMap()).getCollectionFactory().<String, IReifiable>createMap();
for (Occurrence occ: targetTopic.getOccurrences()) {
sigs.put(SignatureGenerator.generateSignature(occ), (IReifiable)occ);
}
+ IReifiable existing = null;
+ for (Occurrence occ: ((TopicImpl) topic).getOccurrences()) {
+ Occurrence targetOcc = targetTopic.createOccurrence((String)null, null, null);
+ _copyType((ITyped)occ, (ITyped)targetOcc, mergeMap);
+ _copyScope((IScoped)occ, (IScoped)targetOcc, mergeMap);
+ if (occ.getValue() != null) {
+ targetOcc.setValue(occ.getValue());
+ }
+ else if (occ.getResource() != null) {
+ targetOcc.setResource(occ.getResource());
+ }
+ existing = sigs.get(SignatureGenerator.generateSignature(targetOcc));
+ if (existing != null) {
+ MergeUtils.removeConstruct((IConstruct) targetOcc);
+ targetOcc = (Occurrence)existing;
+ }
+ _copyReifier((IReifiable) occ, (IReifiable) targetOcc, mergeMap);
+ _copyItemIdentifiers((IConstruct) occ, (IConstruct) targetOcc);
+ }
+ sigs.clear();
+ for (TopicName name: targetTopic.getTopicNames()) {
+ sigs.put(SignatureGenerator.generateSignature(name), (IReifiable)name);
+ }
+ for (TopicName name: ((TopicImpl) topic).getTopicNames()) {
+ TopicName targetName = targetTopic.createTopicName(name.getValue(), null);
+ _copyType((ITyped) name, (ITyped) targetName, mergeMap);
+ _copyScope((IScoped) name, (IScoped) targetName, mergeMap);
+ existing = sigs.get(SignatureGenerator.generateSignature(targetName));
+ if (existing != null) {
+ MergeUtils.removeConstruct((IConstruct)targetName);
+ targetName = (TopicName) existing;
+ }
+ _copyReifier((IReifiable) name, (IReifiable) targetName, mergeMap);
+ _copyItemIdentifiers((IConstruct) name, (IConstruct) targetName);
+ _copyVariants(name, targetName, mergeMap);
+ }
}
+ /**
+ * Copies the variants from <code>source</code> to the <code>target</code>.
+ *
+ * @param source The name to take the variants from.
+ * @param target The target name which receives the variants.
+ * @param mergeMap The map which holds the merge mappings.
+ */
+ private static void _copyVariants(TopicName source, TopicName target,
+ Map<Topic, Topic> mergeMap) {
+ Map<String, Variant> sigs = ((TopicMapImpl) target.getTopicMap()).getCollectionFactory().createMap();
+ for (Variant variant: ((TopicNameImpl) target).getVariants()) {
+ sigs.put(SignatureGenerator.generateSignature(variant), variant);
+ }
+ Variant existing = null;
+ for (Variant variant: ((TopicNameImpl) source).getVariants()) {
+ Variant targetVar = target.createVariant((String) null, null);
+ _copyScope((IScoped) variant, (IScoped) targetVar, mergeMap);
+ if (variant.getValue() != null) {
+ targetVar.setValue(variant.getValue());
+ }
+ else if (variant.getResource() != null) {
+ targetVar.setResource(variant.getResource());
+ }
+ existing = sigs.get(SignatureGenerator.generateSignature(targetVar));
+ if (existing != null) {
+ MergeUtils.removeConstruct((IConstruct) targetVar);
+ targetVar = existing;
+ }
+ _copyReifier((IReifiable) variant, (IReifiable) targetVar, mergeMap);
+ _copyItemIdentifiers((IConstruct) variant, (IConstruct) targetVar);
+ }
+ }
+
+ /**
+ * Copies the reifier of <code>source</code> (if any) to the <code>target</code>.
+ *
+ * @param source The reifiable Topic Maps construct to take the reifier from.
+ * @param target The target Topic Maps construct.
+ * @param mergeMap The map which holds the merge mappings.
+ */
+ private static void _copyReifier(IReifiable source, IReifiable target,
+ Map<Topic, Topic> mergeMap) {
+ Topic sourceReifier = source.getReifier();
+ if (sourceReifier == null) {
+ return;
+ }
+ Topic reifier = mergeMap.containsKey(sourceReifier) ? mergeMap.get(sourceReifier)
+ : _copyTopic(sourceReifier, target.getTopicMap(), mergeMap);
+ target.setReifier(reifier);
+ }
+
+ /**
+ * Copies the type of the <code>source</code> (if any) to the <code>target</code>.
+ *
+ * @param source The Topic Maps construct to take the type from.
+ * @param target The Topic Maps construct which receives the type.
+ * @param mergeMap The map which holds the merge mappings.
+ */
+ private static void _copyType(ITyped source, ITyped target,
+ Map<Topic, Topic> mergeMap) {
+ Topic sourceType = source.getType();
+ if (sourceType == null) {
+ return;
+ }
+ Topic type = mergeMap.containsKey(sourceType) ? mergeMap.get(sourceType)
+ : _copyTopic(sourceType, target.getTopicMap(), mergeMap);
+ target.setType(type);
+ }
+
+ /**
+ * Copies all themes from the <code>source</code> scoped Topic Maps construct
+ * to the <code>target</code>.
+ *
+ * @param source The source to take the scope from.
+ * @param target The target which receives the scope.
+ * @param mergeMap The map which holds the merge mappings.
+ */
+ private static void _copyScope(IScoped source, IScoped target,
+ Map<Topic, Topic> mergeMap) {
+ Topic theme = null;
+ for (Topic sourceTheme: source.getScope()) {
+ theme = mergeMap.containsKey(sourceTheme) ? mergeMap.get(sourceTheme)
+ : _copyTopic(sourceTheme, target.getTopicMap(), mergeMap);
+ target.addTheme(theme);
+ }
+ }
+
+ /**
+ * Copies the item identifiers from <code>source</code> to <code>target</code>.
+ *
+ * @param source The source Topic Maps construct.
+ * @param target The target Topic Maps construct.
+ */
private static void _copyItemIdentifiers(IConstruct source, IConstruct target) {
for(Locator iid: source.getItemIdentifiers()) {
target.addSourceLocator(iid);
}
}
+ /**
+ * Copies the associations from the <code>source</code> topic map to the
+ * <code>target</code> topic map.
+ *
+ * @param source The topic map to take the associations from.
+ * @param target The topic map which receives the associations.
+ * @param mergeMap The map which holds the merge mappings.
+ */
+ @SuppressWarnings("unchecked")
+ private static void _copyAssociations(TopicMapImpl source,
+ TopicMapImpl target, Map<Topic, Topic> mergeMap) {
+ Set<Association> assocs = target.getAssociations();
+ Map<String, Association> sigs = target.getCollectionFactory().createMap(assocs.size());
+ for (Association assoc: assocs) {
+ sigs.put(SignatureGenerator.generateSignature(assoc), assoc);
+ }
+ Association existing = null;
+ for (Association assoc: source.getAssociations()) {
+ Association targetAssoc = target.createAssociation();
+ _copyType((ITyped) assoc, (ITyped) targetAssoc, mergeMap);
+ _copyScope((IScoped) assoc, (IScoped) targetAssoc, mergeMap);
+ for (Iterator<AssociationRole> iter = assoc.getAssociationRoles().iterator(); iter.hasNext();) {
+ AssociationRole role = iter.next();
+ AssociationRole targetRole = targetAssoc.createAssociationRole(role.getPlayer(), role.getType());
+ _copyItemIdentifiers((IConstruct)role, (IConstruct)targetRole);
+ _copyReifier((IReifiable) role, (IReifiable) targetRole, mergeMap);
+ }
+ existing = sigs.get(SignatureGenerator.generateSignature(targetAssoc));
+ if (existing != null) {
+ MergeUtils.moveRoleCharacteristics(targetAssoc, existing);
+ MergeUtils.removeConstruct((IConstruct) targetAssoc);
+ targetAssoc = existing;
+ }
+ _copyReifier((IReifiable) assoc, (IReifiable) targetAssoc, mergeMap);
+ _copyItemIdentifiers((IConstruct) assoc, (IConstruct) targetAssoc);
+ }
+ }
+
+ /**
+ * Adds a mapping from <code>source</code> to <code>target</code> into the
+ * <code>mergeMap</code>.
+ *
+ * If <code>source</code> has already a mapping to another target topic,
+ * <code>target</code> is merged with the existing target topic.
+ *
+ * @param source The source topic.
+ * @param target The target topic.
+ * @param mergeMap The map which holds the merge mappings.
+ */
private static void _addMerge(Topic source, Topic target, Map<Topic, Topic> mergeMap) {
Topic prevTarget = mergeMap.get(source);
if (prevTarget != null) {
Modified: tinytim/trunk/src/main/java/org/tinytim/IMovable.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IMovable.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/IMovable.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -27,7 +27,7 @@
* This interface 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:$
+ * @version $Rev$ - $Date$
*/
interface IMovable<T /* extends IConstruct */> {
Modified: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -95,10 +95,10 @@
if (source.getTopicMap() != target.getTopicMap()) {
throw new IllegalArgumentException("The topics must belong to the same topic map");
}
- IReifiable sourceReifiable = source._reified;
- if (sourceReifiable != null && target._reified != null) {
+ IReifiable sourceReifiable = source.getReifiedConstruct();
+ if (sourceReifiable != null && target.getReifiedConstruct() != null) {
// This should be enforced by the model
- assert sourceReifiable != target._reified;
+ assert sourceReifiable != target.getReifiedConstruct();
throw new ModelConstraintException(target, "The topics cannot be merged. They reify different Topic Maps constructs");
}
_moveItemIdentifiers((IConstruct)source, (IConstruct)target);
@@ -160,7 +160,7 @@
existing = sigs.get(SignatureGenerator.generateSignature(parent));
if (existing != null) {
handleExistingConstruct((IReifiable)parent, existing);
- _moveRoleCharacteristics(parent, (Association)existing);
+ moveRoleCharacteristics(parent, (Association)existing);
removeConstruct((IConstruct)parent);
}
}
@@ -191,7 +191,7 @@
* @param target The association which takes the role characteristics.
*/
@SuppressWarnings("unchecked")
- private static void _moveRoleCharacteristics(Association source, Association target) {
+ static void moveRoleCharacteristics(Association source, Association target) {
Map<String, AssociationRole> sigs = ((TopicMapImpl) target.getTopicMap()).getCollectionFactory().<String, AssociationRole>createMap();
for (AssociationRole role: ((AssociationImpl)target).getAssociationRoles()) {
sigs.put(SignatureGenerator.generateSignature(role), role);
@@ -304,6 +304,14 @@
}
}
+ /**
+ * Replaces the <code>oldTheme</code> with the <code>newTheme</code> in each
+ * scoped Topic Maps construct.
+ *
+ * @param scopedCollection A collection of scoped Topic Maps constructs.
+ * @param oldTheme The old theme.
+ * @param newTheme The theme that is used as replacement for <code>oldTheme</code>.
+ */
private static void _replaceTopicAsTheme(Collection<? extends IScoped> scopedCollection,
Topic oldTheme, Topic newTheme) {
for (IScoped scoped: scopedCollection) {
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -242,6 +242,17 @@
name._parent = null;
}
+ /**
+ * Returns the Topic Maps construct that is reified by
+ * this topic.
+ *
+ * @return The reified construct or <code>null</code> if this
+ * topic reifies nothing.
+ */
+ public IReifiable getReifiedConstruct() {
+ return _reified;
+ }
+
/* (non-Javadoc)
* @see org.tmapi.core.Topic#getReified()
*/
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -49,7 +49,7 @@
* {@link org.tmapi.core.TopicMap} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class TopicMapImpl extends Construct implements TopicMap,
IReifiable, IEventHandler, IEventPublisher {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -197,7 +197,6 @@
private final class AddScopedHandler extends _EvtHandler {
@SuppressWarnings("unchecked")
- @Override
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
ScopedObject scoped = (ScopedObject) newValue;
@@ -228,7 +227,6 @@
private final class RemoveScopedHandler extends _EvtHandler {
@SuppressWarnings("unchecked")
- @Override
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
ScopedObject scoped = (ScopedObject) oldValue;
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -64,7 +64,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.OccurrencesIndex#getOccurrenceTypes()
*/
- @Override
public Collection<Topic> getOccurrenceTypes() {
return _getTypeInstanceIndex().getOccurrenceTypes();
}
@@ -72,7 +71,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.OccurrencesIndex#getOccurrencesByType(org.tmapi.core.Topic)
*/
- @Override
public Collection<OccurrenceImpl> getOccurrencesByType(Topic type) {
return _getTypeInstanceIndex().getOccurrences(type);
}
@@ -80,7 +78,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.OccurrencesIndex#getOccurrencesByResource(org.tmapi.core.Locator)
*/
- @Override
public Collection<Occurrence> getOccurrencesByResource(Locator value) {
List<Occurrence> occs = _loc2Occs.get(value);
return occs == null ? Collections.<Occurrence>emptySet()
@@ -90,7 +87,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.OccurrencesIndex#getOccurrencesByValue(java.lang.String)
*/
- @Override
public Collection<Occurrence> getOccurrencesByValue(String value) {
List<Occurrence> occs = _value2Occs.get(value);
return occs == null ? Collections.<Occurrence>emptySet()
@@ -100,7 +96,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.Index#getFlags()
*/
- @Override
public IndexFlags getFlags() throws TMAPIIndexException {
return IndexFlagsImpl.NOT_AUTOUPDATED;
}
@@ -109,7 +104,6 @@
* @see org.tmapi.index.Index#reindex()
*/
@SuppressWarnings("unchecked")
- @Override
public void reindex() throws TMAPIIndexException {
_value2Occs.clear();
_loc2Occs.clear();
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -61,7 +61,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.TopicNamesIndex#getTopicNameTypes()
*/
- @Override
public Collection<Topic> getTopicNameTypes() {
return _getTypeInstanceIndex().getNameTypes();
}
@@ -69,7 +68,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByType(org.tmapi.core.Topic)
*/
- @Override
public Collection<TopicNameImpl> getTopicNamesByType(Topic type) {
return _getTypeInstanceIndex().getNames(type);
}
@@ -77,7 +75,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByValue(java.lang.String)
*/
- @Override
public Collection<TopicName> getTopicNamesByValue(String value) {
List<TopicName> names = _value2Names.get(value);
return names == null ? Collections.<TopicName>emptySet()
@@ -87,7 +84,6 @@
/* (non-Javadoc)
* @see org.tmapi.index.Index#getFlags()
*/
- @Override
public IndexFlags getFlags() throws TMAPIIndexException {
return IndexFlagsImpl.NOT_AUTOUPDATED;
}
@@ -96,7 +92,6 @@
* @see org.tmapi.index.Index#reindex()
*/
@SuppressWarnings("unchecked")
- @Override
public void reindex() throws TMAPIIndexException {
_value2Names.clear();
for (Topic topic: _weakTopicMap.get().getTopics()) {
Modified: tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory
===================================================================
--- tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory 2008-04-24 12:04:37 UTC (rev 35)
@@ -1 +1 @@
-org.tinytim.TopicMapSystemFactoryImpl
\ No newline at end of file
+org.tinytim.TopicMapSystemFactoryImpl
Modified: tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -36,7 +36,7 @@
* Tests if the TMDM item identifier constraint is respected.
*
* @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 TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -130,19 +130,19 @@
assertEquals(0, reifier.getReified().size());
reifiable.setReifier(reifier);
assertEquals(reifier, reifiable.getReifier());
- assertEquals(reifiable, reifier._reified);
+ assertEquals(reifiable, reifier.getReifiedConstruct());
assertEquals(1, reifier.getReified().size());
assertTrue(reifier.getReified().contains(reifiable));
reifiable.setReifier(null);
assertNull(reifiable.getReifier());
- assertNull(reifier._reified);
+ assertNull(reifier.getReifiedConstruct());
assertEquals(0, reifier.getReified().size());
TopicImpl reifier2 = (TopicImpl) _tm.createTopic();
IReifiable assoc = (IReifiable) _tm.createAssociation();
assoc.setReifier(reifier2);
assertEquals(reifier2, assoc.getReifier());
- assertEquals(assoc, reifier2._reified);
+ assertEquals(assoc, reifier2.getReifiedConstruct());
try {
reifiable.setReifier(reifier2);
fail("Expected an exception. The reifier reifies another Topic Maps construct");
@@ -152,12 +152,12 @@
}
assoc.setReifier(null);
assertNull(assoc.getReifier());
- assertNull(reifier2._reified);
+ assertNull(reifier2.getReifiedConstruct());
reifiable.setReifier(reifier);
assertEquals(reifier, reifiable.getReifier());
- assertEquals(reifiable, reifier._reified);
+ assertEquals(reifiable, reifier.getReifiedConstruct());
reifiable.setReifier(reifier2);
assertEquals(reifier2, reifiable.getReifier());
- assertEquals(reifiable, reifier2._reified);
+ assertEquals(reifiable, reifier2.getReifiedConstruct());
}
}
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-23 17:55:30 UTC (rev 34)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-24 12:04:37 UTC (rev 35)
@@ -154,6 +154,86 @@
}
/**
+ * Tests if merging detects duplicates and that the reifier is kept.
+ */
+ public void testDuplicateDetectionReifier() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Topic reifier = _tm.createTopic();
+ TopicName name1 = topic1.createTopicName("tinyTiM", null, null);
+ TopicName name2 = topic2.createTopicName("tinyTiM", null, null);
+ assertEquals(3, _tm.getTopics().size());
+ ((IReifiable) name1).setReifier(reifier);
+ assertEquals(reifier, name1.getReifier());
+ assertEquals(1, topic1.getTopicNames().size());
+ assertTrue(topic1.getTopicNames().contains(name1));
+ assertEquals(1, topic2.getTopicNames().size());
+ assertTrue(topic2.getTopicNames().contains(name2));
+ topic1.mergeIn(topic2);
+ assertEquals(2, _tm.getTopics().size());
+ assertEquals(1, topic1.getTopicNames().size());
+ TopicName name = (TopicName) topic1.getTopicNames().iterator().next();
+ assertEquals(reifier, name.getReifier());
+ }
+
+ /**
+ * Tests if merging detects duplicates and merges the reifiers of the
+ * duplicates.
+ */
+ public void testDuplicateDetectionReifierMerge() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Topic reifier1 = _tm.createTopic();
+ Topic reifier2 = _tm.createTopic();
+ TopicName name1 = topic1.createTopicName("tinyTiM", null, null);
+ TopicName name2 = topic2.createTopicName("tinyTiM", null, null);
+ assertEquals(4, _tm.getTopics().size());
+ ((IReifiable) name1).setReifier(reifier1);
+ ((IReifiable) name2).setReifier(reifier2);
+ assertEquals(reifier1, name1.getReifier());
+ assertEquals(reifier2, name2.getReifier());
+ assertEquals(1, topic1.getTopicNames().size());
+ assertTrue(topic1.getTopicNames().contains(name1));
+ assertEquals(1, topic2.getTopicNames().size());
+ assertTrue(topic2.getTopicNames().contains(name2));
+ topic1.mergeIn(topic2);
+ assertEquals(2, _tm.getTopics().size());
+ assertEquals(1, topic1.getTopicNames().size());
+ TopicName name = (TopicName) topic1.getTopicNames().iterator().next();
+ Topic reifier = null;
+ for (Topic topic: _tm.getTopics()) {
+ if (!topic.equals(topic1)) {
+ reifier = topic;
+ }
+ }
+ assertEquals(reifier, name.getReifier());
+ }
+
+ /**
+ * Tests if merging detects duplicate associations.
+ */
+ public void testDuplicateSuppressionAssociation() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Topic roleType = _tm.createTopic();
+ Association assoc1 = _tm.createAssociation();
+ Association assoc2 = _tm.createAssociation();
+ AssociationRole role1 = assoc1.createAssociationRole(topic1, roleType);
+ AssociationRole role2 = assoc2.createAssociationRole(topic2, roleType);
+ assertEquals(3, _tm.getTopics().size());
+ assertEquals(2, _tm.getAssociations().size());
+ assertTrue(topic1.getRolesPlayed().contains(role1));
+ assertTrue(topic2.getRolesPlayed().contains(role2));
+ assertEquals(1, topic1.getRolesPlayed().size());
+ assertEquals(1, topic2.getRolesPlayed().size());
+ topic1.mergeIn(topic2);
+ assertEquals(2, _tm.getTopics().size());
+ assertEquals(1, _tm.getAssociations().size());
+ AssociationRole role = (AssociationRole) topic1.getRolesPlayed().iterator().next();
+ assertEquals(roleType, role.getType());
+ }
+
+ /**
* Tests if merging detects duplicate names.
*/
public void testDuplicateSuppressionName() {
@@ -196,6 +276,34 @@
}
/**
+ * Tests if merging detects duplicate names and sets the item
+ * identifier to the union of both names.
+ */
+ public void testDuplicateSuppressionNameMoveItemIdentifiers() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Locator iid1 = _tm.createLocator("http://example.org/iid-1");
+ Locator iid2 = _tm.createLocator("http://example.org/iid-2");
+ TopicName name1 = topic1.createTopicName("tinyTiM", null, null);
+ TopicName name2 = topic2.createTopicName("tinyTiM", null, null);
+ name1.addSourceLocator(iid1);
+ name2.addSourceLocator(iid2);
+ assertTrue(name1.getSourceLocators().contains(iid1));
+ assertTrue(name2.getSourceLocators().contains(iid2));
+ assertEquals(1, topic1.getTopicNames().size());
+ assertTrue(topic1.getTopicNames().contains(name1));
+ assertEquals(1, topic2.getTopicNames().size());
+ assertTrue(topic2.getTopicNames().contains(name2));
+ topic1.mergeIn(topic2);
+ assertEquals(1, topic1.getTopicNames().size());
+ TopicName name = (TopicName) topic1.getTopicNames().iterator().next();
+ assertEquals(2, name.getSourceLocators().size());
+ assertTrue(name.getSourceLocators().contains(iid1));
+ assertTrue(name.getSourceLocators().contains(iid2));
+ assertEquals("tinyTiM", name.getValue());
+ }
+
+ /**
* Tests if merging detects duplicate occurrences.
*/
public void testDuplicateSuppressionOccurrence() {
@@ -214,10 +322,10 @@
}
/**
- * Tests if merging detects duplicate occurrences and moves the
- * item identifiers.
+ * Tests if merging detects duplicate occurrences and sets the item
+ * identifier to the union of both occurrences.
*/
- public void testDuplicateSuppressionOccurrenceItemIdentifiers() {
+ public void testDuplicateSuppressionOccurrenceMoveItemIdentifiers() {
Topic topic1 = _tm.createTopic();
Topic topic2 = _tm.createTopic();
Locator iid1 = _tm.createLocator("http://example.org/iid-1");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-23 17:55:59
|
Revision: 34
http://tinytim.svn.sourceforge.net/tinytim/?rev=34&view=rev
Author: lheuer
Date: 2008-04-23 10:55:30 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
- JavaDocs
- More topic merge tests
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicMapObjectsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -33,7 +33,7 @@
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
abstract class AbstractTMAPIIndex implements Index {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -31,10 +31,10 @@
import org.tmapi.index.core.AssociationRolesIndex;
/**
+ * Implementation of the {@link org.tmapi.index.core.AssociationRolesIndex};
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class AssociationRolesIndexImpl extends AbstractTMAPIIndex implements
AssociationRolesIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -34,7 +34,7 @@
* Implementation of the {@link org.tmapi.index.core.AssociationsIndex};
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class AssociationsIndexImpl extends AbstractTMAPIIndex implements
AssociationsIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -42,7 +42,7 @@
* Implementation of the {@link org.tmapi.index.core.OccurrencesIndex}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class OccurrencesIndexImpl extends AbstractTMAPIIndex implements
OccurrencesIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -39,7 +39,7 @@
* {@link org.tmapi.index.core.ScopedObjectsIndex} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class ScopedObjectsIndexImpl extends AbstractTMAPIIndex implements
ScopedObjectsIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicMapObjectsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicMapObjectsIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicMapObjectsIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -29,10 +29,10 @@
import org.tmapi.index.core.TopicMapObjectsIndex;
/**
+ * Implementation of the {@link org.tmapi.index.core.TopicMapObjectsIndex};
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TopicMapObjectsIndexImpl extends AbstractTMAPIIndex implements TopicMapObjectsIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -38,10 +38,10 @@
import org.tmapi.index.core.TopicNamesIndex;
/**
+ * Implementation of the {@link org.tmapi.index.core.TopicNamesIndex};
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TopicNamesIndexImpl extends AbstractTMAPIIndex implements
TopicNamesIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicsIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicsIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -35,7 +35,7 @@
* {@link org.tmapi.index.core.TopicsIndex} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TopicsIndexImpl extends AbstractTMAPIIndex implements TopicsIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -41,7 +41,7 @@
* Implementation of the {@link org.tmapi.index.core.VariantsIndex}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class VariantsIndexImpl extends AbstractTMAPIIndex implements
VariantsIndex {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-23 16:24:46 UTC (rev 33)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-23 17:55:30 UTC (rev 34)
@@ -26,6 +26,7 @@
import org.tmapi.core.AssociationRole;
import org.tmapi.core.Locator;
import org.tmapi.core.ModelConstraintException;
+import org.tmapi.core.Occurrence;
import org.tmapi.core.Topic;
import org.tmapi.core.TopicName;
import org.tmapi.core.Variant;
@@ -193,4 +194,51 @@
Variant tmpVar = (Variant) tmpName.getVariants().iterator().next();
assertEquals("tiny", tmpVar.getValue());
}
+
+ /**
+ * Tests if merging detects duplicate occurrences.
+ */
+ public void testDuplicateSuppressionOccurrence() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Occurrence occ1 = topic1.createOccurrence("tinyTiM", null, null);
+ Occurrence occ2 = topic2.createOccurrence("tinyTiM", null, null);
+ Occurrence occ3 = topic2.createOccurrence("tiny Topic Maps engine", null, null);
+ assertEquals(1, topic1.getOccurrences().size());
+ assertTrue(topic1.getOccurrences().contains(occ1));
+ assertEquals(2, topic2.getOccurrences().size());
+ assertTrue(topic2.getOccurrences().contains(occ2));
+ assertTrue(topic2.getOccurrences().contains(occ3));
+ topic1.mergeIn(topic2);
+ assertEquals(2, topic1.getOccurrences().size());
+ }
+
+ /**
+ * Tests if merging detects duplicate occurrences and moves the
+ * item identifiers.
+ */
+ public void testDuplicateSuppressionOccurrenceItemIdentifiers() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Locator iid1 = _tm.createLocator("http://example.org/iid-1");
+ Locator iid2 = _tm.createLocator("http://example.org/iid-2");
+ Occurrence occ1 = topic1.createOccurrence("tinyTiM", null, null);
+ occ1.addSourceLocator(iid1);
+ assertTrue(occ1.getSourceLocators().contains(iid1));
+ Occurrence occ2 = topic2.createOccurrence("tinyTiM", null, null);
+ occ2.addSourceLocator(iid2);
+ assertTrue(occ2.getSourceLocators().contains(iid2));
+ assertEquals(1, topic1.getOccurrences().size());
+ assertTrue(topic1.getOccurrences().contains(occ1));
+ assertEquals(1, topic2.getOccurrences().size());
+ assertTrue(topic2.getOccurrences().contains(occ2));
+ topic1.mergeIn(topic2);
+ assertEquals(1, topic1.getOccurrences().size());
+ Occurrence occ = (Occurrence) topic1.getOccurrences().iterator().next();
+ assertEquals(2, occ.getSourceLocators().size());
+ assertTrue(occ.getSourceLocators().contains(iid1));
+ assertTrue(occ.getSourceLocators().contains(iid2));
+ assertEquals("tinyTiM", occ.getValue());
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-23 16:24:41
|
Revision: 33
http://tinytim.svn.sourceforge.net/tinytim/?rev=33&view=rev
Author: lheuer
Date: 2008-04-23 09:24:46 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Deleted unused IndexFlagsImpl; was moved the tmapi subpackage
Removed Paths:
-------------
tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java
Deleted: tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-23 16:15:39 UTC (rev 32)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-23 16:24:46 UTC (rev 33)
@@ -1,58 +0,0 @@
-/*
- * 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.index;
-
-import org.tmapi.index.IndexFlags;
-
-/**
- * Immutable {@link org.tmapi.index.IndexFlags} implementation.
- *
- * Use {@link #AUTOUPDATED} or {@link #NOT_AUTOUPDATED}
- *
- * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev$ - $Date$
- */
-final class IndexFlagsImpl implements IndexFlags {
-
- /**
- * Indicates that the index is auto updated.
- */
- public static IndexFlags AUTOUPDATED = new IndexFlagsImpl(true);
-
- /**
- * Indicates that the index is NOT auto updated.
- */
- public static IndexFlags NOT_AUTOUPDATED = new IndexFlagsImpl(false);
-
- private final boolean _autoUpdated;
-
- private IndexFlagsImpl(boolean autoUpdated) {
- _autoUpdated = autoUpdated;
- }
-
- /* (non-Javadoc)
- * @see org.tmapi.index.IndexFlags#isAutoUpdated()
- */
- public boolean isAutoUpdated() {
- return _autoUpdated;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-23 16:15:43
|
Revision: 32
http://tinytim.svn.sourceforge.net/tinytim/?rev=32&view=rev
Author: lheuer
Date: 2008-04-23 09:15:39 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
- Added missing TopcMapImpl
- Added all TMAPI indexes
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/Construct.java
tinytim/trunk/src/main/java/org/tinytim/Property.java
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/IndexFlagsImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicMapObjectsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicsIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java
Modified: tinytim/trunk/src/main/java/org/tinytim/Construct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -173,9 +173,10 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder(super.toString());
+ sb.append(" ").append(_id);
sb.append(" iids=[");
- for (Locator sid: getItemIdentifiers()) {
- sb.append(sid);
+ for (Locator iid: getItemIdentifiers()) {
+ sb.append(iid);
sb.append(',');
}
sb.append("]");
Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -48,6 +48,11 @@
*
* For backwards compatibilty and to support TMAPI 1.0 this property is
* set to "true" by default.
+ *
+ * Note, that this property is likely to be removed in a future version and
+ * that only the TMDM way of reification will be supported.
+ * Maybe you'll be able to use {@link org.tinytim.ReificationUtils} to support
+ * the XTM 1.0 reification mechanism.
*/
public static final String XTM10_REIFICATION = "org.tinytim.XTM10Reification";
Added: tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -0,0 +1,572 @@
+/*
+ * 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;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.tinytim.index.IndexManager;
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.HelperObjectConfigurationException;
+import org.tmapi.core.HelperObjectInstantiationException;
+import org.tmapi.core.Locator;
+import org.tmapi.core.MergeException;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.TMAPIException;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.TopicMapObject;
+import org.tmapi.core.TopicMapSystem;
+import org.tmapi.core.TopicName;
+import org.tmapi.core.UnsupportedHelperObjectException;
+import org.tmapi.core.Variant;
+
+/**
+ * {@link org.tmapi.core.TopicMap} implementation.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class TopicMapImpl extends Construct implements TopicMap,
+ IReifiable, IEventHandler, IEventPublisher {
+
+ // Fixed set of helper objects, against the TMAPI 1.0 spec., though
+ private static final Map<String, String> _SUPPORTED_HELPER_OBJECTS = new HashMap<String, String>();
+
+ static {
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.TopicMapObjectsIndex.class.getName(),
+ org.tinytim.index.tmapi.TopicMapObjectsIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.ScopedObjectsIndex.class.getName(),
+ org.tinytim.index.tmapi.ScopedObjectsIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.TopicsIndex.class.getName(),
+ org.tinytim.index.tmapi.TopicsIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.AssociationsIndex.class.getName(),
+ org.tinytim.index.tmapi.AssociationsIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.AssociationRolesIndex.class.getName(),
+ org.tinytim.index.tmapi.AssociationRolesIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.OccurrencesIndex.class.getName(),
+ org.tinytim.index.tmapi.OccurrencesIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.TopicNamesIndex.class.getName(),
+ org.tinytim.index.tmapi.TopicNamesIndexImpl.class.getName());
+ _SUPPORTED_HELPER_OBJECTS.put(org.tmapi.index.core.VariantsIndex.class.getName(),
+ org.tinytim.index.tmapi.VariantsIndexImpl.class.getName());
+ };
+
+ private IdentityManager _identityManager;
+ private IndexManager _indexManager;
+ private ICollectionFactory _collectionFactory;
+ private Locator _locator;
+ private Set<Topic> _topics;
+ private Set<Association> _assocs;
+ private TopicMapSystemImpl _sys;
+ private Topic _reifier;
+ private Map<Event, List<IEventHandler>> _evtHandlers;
+ private EventMultiplier _eventMultiplier;
+ private Map<String, Object> _helperObjects;
+ boolean _oldReification;
+
+ TopicMapImpl(TopicMapSystemImpl sys, Locator locator) {
+ super(null);
+ super._tm = this;
+ _sys = sys;
+ _locator = locator;
+ _collectionFactory = _sys.getCollectionFactory();
+ _topics = _collectionFactory.createSet(100);
+ _assocs = _collectionFactory.createSet(100);
+ _evtHandlers = _collectionFactory.createMap();
+ _helperObjects = _collectionFactory.createMap();
+ _identityManager = new IdentityManager(this);
+ _indexManager = new IndexManager(this, _collectionFactory);
+ _eventMultiplier = new EventMultiplier(this);
+ _oldReification = "true".equalsIgnoreCase(sys.getProperty(Property.XTM10_REIFICATION));
+ }
+
+ ICollectionFactory getCollectionFactory() {
+ return _collectionFactory;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getTopicMapSystem()
+ */
+ public TopicMapSystem getTopicMapSystem() {
+ return _sys;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getBaseLocator()
+ */
+ public Locator getBaseLocator() {
+ return _locator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.Construct#getTopicMap()
+ */
+ @Override
+ public TopicMap getTopicMap() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#createLocator(java.lang.String)
+ */
+ public Locator createLocator(String reference) {
+ return new IRI(reference);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#createLocator(java.lang.String, java.lang.String)
+ */
+ public Locator createLocator(String reference, String notation) {
+ assert "URI".equals(notation);
+ return createLocator(reference);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getTopics()
+ */
+ public Set<Topic> getTopics() {
+ return Collections.unmodifiableSet(_topics);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#createTopic()
+ */
+ public Topic createTopic() {
+ TopicImpl topic = new TopicImpl(this);
+ addTopic(topic);
+ return topic;
+ }
+
+ /**
+ * Adds a topic to the topics property.
+ *
+ * @param topic The topic to add.
+ */
+ void addTopic(TopicImpl topic) {
+ if (topic._parent == this) {
+ return;
+ }
+ _fireEvent(Event.ADD_TOPIC, null, topic);
+ topic._parent = this;
+ _topics.add(topic);
+ }
+
+ /**
+ * Removes a topic from the topics property.
+ *
+ * Caution: This method does not check if a topic has any dependencies;
+ * this method never reports that a topic is not removable. This
+ * method should only be used if a topic should be detached.
+ *
+ * @param topic The topic to remove.
+ */
+ void removeTopic(TopicImpl topic) {
+ if (topic._parent != this) {
+ return;
+ }
+ assert topic._parent == null;
+ _fireEvent(Event.REMOVE_TOPIC, topic, null);
+ _topics.remove(topic);
+ topic._parent = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getAssociations()
+ */
+ public Set<Association> getAssociations() {
+ return Collections.unmodifiableSet(_assocs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#createAssociation()
+ */
+ public Association createAssociation() {
+ AssociationImpl assoc = new AssociationImpl(this);
+ addAssociation(assoc);
+ return assoc;
+ }
+
+ void addAssociation(AssociationImpl assoc) {
+ if (assoc._parent == this) {
+ return;
+ }
+ _fireEvent(Event.ADD_ASSOCIATION, null, assoc);
+ assoc._parent = this;
+ _assocs.add(assoc);
+ }
+
+ void removeAssociation(AssociationImpl assoc) {
+ if (assoc._parent != this) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_ASSOCIATION, assoc, null);
+ for (AssociationRole role: assoc.getAssociationRoles()) {
+ TopicImpl player = (TopicImpl) role.getPlayer();
+ if (player != null) {
+ player.removeRolePlayed(role);
+ }
+ }
+ _assocs.remove(assoc);
+ assoc._parent = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getObjectById(java.lang.String)
+ */
+ public TopicMapObject getObjectById(String id) {
+ return _identityManager.getConstructById(id);
+ }
+
+ /**
+ * Returns a toic by its subject identifier.
+ *
+ * @param subjectIdentifier The subject identifier.
+ * @return A topic or <code>null</code> if no topic with the specified
+ * subject identifier exists.
+ */
+ public Topic getTopicBySubjectIdentifier(Locator subjectIdentifier) {
+ return _identityManager.getTopicBySubjectIdentifier(subjectIdentifier);
+ }
+
+ /**
+ * Returns a toic by its subject locator.
+ *
+ * @param subjectLocator The subject locator.
+ * @return A topic or <code>null</code> if no topic with the specified
+ * subject locator exists.
+ */
+ public Topic getTopicBySubjectLocator(Locator subjectLocator) {
+ return _identityManager.getTopicBySubjectLocator(subjectLocator);
+ }
+
+ /**
+ * Returns a Topic Maps construct by its item identifier.
+ *
+ * @param itemIdentifier The item identifier.
+ * @return A Topic Maps construct or <code>null</code> if no topic with
+ * the specified item identifier exists.
+ */
+ public TopicMapObject getObjectByItemIdentifier(Locator itemIdentifier) {
+ return _identityManager.getConstructByItemIdentifier(itemIdentifier);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getReifier()
+ */
+ public Topic getReifier() {
+ if (_oldReification) {
+ return ReificationUtils.getReifier(this);
+ }
+ return _reifier;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic)
+ */
+ public void setReifier(Topic reifier) {
+ if (_reifier == reifier) {
+ return;
+ }
+ _fireEvent(Event.SET_REIFIER, _reifier, reifier);
+ if (_reifier != null) {
+ ((TopicImpl) _reifier)._reified = null;
+ }
+ _reifier = reifier;
+ if (reifier != null) {
+ ((TopicImpl) reifier)._reified = this;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#mergeIn(org.tmapi.core.TopicMap)
+ */
+ public void mergeIn(TopicMap other) throws MergeException {
+ MergeUtils.merge(other, this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#close()
+ */
+ public void close() {
+ try {
+ remove();
+ }
+ catch (TMAPIException ex) {
+ // noop.
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#remove()
+ */
+ public void remove() throws TMAPIException {
+ _sys.removeTopicMap(this);
+ _sys = null;
+ _locator = null;
+ _topics = null;
+ _assocs = null;
+ _indexManager.close();
+ _indexManager = null;
+ _identityManager.close();
+ _identityManager = null;
+ _eventMultiplier = null;
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#getHelperObject(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getHelperObject(Class implInterface)
+ throws UnsupportedHelperObjectException,
+ HelperObjectInstantiationException,
+ HelperObjectConfigurationException {
+ String interfaceName = implInterface.getName();
+ Object instance = _helperObjects.get(interfaceName);
+ if (instance == null) {
+ String className = _SUPPORTED_HELPER_OBJECTS.get(interfaceName);
+ if (className == null) {
+ throw new UnsupportedHelperObjectException("A helper object of class " + implInterface.getName() + " is not supported");
+ }
+ try {
+ Class klass = Class.forName(className);
+ // Caution: Bypassing the configure step etc since we know
+ // that this constructor exists.
+ Constructor constr = klass.getConstructor(TopicMapImpl.class, ICollectionFactory.class);
+ instance = constr.newInstance(this, this._collectionFactory);
+ _helperObjects.put(interfaceName, instance);
+ }
+ catch (Exception ex) {
+ throw new HelperObjectInstantiationException("");
+ }
+ }
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IEventHandler#handleEvent(org.tinytim.Event, org.tinytim.IConstruct, java.lang.Object, java.lang.Object)
+ */
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue) {
+ if (!_evtHandlers.containsKey(evt)) {
+ _eventMultiplier.handleEvent(evt, sender, oldValue, newValue);
+ return;
+ }
+ List<IEventHandler> handlers = _evtHandlers.get(evt);
+ for (IEventHandler handler: handlers) {
+ handler.handleEvent(evt, sender, oldValue, newValue);
+ }
+ _eventMultiplier.handleEvent(evt, sender, oldValue, newValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IEventPublisher#subscribe(org.tinytim.Event, org.tinytim.IEventHandler)
+ */
+ public void subscribe(Event event, IEventHandler handler) {
+ List<IEventHandler> handlers = _evtHandlers.get(event);
+ if (handlers == null) {
+ handlers = new ArrayList<IEventHandler>();
+ _evtHandlers.put(event, handlers);
+ }
+ handlers.add(handler);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IEventPublisher#unsubscribe(org.tinytim.Event, org.tinytim.IEventHandler)
+ */
+ public void unsubscribe(Event event, IEventHandler handler) {
+ List<IEventHandler> handlers = _evtHandlers.get(event);
+ if (handlers != null) {
+ handlers.remove(handler);
+ }
+ }
+
+ public IndexManager getIndexManager() {
+ return _indexManager;
+ }
+
+ private static class EventMultiplier implements IEventHandler {
+
+ private TopicMapImpl _handler;
+
+ EventMultiplier(TopicMapImpl handler) {
+ _handler = handler;
+ }
+
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ switch (evt) {
+ case ADD_TOPIC: _topicAdd((TopicImpl)newValue); break;
+ case ADD_ASSOCIATION: _associationAdd((AssociationImpl)newValue); break;
+ case ADD_ROLE: _roleAdd((AssociationRoleImpl)newValue); break;
+ case ADD_OCCURRENCE: _occurrenceAdd((OccurrenceImpl)newValue); break;
+ case ADD_NAME: _nameAdd((TopicNameImpl)newValue); break;
+ case ADD_VARIANT: _variantAdd((VariantImpl)newValue); break;
+ case REMOVE_TOPIC: _topicRemove((TopicImpl) oldValue); break;
+ case REMOVE_ASSOCIATION: _associationRemove((AssociationImpl) oldValue); break;
+ case REMOVE_ROLE: _roleRemove((AssociationRoleImpl) oldValue); break;
+ case REMOVE_OCCURRENCE: _occurrenceRemove((OccurrenceImpl) oldValue); break;
+ case REMOVE_NAME: _nameRemove((TopicNameImpl) oldValue); break;
+ case REMOVE_VARIANT: _variantRemove((VariantImpl) oldValue); break;
+ }
+ }
+
+ private void _topicAdd(TopicImpl sender) {
+ _constructAdd(sender);
+ for (Locator sid: sender.getSubjectIdentifiers()) {
+ _handler.handleEvent(Event.ADD_SID, sender, null, sid);
+ }
+ for (Locator slo: sender.getSubjectLocators()) {
+ _handler.handleEvent(Event.ADD_SLO, sender, null, slo);
+ }
+ for (Topic type: sender.getTypes()) {
+ _handler.handleEvent(Event.ADD_TYPE, sender, null, type);
+ }
+ for (Occurrence occ: sender.getOccurrences()) {
+ _handler.handleEvent(Event.ADD_OCCURRENCE, sender, null, occ);
+ }
+ for (TopicName name: sender.getTopicNames()) {
+ _handler.handleEvent(Event.ADD_NAME, sender, null, name);
+ }
+ }
+
+ private void _associationAdd(AssociationImpl sender) {
+ _constructAdd(sender);
+ _typedAdd(sender);
+ _scopedAdd(sender);
+ for (AssociationRole role: sender.getAssociationRoles()) {
+ _handler.handleEvent(Event.ADD_ROLE, sender, null, role);
+ }
+ }
+
+ private void _roleAdd(AssociationRoleImpl sender) {
+ _constructAdd(sender);
+ _typedAdd(sender);
+ _handler.handleEvent(Event.SET_PLAYER, sender, null, sender.getPlayer());
+ }
+
+ private void _occurrenceAdd(OccurrenceImpl sender) {
+ _constructAdd(sender);
+ _typedAdd(sender);
+ _scopedAdd(sender);
+ if (sender.getValue() != null) {
+ _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
+ }
+ else if (sender.getResource() != null) {
+ _handler.handleEvent(Event.SET_LOCATOR, sender, null, sender.getResource());
+ }
+ }
+
+ private void _nameAdd(TopicNameImpl sender) {
+ _constructAdd(sender);
+ _typedAdd(sender);
+ _scopedAdd(sender);
+ _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
+ for (Variant variant: sender.getVariants()) {
+ _handler.handleEvent(Event.ADD_VARIANT, sender, null, variant);
+ }
+ }
+
+ private void _variantAdd(VariantImpl sender) {
+ _constructAdd(sender);
+ _scopedAdd(sender);
+ if (sender.getValue() != null) {
+ _handler.handleEvent(Event.SET_VALUE, sender, null, sender.getValue());
+ }
+ else if (sender.getResource() != null) {
+ _handler.handleEvent(Event.SET_LOCATOR, sender, null, sender.getResource());
+ }
+ }
+
+ private void _typedAdd(ITyped typed) {
+ _handler.handleEvent(Event.SET_TYPE, typed, null, typed.getType());
+ }
+
+ private void _scopedAdd(IScoped scoped) {
+ for (Topic theme: scoped.getScope()) {
+ _handler.handleEvent(Event.ADD_THEME, scoped, null, theme);
+ }
+ }
+
+ private void _constructAdd(IConstruct construct) {
+ for (Locator iid: construct.getItemIdentifiers()) {
+ _handler.handleEvent(Event.ADD_IID, construct, null, iid);
+ }
+ }
+
+ private void _constructRemove(IConstruct sender) {
+ for (Locator iid: sender.getItemIdentifiers()) {
+ _handler.handleEvent(Event.REMOVE_IID, sender, iid, null);
+ }
+ }
+
+ private void _topicRemove(TopicImpl sender) {
+ _constructRemove(sender);
+ for (Locator sid: sender.getSubjectIdentifiers()) {
+ _handler.handleEvent(Event.REMOVE_SID, sender, sid, null);
+ }
+ for (Locator slo: sender.getSubjectLocators()) {
+ _handler.handleEvent(Event.REMOVE_SLO, sender, slo, null);
+ }
+ for (Topic type: sender.getTypes()) {
+ _handler.handleEvent(Event.REMOVE_TYPE, sender, type, null);
+ }
+ for (Occurrence occ: sender.getOccurrences()) {
+ _handler.handleEvent(Event.REMOVE_OCCURRENCE, sender, occ, null);
+ }
+ for (TopicName name: sender.getTopicNames()) {
+ _handler.handleEvent(Event.REMOVE_NAME, sender, name, null);
+ }
+ }
+
+ private void _associationRemove(AssociationImpl sender) {
+ _constructRemove(sender);
+ for (AssociationRole role: sender.getAssociationRoles()) {
+ _handler.handleEvent(Event.REMOVE_ROLE, sender, role, null);
+ }
+ }
+
+ private void _roleRemove(AssociationRoleImpl sender) {
+ _constructRemove(sender);
+ }
+
+ private void _occurrenceRemove(OccurrenceImpl sender) {
+ _constructRemove(sender);
+ }
+
+ private void _nameRemove(TopicNameImpl sender) {
+ _constructRemove(sender);
+ for (Variant variant: sender.getVariants()) {
+ _handler.handleEvent(Event.REMOVE_VARIANT, sender, variant, null);
+ }
+ }
+
+ private void _variantRemove(VariantImpl sender) {
+ _constructRemove(sender);
+ }
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -44,7 +44,7 @@
* a typed Topic Maps construct, and is not not used as theme of a scoped
* Topic Maps construct.
*
- * This functions returns the same result as
+ * This function returns the same result as
* <code>isRemovable(topic, false)</code>.
*
* @param topic The topic to check.
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -50,6 +50,8 @@
*/
public Collection<AssociationImpl> getAssociationsByTheme(Topic theme);
+ public Collection<Topic> getAssociationThemes();
+
/**
* Returns all occurrences which use the specified topic as theme.
*
@@ -59,6 +61,8 @@
*/
public Collection<OccurrenceImpl> getOccurrencesByTheme(Topic theme);
+ public Collection<Topic> getOccurrenceThemes();
+
/**
* Returns all names which use the specified topic as theme.
*
@@ -68,6 +72,8 @@
*/
public Collection<TopicNameImpl> getNamesByTheme(Topic theme);
+ public Collection<Topic> getNameThemes();
+
/**
* Returns all variants which use the specified topic as theme.
*
@@ -76,4 +82,6 @@
* in their [scope] property.
*/
public Collection<VariantImpl> getVariantsByTheme(Topic theme);
+
+ public Collection<Topic> getVariantThemes();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -50,9 +50,21 @@
* <code>null</code> all untyped topics will be returned.
* @return A (maybe empty) collection of topic instances.
*/
- public Collection<Topic> getTopics(Topic... type);
+ public Collection<Topic> getTopics(Topic type);
/**
+ * Returns these topics which have the one of the specified
+ * <code>types</code> iff <code>matchAll</code> is false. Iff
+ * <code>matchAll</code> is <code>true</code>, these topics will be returned
+ * which have all the specified <code>types</code>.
+ *
+ * @param types The types to match
+ * @param matchAll Indicates if a topic must have all types to be part of the result.
+ * @return A (maybe empty) collection of topic instances.
+ */
+ public Collection<Topic> getTopics(Topic[] types, boolean matchAll);
+
+ /**
* Returns the associations that are typed by the {@link org.tmapi.core.Topic}
* <code>type</code>.
*
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -39,8 +40,8 @@
import org.tmapi.core.Topic;
/**
+ * {@link IScopedIndex} implementation.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
@@ -58,6 +59,16 @@
_theme2Variants = collFactory.createMap();
publisher.subscribe(Event.ADD_THEME, new AddThemeHandler());
publisher.subscribe(Event.REMOVE_THEME, new RemoveThemeHandler());
+ IEventHandler handler = new AddScopedHandler();
+ publisher.subscribe(Event.ADD_ASSOCIATION, handler);
+ publisher.subscribe(Event.ADD_OCCURRENCE, handler);
+ publisher.subscribe(Event.ADD_NAME, handler);
+ publisher.subscribe(Event.ADD_VARIANT, handler);
+ handler = new RemoveScopedHandler();
+ publisher.subscribe(Event.REMOVE_ASSOCIATION, handler);
+ publisher.subscribe(Event.REMOVE_OCCURRENCE, handler);
+ publisher.subscribe(Event.REMOVE_NAME, handler);
+ publisher.subscribe(Event.REMOVE_VARIANT, handler);
}
/* (non-Javadoc)
@@ -70,6 +81,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.index.IScopedIndex#getAssociationThemes()
+ */
+ public Collection<Topic> getAssociationThemes() {
+ List<Topic> themes = new ArrayList<Topic>(_theme2Assocs.keySet());
+ themes.remove(null);
+ return themes;
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.index.IScopedIndex#getOccurrencesByTheme(org.tmapi.core.Topic)
*/
public Collection<OccurrenceImpl> getOccurrencesByTheme(Topic theme) {
@@ -79,6 +99,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.index.IScopedIndex#getOccurrenceThemes()
+ */
+ public Collection<Topic> getOccurrenceThemes() {
+ List<Topic> themes = new ArrayList<Topic>(_theme2Occs.keySet());
+ themes.remove(null);
+ return themes;
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.index.IScopedIndex#getNamesByTheme(org.tmapi.core.Topic)
*/
public Collection<TopicNameImpl> getNamesByTheme(Topic theme) {
@@ -88,6 +117,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.index.IScopedIndex#getNameThemes()
+ */
+ public Collection<Topic> getNameThemes() {
+ List<Topic> themes = new ArrayList<Topic>(_theme2Names.keySet());
+ themes.remove(null);
+ return themes;
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.index.IScopedIndex#getVariantsByTheme(org.tmapi.core.Topic)
*/
public Collection<VariantImpl> getVariantsByTheme(Topic theme) {
@@ -97,6 +135,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.index.IScopedIndex#getVariantThemes()
+ */
+ public Collection<Topic> getVariantThemes() {
+ List<Topic> themes = new ArrayList<Topic>(_theme2Variants.keySet());
+ themes.remove(null);
+ return themes;
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.index.IIndex#close()
*/
public void close() {
@@ -128,56 +175,126 @@
_theme2Variants = null;
}
- private final class AddThemeHandler implements IEventHandler {
+ private abstract class _EvtHandler implements IEventHandler {
@SuppressWarnings("unchecked")
- public void handleEvent(Event evt, IConstruct sender, Object oldValue,
- Object newValue) {
+ Map<Topic, List<ScopedObject>> getMap(ScopedObject scoped) {
Map<Topic, ?> theme2Scoped = null;
- if (sender instanceof AssociationImpl) {
+ if (scoped instanceof AssociationImpl) {
theme2Scoped = _theme2Assocs;
}
- else if (sender instanceof OccurrenceImpl) {
+ else if (scoped instanceof OccurrenceImpl) {
theme2Scoped = _theme2Occs;
}
- else if (sender instanceof TopicNameImpl) {
+ else if (scoped instanceof TopicNameImpl) {
theme2Scoped = _theme2Names;
}
- else if (sender instanceof VariantImpl) {
+ else if (scoped instanceof VariantImpl) {
theme2Scoped = _theme2Variants;
}
- _index((Map<Topic, List<ScopedObject>>) theme2Scoped, (Topic) newValue, (ScopedObject) sender);
+ return (Map<Topic, List<ScopedObject>>) theme2Scoped;
}
+ }
- private void _index(Map<Topic, List<ScopedObject>> theme2Scoped,
- Topic newValue, ScopedObject sender) {
- List<ScopedObject> scopedConstructs = theme2Scoped.get(newValue);
- if (scopedConstructs == null) {
- scopedConstructs = new ArrayList<ScopedObject>();
- theme2Scoped.put(newValue, scopedConstructs);
+ private final class AddScopedHandler extends _EvtHandler {
+ @SuppressWarnings("unchecked")
+ @Override
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ ScopedObject scoped = (ScopedObject) newValue;
+ Map<Topic, List<ScopedObject>> map = getMap(scoped);
+ List<ScopedObject> list = null;
+ if (scoped.getScope().isEmpty()) {
+ list = map.get(null);
+ if (list == null) {
+ list = new ArrayList<ScopedObject>();
+ map.put(null, list);
+ }
+ list.add(scoped);
}
- scopedConstructs.add(sender);
+ else {
+ for (Iterator<Topic> iter = scoped.getScope().iterator(); iter.hasNext();) {
+ Topic theme = iter.next();
+ list = map.get(theme);
+ if (list == null) {
+ list = new ArrayList<ScopedObject>();
+ map.put(theme, list);
+ }
+ list.add(scoped);
+ }
+ }
}
+
}
- private final class RemoveThemeHandler implements IEventHandler {
+ private final class RemoveScopedHandler extends _EvtHandler {
+ @SuppressWarnings("unchecked")
+ @Override
public void handleEvent(Event evt, IConstruct sender, Object oldValue,
Object newValue) {
- List<?> scoped = null;
- if (sender instanceof AssociationImpl) {
- scoped = _theme2Assocs.get(oldValue);
+ ScopedObject scoped = (ScopedObject) oldValue;
+ Map<Topic, List<ScopedObject>> map = getMap(scoped);
+ List<ScopedObject> list = null;
+ if (scoped.getScope().isEmpty()) {
+ list = map.get(null);
+ if (list != null) {
+ list.remove(scoped);
+ }
}
- else if (sender instanceof OccurrenceImpl) {
- scoped = _theme2Occs.get(oldValue);
+ else {
+ for (Iterator<Topic> iter = scoped.getScope().iterator(); iter.hasNext();) {
+ Topic theme = iter.next();
+ list = map.get(theme);
+ if (list != null) {
+ list.remove(scoped);
+ if (list.isEmpty()) {
+ map.remove(theme);
+ }
+ }
+ }
}
- else if (sender instanceof TopicNameImpl) {
- scoped = _theme2Names.get(oldValue);
+ }
+
+ }
+
+ private final class AddThemeHandler extends _EvtHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ ScopedObject scoped = (ScopedObject) sender;
+ Map<Topic, List<ScopedObject>> map = getMap(scoped);
+ List<ScopedObject> list = map.get(newValue);
+ if (list == null) {
+ list = new ArrayList<ScopedObject>();
+ map.put((Topic)newValue, list);
}
- else if (sender instanceof VariantImpl) {
- scoped = _theme2Variants.get(oldValue);
+ list.add(scoped);
+ list = map.get(null);
+ if (list != null) {
+ list.remove(scoped);
}
- if (scoped != null) {
- scoped.remove(sender);
+ }
+ }
+
+ private final class RemoveThemeHandler extends _EvtHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ ScopedObject scoped = (ScopedObject) sender;
+ Map<Topic, List<ScopedObject>> map = getMap(scoped);
+ List<ScopedObject> list = map.get(oldValue);
+ if (list != null) {
+ list.remove(scoped);
+ if (list.isEmpty()) {
+ map.remove(oldValue);
+ }
}
+ if (scoped.getScope().size() == 1) {
+ list = map.get(null);
+ if (list == null) {
+ list = new ArrayList<ScopedObject>();
+ map.put(null, list);
+ }
+ list.add(scoped);
+ }
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-23 14:35:03 UTC (rev 31)
+++ tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -48,7 +48,7 @@
*/
public class TypeInstanceIndex implements ITypeInstanceIndex {
- private Map<Topic, List<Topic>> _type2Topics;
+ private Map<Topic, Set<Topic>> _type2Topics;
private Map<Topic, List<AssociationImpl>> _type2Assocs;
private Map<Topic, List<AssociationRoleImpl>> _type2Roles;
private Map<Topic, List<OccurrenceImpl>> _type2Occs;
@@ -63,15 +63,26 @@
IEventHandler handler = new TopicTypeHandler();
publisher.subscribe(Event.ADD_TYPE, handler);
publisher.subscribe(Event.REMOVE_TYPE, handler);
+ handler = new AddTopicHandler();
+ publisher.subscribe(Event.ADD_TOPIC, handler);
+ handler = new RemoveTopicHandler();
+ publisher.subscribe(Event.REMOVE_TOPIC, handler);
handler = new TypeHandler();
publisher.subscribe(Event.SET_TYPE, handler);
+ handler = new RemoveTypedHandler();
+ publisher.subscribe(Event.REMOVE_ASSOCIATION, handler);
+ publisher.subscribe(Event.REMOVE_ROLE, handler);
+ publisher.subscribe(Event.REMOVE_OCCURRENCE, handler);
+ publisher.subscribe(Event.REMOVE_NAME, handler);
}
/* (non-Javadoc)
* @see org.tinytim.index.ITypeInstanceIndex#getAssociationTypes()
*/
public Collection<Topic> getAssociationTypes() {
- return Collections.unmodifiableSet(_type2Assocs.keySet());
+ List<Topic> topics = new ArrayList<Topic>(_type2Assocs.keySet());
+ topics.remove(null);
+ return topics;
}
/* (non-Javadoc)
@@ -87,7 +98,9 @@
* @see org.tinytim.index.ITypeInstanceIndex#getRoleTypes()
*/
public Collection<Topic> getRoleTypes() {
- return Collections.unmodifiableSet(_type2Roles.keySet());
+ List<Topic> topics = new ArrayList<Topic>(_type2Roles.keySet());
+ topics.remove(null);
+ return topics;
}
/* (non-Javadoc)
@@ -103,7 +116,9 @@
* @see org.tinytim.index.ITypeInstanceIndex#getOccurrenceTypes()
*/
public Collection<Topic> getOccurrenceTypes() {
- return Collections.unmodifiableSet(_type2Occs.keySet());
+ List<Topic> topics = new ArrayList<Topic>(_type2Occs.keySet());
+ topics.remove(null);
+ return topics;
}
/* (non-Javadoc)
@@ -119,7 +134,9 @@
* @see org.tinytim.index.ITypeInstanceIndex#getNameTypes()
*/
public Collection<Topic> getNameTypes() {
- return Collections.unmodifiableSet(_type2Names.keySet());
+ List<Topic> topics = new ArrayList<Topic>(_type2Names.keySet());
+ topics.remove(null);
+ return topics;
}
/* (non-Javadoc)
@@ -135,28 +152,54 @@
* @see org.tinytim.index.ITypeInstanceIndex#getTopicTypes()
*/
public Collection<Topic> getTopicTypes() {
- return Collections.unmodifiableSet(_type2Topics.keySet());
+ List<Topic> topics = new ArrayList<Topic>(_type2Topics.keySet());
+ topics.remove(null);
+ return topics;
}
/* (non-Javadoc)
* @see org.tinytim.index.ITypeInstanceIndex#getTopics(org.tmapi.core.Topic[])
*/
- public Collection<Topic> getTopics(Topic... types) {
- if (types == null || types.length == 1) {
- List<Topic> topics = _type2Topics.get(types[0]);
- return topics == null ? Collections.<Topic>emptySet()
- : new ArrayList<Topic>(topics);
+ public Collection<Topic> getTopics(Topic type) {
+ Set<Topic> topics = _type2Topics.get(type);
+ return topics == null ? Collections.<Topic>emptySet()
+ : new ArrayList<Topic>(topics);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.index.ITypeInstanceIndex#getTopics(org.tmapi.core.Topic[], boolean)
+ */
+ public Collection<Topic> getTopics(Topic[] types, boolean matchAll) {
+ if (types.length == 1) {
+ return getTopics(types[0]);
}
- Set<Topic> topics = new HashSet<Topic>(10);
- for (Topic type: types) {
- List<Topic> matches = _type2Topics.get(type);
- if (matches != null) {
- topics.addAll(matches);
+ if (!matchAll) {
+ Set<Topic> topics = new HashSet<Topic>();
+ for (Topic type: types) {
+ Set<Topic> matches = _type2Topics.get(type);
+ if (matches != null) {
+ topics.addAll(matches);
+ }
}
+ return topics;
}
- return topics;
+ else {
+ Set<Topic> topics = new HashSet<Topic>(getTopics(types[0]));
+ for (int i=1; i < types.length; i++) {
+ topics.retainAll(getTopics(types[i]));
+ }
+ return topics;
+ }
}
+ private boolean _unindex(List<ITyped> objects, Object obj) {
+ if (objects == null) {
+ return false;
+ }
+ objects.remove(obj);
+ return objects.isEmpty();
+ }
+
/* (non-Javadoc)
* @see org.tinytim.index.IIndex#close()
*/
@@ -178,6 +221,52 @@
// noop.
}
+ private final class AddTopicHandler implements IEventHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Topic topic = (Topic) newValue;
+ Collection<Topic> types = topic.getTypes();
+ if (types.isEmpty()) {
+ Set<Topic> topics = _type2Topics.get(null);
+ if (topics == null) {
+ topics = new HashSet<Topic>();
+ _type2Topics.put(null, topics);
+ }
+ topics.add(topic);
+ }
+ else {
+ for (Topic type: types) {
+ Set<Topic> topics = _type2Topics.get(type);
+ if (topics == null) {
+ topics = new HashSet<Topic>();
+ _type2Topics.put(type, topics);
+ }
+ topics.add(topic);
+ }
+ }
+ }
+ }
+
+ private final class RemoveTopicHandler implements IEventHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Topic topic = (Topic) oldValue;
+ Set<Topic> topics = _type2Topics.get(null);
+ if (topics != null) {
+ topics.remove(topic);
+ }
+ Collection<Topic> types = topic.getTypes();
+ for (Topic type: types) {
+ topics = _type2Topics.get(type);
+ if (topics != null) {
+ topics.remove(topic);
+ }
+ }
+ }
+ }
+
/**
* Handler that (un-)indexes topics by their type.
*/
@@ -186,19 +275,35 @@
Object newValue) {
Topic topic = (Topic) sender;
if (oldValue == null) {
- List<Topic> topics = _type2Topics.get(newValue);
+ // Adding a type
+ Set<Topic> topics = _type2Topics.get(newValue);
if (topics == null) {
- topics = new ArrayList<Topic>();
+ topics = new HashSet<Topic>();
_type2Topics.put((Topic) newValue, topics);
}
topics.add(topic);
+ topics = _type2Topics.get(null);
+ if (topics != null) {
+ topics.remove(topic);
+ }
}
else {
- List<Topic> topics = _type2Topics.get(oldValue);
+ Set<Topic> topics = _type2Topics.get(oldValue);
if (topics == null) {
return;
}
topics.remove(topic);
+ if (topics.isEmpty()) {
+ _type2Topics.remove(oldValue);
+ }
+ if (topic.getTypes().size() == 1) {
+ topics = _type2Topics.get(null);
+ if (topics == null) {
+ topics = new HashSet<Topic>();
+ _type2Topics.put(null, topics);
+ }
+ topics.add(topic);
+ }
}
}
}
@@ -220,7 +325,9 @@
else if (sender instanceof TopicNameImpl) {
type2Typed = _type2Names;
}
- _unindex((List<ITyped>)type2Typed.get(oldValue), sender);
+ if (_unindex((List<ITyped>)type2Typed.get((Topic)oldValue), sender)) {
+ type2Typed.remove(oldValue);
+ }
_index((Map<Topic, List<ITyped>>) type2Typed, (Topic) newValue, (ITyped) sender);
}
@@ -233,12 +340,29 @@
}
typedConstructs.add(sender);
}
+ }
- private void _unindex(List<ITyped> objects, Object obj) {
- if (objects == null) {
- return;
+ private final class RemoveTypedHandler implements IEventHandler {
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Map<Topic, ?> type2Typed = null;
+ if (oldValue instanceof AssociationImpl) {
+ type2Typed = _type2Assocs;
}
- objects.remove(obj);
+ else if (oldValue instanceof AssociationRoleImpl) {
+ type2Typed = _type2Roles;
+ }
+ else if (oldValue instanceof OccurrenceImpl) {
+ type2Typed = _type2Occs;
+ }
+ else if (oldValue instanceof TopicNameImpl) {
+ type2Typed = _type2Names;
+ }
+ Topic type = ((ITyped) oldValue).getType();
+ if (_unindex((List<ITyped>)type2Typed.get(type), oldValue)) {
+ type2Typed.remove(type);
+ }
}
}
Added: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -0,0 +1,75 @@
+/*
+ * 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.index.tmapi;
+
+import java.lang.ref.WeakReference;
+
+import org.tinytim.ICollectionFactory;
+import org.tinytim.TopicMapImpl;
+import org.tmapi.core.HelperObjectConfigurationException;
+import org.tmapi.core.TopicMap;
+import org.tmapi.index.Index;
+import org.tmapi.index.TMAPIIndexException;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+abstract class AbstractTMAPIIndex implements Index {
+
+ protected WeakReference<TopicMapImpl> _weakTopicMap;
+
+ public AbstractTMAPIIndex(TopicMapImpl topicMap, ICollectionFactory collFactory) {
+ _weakTopicMap = new WeakReference<TopicMapImpl>(topicMap);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#close()
+ */
+ public void close() throws TMAPIIndexException {
+ // noop.
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#isOpen()
+ */
+ public boolean isOpen() throws TMAPIIndexException {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#open()
+ */
+ public void open() throws TMAPIIndexException {
+ // noop.
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMapSystem.ConfigurableHelperObject#configure(org.tmapi.core.TopicMap)
+ */
+ public void configure(TopicMap tm)
+ throws HelperObjectConfigurationException {
+ // noop.
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AbstractTMAPIIndex.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -0,0 +1,75 @@
+/*
+ * 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.index.tmapi;
+
+import java.util.Collection;
+
+import org.tinytim.AssociationRoleImpl;
+import org.tinytim.ICollectionFactory;
+import org.tinytim.TopicMapImpl;
+import org.tmapi.core.Topic;
+import org.tmapi.index.IndexFlags;
+import org.tmapi.index.TMAPIIndexException;
+import org.tmapi.index.core.AssociationRolesIndex;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class AssociationRolesIndexImpl extends AbstractTMAPIIndex implements
+ AssociationRolesIndex {
+
+ public AssociationRolesIndexImpl(TopicMapImpl topicMap,
+ ICollectionFactory collFactory) {
+ super(topicMap, collFactory);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.core.AssociationRolesIndex#getAssociationRoleTypes()
+ */
+ public Collection<Topic> getAssociationRoleTypes() {
+ return _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().getRoleTypes();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.core.AssociationRolesIndex#getAssociationRolesByType(org.tmapi.core.Topic)
+ */
+ public Collection<AssociationRoleImpl> getAssociationRolesByType(Topic type) {
+ return _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().getRoles(type);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#getFlags()
+ */
+ public IndexFlags getFlags() throws TMAPIIndexException {
+ return IndexFlagsImpl.AUTOUPDATED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#reindex()
+ */
+ public void reindex() throws TMAPIIndexException {
+ // noop.
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -0,0 +1,75 @@
+/*
+ * 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.index.tmapi;
+
+import java.util.Collection;
+
+import org.tinytim.AssociationImpl;
+import org.tinytim.ICollectionFactory;
+import org.tinytim.TopicMapImpl;
+import org.tmapi.core.Topic;
+import org.tmapi.index.IndexFlags;
+import org.tmapi.index.TMAPIIndexException;
+import org.tmapi.index.core.AssociationsIndex;
+
+/**
+ * Implementation of the {@link org.tmapi.index.core.AssociationsIndex};
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class AssociationsIndexImpl extends AbstractTMAPIIndex implements
+ AssociationsIndex {
+
+ public AssociationsIndexImpl(TopicMapImpl topicMap,
+ ICollectionFactory collFactory) {
+ super(topicMap, collFactory);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.core.AssociationsIndex#getAssociationTypes()
+ */
+ public Collection<Topic> getAssociationTypes() {
+ return _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().getAssociationTypes();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.core.AssociationsIndex#getAssociationsByType(org.tmapi.core.Topic)
+ */
+ public Collection<AssociationImpl> getAssociationsByType(Topic type) {
+ return _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().getAssociations(type);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#getFlags()
+ */
+ public IndexFlags getFlags() throws TMAPIIndexException {
+ return IndexFlagsImpl.AUTOUPDATED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.Index#reindex()
+ */
+ public void reindex() throws TMAPIIndexException {
+ // noop.
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/IndexFlagsImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/IndexFlagsImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/IndexFlagsImpl.java 2008-04-23 16:15:39 UTC (rev 32)
@@ -0,0 +1,58 @@
+/*
+ * 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.index.tmapi;
+
+import org.tmapi.index.IndexFlags;
+
+/**
+ * Immutable {@link org.tmapi.index.IndexFlags} implementation.
+ *
+ * Use {@link #AUTOUPDATED} or {@link #NOT_AUTOUPDATED}
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev$ - $Date$
+ */
+final class IndexFlagsImpl implements IndexFlags {
+
+ /**
+ * Indicates that the index is auto updated.
+ */
+ public static IndexFlags AUTOUPDATED = new IndexFlagsImpl(true);
+
+ /**
+ * Indicates that the index is NOT auto updated.
+ */
+ public static IndexFlags NOT_AUTOUPDATED = new IndexFlagsImpl(false);
+
+ private final boolean _autoUpdated;
+
+ private IndexFlagsImpl(boolean autoUpdated) {
+ _autoUpdated = autoUpdated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.index.IndexFlags#isAutoUpdated()
+ */
+ public boolean isAutoUpdated() {
+ return _autoUpdated;
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/IndexFlagsImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-sty...
[truncated message content] |
|
From: <lh...@us...> - 2008-04-23 14:35:05
|
Revision: 31
http://tinytim.svn.sourceforge.net/tinytim/?rev=31&view=rev
Author: lheuer
Date: 2008-04-23 07:35:03 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
- TypeInstanceIndex added
Added Paths:
-----------
tinytim/trunk/src/test/java/org/tinytim/index/
tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java
Added: tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java 2008-04-23 14:35:03 UTC (rev 31)
@@ -0,0 +1,279 @@
+/*
+ * 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.index;
+
+import org.tinytim.TinyTimTestCase;
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicName;
+
+/**
+ * Tests against {@link ITypeInstanceIndex}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestTypeInstanceIndex extends TinyTimTestCase {
+
+ private ITypeInstanceIndex _typeInstanceIdx;
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ _typeInstanceIdx = _tm.getIndexManager().getTypeInstanceIndex();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ _typeInstanceIdx = null;
+ }
+
+ private void _updateIndex() {
+ if (!_typeInstanceIdx.isAutoUpdated()) {
+ _typeInstanceIdx.reindex();
+ }
+ }
+
+ public void testTopic() throws Exception {
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getTopics(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getTopicTypes().isEmpty());
+ Topic topic = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getTopicTypes().isEmpty());
+ assertEquals(1, _typeInstanceIdx.getTopics(null).size());
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(topic));
+ Topic type1 = _tm.createTopic();
+ Topic type2 = _tm.createTopic();
+ assertTrue(_typeInstanceIdx.getTopicTypes().isEmpty());
+ assertEquals(3, _typeInstanceIdx.getTopics(null).size());
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(topic));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type1));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type2));
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).isEmpty());
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, true).isEmpty());
+ // Topic with one type
+ topic.addType(type1);
+ assertEquals(1, _typeInstanceIdx.getTopicTypes().size());
+ assertTrue(_typeInstanceIdx.getTopicTypes().contains(type1));
+ assertEquals(2, _typeInstanceIdx.getTopics(null).size());
+ assertFalse(_typeInstanceIdx.getTopics(null).contains(topic));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type1));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type2));
+ assertEquals(1, _typeInstanceIdx.getTopics(type1).size());
+ assertTrue(_typeInstanceIdx.getTopics(type1).contains(topic));
+ assertEquals(1, _typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).size());
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).contains(topic));
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, true).isEmpty());
+ // Topic with two types
+ topic.addType(type2);
+ assertEquals(2, _typeInstanceIdx.getTopicTypes().size());
+ assertTrue(_typeInstanceIdx.getTopicTypes().contains(type1));
+ assertTrue(_typeInstanceIdx.getTopicTypes().contains(type2));
+ assertEquals(2, _typeInstanceIdx.getTopics(null).size());
+ assertFalse(_typeInstanceIdx.getTopics(null).contains(topic));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type1));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type2));
+ assertEquals(1, _typeInstanceIdx.getTopics(type1).size());
+ assertTrue(_typeInstanceIdx.getTopics(type1).contains(topic));
+ assertEquals(1, _typeInstanceIdx.getTopics(type2).size());
+ assertTrue(_typeInstanceIdx.getTopics(type2).contains(topic));
+ assertEquals(1, _typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).size());
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).contains(topic));
+ assertEquals(1, _typeInstanceIdx.getTopics(new Topic[] {type1, type2}, true).size());
+ assertTrue(_typeInstanceIdx.getTopics(new Topic[] {type1, type2}, true).contains(topic));
+ // Topic removal
+ topic.remove();
+ assertEquals(0, _typeInstanceIdx.getTopicTypes().size());
+ assertEquals(2, _typeInstanceIdx.getTopics(null).size());
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type1));
+ assertTrue(_typeInstanceIdx.getTopics(null).contains(type2));
+ assertTrue(_typeInstanceIdx.getTopics(type1).isEmpty());
+ assertTrue(_typeInstanceIdx.getTopics(type2).isEmpty());
+ assertEquals(0, _typeInstanceIdx.getTopics(new Topic[] {type1, type2}, false).size());
+ assertEquals(0, _typeInstanceIdx.getTopics(new Topic[] {type1, type2}, true).size());
+ }
+
+ public void testAssociation() throws Exception {
+ Topic type = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getAssociations(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getAssociations(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getAssociationTypes().isEmpty());
+ Association typed = _tm.createAssociation();
+ assertNull(typed.getType());
+ _updateIndex();
+ assertEquals(1, _typeInstanceIdx.getAssociations(null).size());
+ assertTrue(_typeInstanceIdx.getAssociations(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getAssociationTypes().contains(type));
+ assertTrue(_typeInstanceIdx.getAssociationTypes().isEmpty());
+ typed.setType(type);
+ _updateIndex();
+ assertEquals(0, _typeInstanceIdx.getAssociations(null).size());
+ assertFalse(_typeInstanceIdx.getAssociations(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getAssociationTypes().isEmpty());
+ assertEquals(1, _typeInstanceIdx.getAssociations(type).size());
+ assertTrue(_typeInstanceIdx.getAssociations(type).contains(typed));
+ assertTrue(_typeInstanceIdx.getAssociationTypes().contains(type));
+ typed.setType(null);
+ assertNull(typed.getType());
+ assertEquals(1, _typeInstanceIdx.getAssociations(null).size());
+ assertTrue(_typeInstanceIdx.getAssociations(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getAssociationTypes().contains(type));
+ assertTrue(_typeInstanceIdx.getAssociationTypes().isEmpty());
+ typed.setType(type);
+ typed.remove();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getAssociations(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getAssociations(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getAssociationTypes().isEmpty());
+ }
+
+ public void testRole() throws Exception {
+ Topic type = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getRoles(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getRoles(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getRoleTypes().isEmpty());
+ Association parent = _tm.createAssociation();
+ AssociationRole typed = parent.createAssociationRole(null, null);
+ assertNull(typed.getType());
+ _updateIndex();
+ assertEquals(1, _typeInstanceIdx.getRoles(null).size());
+ assertTrue(_typeInstanceIdx.getRoles(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getRoleTypes().contains(type));
+ typed.setType(type);
+ _updateIndex();
+ assertEquals(0, _typeInstanceIdx.getRoles(null).size());
+ assertFalse(_typeInstanceIdx.getRoles(null).contains(typed));
+ assertEquals(1, _typeInstanceIdx.getRoles(type).size());
+ assertTrue(_typeInstanceIdx.getRoles(type).contains(typed));
+ typed.setType(null);
+ assertNull(typed.getType());
+ assertEquals(1, _typeInstanceIdx.getRoles(null).size());
+ assertTrue(_typeInstanceIdx.getRoles(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getRoleTypes().contains(type));
+ assertTrue(_typeInstanceIdx.getRoleTypes().isEmpty());
+ typed.setType(type);
+ typed.remove();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getRoles(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getRoles(type).isEmpty());
+ // The same test, but the parent is removed
+ typed = parent.createAssociationRole(null, null);
+ assertNull(typed.getType());
+ _updateIndex();
+ assertEquals(1, _typeInstanceIdx.getRoles(null).size());
+ assertTrue(_typeInstanceIdx.getRoles(null).contains(typed));
+ typed.setType(type);
+ _updateIndex();
+ assertEquals(0, _typeInstanceIdx.getRoles(null).size());
+ assertFalse(_typeInstanceIdx.getRoles(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getRoleTypes().isEmpty());
+ assertEquals(1, _typeInstanceIdx.getRoles(type).size());
+ assertTrue(_typeInstanceIdx.getRoles(type).contains(typed));
+ assertTrue(_typeInstanceIdx.getRoleTypes().contains(type));
+ parent.remove();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getRoles(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getRoles(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getRoleTypes().isEmpty());
+ }
+
+ public void testOccurrence() throws Exception {
+ Topic type = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getOccurrences(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getOccurrences(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getOccurrenceTypes().isEmpty());
+ Topic parent = _tm.createTopic();
+ Occurrence typed = parent.createOccurrence("tinyTiM", null, null);
+ assertNull(typed.getType());
+ _updateIndex();
+ assertEquals(1, _typeInstanceIdx.getOccurrences(null).size());
+ assertTrue(_typeInstanceIdx.getOccurrences(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getOccurrenceTypes().contains(type));
+ typed.setType(type);
+ _updateIndex();
+ assertEquals(0, _typeInstanceIdx.getOccurrences(null).size());
+ assertFalse(_typeInstanceIdx.getOccurrences(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getOccurrenceTypes().isEmpty());
+ assertEquals(1, _typeInstanceIdx.getOccurrences(type).size());
+ assertTrue(_typeInstanceIdx.getOccurrences(type).contains(typed));
+ assertTrue(_typeInstanceIdx.getOccurrenceTypes().contains(type));
+ typed.setType(null);
+ assertNull(typed.getType());
+ assertEquals(1, _typeInstanceIdx.getOccurrences(null).size());
+ assertTrue(_typeInstanceIdx.getOccurrences(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getOccurrenceTypes().contains(type));
+ assertTrue(_typeInstanceIdx.getOccurrenceTypes().isEmpty());
+ typed.setType(type);
+ typed.remove();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getOccurrences(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getOccurrences(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getOccurrenceTypes().isEmpty());
+ }
+
+ public void testName() throws Exception {
+ Topic type = _tm.createTopic();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getNames(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getNames(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getNameTypes().isEmpty());
+ Topic parent = _tm.createTopic();
+ TopicName typed = parent.createTopicName("tinyTiM", null, null);
+ assertNull(typed.getType());
+ _updateIndex();
+ assertEquals(1, _typeInstanceIdx.getNames(null).size());
+ assertTrue(_typeInstanceIdx.getNames(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getNameTypes().contains(type));
+ typed.setType(type);
+ _updateIndex();
+ assertEquals(0, _typeInstanceIdx.getNames(null).size());
+ assertFalse(_typeInstanceIdx.getNames(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getNameTypes().isEmpty());
+ assertEquals(1, _typeInstanceIdx.getNames(type).size());
+ assertTrue(_typeInstanceIdx.getNames(type).contains(typed));
+ assertTrue(_typeInstanceIdx.getNameTypes().contains(type));
+ typed.setType(null);
+ assertNull(typed.getType());
+ assertEquals(1, _typeInstanceIdx.getNames(null).size());
+ assertTrue(_typeInstanceIdx.getNames(null).contains(typed));
+ assertFalse(_typeInstanceIdx.getNameTypes().contains(type));
+ assertTrue(_typeInstanceIdx.getNameTypes().isEmpty());
+ typed.setType(type);
+ typed.remove();
+ _updateIndex();
+ assertTrue(_typeInstanceIdx.getNames(null).isEmpty());
+ assertTrue(_typeInstanceIdx.getNames(type).isEmpty());
+ assertTrue(_typeInstanceIdx.getNameTypes().isEmpty());
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/index/TestTypeInstanceIndex.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-23 12:18:21
|
Revision: 30
http://tinytim.svn.sourceforge.net/tinytim/?rev=30&view=rev
Author: lheuer
Date: 2008-04-23 05:18:28 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
- META-INF added
Added Paths:
-----------
tinytim/trunk/src/main/resources/
tinytim/trunk/src/main/resources/META-INF/
tinytim/trunk/src/main/resources/META-INF/services/
tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory
Added: tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory
===================================================================
--- tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory (rev 0)
+++ tinytim/trunk/src/main/resources/META-INF/services/org.tmapi.core.TopicMapSystemFactory 2008-04-23 12:18:28 UTC (rev 30)
@@ -0,0 +1 @@
+org.tinytim.TopicMapSystemFactoryImpl
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-23 12:16:13
|
Revision: 29
http://tinytim.svn.sourceforge.net/tinytim/?rev=29&view=rev
Author: lheuer
Date: 2008-04-23 05:16:08 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
- Added moveable to move a Topic Maps construct to another
- Tests for item identifier constraints
- Enhanced TopicUtils
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/Construct.java
tinytim/trunk/src/main/java/org/tinytim/Event.java
tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java
tinytim/trunk/src/main/java/org/tinytim/Scoped.java
tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/Typed.java
tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java
tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/IMovable.java
tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java
Modified: tinytim/trunk/src/main/java/org/tinytim/Construct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/Construct.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -167,4 +167,18 @@
_iids = null;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append(" iids=[");
+ for (Locator sid: getItemIdentifiers()) {
+ sb.append(sid);
+ sb.append(',');
+ }
+ sb.append("]");
+ return sb.toString();
+ }
}
Modified: tinytim/trunk/src/main/java/org/tinytim/Event.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Event.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/Event.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -151,6 +151,10 @@
* Notification that the "resource" of an occurrence or variant should be
* set.
*/
- SET_LOCATOR; //TODO: Remove this once we have a TMDM-compatible version
+ SET_LOCATOR, //TODO: Remove this once we have a TMDM-compatible version
+ MOVE_OCCURRENCE,
+ MOVE_NAME,
+ MOVE_VARIANT
+
}
Added: tinytim/trunk/src/main/java/org/tinytim/IMovable.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IMovable.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/IMovable.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * Indicates that a Topic Maps construct is able to be detached from the
+ * current parent and attached to another parent.
+ *
+ * This interface 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:$
+ */
+interface IMovable<T /* extends IConstruct */> {
+
+ /**
+ * Moves this Topic Maps construct to the new parent.
+ *
+ * @param newParent The parent to move this construct to.
+ */
+ public void moveTo(T newParent);
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/IMovable.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -84,6 +84,7 @@
/**
* @see #merge(Topic, Topic)
*/
+ @SuppressWarnings("unchecked")
private static void _merge(TopicImpl source, TopicImpl target) {
if (source == null || target == null) {
throw new IllegalArgumentException("Neither the source topic nor the target topic must be null");
@@ -130,8 +131,7 @@
removeConstruct((IConstruct)occ);
}
else {
- source.removeOccurrence(occ);
- target.addOccurrence(occ);
+ ((IMovable<Topic>) occ).moveTo(target);
}
}
sigs.clear();
@@ -146,8 +146,7 @@
removeConstruct((IConstruct) name);
}
else {
- source.removeName(name);
- target.addName(name);
+ ((IMovable<Topic>) name).moveTo(target);
}
}
sigs.clear();
@@ -210,6 +209,7 @@
* @param source The name to take the variants from.
* @param target The target to add the variants to.
*/
+ @SuppressWarnings("unchecked")
static void moveVariants(TopicNameImpl source, TopicNameImpl target) {
Map<String, Variant> sigs = ((TopicMapImpl) target.getTopicMap()).getCollectionFactory().<String, Variant>createMap();
for (Variant var: target.getVariants()) {
@@ -223,8 +223,7 @@
removeConstruct((IConstruct)var);
}
else {
- source.removeVariant(var);
- target.addVariant(var);
+ ((IMovable<TopicName>) var).moveTo(target);
}
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -34,7 +34,7 @@
* @version $Rev$ - $Date$
*/
public final class OccurrenceImpl extends DatatypeAwareConstruct implements
- Occurrence, ITyped, IScoped {
+ Occurrence, ITyped, IScoped, IMovable<Topic> {
OccurrenceImpl(TopicMapImpl topicMap, Topic type, String value, Collection<Topic> scope) {
super(topicMap, type, value, scope);
@@ -52,6 +52,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.IMovable#moveTo(java.lang.Object)
+ */
+ public void moveTo(Topic newParent) {
+ _fireEvent(Event.MOVE_OCCURRENCE, _parent, newParent);
+ ((TopicImpl) _parent).detachOccurrence(this);
+ ((TopicImpl) newParent).attachOccurrence(this);
+ }
+
+ /* (non-Javadoc)
* @see org.tmapi.core.TopicMapObject#remove()
*/
public void remove() throws TMAPIException {
Modified: tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -30,12 +30,10 @@
/**
* Functions to support the XTM 1.0 reification mechanism.
*
- * 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:$
+ * @version $Rev$ - $Date$
*/
-final class ReificationUtils {
+public final class ReificationUtils {
/**
* Returns all Topic Maps constructs which have an item identifier
Modified: tinytim/trunk/src/main/java/org/tinytim/Scoped.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -97,7 +97,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.Construct#dispose()
+ * @see org.tinytim.Typed#dispose()
*/
@Override
protected void dispose() {
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -159,8 +159,7 @@
return;
}
_fireEvent(Event.ADD_OCCURRENCE, null, o);
- o._parent = this;
- _occs.add(o);
+ attachOccurrence(o);
}
/**
@@ -174,10 +173,19 @@
return;
}
_fireEvent(Event.REMOVE_OCCURRENCE, o, null);
- _occs.remove(o);
- o._parent = null;
+ detachOccurrence(o);
}
+ void attachOccurrence(OccurrenceImpl occ) {
+ occ._parent = this;
+ _occs.add(occ);
+ }
+
+ void detachOccurrence(OccurrenceImpl occ) {
+ _occs.remove(occ);
+ occ._parent = null;
+ }
+
/* (non-Javadoc)
* @see org.tmapi.core.Topic#getTopicNames()
*/
@@ -212,8 +220,7 @@
}
assert n._parent == null;
_fireEvent(Event.ADD_NAME, null, n);
- n._parent = this;
- _names.add(n);
+ attachName(n);
}
void removeName(TopicName name) {
@@ -222,10 +229,19 @@
return;
}
_fireEvent(Event.REMOVE_NAME, n, null);
- _names.remove(n);
- n._parent = null;
+ detachName(n);
}
+ void attachName(TopicNameImpl name) {
+ name._parent = this;
+ _names.add(name);
+ }
+
+ void detachName(TopicNameImpl name) {
+ _names.remove(name);
+ name._parent = null;
+ }
+
/* (non-Javadoc)
* @see org.tmapi.core.Topic#getReified()
*/
@@ -303,9 +319,12 @@
* @see org.tmapi.core.TopicMapObject#remove()
*/
public void remove() throws TopicInUseException {
- if (!TopicUtils.isRemovable(this)) {
- throw new TopicInUseException("The topic is used as type, player, reifier or theme");
+ if (!TopicUtils.isRemovable(this, false)) {
+ throw new TopicInUseException("The topic is used as type, player, or theme");
}
+ if (_reified != null) {
+ _reified.setReifier(null);
+ }
_tm.removeTopic(this);
_sids = null;
_slos = null;
@@ -317,4 +336,24 @@
super.dispose();
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append(", sids=[");
+ for (Locator sid: getSubjectIdentifiers()) {
+ sb.append(sid);
+ sb.append(',');
+ }
+ sb.append("], slos=[");
+ for (Locator slo: getSubjectLocators()) {
+ sb.append(slo);
+ sb.append(',');
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
}
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -37,7 +37,8 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-public final class TopicNameImpl extends Scoped implements TopicName, ITyped, IScoped {
+public final class TopicNameImpl extends Scoped implements TopicName, ITyped,
+ IScoped, IMovable<Topic> {
private String _value;
private Set<Variant> _variants;
@@ -104,11 +105,7 @@
}
assert v._parent == null;
_fireEvent(Event.ADD_VARIANT, null, v);
- if (_variants == null) {
- _variants = _tm.getCollectionFactory().createSet();
- }
- v._parent = this;
- _variants.add(v);
+ attachVariant(v);
}
void removeVariant(Variant variant) {
@@ -117,10 +114,31 @@
return;
}
_fireEvent(Event.REMOVE_VARIANT, v, null);
- _variants.remove(v);
- v._parent = null;
+ detachVariant(v);
}
+ void attachVariant(VariantImpl variant) {
+ if (_variants == null) {
+ _variants = _tm.getCollectionFactory().createSet();
+ }
+ variant._parent = this;
+ _variants.add(variant);
+ }
+
+ void detachVariant(VariantImpl variant) {
+ _variants.remove(variant);
+ variant._parent = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IMovable#moveTo(java.lang.Object)
+ */
+ public void moveTo(Topic newParent) {
+ _fireEvent(Event.MOVE_NAME, _parent, newParent);
+ ((TopicImpl) _parent).detachName(this);
+ ((TopicImpl) newParent).attachName(this);
+ }
+
/* (non-Javadoc)
* @see org.tmapi.core.TopicMapObject#remove()
*/
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -41,15 +41,36 @@
* Returns if the <code>topic</code> is removable.
*
* A topic is removable iff it plays no role, is not used as type of
+ * a typed Topic Maps construct, and is not not used as theme of a scoped
+ * Topic Maps construct.
+ *
+ * This functions returns the same result as
+ * <code>isRemovable(topic, false)</code>.
+ *
+ * @param topic The topic to check.
+ * @return <code>true</code> if the topic is removable, <code>false</code>
+ * otherwise.
+ */
+ public static boolean isRemovable(Topic topic) {
+ return isRemovable(topic, false);
+ }
+
+ /**
+ * Returns if the <code>topic</code> is removable.
+ *
+ * A topic is removable iff it plays no role, is not used as type of
* a typed Topic Maps construct, is not not used as theme of a scoped
- * Topic Maps construct and iff it is not used reifier.
+ * Topic Maps construct and iff it is not used reifier
+ * (if <code>includeReified</code> is <code>true</code>).
*
* @param topic The topic to check.
+ * @param includeReified Indicates if a reified Topic Maps construct (if any)
+ * is considered as dependency.
* @return <code>true</code> if the topic is removable, <code>false</code>
* otherwise.
*/
- public static boolean isRemovable(Topic topic) {
- if (((TopicImpl) topic)._reified != null) {
+ public static boolean isRemovable(Topic topic, boolean includeReified) {
+ if (includeReified && ((TopicImpl) topic)._reified != null) {
return false;
}
if (!topic.getRolesPlayed().isEmpty()) {
@@ -78,4 +99,5 @@
}
return removable;
}
+
}
Modified: tinytim/trunk/src/main/java/org/tinytim/Typed.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -89,7 +89,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.Scoped#dispose()
+ * @see org.tinytim.Construct#dispose()
*/
@Override
protected void dispose() {
Modified: tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -35,7 +35,7 @@
* @version $Rev$ - $Date$
*/
public final class VariantImpl extends DatatypeAwareConstruct implements
- Variant, IScoped {
+ Variant, IScoped, IMovable<TopicName> {
VariantImpl(TopicMapImpl topicMap, String value, Collection<Topic> scope) {
super(topicMap, null, value, scope);
@@ -53,6 +53,15 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.IMovable#moveTo(java.lang.Object)
+ */
+ public void moveTo(TopicName newParent) {
+ _fireEvent(Event.MOVE_VARIANT, _parent, newParent);
+ ((TopicNameImpl) _parent).detachVariant(this);
+ ((TopicNameImpl) newParent).attachVariant(this);
+ }
+
+ /* (non-Javadoc)
* @see org.tmapi.core.Variant#remove()
*/
public void remove() throws TMAPIException {
Added: tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -0,0 +1,155 @@
+/*
+ * 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;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.DuplicateSourceLocatorException;
+import org.tmapi.core.Locator;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.TopicMapObject;
+import org.tmapi.core.TopicName;
+import org.tmapi.core.TopicsMustMergeException;
+import org.tmapi.core.Variant;
+
+/**
+ * Tests if the TMDM item identifier constraint is respected.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestItemIdentifierConstraint extends TinyTimTestCase {
+
+ /**
+ * Tests against a topic map.
+ */
+ public void testTopicMap() throws Exception {
+ _testConstraint(_tm);
+ }
+
+ /**
+ * Tests againts a topic.
+ */
+ public void testTopic() throws Exception {
+ Topic topic = _tm.createTopic();
+ Locator iid = _tm.createLocator("http://sf.net/projects/tinytim");
+ topic.addSourceLocator(iid);
+ assertTrue(topic.getSourceLocators().contains(iid));
+ Topic topic2 = _tm.createTopic();
+ try {
+ topic2.addSourceLocator(iid);
+ }
+ catch (TopicsMustMergeException ex) {
+ // noop.
+ }
+ topic.removeSourceLocator(iid);
+ assertFalse(topic.getSourceLocators().contains(iid));
+ topic2.addSourceLocator(iid);
+ assertTrue(topic2.getSourceLocators().contains(iid));
+ topic2.removeSourceLocator(iid);
+ topic.addSourceLocator(iid);
+ assertTrue(topic.getSourceLocators().contains(iid));
+ assertFalse(topic2.getSourceLocators().contains(iid));
+ topic.remove();
+ topic2.addSourceLocator(iid);
+ assertTrue(topic2.getSourceLocators().contains(iid));
+ }
+
+ /**
+ * Tests against an association.
+ */
+ public void testAssociation() throws Exception {
+ _testConstraint(_tm.createAssociation());
+ }
+
+ /**
+ * Tests against a role.
+ */
+ public void testRole() throws Exception {
+ Association assoc = _tm.createAssociation();
+ AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic());
+ _testConstraint(role);
+ }
+
+ /**
+ * Tests against an occurrence.
+ */
+ public void testOccurrence() throws Exception {
+ Topic topic = _tm.createTopic();
+ Occurrence occ = topic.createOccurrence("tinyTiM", null, null);
+ _testConstraint(occ);
+ }
+
+ /**
+ * Tests against a name.
+ */
+ public void testName() throws Exception {
+ Topic topic = _tm.createTopic();
+ TopicName name = topic.createTopicName("tinyTiM", null, null);
+ _testConstraint(name);
+ }
+
+ /**
+ * Tests against a variant.
+ */
+ public void testVariant() throws Exception {
+ Topic topic = _tm.createTopic();
+ TopicName name = topic.createTopicName("tinyTiM", null, null);
+ Variant variant = name.createVariant("tinyTiM", null);
+ _testConstraint(variant);
+ }
+
+ /**
+ * The item identifier constraint test.
+ *
+ * @param tmo The Topic Maps construct to test.
+ */
+ private void _testConstraint(TopicMapObject tmo) throws Exception {
+ assertTrue(tmo.getSourceLocators().isEmpty());
+ Locator iid = _tm.createLocator("http://sf.net/projects/tinytim");
+ tmo.addSourceLocator(iid);
+ assertTrue(tmo.getSourceLocators().contains(iid));
+ Association assoc = _tm.createAssociation();
+ try {
+ assoc.addSourceLocator(iid);
+ fail("Topic Maps constructs with the same item identifier are not allowed");
+ }
+ catch (DuplicateSourceLocatorException ex) {
+ // noop
+ }
+ tmo.removeSourceLocator(iid);
+ assertFalse(tmo.getSourceLocators().contains(iid));
+ assoc.addSourceLocator(iid);
+ assertTrue(assoc.getSourceLocators().contains(iid));
+ assoc.removeSourceLocator(iid);
+ assertFalse(assoc.getSourceLocators().contains(iid));
+ tmo.addSourceLocator(iid);
+ assertTrue(tmo.getSourceLocators().contains(iid));
+ if (!(tmo instanceof TopicMap)) {
+ // Removal should 'free' the item identifier
+ tmo.remove();
+ assoc.addSourceLocator(iid);
+ assertTrue(assoc.getSourceLocators().contains(iid));
+ }
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Modified: tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -34,7 +34,7 @@
* Tests against the {@link ReificationUtils}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestReificationUtils extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -99,9 +99,9 @@
}
/**
- * Tests if adding a subject identifier equals to an item identifier is detected.
+ * Tests if adding an item identifier equals to a subject identifier is detected.
*/
- public void testExistingSubjectIdentifierItemIdentifier() {
+ public void testExistingSubjectIdentifierAddItemIdentifier() {
Topic topic1 = _tm.createTopic();
Topic topic2 = _tm.createTopic();
Locator loc = _tm.createLocator("http://sf.net/projects/tinytim");
@@ -118,10 +118,10 @@
}
/**
- * Tests if adding a subject identifier equals to an item identifier
+ * Tests if adding an item identifier equals to a subject identifier
* on the SAME topic is accepted
*/
- public void testExistingSubjectIdentifierItemIdentifierLegal() {
+ public void testExistingSubjectIdentifierAddItemIdentifierLegal() {
Topic topic1 = _tm.createTopic();
Locator loc = _tm.createLocator("http://sf.net/projects/tinytim");
topic1.addSubjectIdentifier(loc);
@@ -138,4 +138,45 @@
assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc));
assertEquals(topic1, _tm.getObjectByItemIdentifier(loc));
}
+
+ /**
+ * Tests if adding a subject identifier equals to an item identifier is detected.
+ */
+ public void testExistingItemIdentifierAddSubjectIdentifier() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ Locator loc = _tm.createLocator("http://sf.net/projects/tinytim");
+ topic1.addSourceLocator(loc);
+ assertTrue(topic1.getSourceLocators().contains(loc));
+ assertEquals(topic1, _tm.getObjectByItemIdentifier(loc));
+ try {
+ topic2.addSubjectIdentifier(loc);
+ fail("A topic with an item identifier equals to the subject identifier '" + loc + "' exists.");
+ }
+ catch (TopicsMustMergeException ex) {
+ // noop.
+ }
+ }
+
+ /**
+ * Tests if adding a subject identifier equals to an item identifier
+ * on the SAME topic is accepted
+ */
+ public void testExistingItemIdentifierAddSubjectIdentifierLegal() {
+ Topic topic1 = _tm.createTopic();
+ Locator loc = _tm.createLocator("http://sf.net/projects/tinytim");
+ topic1.addSourceLocator(loc);
+ assertEquals(1, topic1.getSourceLocators().size());
+ assertEquals(0, topic1.getSubjectIdentifiers().size());
+ assertTrue(topic1.getSourceLocators().contains(loc));
+ assertEquals(topic1, _tm.getObjectByItemIdentifier(loc));
+ assertNull(_tm.getTopicBySubjectIdentifier(loc));
+ topic1.addSubjectIdentifier(loc);
+ assertEquals(1, topic1.getSubjectIdentifiers().size());
+ assertEquals(1, topic1.getSourceLocators().size());
+ assertTrue(topic1.getSubjectIdentifiers().contains(loc));
+ assertTrue(topic1.getSourceLocators().contains(loc));
+ assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc));
+ assertEquals(topic1, _tm.getObjectByItemIdentifier(loc));
+ }
}
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-22 15:12:58 UTC (rev 28)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-23 12:16:08 UTC (rev 29)
@@ -56,7 +56,8 @@
assertTrue(TopicUtils.isRemovable(topic));
// Reifier
((IReifiable) assoc).setReifier(topic);
- assertFalse(TopicUtils.isRemovable(topic));
+ assertTrue(TopicUtils.isRemovable(topic));
+ assertFalse(TopicUtils.isRemovable(topic, true));
((IReifiable) assoc).setReifier(null);
assertTrue(TopicUtils.isRemovable(topic));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-22 15:13:38
|
Revision: 28
http://tinytim.svn.sourceforge.net/tinytim/?rev=28&view=rev
Author: lheuer
Date: 2008-04-22 08:12:58 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Forgot ReificationUtils test, now added
Added Paths:
-----------
tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java
Added: tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java 2008-04-22 15:12:58 UTC (rev 28)
@@ -0,0 +1,138 @@
+/*
+ * 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;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.Locator;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.TopicMapObject;
+import org.tmapi.core.TopicName;
+import org.tmapi.core.Variant;
+
+/**
+ * Tests against the {@link ReificationUtils}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestReificationUtils extends TinyTimTestCase {
+
+ /**
+ * Tests reification of a topic map
+ */
+ public void testTopicMap() throws Exception {
+ _testReification(_tm);
+ }
+
+ /**
+ * Tests reification of a topic (which is not possible)
+ */
+ public void testTopic() {
+ try {
+ ReificationUtils.getReifier(_tm.createTopic());
+ fail("Topic cannot be reified");
+ }
+ catch (IllegalArgumentException ex) {
+ // noop.
+ }
+ }
+
+ /**
+ * Tests reification of an association.
+ */
+ public void testAssociation() throws Exception {
+ _testReification(_tm.createAssociation());
+ }
+
+ /**
+ * Tests reification of a role.
+ */
+ public void testRole() throws Exception {
+ Association assoc = _tm.createAssociation();
+ AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic());
+ _testReification(role);
+ }
+
+ /**
+ * Tests reification of an occurrence.
+ */
+ public void testOccurrence() throws Exception {
+ Topic topic = _tm.createTopic();
+ Occurrence occ = topic.createOccurrence("tinyTiM", null, null);
+ _testReification(occ);
+ }
+
+ /**
+ * Tests reification of a name.
+ */
+ public void testName() throws Exception {
+ Topic topic = _tm.createTopic();
+ TopicName name = topic.createTopicName("tinyTiM", null, null);
+ _testReification(name);
+ }
+
+ /**
+ * Tests reification of a variant.
+ */
+ public void testVariant() throws Exception {
+ Topic topic = _tm.createTopic();
+ TopicName name = topic.createTopicName("tinyTiM", null, null);
+ Variant variant = name.createVariant("tinyTiM", null);
+ _testReification(variant);
+ }
+
+ /**
+ * The reification test.
+ *
+ * @param tmo The Topic Maps construct to test.
+ * @throws Exception
+ */
+ private void _testReification(TopicMapObject tmo) throws Exception {
+ assertTrue(tmo.getSourceLocators().isEmpty());
+ assertNull(ReificationUtils.getReifier(tmo));
+ Locator loc = _tm.createLocator("http://sf.net/projects/tinytim/#example");
+ Topic reifier = _tm.createTopic();
+ assertTrue(reifier.getSubjectIdentifiers().isEmpty());
+ assertEquals(0, ReificationUtils.getReified(reifier).size());
+ reifier.addSubjectIdentifier(loc);
+ assertEquals(1, reifier.getSubjectIdentifiers().size());
+ assertEquals(0, ReificationUtils.getReified(reifier).size());
+ tmo.addSourceLocator(loc);
+ assertEquals(1, ReificationUtils.getReified(reifier).size());
+ assertTrue(ReificationUtils.getReified(reifier).contains(tmo));
+ assertEquals(reifier, ReificationUtils.getReifier(tmo));
+ tmo.removeSourceLocator(loc);
+ assertEquals(0, ReificationUtils.getReified(reifier).size());
+ assertFalse(ReificationUtils.getReified(reifier).contains(tmo));
+ assertNull(ReificationUtils.getReifier(tmo));
+ if (!(tmo instanceof TopicMap)) {
+ tmo.addSourceLocator(loc);
+ assertEquals(1, ReificationUtils.getReified(reifier).size());
+ assertTrue(ReificationUtils.getReified(reifier).contains(tmo));
+ assertEquals(reifier, ReificationUtils.getReifier(tmo));
+ tmo.remove();
+ assertEquals(0, ReificationUtils.getReified(reifier).size());
+ }
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-22 13:13:20
|
Revision: 27
http://tinytim.svn.sourceforge.net/tinytim/?rev=27&view=rev
Author: lheuer
Date: 2008-04-22 06:13:08 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
- Refactored Scoped and Typed: Scoped does not implement IReifiable, Typed does
- All instances return copies of theirs list
- Added ReificationUtils to support XTM 1.0 reification
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java
tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java
tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
tinytim/trunk/src/main/java/org/tinytim/Property.java
tinytim/trunk/src/main/java/org/tinytim/Scoped.java
tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/Typed.java
tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java
Modified: tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -33,7 +33,7 @@
* {@link org.tmapi.core.Association} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class AssociationImpl extends Scoped implements Association,
IReifiable, ITyped, IScoped {
@@ -42,7 +42,7 @@
private Topic _type;
AssociationImpl(TopicMapImpl topicMap) {
- super(topicMap, null);
+ super(topicMap, null, null);
_roles = topicMap.getCollectionFactory().createSet(2);
}
Modified: tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -29,7 +29,7 @@
* {@link org.tmapi.core.AssociationRole} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class AssociationRoleImpl extends Typed implements AssociationRole,
ITyped {
@@ -37,7 +37,7 @@
private Topic _player;
AssociationRoleImpl(TopicMapImpl tm, Topic type, Topic player) {
- super(tm, type, null);
+ super(tm, type);
_player = player;
}
Modified: tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -34,7 +34,7 @@
* topic map to another without creating duplicates.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class CopyUtils {
Modified: tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -29,10 +29,10 @@
* Implementation of {@link org.tinytim.IDatatypeAwareConstruct}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
-abstract class DatatypeAwareConstruct extends Typed implements
- IDatatypeAwareConstruct, IScoped {
+abstract class DatatypeAwareConstruct extends Scoped implements
+ IDatatypeAwareConstruct {
private String _value;
private Locator _resource;
@@ -58,9 +58,11 @@
}
/**
+ * Sets the value (xsd:string) of this construct.
*
+ * Sideeffect: The resource is set to null.
*
- * @param value
+ * @param value Sets the value of this construct.
*/
public void setValue(String value) {
_fireEvent(Event.SET_VALUE, _value, value);
@@ -69,25 +71,29 @@
}
/**
- *
+ * Returns the value of this construct.
*
- * @return
+ * @return The value or <code>null</code>.
*/
public String getValue() {
return _value;
}
/**
- *
+ * Returns the locator (xsd:anyURI value) of this construct.
*
- * @return
+ * @return The locator or <code>null</code>.
*/
public Locator getResource() {
return _resource;
}
- /* (non-Javadoc)
- * @see org.tmapi.core.Occurrence#setResource(org.tmapi.core.Locator)
+ /**
+ * Sets the value (xsd:anyURI) of this construct.
+ *
+ * Side effect: The string value (if any) is set to <code>null</code>.
+ *
+ * @param value The locator.
*/
public void setResource(Locator value) {
_fireEvent(Event.SET_VALUE, _value, value);
Modified: tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -26,7 +26,7 @@
* Indicates that a Topic Maps construct has a value and a datatype.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
interface IDatatypeAwareConstruct extends IConstruct {
Modified: tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -33,7 +33,7 @@
* provides an index to get Topic Maps constructs by their identity.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class IdentityManager {
Modified: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -47,7 +47,7 @@
* changes, check the <code>==</code> comparisons.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class MergeUtils {
@@ -272,32 +272,23 @@
if (!typeInstanceIndex.isAutoUpdated()) {
typeInstanceIndex.reindex();
}
- List<Topic> topics = new ArrayList<Topic>(typeInstanceIndex.getTopics(source));
- for (Topic topic: topics) {
+ for (Topic topic: typeInstanceIndex.getTopics(source)) {
topic.removeType(source);
topic.addType(replacement);
}
- Collection<ITyped> typed = new ArrayList<ITyped>(typeInstanceIndex.getAssociations(source));
- _replaceTopicAsType(typed, replacement);
- typed = new ArrayList<ITyped>(typeInstanceIndex.getRoles(source));
- _replaceTopicAsType(typed, replacement);
- typed = new ArrayList<ITyped>(typeInstanceIndex.getOccurrences(source));
- _replaceTopicAsType(typed, replacement);
- typed = new ArrayList<ITyped>(typeInstanceIndex.getNames(source));
- _replaceTopicAsType(typed, replacement);
+ _replaceTopicAsType(typeInstanceIndex.getAssociations(source), replacement);
+ _replaceTopicAsType(typeInstanceIndex.getRoles(source), replacement);
+ _replaceTopicAsType(typeInstanceIndex.getOccurrences(source), replacement);
+ _replaceTopicAsType(typeInstanceIndex.getNames(source), replacement);
typeInstanceIndex.close();
IScopedIndex scopedIndex = idxMan.getScopedIndex();
if (!scopedIndex.isAutoUpdated()) {
scopedIndex.reindex();
}
- Collection<IScoped> scoped = new ArrayList<IScoped>(scopedIndex.getAssociationsByTheme(source));
- _replaceTopicAsTheme(scoped, source, replacement);
- scoped = new ArrayList<IScoped>(scopedIndex.getOccurrencesByTheme(source));
- _replaceTopicAsTheme(scoped, source, replacement);
- scoped = new ArrayList<IScoped>(scopedIndex.getNamesByTheme(source));
- _replaceTopicAsTheme(scoped, source, replacement);
- scoped = new ArrayList<IScoped>(scopedIndex.getVariantsByTheme(source));
- _replaceTopicAsTheme(scoped, source, replacement);
+ _replaceTopicAsTheme(scopedIndex.getAssociationsByTheme(source), source, replacement);
+ _replaceTopicAsTheme(scopedIndex.getOccurrencesByTheme(source), source, replacement);
+ _replaceTopicAsTheme(scopedIndex.getNamesByTheme(source), source, replacement);
+ _replaceTopicAsTheme(scopedIndex.getVariantsByTheme(source), source, replacement);
scopedIndex.close();
}
@@ -307,14 +298,14 @@
* @param typedConstructs A collection of typed constructs.
* @param replacement The type.
*/
- private static void _replaceTopicAsType(Collection<ITyped> typedConstructs,
+ private static void _replaceTopicAsType(Collection<? extends ITyped> typedConstructs,
Topic replacement) {
for (ITyped typed: typedConstructs) {
typed.setType(replacement);
}
}
- private static void _replaceTopicAsTheme(Collection<IScoped> scopedCollection,
+ private static void _replaceTopicAsTheme(Collection<? extends IScoped> scopedCollection,
Topic oldTheme, Topic newTheme) {
for (IScoped scoped: scopedCollection) {
scoped.removeTheme(oldTheme);
Modified: tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -31,10 +31,10 @@
* {@link org.tmapi.core.Occurrence} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class OccurrenceImpl extends DatatypeAwareConstruct implements
- Occurrence, ITyped {
+ Occurrence, ITyped, IScoped {
OccurrenceImpl(TopicMapImpl topicMap, Topic type, String value, Collection<Topic> scope) {
super(topicMap, type, value, scope);
Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -41,4 +41,14 @@
* default Java collections.
*/
public static final String COLLECTION_FACTORY = "org.tinytim.CollectionFactory";
+
+ /**
+ * Property which indicates if the "old" XTM 1.0 reification mechansm should
+ * be used.
+ *
+ * For backwards compatibilty and to support TMAPI 1.0 this property is
+ * set to "true" by default.
+ */
+ public static final String XTM10_REIFICATION = "org.tinytim.XTM10Reification";
+
}
Added: tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -0,0 +1,80 @@
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.tmapi.core.Locator;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMapObject;
+
+/**
+ * Functions to support the XTM 1.0 reification mechanism.
+ *
+ * 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 ReificationUtils {
+
+ /**
+ * Returns all Topic Maps constructs which have an item identifier
+ * equals to a subject identifier of the specified <code>reifier</code>.
+ *
+ * @param reifier A topic.
+ * @return A (maybe empty) collection of Topic Maps constructs.
+ */
+ public static Set<TopicMapObject> getReified(Topic reifier) {
+ TopicMapImpl tm = (TopicMapImpl) reifier.getTopicMap();
+ Set<TopicMapObject> reified = tm.getCollectionFactory().createSet();
+ for (Locator sid: ((TopicImpl) reifier).getSubjectIdentifiers()) {
+ TopicMapObject obj = tm.getObjectByItemIdentifier(sid);
+ if (obj != null) {
+ reified.add(obj);
+ }
+ }
+ return reified;
+ }
+
+ /**
+ * Returns a topic that has a subject identifier equals to one of the
+ * item identifiers of the <code>reifiable</code>.
+ *
+ * @param reifiable The reifiable Topic Maps construct.
+ * @return A topic or <code>null</code>.
+ */
+ @SuppressWarnings("unchecked")
+ public static Topic getReifier(TopicMapObject reifiable) {
+ if (reifiable instanceof Topic) {
+ throw new IllegalArgumentException("Topics are not reifiable");
+ }
+ TopicMapImpl tm = (TopicMapImpl) reifiable.getTopicMap();
+ for (Iterator<Locator> iter = reifiable.getSourceLocators().iterator(); iter.hasNext();) {
+ Topic reifier = tm.getTopicBySubjectIdentifier(iter.next());
+ if (reifier != null) {
+ return reifier;
+ }
+ }
+ return null;
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/Scoped.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -28,25 +28,23 @@
/**
* Class that provides a "scope" property and sends events if that
- * scope property changes. Additionally, this class provides
- * a {@link IReifiable} implementation.
+ * scope property changes.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-abstract class Scoped extends Construct implements IReifiable {
+abstract class Scoped extends Typed {
//NOTE: This class does NOT implement IScoped by intention!
- // Typed extends this class and roles are not IScoped!
private Set<Topic> _scope;
- private Topic _reifier;
- Scoped(TopicMapImpl topicMap, Collection<Topic> scope) {
- super(topicMap);
+ Scoped(TopicMapImpl topicMap, Topic type, Collection<Topic> scope) {
+ super(topicMap, type);
if (scope != null) {
- for(Topic theme: scope) {
- addTheme(theme);
+ _scope = topicMap.getCollectionFactory().createSet(scope.size());
+ for (Topic theme: scope) {
+ _scope.add(theme);
}
}
}
@@ -99,36 +97,11 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.Association#getReifier()
- */
- public Topic getReifier() {
- return _reifier;
- }
-
- /* (non-Javadoc)
- * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic)
- */
- public void setReifier(Topic reifier) {
- if (_reifier == reifier) {
- return;
- }
- _fireEvent(Event.SET_REIFIER, _reifier, reifier);
- if (_reifier != null) {
- ((TopicImpl) _reifier)._reified = null;
- }
- _reifier = reifier;
- if (reifier != null) {
- ((TopicImpl) reifier)._reified = this;
- }
- }
-
- /* (non-Javadoc)
* @see org.tinytim.Construct#dispose()
*/
@Override
protected void dispose() {
_scope = null;
- _reifier = null;
super.dispose();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -38,7 +38,7 @@
* {@link org.tmapi.core.Topic} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class TopicImpl extends Construct implements Topic {
@@ -230,6 +230,9 @@
* @see org.tmapi.core.Topic#getReified()
*/
public Set<TopicMapObject> getReified() {
+ if (_tm._oldReification) {
+ return ReificationUtils.getReified(this);
+ }
return _reified != null ? Collections.<TopicMapObject>singleton(_reified)
: Collections.<TopicMapObject>emptySet();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -59,6 +59,7 @@
for (FeatureInfo feature: _FEATURES) {
_features.put(feature.name, feature.defaultValue);
}
+ _properties.setProperty(Property.XTM10_REIFICATION, "true");
_properties.setProperty(Property.COLLECTION_FACTORY, _COLL_FACTORY_JAVA);
try {
// Probe if Trove is available.
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -35,9 +35,9 @@
* {@link org.tmapi.core.TopicName} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
-public final class TopicNameImpl extends Typed implements TopicName, ITyped, IScoped {
+public final class TopicNameImpl extends Scoped implements TopicName, ITyped, IScoped {
private String _value;
private Set<Variant> _variants;
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -45,8 +45,8 @@
* Topic Maps construct and iff it is not used reifier.
*
* @param topic The topic to check.
- * @return <code>true</code> if the topic has no dependencies,
- * otherwise <code>false</code>.
+ * @return <code>true</code> if the topic is removable, <code>false</code>
+ * otherwise.
*/
public static boolean isRemovable(Topic topic) {
if (((TopicImpl) topic)._reified != null) {
@@ -60,22 +60,22 @@
if (!typeInstanceIdx.isAutoUpdated()) {
typeInstanceIdx.reindex();
}
- if (!typeInstanceIdx.getAssociations(topic).isEmpty()
- || !typeInstanceIdx.getRoles(topic).isEmpty()
- || !typeInstanceIdx.getOccurrences(topic).isEmpty()
- || !typeInstanceIdx.getNames(topic).isEmpty()) {
- return false;
+ boolean removable = typeInstanceIdx.getAssociations(topic).isEmpty()
+ && typeInstanceIdx.getRoles(topic).isEmpty()
+ && typeInstanceIdx.getOccurrences(topic).isEmpty()
+ && typeInstanceIdx.getNames(topic).isEmpty();
+ typeInstanceIdx.close();
+ if (removable) {
+ IScopedIndex scopedIdx = idxMan.getScopedIndex();
+ if (!scopedIdx.isAutoUpdated()) {
+ scopedIdx.reindex();
+ }
+ removable = scopedIdx.getAssociationsByTheme(topic).isEmpty()
+ && scopedIdx.getOccurrencesByTheme(topic).isEmpty()
+ && scopedIdx.getNamesByTheme(topic).isEmpty()
+ && scopedIdx.getVariantsByTheme(topic).isEmpty();
+ scopedIdx.close();
}
- IScopedIndex scopedIdx = idxMan.getScopedIndex();
- if (!scopedIdx.isAutoUpdated()) {
- scopedIdx.reindex();
- }
- if (!scopedIdx.getAssociationsByTheme(topic).isEmpty()
- || !scopedIdx.getOccurrencesByTheme(topic).isEmpty()
- || !scopedIdx.getNamesByTheme(topic).isEmpty()
- || !scopedIdx.getVariantsByTheme(topic).isEmpty()) {
- return false;
- }
- return true;
+ return removable;
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/Typed.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -20,26 +20,26 @@
*/
package org.tinytim;
-import java.util.Collection;
-
import org.tmapi.core.Topic;
/**
- * Class that provides a "type" property and fires and event if that type
- * property changes.
+ * Class that provides a "type" property and fires an event if that type
+ * property changes. Additionally, this class provides
+ * a {@link IReifiable} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-abstract class Typed extends Scoped {
+abstract class Typed extends Construct implements IReifiable {
//NOTE: This class does NOT implement ITyped by intention!
// DatatypeAwareConstruct extends this class and variants are not ITyped!
private Topic _type;
+ private Topic _reifier;
- Typed(TopicMapImpl topicMap, Topic type, Collection<Topic> scope) {
- super(topicMap, scope);
+ Typed(TopicMapImpl topicMap, Topic type) {
+ super(topicMap);
_type = type;
}
@@ -62,11 +62,39 @@
}
/* (non-Javadoc)
+ * @see org.tmapi.core.IReifiable#getReifier()
+ */
+ public Topic getReifier() {
+ if (_tm._oldReification) {
+ return ReificationUtils.getReifier(this);
+ }
+ return _reifier;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic)
+ */
+ public void setReifier(Topic reifier) {
+ if (_reifier == reifier) {
+ return;
+ }
+ _fireEvent(Event.SET_REIFIER, _reifier, reifier);
+ if (_reifier != null) {
+ ((TopicImpl) _reifier)._reified = null;
+ }
+ _reifier = reifier;
+ if (reifier != null) {
+ ((TopicImpl) reifier)._reified = this;
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.Scoped#dispose()
*/
@Override
protected void dispose() {
_type = null;
+ _reifier = null;
super.dispose();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -32,9 +32,10 @@
* {@link org.tmapi.core.Variant} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
-public final class VariantImpl extends DatatypeAwareConstruct implements Variant {
+public final class VariantImpl extends DatatypeAwareConstruct implements
+ Variant, IScoped {
VariantImpl(TopicMapImpl topicMap, String value, Collection<Topic> scope) {
super(topicMap, null, value, scope);
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -27,7 +27,7 @@
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class IndexManager {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -42,7 +42,7 @@
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class ScopedIndex implements IScopedIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -23,8 +23,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.tinytim.AssociationImpl;
import org.tinytim.AssociationRoleImpl;
@@ -39,10 +41,10 @@
import org.tmapi.core.Topic;
/**
+ * {@link ITypeInstanceIndex} implementation.
*
- *
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TypeInstanceIndex implements ITypeInstanceIndex {
@@ -78,7 +80,7 @@
public Collection<AssociationImpl> getAssociations(Topic type) {
List<AssociationImpl> assocs = _type2Assocs.get(type);
return assocs == null ? Collections.<AssociationImpl>emptySet()
- : Collections.unmodifiableCollection(assocs);
+ : new ArrayList<AssociationImpl>(assocs);
}
/* (non-Javadoc)
@@ -94,7 +96,7 @@
public Collection<AssociationRoleImpl> getRoles(Topic type) {
List<AssociationRoleImpl> roles = _type2Roles.get(type);
return roles == null ? Collections.<AssociationRoleImpl>emptySet()
- : Collections.unmodifiableCollection(roles);
+ : new ArrayList<AssociationRoleImpl>(roles);
}
/* (non-Javadoc)
@@ -110,7 +112,7 @@
public Collection<OccurrenceImpl> getOccurrences(Topic type) {
List<OccurrenceImpl> occs = _type2Occs.get(type);
return occs == null ? Collections.<OccurrenceImpl>emptySet()
- : Collections.unmodifiableCollection(occs);
+ : new ArrayList<OccurrenceImpl>(occs);
}
/* (non-Javadoc)
@@ -126,7 +128,7 @@
public Collection<TopicNameImpl> getNames(Topic type) {
List<TopicNameImpl> names = _type2Names.get(type);
return names == null ? Collections.<TopicNameImpl>emptySet()
- : Collections.unmodifiableCollection(names);
+ : new ArrayList<TopicNameImpl>(names);
}
/* (non-Javadoc)
@@ -139,13 +141,20 @@
/* (non-Javadoc)
* @see org.tinytim.index.ITypeInstanceIndex#getTopics(org.tmapi.core.Topic[])
*/
- public Collection<Topic> getTopics(Topic... type) {
- if (type == null || type.length == 1) {
- List<Topic> topics = _type2Topics.get(type);
+ public Collection<Topic> getTopics(Topic... types) {
+ if (types == null || types.length == 1) {
+ List<Topic> topics = _type2Topics.get(types[0]);
return topics == null ? Collections.<Topic>emptySet()
- : Collections.unmodifiableCollection(topics);
+ : new ArrayList<Topic>(topics);
}
- return null;
+ Set<Topic> topics = new HashSet<Topic>(10);
+ for (Topic type: types) {
+ List<Topic> matches = _type2Topics.get(type);
+ if (matches != null) {
+ topics.addAll(matches);
+ }
+ }
+ return topics;
}
/* (non-Javadoc)
Modified: tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -20,6 +20,8 @@
*/
package org.tinytim;
+import java.util.Properties;
+
import org.tmapi.core.Association;
import org.tmapi.core.AssociationRole;
import org.tmapi.core.ModelConstraintException;
@@ -37,6 +39,16 @@
*/
public class TestReifiable extends TinyTimTestCase {
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#getAdditionalProperties()
+ */
+ @Override
+ protected Properties getAdditionalProperties() {
+ Properties props = new Properties();
+ props.setProperty(Property.XTM10_REIFICATION, "false");
+ return props;
+ }
+
/**
* Tests if a Topic Maps construct is an instance of IReifiable.
*/
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -20,6 +20,8 @@
*/
package org.tinytim;
+import java.util.Properties;
+
import org.tmapi.core.Association;
import org.tmapi.core.AssociationRole;
import org.tmapi.core.Locator;
@@ -36,6 +38,16 @@
*/
public class TestTopicMerge extends TinyTimTestCase {
+ /* (non-Javadoc)
+ * @see org.tinytim.TinyTimTestCase#getAdditionalProperties()
+ */
+ @Override
+ protected Properties getAdditionalProperties() {
+ Properties props = new Properties();
+ props.setProperty(Property.XTM10_REIFICATION, "false");
+ return props;
+ }
+
/**
* If topics reify different Topic Maps constructs they cannot be merged.
*/
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -28,7 +28,7 @@
* Tests against the {@link TopicUtils}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTopicUtils extends TinyTimTestCase {
@@ -60,4 +60,5 @@
((IReifiable) assoc).setReifier(null);
assertTrue(TopicUtils.isRemovable(topic));
}
+
}
Modified: tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java 2008-04-21 14:59:01 UTC (rev 26)
+++ tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java 2008-04-22 13:13:08 UTC (rev 27)
@@ -20,6 +20,9 @@
*/
package org.tinytim;
+import java.util.Enumeration;
+import java.util.Properties;
+
import org.tinytim.TopicMapImpl;
import org.tinytim.TopicMapSystemFactoryImpl;
import org.tinytim.TopicMapSystemImpl;
@@ -45,6 +48,17 @@
protected TopicMapSystemImpl _sys;
protected TopicMapSystemFactoryImpl _sysFactory;
+ /**
+ * Returns additional / non-default properties which should be set
+ * to configure the {@link org.tmapi.core.TopicMapSystemFactory}.
+ *
+ * @return Properties instance or <code>null</code> if no properties !=
+ * default properties should be set.
+ */
+ protected Properties getAdditionalProperties() {
+ return null;
+ }
+
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
@@ -52,6 +66,13 @@
protected void setUp() throws Exception {
super.setUp();
_sysFactory = new TopicMapSystemFactoryImpl();
+ Properties properties = getAdditionalProperties();
+ if (properties != null) {
+ for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
+ String name = (String) e.nextElement();
+ _sysFactory.setProperty(name, properties.getProperty(name));
+ }
+ }
_sys = (TopicMapSystemImpl) _sysFactory.newTopicMapSystem();
_tm = (TopicMapImpl) _sys.createTopicMap(_IRI);
_base = _tm.getBaseLocator();
@@ -66,6 +87,7 @@
_sysFactory = null;
_sys = null;
_tm = null;
+ _base = null;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 14:59:07
|
Revision: 26
http://tinytim.svn.sourceforge.net/tinytim/?rev=26&view=rev
Author: lheuer
Date: 2008-04-21 07:59:01 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
- Initial import of the core and some indexes
- CopyUtils is not ready yet
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java
tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java
tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
tinytim/trunk/src/main/java/org/tinytim/TopicNameImpl.java
tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndex.java
Added: tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,133 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.TMAPIException;
+import org.tmapi.core.Topic;
+
+/**
+ * {@link org.tmapi.core.Association} implementation.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class AssociationImpl extends Scoped implements Association,
+ IReifiable, ITyped, IScoped {
+
+ private Set<AssociationRole> _roles;
+ private Topic _type;
+
+ AssociationImpl(TopicMapImpl topicMap) {
+ super(topicMap, null);
+ _roles = topicMap.getCollectionFactory().createSet(2);
+ }
+
+ /**
+ * Adds a role to this association.
+ *
+ * @param role The role to add.
+ */
+ void addRole(AssociationRole role) {
+ AssociationRoleImpl r = (AssociationRoleImpl) role;
+ if (r._parent == this) {
+ return;
+ }
+ assert r._parent == null;
+ _fireEvent(Event.ADD_ROLE, null, r);
+ _roles.add(r);
+ r._parent = this;
+ TopicImpl player = (TopicImpl) r.getPlayer();
+ if (player != null) {
+ player.addRolePlayed(r);
+ }
+ }
+
+ /**
+ * Removes a role from this association.
+ *
+ * @param role The role to remove.
+ */
+ void removeRole(AssociationRole role) {
+ AssociationRoleImpl r = (AssociationRoleImpl) role;
+ if (r._parent != this) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_ROLE, r, null);
+ _roles.remove(role);
+ r._parent = null;
+ TopicImpl player = (TopicImpl) r.getPlayer();
+ if (player != null) {
+ player.removeRolePlayed(r);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Association#createAssociationRole(org.tmapi.core.Topic, org.tmapi.core.Topic)
+ */
+ public AssociationRole createAssociationRole(Topic player, Topic type) {
+ AssociationRoleImpl role = new AssociationRoleImpl(_tm, type, player);
+ addRole(role);
+ return role;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Association#getAssociationRoles()
+ */
+ public Set<AssociationRole> getAssociationRoles() {
+ return Collections.unmodifiableSet(_roles);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Association#getType()
+ */
+ public Topic getType() {
+ return _type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Association#setType(org.tmapi.core.Topic)
+ */
+ public void setType(Topic type) {
+ if (_type == type) {
+ return;
+ }
+ _fireEvent(Event.SET_TYPE, _type, type);
+ _type = type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMapObject#remove()
+ */
+ public void remove() throws TMAPIException {
+ _tm.removeAssociation(this);
+ for (AssociationRole role: new ArrayList<AssociationRole>(_roles)) {
+ role.remove();
+ }
+ _roles = null;
+ super.dispose();
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/AssociationImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.TMAPIException;
+import org.tmapi.core.Topic;
+
+/**
+ * {@link org.tmapi.core.AssociationRole} implementation.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class AssociationRoleImpl extends Typed implements AssociationRole,
+ ITyped {
+
+ private Topic _player;
+
+ AssociationRoleImpl(TopicMapImpl tm, Topic type, Topic player) {
+ super(tm, type, null);
+ _player = player;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.AssociationRole#getAssociation()
+ */
+ public Association getAssociation() {
+ return (Association) _parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.AssociationRole#getPlayer()
+ */
+ public Topic getPlayer() {
+ return _player;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.AssociationRole#setPlayer(org.tmapi.core.Topic)
+ */
+ public void setPlayer(Topic player) {
+ if (_player == player) {
+ return;
+ }
+ _fireEvent(Event.SET_PLAYER, _player, player);
+ if (_player != null) {
+ ((TopicImpl)_player).removeRolePlayed(this);
+ }
+ _player = player;
+ if (player != null) {
+ ((TopicImpl) player).addRolePlayed(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.TopicMapObjectImpl#remove()
+ */
+ public void remove() throws TMAPIException {
+ ((AssociationImpl) _parent).removeRole(this);
+ super.dispose();
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/AssociationRoleImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,171 @@
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.tmapi.core.Locator;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.TopicMapObject;
+
+/**
+ * This class provides methods to copy Topic Maps constructs from one
+ * topic map to another without creating duplicates.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+final class CopyUtils {
+
+ /**
+ * Copies the topics and associations from the <code>source</code> to the
+ * <code>target</code> topic map.
+ *
+ * @param source The topic map to take the topics and associations from.
+ * @param target The topic map which should receive the topics and associations.
+ */
+ public static void copy(TopicMap source, TopicMap target) {
+ _copy((TopicMapImpl) source, (TopicMapImpl) target);
+ }
+
+ /**
+ * @see #copy(TopicMap, TopicMap)
+ */
+ @SuppressWarnings("unchecked")
+ private static void _copy(TopicMapImpl source, TopicMapImpl target) {
+ if (source == null || target == null) {
+ throw new IllegalArgumentException("Neither the source topic map nor the target topic map must be null");
+ }
+ if (source == target) {
+ return;
+ }
+ Map<Topic, Topic> mergeMap = target.getCollectionFactory().createMap();
+ Topic existing = null;
+ TopicMapObject existingConstruct = null;
+ for (Topic topic: source.getTopics()) {
+ for (Iterator<Locator> iter = topic.getSubjectLocators().iterator(); iter.hasNext();) {
+ existing = target.getTopicBySubjectLocator(iter.next());
+ if (existing != null) {
+ _addMerge(topic, existing, mergeMap);
+ }
+ }
+ for (Iterator<Locator> iter = topic.getSubjectIdentifiers().iterator(); iter.hasNext();) {
+ Locator sid = iter.next();
+ existing = target.getTopicBySubjectIdentifier(sid);
+ if (existing != null) {
+ _addMerge(topic, existing, mergeMap);
+ }
+ existingConstruct = target.getObjectByItemIdentifier(sid);
+ if (existingConstruct instanceof Topic) {
+ _addMerge(topic, (Topic) existingConstruct, mergeMap);
+ }
+ }
+ for (Iterator<Locator> iter = topic.getSourceLocators().iterator(); iter.hasNext();) {
+ Locator iid = iter.next();
+ existingConstruct = target.getObjectByItemIdentifier(iid);
+ if (existingConstruct instanceof Topic) {
+ _addMerge(topic, (Topic) existingConstruct, mergeMap);
+ }
+ existing = target.getTopicBySubjectIdentifier(iid);
+ if (existing != null) {
+ _addMerge(topic, existing, mergeMap);
+ }
+ }
+ }
+ if (source.getReifier() != null && target.getReifier() != null) {
+ _addMerge(source.getReifier(), target.getReifier(), mergeMap);
+ }
+ for (Topic topic: source.getTopics()) {
+ if (!mergeMap.containsKey(topic)) {
+ _copyTopic(topic, target, mergeMap);
+ }
+ }
+ for (Topic topic: mergeMap.keySet()) {
+ Topic targetTopic = mergeMap.get(topic);
+ _copyIdentities(topic, targetTopic);
+ _copyTypes(topic, targetTopic, mergeMap);
+ _copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap);
+ }
+ }
+
+ private static Topic _copyTopic(Topic topic, TopicMap target,
+ Map<Topic, Topic> mergeMap) {
+ Topic targetTopic = target.createTopic();
+ _copyIdentities(topic, targetTopic);
+ _copyTypes(topic, targetTopic, mergeMap);
+ _copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap);
+ return targetTopic;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void _copyIdentities(Topic topic, Topic targetTopic) {
+ for(Iterator<Locator> iter = topic.getSubjectIdentifiers().iterator(); iter.hasNext();) {
+ targetTopic.addSubjectIdentifier(iter.next());
+ }
+ for(Iterator<Locator> iter = topic.getSubjectLocators().iterator(); iter.hasNext();) {
+ targetTopic.addSubjectLocator(iter.next());
+ }
+ _copyItemIdentifiers((IConstruct)topic, (IConstruct)targetTopic);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void _copyTypes(Topic topic, Topic targetTopic,
+ Map<Topic, Topic> mergeMap) {
+ for (Iterator<Topic> iter = topic.getTypes().iterator(); iter.hasNext();) {
+ Topic type = iter.next();
+ Topic targetType = mergeMap.get(type);
+ if (targetType == null) {
+ targetType = _copyTopic(type, targetTopic.getTopicMap(), mergeMap);
+ }
+ targetTopic.addType(targetType);
+ }
+ }
+
+ private static void _copyCharacteristics(Topic topic, TopicImpl targetTopic,
+ Map<Topic, Topic> mergeMap) {
+ Map<String, IReifiable> sigs = ((TopicMapImpl) targetTopic.getTopicMap()).getCollectionFactory().<String, IReifiable>createMap();
+ for (Occurrence occ: targetTopic.getOccurrences()) {
+ sigs.put(SignatureGenerator.generateSignature(occ), (IReifiable)occ);
+ }
+ }
+
+ private static void _copyItemIdentifiers(IConstruct source, IConstruct target) {
+ for(Locator iid: source.getItemIdentifiers()) {
+ target.addSourceLocator(iid);
+ }
+ }
+
+ private static void _addMerge(Topic source, Topic target, Map<Topic, Topic> mergeMap) {
+ Topic prevTarget = mergeMap.get(source);
+ if (prevTarget != null) {
+ if (!prevTarget.equals(target)) {
+ MergeUtils.merge(target, prevTarget);
+ }
+ }
+ else {
+ mergeMap.put(source, target);
+ }
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/CopyUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,117 @@
+/*
+ * 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;
+
+import java.util.Collection;
+
+import org.tmapi.core.Locator;
+import org.tmapi.core.Topic;
+
+/**
+ * Implementation of {@link org.tinytim.IDatatypeAwareConstruct}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+abstract class DatatypeAwareConstruct extends Typed implements
+ IDatatypeAwareConstruct, IScoped {
+
+ private String _value;
+ private Locator _resource;
+
+ DatatypeAwareConstruct(TopicMapImpl topicMap, Topic type, String value, Collection<Topic> scope) {
+ super(topicMap, type, scope);
+ _value = value;
+ }
+
+ DatatypeAwareConstruct(TopicMapImpl topicMap, Topic type, Locator value, Collection<Topic> scope) {
+ super(topicMap, type, scope);
+ _resource = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IDatatypeAwareConstruct#getValue2()
+ */
+ public String getValue2() {
+ if (_value != null) {
+ return _value;
+ }
+ return _resource != null ? _resource.getReference() : "";
+ }
+
+ /**
+ *
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ _fireEvent(Event.SET_VALUE, _value, value);
+ _resource = null;
+ _value = value;
+ }
+
+ /**
+ *
+ *
+ * @return
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ /**
+ *
+ *
+ * @return
+ */
+ public Locator getResource() {
+ return _resource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Occurrence#setResource(org.tmapi.core.Locator)
+ */
+ public void setResource(Locator value) {
+ _fireEvent(Event.SET_VALUE, _value, value);
+ _value = null;
+ _resource = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.IDatatypeAwareConstruct#getDatatype()
+ */
+ public Locator getDatatype() {
+ if (_value != null || _resource == null) {
+ return STRING;
+ }
+ return ANY_URI;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.Construct#dispose()
+ */
+ @Override
+ protected void dispose() {
+ _value = null;
+ _resource = null;
+ super.dispose();
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/DatatypeAwareConstruct.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import org.tmapi.core.Locator;
+
+/**
+ * Indicates that a Topic Maps construct has a value and a datatype.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+interface IDatatypeAwareConstruct extends IConstruct {
+
+ static final String _XSD_BASE = "http://www.w3.org/2001/XMLSchema#";
+ static final Locator STRING = new IRI(_XSD_BASE + "string");
+ static final Locator ANY_URI = new IRI(_XSD_BASE + "anyURI");
+
+ /**
+ * The value of this Topic Maps construct.
+ *
+ * This method differs from TMAPI: This method MUST return the value OR the
+ * locator as string. This method should be removed if we have TMAPI 2.0
+ * (maybe the whole interface should be removed).
+ * Currently, the {@link SignatureGenerator} needs it.
+ *
+ * @return The value.
+ */
+ public String getValue2();
+
+ /**
+ * Returns the datatype of this Topic Maps construct.
+ *
+ * @return The datatype.
+ */
+ public Locator getDatatype();
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,250 @@
+/*
+ * 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;
+
+import java.util.Map;
+
+import org.tmapi.core.DuplicateSourceLocatorException;
+import org.tmapi.core.Locator;
+import org.tmapi.core.ModelConstraintException;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicsMustMergeException;
+
+/**
+ * The identity manager takes care about the TMDM identity constraints and
+ * provides an index to get Topic Maps constructs by their identity.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+final class IdentityManager {
+
+ private long _nextId;
+ private Map<Locator, Topic> _sid2Topic;
+ private Map<Locator, Topic> _slo2Topic;
+ private Map<Locator, IConstruct> _iid2Construct;
+ private Map<String, IConstruct> _id2Construct;
+
+ IdentityManager(TopicMapImpl tm) {
+ ICollectionFactory collFactory = tm.getCollectionFactory();
+ _id2Construct = collFactory.<String, IConstruct>createMap();
+ _sid2Topic = collFactory.<Locator, Topic>createMap();
+ _slo2Topic = collFactory.<Locator, Topic>createMap();
+ _iid2Construct = collFactory.<Locator, IConstruct>createMap();
+ _subscribe(tm);
+ _register(tm);
+ }
+
+ private void _subscribe(IEventPublisher publisher) {
+ IEventHandler handler = new TopicMapsConstructAddHandler();
+ publisher.subscribe(Event.ADD_TOPIC, handler);
+ publisher.subscribe(Event.ADD_ASSOCIATION, handler);
+ publisher.subscribe(Event.ADD_ROLE, handler);
+ publisher.subscribe(Event.ADD_OCCURRENCE, handler);
+ publisher.subscribe(Event.ADD_NAME, handler);
+ publisher.subscribe(Event.ADD_VARIANT, handler);
+ handler = new TopicMapsConstructRemoveHandler();
+ publisher.subscribe(Event.REMOVE_TOPIC, handler);
+ publisher.subscribe(Event.REMOVE_ASSOCIATION, handler);
+ publisher.subscribe(Event.REMOVE_ROLE, handler);
+ publisher.subscribe(Event.REMOVE_OCCURRENCE, handler);
+ publisher.subscribe(Event.REMOVE_NAME, handler);
+ publisher.subscribe(Event.REMOVE_VARIANT, handler);
+ handler = new AddItemIdentifierHandler();
+ publisher.subscribe(Event.ADD_IID, handler);
+ handler = new RemoveItemIdentifierHandler();
+ publisher.subscribe(Event.REMOVE_IID, handler);
+ handler = new AddSubjectIdentifierHandler();
+ publisher.subscribe(Event.ADD_SID, handler);
+ handler = new RemoveSubjectIdentifierHandler();
+ publisher.subscribe(Event.REMOVE_SID, handler);
+ handler = new AddSubjectLocatorHandler();
+ publisher.subscribe(Event.ADD_SLO, handler);
+ handler = new RemoveSubjectLocatorHandler();
+ publisher.subscribe(Event.REMOVE_SLO, handler);
+ handler = new ReifierConstraintHandler();
+ publisher.subscribe(Event.SET_REIFIER, handler);
+ }
+
+ private void _register(IConstruct construct) {
+ Construct c = (Construct) construct;
+ if (c._id == null) {
+ c._id = "" + _nextId++;
+ }
+ if (!_id2Construct.containsKey(c)) {
+ _id2Construct.put(c._id, c);
+ }
+ }
+
+ private void _unregister(IConstruct construct) {
+ _id2Construct.remove(((Construct) construct)._id);
+ }
+
+ public IConstruct getConstructById(String id) {
+ return _id2Construct.get(id);
+ }
+
+ public Topic getTopicBySubjectIdentifier(Locator sid) {
+ return _sid2Topic.get(sid);
+ }
+
+ public Topic getTopicBySubjectLocator(Locator slo) {
+ return _slo2Topic.get(slo);
+ }
+
+ public IConstruct getConstructByItemIdentifier(Locator iid) {
+ return _iid2Construct.get(iid);
+ }
+
+ public void close() {
+ _id2Construct = null;
+ _iid2Construct = null;
+ _sid2Topic = null;
+ _slo2Topic = null;
+ }
+
+ private class TopicMapsConstructAddHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ _register((IConstruct)newValue);
+ }
+ }
+
+ private class TopicMapsConstructRemoveHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ _unregister((IConstruct)oldValue);
+ }
+ }
+
+ /**
+ * Checks identity constraints and adds the Topic Maps construct and the
+ * item identifier to the index.
+ */
+ private class AddItemIdentifierHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Locator iid = (Locator) newValue;
+ IConstruct existing = _iid2Construct.get(iid);
+ if (existing != null) {
+ if (existing != sender) {
+ if (sender instanceof Topic && existing instanceof Topic) {
+ throw new TopicsMustMergeException((Topic) sender, (Topic) existing, "A topic with the same item identifier '" + iid.getReference() + "' exists");
+ }
+ throw new DuplicateSourceLocatorException(sender, existing, iid, "A Topic Maps construct with the same item identifier '" + iid.getReference() + "' exists");
+ }
+ }
+ if (sender instanceof Topic) {
+ Topic existingTopic = _sid2Topic.get(iid);
+ if (existingTopic != null && existingTopic != sender) {
+ throw new TopicsMustMergeException((Topic) sender, existingTopic, "A topic with a subject identifier equals to the item identifier '" + iid.getReference() + "' exists");
+ }
+ }
+ _iid2Construct.put(iid, sender);
+ }
+ }
+
+ /**
+ * Removes an item identifier and its Topic Maps constructs from the index.
+ */
+ private class RemoveItemIdentifierHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ _iid2Construct.remove(oldValue);
+ }
+ }
+
+ /**
+ * Checks identity constraints and adds the topic and the
+ * subject identifier to the index.
+ */
+ private class AddSubjectIdentifierHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Topic topic = (Topic) sender;
+ Locator sid = (Locator) newValue;
+ IConstruct existing = (IConstruct) _sid2Topic.get(sid);
+ if (existing != null && existing != topic) {
+ throw new TopicsMustMergeException(topic, (Topic) existing, "A topic with the same subject identifier '" + sid.getReference() + "' exists");
+ }
+ existing = _iid2Construct.get(sid);
+ if (existing != null && existing instanceof Topic && existing != topic) {
+ throw new TopicsMustMergeException(topic, (Topic) existing, "A topic with an item identifier equals to the subject identifier '" + sid.getReference() + "' exists");
+ }
+ _sid2Topic.put(sid, topic);
+ }
+ }
+
+ /**
+ * Removes a subject identifier and its topic from the index.
+ */
+ private class RemoveSubjectIdentifierHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Locator slo = (Locator) oldValue;
+ _sid2Topic.remove(slo);
+ }
+ }
+
+ /**
+ * Checks identity constraints and adds the topic and the
+ * subject locator to the index.
+ */
+ private class AddSubjectLocatorHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Topic topic = (Topic) sender;
+ Locator slo = (Locator) newValue;
+ Topic existing = _slo2Topic.get(slo);
+ if (existing != null && existing != topic) {
+ throw new TopicsMustMergeException(topic, existing, "A topic with the same subject locator '" + slo.getReference() + "' exists");
+ }
+ _slo2Topic.put(slo, topic);
+ }
+ }
+
+ /**
+ * Removes a subject locator and its topic from the index.
+ */
+ private class RemoveSubjectLocatorHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ Locator slo = (Locator) oldValue;
+ _slo2Topic.remove(slo);
+ }
+ }
+
+ /**
+ * Checks if setting the reifier is allowed.
+ */
+ private static class ReifierConstraintHandler implements IEventHandler {
+ public void handleEvent(Event evt, IConstruct sender, Object oldValue,
+ Object newValue) {
+ if (newValue == null) {
+ return;
+ }
+ IReifiable currentReified = ((TopicImpl) newValue)._reified;
+ if (currentReified != null && currentReified != sender) {
+ throw new ModelConstraintException(sender, "The topic reifies another Topic Maps construct");
+ }
+ }
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/IdentityManager.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,339 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.tinytim.index.IScopedIndex;
+import org.tinytim.index.ITypeInstanceIndex;
+import org.tinytim.index.IndexManager;
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.Locator;
+import org.tmapi.core.ModelConstraintException;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.TMAPIException;
+import org.tmapi.core.TMAPIRuntimeException;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.TopicName;
+import org.tmapi.core.Variant;
+
+/**
+ * This class does provides functions to merge topic maps and topics.
+ *
+ * This class relies on the implementation of tinyTiM, if the implementation
+ * changes, check the <code>==</code> comparisons.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+final class MergeUtils {
+
+ private MergeUtils() {
+ // noop.
+ }
+
+ /**
+ * Merges two topic maps.
+ *
+ * @param source The source topic map.
+ * @param target The target topic map which receives all
+ * topics / associations from <code>source</code>.
+ */
+ public static void merge(TopicMap source, TopicMap target) {
+ CopyUtils.copy(source, target);
+ }
+
+ /**
+ * Merges two topics.
+ *
+ * The topics MUST belong to the same topic map. The <code>source</code>
+ * will be removed from the topic map and <code>target</code> takes all
+ * characteristics of the <code>source</code>.
+ *
+ * @param source The source topic.
+ * @param target The target topic which receives all characteristics from
+ * <code>source</code>.
+ */
+ public static void merge(Topic source, Topic target) {
+ _merge((TopicImpl) source, (TopicImpl) target);
+ }
+
+ /**
+ * @see #merge(Topic, Topic)
+ */
+ private static void _merge(TopicImpl source, TopicImpl target) {
+ if (source == null || target == null) {
+ throw new IllegalArgumentException("Neither the source topic nor the target topic must be null");
+ }
+ if (source == target) {
+ return;
+ }
+ if (source.getTopicMap() != target.getTopicMap()) {
+ throw new IllegalArgumentException("The topics must belong to the same topic map");
+ }
+ IReifiable sourceReifiable = source._reified;
+ if (sourceReifiable != null && target._reified != null) {
+ // This should be enforced by the model
+ assert sourceReifiable != target._reified;
+ throw new ModelConstraintException(target, "The topics cannot be merged. They reify different Topic Maps constructs");
+ }
+ _moveItemIdentifiers((IConstruct)source, (IConstruct)target);
+ if (sourceReifiable != null) {
+ sourceReifiable.setReifier(target);
+ }
+ List<Locator> locs = new ArrayList<Locator>(source.getSubjectIdentifiers());
+ for (Locator sid: locs) {
+ source.removeSubjectIdentifier(sid);
+ target.addSubjectIdentifier(sid);
+ }
+ locs = new ArrayList<Locator>(source.getSubjectLocators());
+ for (Locator slo: locs) {
+ source.removeSubjectLocator(slo);
+ target.addSubjectLocator(slo);
+ }
+ _replaceTopics(source, target);
+ for(Topic type: source.getTypes()) {
+ target.addType(type);
+ }
+ Map<String, IReifiable> sigs = ((TopicMapImpl) source.getTopicMap()).getCollectionFactory().<String, IReifiable>createMap();
+ for (Occurrence occ: target.getOccurrences()) {
+ sigs.put(SignatureGenerator.generateSignature(occ), (IReifiable)occ);
+ }
+ IReifiable existing = null;
+ for (Occurrence occ: new ArrayList<Occurrence>(source.getOccurrences())) {
+ existing = sigs.get(SignatureGenerator.generateSignature(occ));
+ if (existing != null) {
+ handleExistingConstruct((IReifiable) occ, existing);
+ removeConstruct((IConstruct)occ);
+ }
+ else {
+ source.removeOccurrence(occ);
+ target.addOccurrence(occ);
+ }
+ }
+ sigs.clear();
+ for (TopicName name: target.getTopicNames()) {
+ sigs.put(SignatureGenerator.generateSignature(name), (IReifiable) name);
+ }
+ for (TopicName name: new ArrayList<TopicName>(source.getTopicNames())) {
+ existing = sigs.get(SignatureGenerator.generateSignature(name));
+ if (existing != null) {
+ handleExistingConstruct((IReifiable) name, existing);
+ moveVariants((TopicNameImpl)name, (TopicNameImpl) existing);
+ removeConstruct((IConstruct) name);
+ }
+ else {
+ source.removeName(name);
+ target.addName(name);
+ }
+ }
+ sigs.clear();
+ for (AssociationRole role: target.getRolesPlayed()) {
+ Association parent = role.getAssociation();
+ sigs.put(SignatureGenerator.generateSignature(parent), (IReifiable) parent);
+ }
+ for (AssociationRole role: new ArrayList<AssociationRole>(source.getRolesPlayed())) {
+ role.setPlayer(target);
+ Association parent = role.getAssociation();
+ existing = sigs.get(SignatureGenerator.generateSignature(parent));
+ if (existing != null) {
+ handleExistingConstruct((IReifiable)parent, existing);
+ _moveRoleCharacteristics(parent, (Association)existing);
+ removeConstruct((IConstruct)parent);
+ }
+ }
+ removeConstruct(source);
+ }
+
+ /**
+ * Removes a Topic Maps construct.
+ *
+ * If the construct is not removable, a runtime exception is thrown.
+ *
+ * @param construct The construct to remove.
+ */
+ static void removeConstruct(IConstruct construct) {
+ try {
+ construct.remove();
+ }
+ catch (TMAPIException ex) {
+ throw new TMAPIRuntimeException("Unexpected exception while Topic Maps construct removal", ex);
+ }
+ }
+
+ /**
+ * Moves role item identifiers and reifier from the <code>source</code> to
+ * the <code>target</code>'s equivalent role.
+ *
+ * @param source The association to remove the characteristics from.
+ * @param target The association which takes the role characteristics.
+ */
+ @SuppressWarnings("unchecked")
+ private static void _moveRoleCharacteristics(Association source, Association target) {
+ Map<String, AssociationRole> sigs = ((TopicMapImpl) target.getTopicMap()).getCollectionFactory().<String, AssociationRole>createMap();
+ for (AssociationRole role: ((AssociationImpl)target).getAssociationRoles()) {
+ sigs.put(SignatureGenerator.generateSignature(role), role);
+ }
+ List<AssociationRole> roles = new ArrayList<AssociationRole>(source.getAssociationRoles());
+ for (AssociationRole role: roles) {
+ handleExistingConstruct((IReifiable)role, (IReifiable)sigs.get(SignatureGenerator.generateSignature(role)));
+ removeConstruct((IConstruct)role);
+ }
+ }
+
+ /**
+ * Moves the variants from <code>source</code> to <code>target</code>.
+ *
+ * @param source The name to take the variants from.
+ * @param target The target to add the variants to.
+ */
+ static void moveVariants(TopicNameImpl source, TopicNameImpl target) {
+ Map<String, Variant> sigs = ((TopicMapImpl) target.getTopicMap()).getCollectionFactory().<String, Variant>createMap();
+ for (Variant var: target.getVariants()) {
+ sigs.put(SignatureGenerator.generateSignature(var), var);
+ }
+ Variant existing = null;
+ for (Variant var: new ArrayList<Variant>(source.getVariants())) {
+ existing = sigs.get(SignatureGenerator.generateSignature(var));
+ if (existing != null) {
+ handleExistingConstruct((IReifiable) var, (IReifiable) existing);
+ removeConstruct((IConstruct)var);
+ }
+ else {
+ source.removeVariant(var);
+ target.addVariant(var);
+ }
+ }
+ }
+
+ /**
+ * Moves the item identifiers and reifier from <code>source</code> to
+ * <code>target</code>.
+ *
+ * If the <code>source</code> is reified, the <code>target</code>'s reifier
+ * is set to the source reifier unless the target is also reified.
+ * If <code>source</code> and <code>target</code> are reified, the reifiers
+ * are merged.
+ *
+ * @param source The source Topic Maps construct.
+ * @param target The target Topic Maps construct.
+ */
+ static void handleExistingConstruct(IReifiable source, IReifiable target) {
+ _moveItemIdentifiers(source, target);
+ if (source.getReifier() == null) {
+ return;
+ }
+ if (target.getReifier() != null) {
+ Topic reifier = source.getReifier();
+ source.setReifier(null);
+ merge(reifier, target.getReifier());
+ }
+ else {
+ Topic reifier = source.getReifier();
+ source.setReifier(null);
+ target.setReifier(reifier);
+ }
+ }
+
+ /**
+ * Replaces the <code>source</code> topic with the <code>replacement</code>
+ * everywhere where <code>source</code> is used as type or theme.
+ *
+ * @param source The topic to replace.
+ * @param replacement The topic which replaces the <code>source</code>.
+ */
+ private static void _replaceTopics(Topic source, Topic replacement) {
+ TopicMapImpl tm = (TopicMapImpl) replacement.getTopicMap();
+ IndexManager idxMan = tm.getIndexManager();
+ ITypeInstanceIndex typeInstanceIndex = idxMan.getTypeInstanceIndex();
+ if (!typeInstanceIndex.isAutoUpdated()) {
+ typeInstanceIndex.reindex();
+ }
+ List<Topic> topics = new ArrayList<Topic>(typeInstanceIndex.getTopics(source));
+ for (Topic topic: topics) {
+ topic.removeType(source);
+ topic.addType(replacement);
+ }
+ Collection<ITyped> typed = new ArrayList<ITyped>(typeInstanceIndex.getAssociations(source));
+ _replaceTopicAsType(typed, replacement);
+ typed = new ArrayList<ITyped>(typeInstanceIndex.getRoles(source));
+ _replaceTopicAsType(typed, replacement);
+ typed = new ArrayList<ITyped>(typeInstanceIndex.getOccurrences(source));
+ _replaceTopicAsType(typed, replacement);
+ typed = new ArrayList<ITyped>(typeInstanceIndex.getNames(source));
+ _replaceTopicAsType(typed, replacement);
+ typeInstanceIndex.close();
+ IScopedIndex scopedIndex = idxMan.getScopedIndex();
+ if (!scopedIndex.isAutoUpdated()) {
+ scopedIndex.reindex();
+ }
+ Collection<IScoped> scoped = new ArrayList<IScoped>(scopedIndex.getAssociationsByTheme(source));
+ _replaceTopicAsTheme(scoped, source, replacement);
+ scoped = new ArrayList<IScoped>(scopedIndex.getOccurrencesByTheme(source));
+ _replaceTopicAsTheme(scoped, source, replacement);
+ scoped = new ArrayList<IScoped>(scopedIndex.getNamesByTheme(source));
+ _replaceTopicAsTheme(scoped, source, replacement);
+ scoped = new ArrayList<IScoped>(scopedIndex.getVariantsByTheme(source));
+ _replaceTopicAsTheme(scoped, source, replacement);
+ scopedIndex.close();
+ }
+
+ /**
+ * Sets <code>replacement</code> as type of each typed Topic Maps construct.
+ *
+ * @param typedConstructs A collection of typed constructs.
+ * @param replacement The type.
+ */
+ private static void _replaceTopicAsType(Collection<ITyped> typedConstructs,
+ Topic replacement) {
+ for (ITyped typed: typedConstructs) {
+ typed.setType(replacement);
+ }
+ }
+
+ private static void _replaceTopicAsTheme(Collection<IScoped> scopedCollection,
+ Topic oldTheme, Topic newTheme) {
+ for (IScoped scoped: scopedCollection) {
+ scoped.removeTheme(oldTheme);
+ scoped.addTheme(newTheme);
+ }
+ }
+
+ /**
+ * Moves the item identifiers from <code>source</code> to <code>target</code>.
+ *
+ * @param source The source to remove the item identifiers from.
+ * @param target The target which get the item identifiers.
+ */
+ private static void _moveItemIdentifiers(IConstruct source, IConstruct target) {
+ List<Locator> iids = new ArrayList<Locator>(source.getItemIdentifiers());
+ for (Locator iid: iids) {
+ source.removeItemIdentifier(iid);
+ target.addItemIdentifier(iid);
+ }
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.util.Collection;
+
+import org.tmapi.core.Locator;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.TMAPIException;
+import org.tmapi.core.Topic;
+
+/**
+ * {@link org.tmapi.core.Occurrence} implementation.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class OccurrenceImpl extends DatatypeAwareConstruct implements
+ Occurrence, ITyped {
+
+ OccurrenceImpl(TopicMapImpl topicMap, Topic type, String value, Collection<Topic> scope) {
+ super(topicMap, type, value, scope);
+ }
+
+ OccurrenceImpl(TopicMapImpl topicMap, Topic type, Locator value, Collection<Topic> scope) {
+ super(topicMap, type, value, scope);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Occurrence#getTopic()
+ */
+ public Topic getTopic() {
+ return (Topic) _parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMapObject#remove()
+ */
+ public void remove() throws TMAPIException {
+ ((TopicImpl) _parent).removeOccurrence(this);
+ super.dispose();
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/OccurrenceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Added: tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicImpl.java 2008-04-21 14:59:01 UTC (rev 26)
@@ -0,0 +1,317 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.Locator;
+import org.tmapi.core.MergeException;
+import org.tmapi.core.ModelConstraintException;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicInUseException;
+import org.tmapi.core.TopicMapObject;
+import org.tmapi.core.TopicName;
+
+/**
+ * {@link org.tmapi.core.Topic} implementation.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class TopicImpl extends Construct implements Topic {
+
+ private Set<AssociationRole> _rolesPlayed;
+ IReifiable _reified;
+ private Set<Topic> _types;
+ private Set<Locator> _sids;
+ private Set<Locator> _slos;
+ private Set<Occurrence> _occs;
+ private Set<TopicName> _names;
+
+ TopicImpl(TopicMapImpl topicMap) {
+ super(topicMap);
+ ICollectionFactory collFactory = topicMap.getCollectionFactory();
+ _sids = collFactory.<Locator>createSet(2);
+ _occs = collFactory.<Occurrence>createSet(2);
+ _names = collFactory.<TopicName>createSet(2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getSubjectIdentifiers()
+ */
+ public Set<Locator> getSubjectIdentifiers() {
+ return Collections.unmodifiableSet(_sids);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#addSubjectIdentifier(org.tmapi.core.Locator)
+ */
+ public void addSubjectIdentifier(Locator sid) throws MergeException {
+ if (_sids.contains(sid)) {
+ return;
+ }
+ _fireEvent(Event.ADD_SID, null, sid);
+ _sids.add(sid);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#removeSubjectIdentifier(org.tmapi.core.Locator)
+ */
+ public void removeSubjectIdentifier(Locator sid) {
+ if (!_sids.contains(sid)) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_SID, sid, null);
+ _sids.remove(sid);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getSubjectLocators()
+ */
+ public Set<Locator> getSubjectLocators() {
+ return _slos == null ? Collections.<Locator>emptySet()
+ : Collections.unmodifiableSet(_slos);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#addSubjectLocator(org.tmapi.core.Locator)
+ */
+ public void addSubjectLocator(Locator slo) throws MergeException,
+ ModelConstraintException {
+ if (_slos != null && _sids.contains(slo)) {
+ return;
+ }
+ _fireEvent(Event.ADD_SLO, null, slo);
+ if (_slos == null) {
+ _slos = _tm.getCollectionFactory().createSet();
+ }
+ _slos.add(slo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#removeSubjectLocator(org.tmapi.core.Locator)
+ */
+ public void removeSubjectLocator(Locator slo) {
+ if (_slos == null || !_slos.contains(slo)) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_SLO, slo, null);
+ _sids.remove(slo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getOccurrences()
+ */
+ public Set<Occurrence> getOccurrences() {
+ return Collections.unmodifiableSet(_occs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#createOccurrence(java.lang.String, org.tmapi.core.Topic, java.util.Collection)
+ */
+ @SuppressWarnings("unchecked")
+ public Occurrence createOccurrence(String value, Topic type, Collection scope) {
+ Occurrence occ = new OccurrenceImpl(_tm, type, value, scope);
+ addOccurrence(occ);
+ return occ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#createOccurrence(org.tmapi.core.Locator, org.tmapi.core.Topic, java.util.Collection)
+ */
+ @SuppressWarnings("unchecked")
+ public Occurrence createOccurrence(Locator value, Topic type, Collection scope) {
+ Occurrence occ = new OccurrenceImpl(_tm, type, value, scope);
+ addOccurrence(occ);
+ return occ;
+ }
+
+ /**
+ * Adds an occurrence to the [occurrences] property.
+ *
+ * @param occ The occurrence to add.
+ */
+ void addOccurrence(Occurrence occ) {
+ OccurrenceImpl o = (OccurrenceImpl) occ;
+ if (o._parent == this) {
+ return;
+ }
+ _fireEvent(Event.ADD_OCCURRENCE, null, o);
+ o._parent = this;
+ _occs.add(o);
+ }
+
+ /**
+ * Removes an occurrence from the [occurrences] property.
+ *
+ * @param occ The occurrence to remove.
+ */
+ void removeOccurrence(Occurrence occ) {
+ OccurrenceImpl o = (OccurrenceImpl) occ;
+ if (o._parent != this) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_OCCURRENCE, o, null);
+ _occs.remove(o);
+ o._parent = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getTopicNames()
+ */
+ public Set<TopicName> getTopicNames() {
+ return Collections.unmodifiableSet(_names);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#createTopicName(java.lang.String, java.util.Collection)
+ */
+ @SuppressWarnings("unchecked")
+ public TopicName createTopicName(String value, Collection scope)
+ throws MergeException {
+ return createTopicName(value, null, scope);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#createTopicName(java.lang.String, org.tmapi.core.Topic, java.util.Collection)
+ */
+ @SuppressWarnings("unchecked")
+ public TopicName createTopicName(String value, Topic type, Collection scope)
+ throws UnsupportedOperationException, MergeException {
+ TopicNameImpl name = new TopicNameImpl(_tm, type, value, scope);
+ addName(name);
+ return name;
+ }
+
+ void addName(TopicName name) {
+ TopicNameImpl n = (TopicNameImpl) name;
+ if (n._parent == this) {
+ return;
+ }
+ assert n._parent == null;
+ _fireEvent(Event.ADD_NAME, null, n);
+ n._parent = this;
+ _names.add(n);
+ }
+
+ void removeName(TopicName name) {
+ TopicNameImpl n = (TopicNameImpl) name;
+ if (n._parent != this) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_NAME, n, null);
+ _names.remove(n);
+ n._parent = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getReified()
+ */
+ public Set<TopicMapObject> getReified() {
+ return _reified != null ? Collections.<TopicMapObject>singleton(_reified)
+ : Collections.<TopicMapObject>emptySet();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getRolesPlayed()
+ */
+ public Set<AssociationRole> getRolesPlayed() {
+ return _rolesPlayed == null ? Collections.<AssociationRole>emptySet()
+ : Collections.unmodifiableSet(_rolesPlayed);
+ }
+
+ void addRolePlayed(AssociationRole role) {
+ if (_rolesPlayed == null) {
+ _rolesPlayed = _tm.getCollectionFactory().createSet(4);
+ }
+ _rolesPlayed.add(role);
+ }
+
+ void removeRolePlayed(AssociationRole role) {
+ if (_rolesPlayed == null) {
+ return;
+ }
+ _rolesPlayed.remove(role);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#getTypes()
+ */
+ public Set<Topic> getTypes() {
+ return _types == null ? Collections.<Topic>emptySet()
+ : Collections.unmodifiableSet(_types);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#addType(org.tmapi.core.Topic)
+ */
+ public void addType(Topic type) {
+ if (_types != null && _types.contains(type)) {
+ return;
+ }
+ _fireEvent(Event.ADD_TYPE, null, type);
+ if (_types == null) {
+ _types = _tm.getCollectionFactory().createSet();
+ }
+ _types.add(type);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tmapi.core.Topic#removeType(org.tmapi.core.Topic)
+ */
+ public void removeType(Topic type) {
+ if (_types ==...
[truncated message content] |
|
From: <lh...@us...> - 2008-04-21 14:33:15
|
Revision: 25
http://tinytim.svn.sourceforge.net/tinytim/?rev=25&view=rev
Author: lheuer
Date: 2008-04-21 07:33:22 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Inserted break to find supported features faster
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 14:31:49 UTC (rev 24)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 14:33:22 UTC (rev 25)
@@ -126,9 +126,10 @@
reportFeatureNotRecognized(featureName);
}
FeatureInfo feature = null;
- for (FeatureInfo feature_: _FEATURES) {
- if (feature_.name.equals(featureName)) {
- feature = feature_;
+ for (FeatureInfo feat: _FEATURES) {
+ if (feat.name.equals(featureName)) {
+ feature = feat;
+ break;
}
}
if (feature.fixed && feature.defaultValue != enabled) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 14:31:49
|
Revision: 24
http://tinytim.svn.sourceforge.net/tinytim/?rev=24&view=rev
Author: lheuer
Date: 2008-04-21 07:31:49 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Made ITyped public due to issues with the indexes
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/ITyped.java
Modified: tinytim/trunk/src/main/java/org/tinytim/ITyped.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/ITyped.java 2008-04-21 14:02:48 UTC (rev 23)
+++ tinytim/trunk/src/main/java/org/tinytim/ITyped.java 2008-04-21 14:31:49 UTC (rev 24)
@@ -30,7 +30,7 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-interface ITyped extends IConstruct {
+public interface ITyped extends IConstruct {
/**
* Returns the type of the construct.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 14:03:13
|
Revision: 23
http://tinytim.svn.sourceforge.net/tinytim/?rev=23&view=rev
Author: lheuer
Date: 2008-04-21 07:02:48 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Added TopicUtils, updated TopicMerge test
Modified Paths:
--------------
tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
Added: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-04-21 14:02:48 UTC (rev 23)
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import org.tinytim.index.IScopedIndex;
+import org.tinytim.index.ITypeInstanceIndex;
+import org.tinytim.index.IndexManager;
+import org.tmapi.core.Topic;
+
+/**
+ * This class provides utility functions for {@link org.tmapi.core.Topic}s.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public final class TopicUtils {
+
+ private TopicUtils() {
+ // noop.
+ }
+
+ /**
+ * Returns if the <code>topic</code> is removable.
+ *
+ * A topic is removable iff it plays no role, is not used as type of
+ * a typed Topic Maps construct, is not not used as theme of a scoped
+ * Topic Maps construct and iff it is not used reifier.
+ *
+ * @param topic The topic to check.
+ * @return <code>true</code> if the topic has no dependencies,
+ * otherwise <code>false</code>.
+ */
+ public static boolean isRemovable(Topic topic) {
+ if (((TopicImpl) topic)._reified != null) {
+ return false;
+ }
+ if (!topic.getRolesPlayed().isEmpty()) {
+ return false;
+ }
+ IndexManager idxMan = ((TopicMapImpl) topic.getTopicMap()).getIndexManager();
+ ITypeInstanceIndex typeInstanceIdx = idxMan.getTypeInstanceIndex();
+ if (!typeInstanceIdx.isAutoUpdated()) {
+ typeInstanceIdx.reindex();
+ }
+ if (!typeInstanceIdx.getAssociations(topic).isEmpty()
+ || !typeInstanceIdx.getRoles(topic).isEmpty()
+ || !typeInstanceIdx.getOccurrences(topic).isEmpty()
+ || !typeInstanceIdx.getNames(topic).isEmpty()) {
+ return false;
+ }
+ IScopedIndex scopedIdx = idxMan.getScopedIndex();
+ if (!scopedIdx.isAutoUpdated()) {
+ scopedIdx.reindex();
+ }
+ if (!scopedIdx.getAssociationsByTheme(topic).isEmpty()
+ || !scopedIdx.getOccurrencesByTheme(topic).isEmpty()
+ || !scopedIdx.getNamesByTheme(topic).isEmpty()
+ || !scopedIdx.getVariantsByTheme(topic).isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 13:55:44 UTC (rev 22)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 14:02:48 UTC (rev 23)
@@ -26,6 +26,7 @@
import org.tmapi.core.ModelConstraintException;
import org.tmapi.core.Topic;
import org.tmapi.core.TopicName;
+import org.tmapi.core.Variant;
/**
* Tests merging of topics.
@@ -156,4 +157,28 @@
topic1.mergeIn(topic2);
assertEquals(2, topic1.getTopicNames().size());
}
+
+ /**
+ * Tests if merging detects duplicate names and moves the variants.
+ */
+ public void testDuplicateSuppressionName2() {
+ Topic topic1 = _tm.createTopic();
+ Topic topic2 = _tm.createTopic();
+ TopicName name1 = topic1.createTopicName("tinyTiM", null, null);
+ TopicName name2 = topic2.createTopicName("tinyTiM", null, null);
+ Variant var = name2.createVariant("tiny", null);
+ assertEquals(1, topic1.getTopicNames().size());
+ assertTrue(topic1.getTopicNames().contains(name1));
+ assertEquals(0, name1.getVariants().size());
+ assertEquals(1, topic2.getTopicNames().size());
+ assertTrue(topic2.getTopicNames().contains(name2));
+ assertEquals(1, name2.getVariants().size());
+ assertTrue(name2.getVariants().contains(var));
+ topic1.mergeIn(topic2);
+ assertEquals(1, topic1.getTopicNames().size());
+ TopicName tmpName = (TopicName) topic1.getTopicNames().iterator().next();
+ assertEquals(1, tmpName.getVariants().size());
+ Variant tmpVar = (Variant) tmpName.getVariants().iterator().next();
+ assertEquals("tiny", tmpVar.getValue());
+ }
}
Added: tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java 2008-04-21 14:02:48 UTC (rev 23)
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.AssociationRole;
+import org.tmapi.core.Topic;
+
+/**
+ * Tests against the {@link TopicUtils}.
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestTopicUtils extends TinyTimTestCase {
+
+ /**
+ * Tests if a topic is considered as 'removable'.
+ */
+ public void testRemovable() {
+ Topic topic = _tm.createTopic();
+ assertTrue(TopicUtils.isRemovable(topic));
+ Association assoc = _tm.createAssociation();
+ // Type
+ assoc.setType(topic);
+ assertFalse(TopicUtils.isRemovable(topic));
+ assoc.setType(null);
+ assertTrue(TopicUtils.isRemovable(topic));
+ // Role played
+ AssociationRole role = assoc.createAssociationRole(topic, _tm.createTopic());
+ assertFalse(TopicUtils.isRemovable(topic));
+ role.setPlayer(null);
+ assertTrue(TopicUtils.isRemovable(topic));
+ // Theme
+ assoc.addScopingTopic(topic);
+ assertFalse(TopicUtils.isRemovable(topic));
+ assoc.removeScopingTopic(topic);
+ assertTrue(TopicUtils.isRemovable(topic));
+ // Reifier
+ ((IReifiable) assoc).setReifier(topic);
+ assertFalse(TopicUtils.isRemovable(topic));
+ ((IReifiable) assoc).setReifier(null);
+ assertTrue(TopicUtils.isRemovable(topic));
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 13:55:55
|
Revision: 22
http://tinytim.svn.sourceforge.net/tinytim/?rev=22&view=rev
Author: lheuer
Date: 2008-04-21 06:55:44 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
LGPL 2.1 lic added
Added Paths:
-----------
tinytim/trunk/src/LICENSE.txt
Added: tinytim/trunk/src/LICENSE.txt
===================================================================
--- tinytim/trunk/src/LICENSE.txt (rev 0)
+++ tinytim/trunk/src/LICENSE.txt 2008-04-21 13:55:44 UTC (rev 22)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 13:52:44
|
Revision: 21
http://tinytim.svn.sourceforge.net/tinytim/?rev=21&view=rev
Author: lheuer
Date: 2008-04-21 06:51:38 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Moved main and test into the right directory
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/Event.java
tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java
tinytim/trunk/src/main/java/org/tinytim/IConstruct.java
tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java
tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java
tinytim/trunk/src/main/java/org/tinytim/IRI.java
tinytim/trunk/src/main/java/org/tinytim/IReifiable.java
tinytim/trunk/src/main/java/org/tinytim/IScoped.java
tinytim/trunk/src/main/java/org/tinytim/ITyped.java
tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java
tinytim/trunk/src/main/java/org/tinytim/Property.java
tinytim/trunk/src/main/java/org/tinytim/Scoped.java
tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java
tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java
tinytim/trunk/src/main/java/org/tinytim/Typed.java
tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java
tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java
tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java
tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
tinytim/trunk/src/test/java/org/tinytim/TestScoped.java
tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java
tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java
tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java
tinytim/trunk/src/test/java/org/tinytim/TestTyped.java
tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java
Added Paths:
-----------
tinytim/trunk/src/main/
tinytim/trunk/src/main/java/
tinytim/trunk/src/test/
tinytim/trunk/src/test/java/
Removed Paths:
-------------
tinytim/trunk/main/
tinytim/trunk/src/main/java/
tinytim/trunk/src/test/java/
tinytim/trunk/test/
Copied: tinytim/trunk/src/main (from rev 12, tinytim/trunk/main)
Copied: tinytim/trunk/src/main/java (from rev 20, tinytim/trunk/main/java)
Modified: tinytim/trunk/src/main/java/org/tinytim/Event.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/Event.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/Event.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* 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:$
+ * @version $Rev$ - $Date$
*/
public enum Event {
Modified: tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* Implementations of this interface must provide a default constructor.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface ICollectionFactory {
Modified: tinytim/trunk/src/main/java/org/tinytim/IConstruct.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IConstruct.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IConstruct.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -31,7 +31,7 @@
* This interface 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:$
+ * @version $Rev$ - $Date$
*/
public interface IConstruct extends TopicMapObject {
Modified: tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IEventHandler.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -26,7 +26,7 @@
* This interface 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:$
+ * @version $Rev$ - $Date$
*/
public interface IEventHandler {
Modified: tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IEventPublisher.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -26,7 +26,7 @@
* This interface 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:$
+ * @version $Rev$ - $Date$
*/
public interface IEventPublisher {
Modified: tinytim/trunk/src/main/java/org/tinytim/IRI.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IRI.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IRI.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -28,7 +28,7 @@
* Immutable representation of an IRI.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class IRI implements Locator {
Modified: tinytim/trunk/src/main/java/org/tinytim/IReifiable.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IReifiable.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IReifiable.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -28,7 +28,7 @@
* Every Topic Maps construct != topic is reifiable.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface IReifiable extends IConstruct {
Modified: tinytim/trunk/src/main/java/org/tinytim/IScoped.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/IScoped.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/IScoped.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* constructs.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
interface IScoped extends IConstruct, ScopedObject {
Modified: tinytim/trunk/src/main/java/org/tinytim/ITyped.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/ITyped.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/ITyped.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -28,7 +28,7 @@
* Associations, roles, occurrences, and names are typed Topic Maps constructs.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
interface ITyped extends IConstruct {
Modified: tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* {@link ICollectionFactory} which uses the standard Java collections.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class JavaCollectionFactory implements ICollectionFactory {
Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/Property.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -24,7 +24,7 @@
* Provides constants for all tinyTiM-specific TMAPI properties.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class Property {
Modified: tinytim/trunk/src/main/java/org/tinytim/Scoped.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/Scoped.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* a {@link IReifiable} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
abstract class Scoped extends Construct implements IReifiable {
Modified: tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -27,7 +27,7 @@
* Copied from the TMAPIX-project.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class TMAPIFeature {
Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -34,7 +34,7 @@
* {@link org.tmapi.core.TopicMapSystemFactory} implementation.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public final class TopicMapSystemFactoryImpl extends TopicMapSystemFactory {
Modified: tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -31,7 +31,7 @@
* <a href="http://sourceforge.net/projects/trove4j/">Trove library </a>.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class TroveCollectionFactory implements ICollectionFactory {
Modified: tinytim/trunk/src/main/java/org/tinytim/Typed.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/Typed.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* property changes.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
abstract class Typed extends Scoped {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/index/IIndex.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -26,7 +26,7 @@
* Copied from the TMAPIX-project.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface IIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/index/IScopedIndex.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -37,7 +37,7 @@
* implementations.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface IScopedIndex extends IIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -38,7 +38,7 @@
* implementations.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface ITypeInstanceIndex extends IIndex {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java
===================================================================
--- tinytim/trunk/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -28,7 +28,7 @@
* Use {@link #AUTOUPDATED} or {@link #NOT_AUTOUPDATED}
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class IndexFlagsImpl implements IndexFlags {
Copied: tinytim/trunk/src/test (from rev 11, tinytim/trunk/test)
Copied: tinytim/trunk/src/test/java (from rev 20, tinytim/trunk/test/java)
Modified: tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -26,7 +26,7 @@
* Base class for all TMAPI-related test cases.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TMAPITestCase extends TestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestConstruct.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* Tests against {@link IConstruct}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestConstruct extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestReifiable.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -33,7 +33,7 @@
* Tests against the {@link org.tinytim.IReifiable} interface.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestReifiable extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestScoped.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestScoped.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestScoped.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* Tests against the {@link org.tinytim.IScoped} interface.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestScoped extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* Tests against the {@link org.tinytim.SignatureGenerator}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestSignatureGenerator extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* Runs the TMAPI core test suite against tinyTiM.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTMAPICore extends TMAPITestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -29,7 +29,7 @@
* Runs the TMAPI index test suite against tinyTiM.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTMAPIIndex extends TMAPITestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -37,7 +37,7 @@
* Tests against the {@link org.tinytim.TopicMapSystemFactoryImpl}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTopicMapSystemFactoryImpl extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -31,7 +31,7 @@
* Tests merging of topics.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTopicMerge extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -28,7 +28,7 @@
* Tests if merging situations are detected.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTopicMergeDetection extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TestTyped.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TestTyped.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TestTyped.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -32,7 +32,7 @@
* Tests against the {@link org.tinytim.ITyped} interface.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTyped extends TinyTimTestCase {
Modified: tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java
===================================================================
--- tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java 2008-04-21 13:42:04 UTC (rev 20)
+++ tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java 2008-04-21 13:51:38 UTC (rev 21)
@@ -35,7 +35,7 @@
* {@link org.tinytim.TopicMapImpl}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TinyTimTestCase extends TestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-04-21 13:42:56
|
Revision: 20
http://tinytim.svn.sourceforge.net/tinytim/?rev=20&view=rev
Author: lheuer
Date: 2008-04-21 06:42:04 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Added Paths:
-----------
tinytim/trunk/src/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|