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-12-06 14:13:32
|
Revision: 244 http://tinytim.svn.sourceforge.net/tinytim/?rev=244&view=rev Author: lheuer Date: 2008-12-06 14:13:20 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Aligned version info Modified Paths: -------------- tinytim/trunk/README.txt Modified: tinytim/trunk/README.txt =================================================================== --- tinytim/trunk/README.txt 2008-12-05 17:21:18 UTC (rev 243) +++ tinytim/trunk/README.txt 2008-12-06 14:13:20 UTC (rev 244) @@ -11,7 +11,7 @@ Installation ------------ -No real installation needed, simply put the ``tinytim-2.0.0a3.jar`` and +No real installation needed, simply put the ``tinytim-2.0.0a4.jar`` and ``tmapi-2.0a1.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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-12-05 17:21:30
|
Revision: 243 http://tinytim.svn.sourceforge.net/tinytim/?rev=243&view=rev Author: lheuer Date: 2008-12-05 17:21:18 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Changed release date to 06.12. ho ho ho *<|:-) Modified Paths: -------------- tinytim/trunk/CHANGES.txt tinytim-mio/trunk/CHANGES.txt Modified: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt 2008-11-28 13:47:49 UTC (rev 242) +++ tinytim/trunk/CHANGES.txt 2008-12-05 17:21:18 UTC (rev 243) @@ -2,7 +2,7 @@ Changes Log =========== -2.0.0 a4 (05.12.2008) +2.0.0 a4 (06.12.2008) --------------------- Bugfixes: Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-28 13:47:49 UTC (rev 242) +++ tinytim-mio/trunk/CHANGES.txt 2008-12-05 17:21:18 UTC (rev 243) @@ -2,7 +2,7 @@ Changes Log =========== -2.0.0 a4 (05.12.2008) +2.0.0 a4 (06.12.2008) --------------------- * Initial .mio release for tinyTiM 2.x * Changed license to Apache License 2.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-28 13:47:53
|
Revision: 242 http://tinytim.svn.sourceforge.net/tinytim/?rev=242&view=rev Author: lheuer Date: 2008-11-28 13:47:49 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Added RDF readers / JTM reader Modified Paths: -------------- tinytim-mio/trunk/CHANGES.txt Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-28 13:18:30 UTC (rev 241) +++ tinytim-mio/trunk/CHANGES.txt 2008-11-28 13:47:49 UTC (rev 242) @@ -13,9 +13,18 @@ - XTM 2.0 reader - CTM reader which implements draft dtd. 2008-05-15 (does not suppot %include and %mergemap) + - JTM reader - TM/XML - Snello - LTM 1.3 +* Introduced a RDFTopicMapReader interface +* Added RDF reader implementations: + - N3 reader + - N-Triples reader + - RDF/XML reader + - TriG reader + - TriX reader + - Turtle reader * Moved CXTMWriter into .mio package, implements TopicMapWriter * CXTMWriter does not normalize datatype locators anymore (this is not in the current CXTM draft but becomes part of the next draft) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-28 13:18:42
|
Revision: 241 http://tinytim.svn.sourceforge.net/tinytim/?rev=241&view=rev Author: lheuer Date: 2008-11-28 13:18:30 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Updated changes for next release (expected 05.12.) Modified Paths: -------------- tinytim/trunk/CHANGES.txt tinytim-mio/trunk/CHANGES.txt Modified: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt 2008-11-27 15:55:32 UTC (rev 240) +++ tinytim/trunk/CHANGES.txt 2008-11-28 13:18:30 UTC (rev 241) @@ -2,12 +2,14 @@ Changes Log =========== -2.0.0 a4 (xx.11.2008) +2.0.0 a4 (05.12.2008) --------------------- Bugfixes: --------- -* Bug #2315558 -- Decimal value "9.3" is not accepted +* Bug #2315558 -- Decimal values like "9.3" are not accepted +* Bug #2353673 -- Locator.resolve returns new Locator objects + even if they have been created before Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-27 15:55:32 UTC (rev 240) +++ tinytim-mio/trunk/CHANGES.txt 2008-11-28 13:18:30 UTC (rev 241) @@ -2,7 +2,7 @@ Changes Log =========== -2.0.0 a4 (xx.11.2008) +2.0.0 a4 (05.12.2008) --------------------- * Initial .mio release for tinyTiM 2.x * Changed license to Apache License 2.0 @@ -17,6 +17,8 @@ - Snello - LTM 1.3 * Moved CXTMWriter into .mio package, implements TopicMapWriter +* CXTMWriter does not normalize datatype locators anymore + (this is not in the current CXTM draft but becomes part of the next draft) * JSON Topic Maps (JTM) writer * XML Topic Maps (XTM) 1.0 writer * XML Topic Maps (XTM) 2.0 writer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-27 15:55:51
|
Revision: 240 http://tinytim.svn.sourceforge.net/tinytim/?rev=240&view=rev Author: lheuer Date: 2008-11-27 15:55:32 +0000 (Thu, 27 Nov 2008) Log Message: ----------- A few examples Added Paths: ----------- tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/AbstractDuplicateRemovalExample.java tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateNames.java tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateOccurrences.java tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/mio/ Added: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/AbstractDuplicateRemovalExample.java =================================================================== --- tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/AbstractDuplicateRemovalExample.java (rev 0) +++ tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/AbstractDuplicateRemovalExample.java 2008-11-27 15:55:32 UTC (rev 240) @@ -0,0 +1,70 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.examples.tinytim; + +import org.tmapi.core.Locator; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicMapSystem; +import org.tmapi.core.TopicMapSystemFactory; + +/** + * Base class for the duplicate removal examples. + * + * Sets up the topic map system and provides some utility methods. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +abstract class AbstractDuplicateRemovalExample { + + protected TopicMapSystem _system; + protected TopicMap _topicMap; + protected Locator _tmIRI; + + /** + * Creates a topic with the item identifier "a-topic" + */ + protected Topic createTopic() throws TMAPIException { + final Locator iid = resolve("a-topic"); + System.out.println("Creating a topic with the item identifier '" + iid.getReference() + "'"); + Topic topic = _topicMap.createTopicByItemIdentifier(iid); + System.out.println("Created the topic"); + return topic; + } + + /** + * Returns a locator resolved against the base locator + */ + protected Locator resolve(String localId) { + return _tmIRI.resolve("#" + localId); + } + + protected Topic createTopic(String localId) { + return _topicMap.createTopicByItemIdentifier(resolve(localId)); + } + + protected Locator createLocator(String reference) { + return _tmIRI.resolve(reference); + } + + protected void runExample() throws TMAPIException { + _system = TopicMapSystemFactory.newInstance().newTopicMapSystem(); + _tmIRI = _system.createLocator("http://tinytim.sourceforge/example/remove-duplicates"); + _topicMap = _system.createTopicMap(_tmIRI); + } +} Property changes on: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/AbstractDuplicateRemovalExample.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateNames.java =================================================================== --- tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateNames.java (rev 0) +++ tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateNames.java 2008-11-27 15:55:32 UTC (rev 240) @@ -0,0 +1,67 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.examples.tinytim; + +import org.tinytim.utils.DuplicateRemovalUtils; + +import org.tmapi.core.Name; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.Topic; + +/** + * This example shows how to use the {@DuplicateRemovalUtils} and the effects of the + * DuplicateRemovalUtils on topic names. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class RemoveDuplicateNames extends AbstractDuplicateRemovalExample { + + public static void main(String[] args) { + RemoveDuplicateNames example = new RemoveDuplicateNames(); + try { + example.runExample(); + } + catch (TMAPIException ex) { + ex.printStackTrace(); + } + } + + public void runExample() throws TMAPIException { + super.runExample(); + Topic topic = createTopic(); + final String value = "tinyTiM"; + System.out.println("Creating a name: '" + value + "'"); + topic.createName(value); + System.out.println("Created the name."); + System.out.println("Creating another name with the same value: '" + value + "'"); + topic.createName(value); + System.out.println("Created the name."); + System.out.println("The topic has " + topic.getNames().size() + " names:"); + for (Name name: topic.getNames()) { + System.out.println("- " + name.getValue()); + } + System.out.println("=> The topic has two names with the value '" + value + "' (duplicates)"); + System.out.println("Invoking " + DuplicateRemovalUtils.class.getName() + ".removeDuplicates(topic)"); + DuplicateRemovalUtils.removeDuplicates(topic); + System.out.println("The topic has " + topic.getNames().size() + " name:"); + for (Name name: topic.getNames()) { + System.out.println("- " + name.getValue()); + } + System.out.println("=> The topic has no duplicate names"); + } + +} Property changes on: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateNames.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateOccurrences.java =================================================================== --- tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateOccurrences.java (rev 0) +++ tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateOccurrences.java 2008-11-27 15:55:32 UTC (rev 240) @@ -0,0 +1,83 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.examples.tinytim; + +import org.tinytim.utils.DuplicateRemovalUtils; + +import org.tmapi.core.Occurrence; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.Topic; + +/** + * This example shows how to use the {@DuplicateRemovalUtils} and the effects of the + * DuplicateRemovalUtils on occurrences. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class RemoveDuplicateOccurrences extends AbstractDuplicateRemovalExample { + + /** + * + * + * @param args + */ + public static void main(String[] args) { + RemoveDuplicateOccurrences example = new RemoveDuplicateOccurrences(); + try { + example.runExample(); + } + catch (TMAPIException ex) { + ex.printStackTrace(); + } + } + + /* (non-Javadoc) + * @see org.tinytim.examples.tinytim.AbstractDuplicateRemovalExample#runExample() + */ + public void runExample() throws TMAPIException { + super.runExample(); + Topic topic = createTopic(); + final String website = "website"; + final String value = "http://tinytim.sourceforge.net/"; + System.out.println("Creating an occurrence with the type: '" + website + "' and the URI value '" + value + "'"); + createWebsite(topic, value); + System.out.println("Created the occurrence."); + System.out.println("Creating another occurrence with the type and value: '" + website + "' and the URI value '" + value + "'"); + createWebsite(topic, value); + System.out.println("Created the occurrence."); + System.out.println("The topic has " + topic.getOccurrences().size() + " occurrences:"); + for (Occurrence occ: topic.getOccurrences()) { + System.out.println("* " + occ.getValue()); + } + System.out.println("=> The topic has two occs with the value '" + value + "' (duplicates)"); + System.out.println("Invoking " + DuplicateRemovalUtils.class.getName() + ".removeDuplicates(topic)"); + DuplicateRemovalUtils.removeDuplicates(topic); + System.out.println("The topic has " + topic.getOccurrences().size() + " occurrence:"); + for (Occurrence occ: topic.getOccurrences()) { + System.out.println("* " + occ.getValue()); + } + System.out.println("=> The topic has no duplicate occurrences"); + } + + /** + * Creates an occurrence of type "website" + */ + private void createWebsite(Topic topic, String value) { + topic.createOccurrence(createTopic("website"), createLocator(value)); + } + +} Property changes on: tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/RemoveDuplicateOccurrences.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: 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-11-27 14:14:23
|
Revision: 239 http://tinytim.svn.sourceforge.net/tinytim/?rev=239&view=rev Author: lheuer Date: 2008-11-27 14:14:16 +0000 (Thu, 27 Nov 2008) Log Message: ----------- Fixed bug #2353673 -- Locator.resolve returns new Locator objects Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java 2008-11-26 16:26:07 UTC (rev 238) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java 2008-11-27 14:14:16 UTC (rev 239) @@ -38,7 +38,6 @@ */ public final class Literal implements ILiteral { - private static final WeakObjectRegistry<LocatorImpl> _IRIS = new WeakObjectRegistry<LocatorImpl>(IConstant.LITERAL_IRI_SIZE); private static final WeakObjectRegistry<ILiteral> _STRINGS = new WeakObjectRegistry<ILiteral>(IConstant.LITERAL_STRING_SIZE); private static final WeakObjectRegistry<ILiteral> _OTHERS = new WeakObjectRegistry<ILiteral>(IConstant.LITERAL_OTHER_SIZE); @@ -57,11 +56,11 @@ return _STRINGS.get(new Literal(value, XSD.STRING)); } - public static synchronized ILiteral getIRI(String value) { + public static ILiteral getIRI(String value) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - return _IRIS.get(new LocatorImpl(value)); + return LocatorImpl.get(value); } public static synchronized ILiteral get(String value, Locator datatype) { @@ -154,7 +153,7 @@ if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - return _registerIfAbsent(_IRIS, new LocatorImpl(value)); + return LocatorImpl.create(value); } public static ILiteral createDecimal(String value) { Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2008-11-26 16:26:07 UTC (rev 238) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2008-11-27 14:14:16 UTC (rev 239) @@ -26,7 +26,10 @@ import java.net.URI; import java.net.URLDecoder; +import org.tinytim.internal.api.IConstant; +import org.tinytim.internal.api.ILiteral; import org.tinytim.internal.api.ILocator; +import org.tinytim.internal.utils.WeakObjectRegistry; import org.tinytim.voc.XSD; import org.tmapi.core.Locator; @@ -44,10 +47,11 @@ */ final class LocatorImpl implements ILocator { + private static final WeakObjectRegistry<ILocator> _IRIS = new WeakObjectRegistry<ILocator>(IConstant.LITERAL_IRI_SIZE); private final URI _uri; private final String _reference; - LocatorImpl(String reference) { + private LocatorImpl(String reference) { try { _reference = URLDecoder.decode(reference, "utf-8"); } @@ -127,7 +131,7 @@ * @see org.tmapi.core.Locator#resolve(java.lang.String) */ public Locator resolve(String reference) { - return new LocatorImpl(_uri.resolve(reference)); + return create(_uri.resolve(reference)); } /* (non-Javadoc) @@ -161,4 +165,28 @@ return _uri.toString(); } + static synchronized ILiteral get(String value) { + return _IRIS.get(new LocatorImpl(value)); + } + + private static synchronized ILocator create(URI value) { + ILocator loc = new LocatorImpl(value); + final ILocator existing = _IRIS.get(loc); + if (existing != null) { + return existing; + } + _IRIS.add(loc); + return loc; + } + + static synchronized ILocator create(String value) { + ILocator loc = new LocatorImpl(value); + final ILocator existing = _IRIS.get(loc); + if (existing != null) { + return existing; + } + _IRIS.add(loc); + return loc; + } + } Modified: tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java 2008-11-26 16:26:07 UTC (rev 238) +++ tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java 2008-11-27 14:14:16 UTC (rev 239) @@ -28,6 +28,12 @@ */ public class TestLiteral extends TinyTimTestCase { + public void testLocatorResolve() { + Locator base = Literal.createIRI("http://www.semagia.com/"); + Locator loc1 = base.resolve("#iid"); + Locator loc2 = base.resolve("#iid"); + assertSame(loc1, loc2); + } public void testStringGet() { final String value = "tiny tiny tiny"; @@ -63,7 +69,7 @@ } public void testIRIEquality() { - final String value = "http://www.semagia.com/"; + final String value = "http://www.semagia.com/test-iri-eq"; assertNull(Literal.get(value, XSD.ANY_URI)); final Locator loc = _sys.createLocator(value); ILiteral lit1 = Literal.create(loc); @@ -72,7 +78,7 @@ } public void testIRIEquality2() { - final String value = "http://www.semagia.net/"; + final String value = "http://www.semagia.net/test-iri-eq2"; assertNull(Literal.get(value, XSD.ANY_URI)); final Locator loc = _sys.createLocator(value); ILiteral lit1 = Literal.create(loc); @@ -81,7 +87,7 @@ } public void testIRIEquality3() { - final String value = "http://www.semagia.de/"; + final String value = "http://www.semagia.de/test-iri-eq3"; assertNull(Literal.get(value, XSD.ANY_URI)); final Locator loc = _sys.createLocator(value); ILiteral lit1 = Literal.create(value, XSD.ANY_URI); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-26 16:26:30
|
Revision: 238 http://tinytim.svn.sourceforge.net/tinytim/?rev=238&view=rev Author: lheuer Date: 2008-11-26 16:26:07 +0000 (Wed, 26 Nov 2008) Log Message: ----------- - Changed JTM links to the new (non-existing) JTM homepage - Added links to the RDF syntax specs Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFXMLTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrigTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrixTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TurtleTopicMapReader.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -30,7 +30,7 @@ /** * {@link TopicMapReader} implementation that deserializes - * <a href="http://www.cerny-online.com/topincs/technical-whitepaper">JSON Topic Maps (JTM)</a>. + * <a href="http://www.cerny-online.com/jtm/">JSON Topic Maps (JTM)</a>. * <p> * The reader does not accept fragments, i.e. only a topic in a JSON document; * each JTM instance must start with a topic map container, i.e. Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-26 16:26:07 UTC (rev 238) @@ -42,7 +42,7 @@ /** * A {@link TopicMapWriter} implementation that serializes a topic map into - * a <a href="http://www.cerny-online.com/topincs/technical-whitepaper">JSON Topic Maps (JTM)</a> + * a <a href="http://www.cerny-online.com/jtm/">JSON Topic Maps (JTM)</a> * representation. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> @@ -83,12 +83,12 @@ } _baseIRI = baseIRI; _out = new JSONWriter(out, encoding); - _out.setPrettify(true); + _out.setPrettify(false); } /** - * Enables / disables newlines and indentation of JSON elements. - * (newlines and indentation is enabled by default) + * Enables / disables newlines and indentation of the JSON output. + * (disabled by default) * * @param prettify <tt>true</tt> to enable prettified JSON, otherwise <tt>false</tt>. */ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -25,7 +25,8 @@ import com.semagia.mio.Syntax; /** - * {@link RDFTopicMapReader} implementation that is able to deserialize RDF N3. + * {@link RDFTopicMapReader} implementation that is able to deserialize RDF + * <a href="http://www.w3c.org/2000/10/swap/Primer.html">N3</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -26,7 +26,7 @@ /** * {@link RDFTopicMapReader} implementation that is able to deserialize RDF - * N-Triples. + * <a href="http://www.w3.org/TR/rdf-testcases/#ntriples">N-Triples</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFXMLTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFXMLTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFXMLTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -25,7 +25,8 @@ import com.semagia.mio.Syntax; /** - * {@link RDFTopicMapReader} implementation that is able to deserialize RDF/XML. + * {@link RDFTopicMapReader} implementation that is able to deserialize + * <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrigTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrigTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrigTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -25,7 +25,8 @@ import com.semagia.mio.Syntax; /** - * {@link RDFTopicMapReader} implementation that is able to deserialize RDF TriG. + * {@link RDFTopicMapReader} implementation that is able to deserialize RDF + * <a href="http://www.wiwiss.fu-berlin.de/suhl/bizer/TriG/Spec/">TriG</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrixTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrixTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrixTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -25,7 +25,8 @@ import com.semagia.mio.Syntax; /** - * {@link RDFTopicMapReader} implementation that is able to deserialize RDF TriX. + * {@link RDFTopicMapReader} implementation that is able to deserialize RDF + * <a href="http://swdev.nokia.com/trix/TriX.html">TriX</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TurtleTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TurtleTopicMapReader.java 2008-11-25 14:24:19 UTC (rev 237) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TurtleTopicMapReader.java 2008-11-26 16:26:07 UTC (rev 238) @@ -26,7 +26,7 @@ /** * {@link RDFTopicMapReader} implementation that is able to deserialize RDF - * Turtle. + * <a href="http://www.dajobe.org/2004/01/turtle/">Turtle</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-25 14:24:22
|
Revision: 237 http://tinytim.svn.sourceforge.net/tinytim/?rev=237&view=rev Author: lheuer Date: 2008-11-25 14:24:19 +0000 (Tue, 25 Nov 2008) Log Message: ----------- - Updated build files for 2.0 and 1.5 - 1.5 does not support JTMTopicMapWriter, but all readers are supported Modified Paths: -------------- tinytim-mio/trunk/build-15.xml tinytim-mio/trunk/build.xml Modified: tinytim-mio/trunk/build-15.xml =================================================================== --- tinytim-mio/trunk/build-15.xml 2008-11-25 14:18:12 UTC (rev 236) +++ tinytim-mio/trunk/build-15.xml 2008-11-25 14:24:19 UTC (rev 237) @@ -13,6 +13,7 @@ <property name="lib.tinytim" value="${dir.lib}/tinytim-1.5.0b2.jar"/> <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.6.jar"/> <property name="lib.mio" value="${dir.lib}/semagia-mio-0.9.3.jar"/> + <property name="lib.json" value="${dir.lib}/json_simple.jar"/> <target name="help"> <echo message="------------------------"/> @@ -123,7 +124,7 @@ <target name="compile" depends="clean, prepare"> <javac destdir="${dir.build.classes}" debug="${debug}" - excludes="org/tinytim/mio/AbstractTopicMapWriter* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter* org/tinytim/mio/JTM* org/tinytim/mio/JSON*" + excludes="org/tinytim/mio/AbstractTopicMapWriter* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter* org/tinytim/mio/JTM*Writer* org/tinytim/mio/JSON*" includes="org/tinytim/mio15/** org/tinytim/mio/*TopicMapReader* org/tinytim/mio/*TopicMapImporter*" target="1.5"> <classpath> @@ -131,6 +132,7 @@ <pathelement location="${lib.tinytim}"/> <pathelement location="${lib.mio}"/> <pathelement location="${lib.logging}"/> + <pathelement location="${lib.json}"/> </classpath> <src path="${dir.src}"/> </javac> Modified: tinytim-mio/trunk/build.xml =================================================================== --- tinytim-mio/trunk/build.xml 2008-11-25 14:18:12 UTC (rev 236) +++ tinytim-mio/trunk/build.xml 2008-11-25 14:24:19 UTC (rev 237) @@ -13,6 +13,7 @@ <property name="lib.tinytim" value="${dir.lib}/tinytim-2.0.0a3.jar"/> <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.6.jar"/> <property name="lib.mio" value="${dir.lib}/semagia-mio-0.9.3.jar"/> + <property name="lib.json" value="${dir.lib}/json_simple.jar"/> <target name="help"> <echo message="------------------------"/> @@ -130,6 +131,7 @@ <pathelement location="${lib.tinytim}"/> <pathelement location="${lib.mio}"/> <pathelement location="${lib.logging}"/> + <pathelement location="${lib.json}"/> </classpath> <src path="${dir.src}"/> </javac> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-25 14:18:15
|
Revision: 236 http://tinytim.svn.sourceforge.net/tinytim/?rev=236&view=rev Author: lheuer Date: 2008-11-25 14:18:12 +0000 (Tue, 25 Nov 2008) Log Message: ----------- Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20TopicMapWriter.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java 2008-11-25 14:11:21 UTC (rev 235) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java 2008-11-25 14:18:12 UTC (rev 236) @@ -47,7 +47,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class XTM10TopicMapWriter extends AbstractXTMWriter { +public class XTM10TopicMapWriter extends AbstractXTMTopicMapWriter { private static final Logger LOG = Logger.getLogger(XTM10TopicMapWriter.class.getName()); Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20TopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20TopicMapWriter.java 2008-11-25 14:11:21 UTC (rev 235) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20TopicMapWriter.java 2008-11-25 14:18:12 UTC (rev 236) @@ -50,7 +50,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class XTM20TopicMapWriter extends AbstractXTMWriter { +public class XTM20TopicMapWriter extends AbstractXTMTopicMapWriter { private Topic _defaultNameType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-25 14:11:39
|
Revision: 235 http://tinytim.svn.sourceforge.net/tinytim/?rev=235&view=rev Author: lheuer Date: 2008-11-25 14:11:21 +0000 (Tue, 25 Nov 2008) Log Message: ----------- - Reduced visibility of constructors from abstract classes - Introduced RDFTopicMapReader (derived from TopicMapReader) - Added several RDFTopicMapReader implementations - Updated mio core - Added JTM reader (inefficient implementation, to be replaced by a specialized deserializer) - Updated TopicMapImporter for the new RDF topic map readers but *not* JTMTopicMapReader Modified Paths: -------------- tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java Added Paths: ----------- tinytim-mio/trunk/lib/LICENSE.json_simple.txt tinytim-mio/trunk/lib/json_simple.jar tinytim-mio/trunk/lib/semagia-mio-rdf-0.9.3.jar tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFXMLTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrigTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TrixTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TurtleTopicMapReader.java Added: tinytim-mio/trunk/lib/LICENSE.json_simple.txt =================================================================== --- tinytim-mio/trunk/lib/LICENSE.json_simple.txt (rev 0) +++ tinytim-mio/trunk/lib/LICENSE.json_simple.txt 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, 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 Street, 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! + + Added: tinytim-mio/trunk/lib/json_simple.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/json_simple.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar =================================================================== (Binary files differ) Added: tinytim-mio/trunk/lib/semagia-mio-rdf-0.9.3.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/semagia-mio-rdf-0.9.3.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,153 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import org.tmapi.core.TopicMap; + +import com.semagia.mio.IMapHandler; +import com.semagia.mio.Property; +import com.semagia.mio.Source; +import com.semagia.mio.Syntax; + +/** + * Common superclass for {@link RDFTopicMapReader}s. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +abstract class AbstractRDFTopicMapReader extends AbstractTopicMapReader + implements RDFTopicMapReader { + + protected AbstractRDFTopicMapReader(IMapHandler handler, Syntax syntax, + Source source) { + super(handler, syntax, source); + } + + protected AbstractRDFTopicMapReader(TopicMap topicMap, Syntax syntax, + File source, String docIRI) throws IOException { + super(topicMap, syntax, source, docIRI); + } + + protected AbstractRDFTopicMapReader(TopicMap topicMap, Syntax syntax, + File source) throws IOException { + super(topicMap, syntax, source); + } + + protected AbstractRDFTopicMapReader(TopicMap topicMap, Syntax syntax, + InputStream source, String docIRI) { + super(topicMap, syntax, source, docIRI); + } + + protected AbstractRDFTopicMapReader(TopicMap topicMap, Syntax syntax, + Source source) { + super(topicMap, syntax, source); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.io.File) + */ + public void setMappingSource(File file) { + try { + setMappingSource(file.toURI().toURL()); + } + catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.net.URL) + */ + public void setMappingSource(URL url) { + setMappingSource(url.toExternalForm()); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.lang.String) + */ + public void setMappingSource(String iri) { + _deserializer.setProperty(Property.RDF2TM_MAPPING_IRI, iri); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#getMappingSource() + */ + public String getMappingSource() { + return (String) _deserializer.getProperty(Property.RDF2TM_MAPPING_IRI); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#getMappingSourceSyntax() + */ + public MappingSyntax getMappingSourceSyntax() { + Syntax syntax = (Syntax) _deserializer.getProperty(Property.RDF2TM_MAPPING_SYNTAX); + return _toMappingSyntax(syntax); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.RDFTopicMapReader#setMappingSourceSyntax(org.tinytim.mio.RDFTopicMapReader.MappingSyntax) + */ + public void setMappingSourceSyntax(MappingSyntax syntax) { + _deserializer.setProperty(Property.RDF2TM_MAPPING_SYNTAX, _fromMappingSyntax(syntax)); + } + + private static MappingSyntax _toMappingSyntax(Syntax syntax) { + if (syntax == null) { + return null; + } + if (Syntax.N3.equals(syntax)) { + return MappingSyntax.N3; + } + if (Syntax.NTRIPLES.equals(syntax)) { + return MappingSyntax.NTRIPLES; + } + if (Syntax.RDFXML.equals(syntax)) { + return MappingSyntax.RDFXML; + } + if (Syntax.TRIG.equals(syntax)) { + return MappingSyntax.TRIG; + } + if (Syntax.TRIX.equals(syntax)) { + return MappingSyntax.TRIX; + } + if (Syntax.TURTLE.equals(syntax)) { + return MappingSyntax.TURTLE; + } + throw new RuntimeException("Internal error, no MappingSyntax found for " + syntax.getName()); + } + + + private static Syntax _fromMappingSyntax(MappingSyntax syntax) { + if (syntax == null) { + return null; + } + switch (syntax) { + case N3: return Syntax.N3; + case NTRIPLES: return Syntax.NTRIPLES; + case RDFXML: return Syntax.RDFXML; + case TRIG: return Syntax.TRIG; + case TRIX: return Syntax.TRIX; + case TURTLE: return Syntax.TURTLE; + } + throw new RuntimeException("Internal error, no mio.Syntax found for " + syntax); + } +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2008-11-24 15:35:42 UTC (rev 234) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -33,29 +33,29 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public abstract class AbstractXTMTopicMapReader extends AbstractTopicMapReader { +abstract class AbstractXTMTopicMapReader extends AbstractTopicMapReader { - public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + protected AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, File source) throws IOException { super(topicMap, syntax, source); } - public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + protected AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, File source, String docIRI) throws IOException { super(topicMap, syntax, source, docIRI); } - public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + protected AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, InputStream source, String docIRI) { super(topicMap, syntax, source, docIRI); } - public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + protected AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, Source source) { super(topicMap, syntax, source); } - public AbstractXTMTopicMapReader(IMapHandler handler, Syntax syntax, + protected AbstractXTMTopicMapReader(IMapHandler handler, Syntax syntax, Source source) { super(handler, syntax, source); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2008-11-24 15:35:42 UTC (rev 234) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2008-11-25 14:11:21 UTC (rev 235) @@ -72,7 +72,7 @@ /** * Enables / disables newlines and indentation of XML elements. - * (newlines and indentation is enabled by default) + * (enabled by default) * * @param prettify <tt>true</tt> to enable prettified XML, otherwise <tt>false</tt>. */ Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,296 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.IOException; +import java.io.Reader; +import java.util.List; + +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.tmapi.core.TMAPIRuntimeException; +import org.tmapi.core.TopicMap; + +import com.semagia.mio.MIOException; +import com.semagia.mio.helpers.Ref; +import com.semagia.mio.helpers.SimpleMapHandler; + +/** + * {@link TopicMapReader} implementation that deserializes + * <a href="http://www.cerny-online.com/topincs/technical-whitepaper">JSON Topic Maps (JTM)</a>. + * <p> + * The reader does not accept fragments, i.e. only a topic in a JSON document; + * each JTM instance must start with a topic map container, i.e. + * <tt>{"topics":[...]"}</tt>. The TMDM constructs must provide all + * properties, i.e. it is not allowed to omit the type of an association. The + * only exception are topic names: If the "type" property is not provided, the + * default topic name type is automatically assigned. + * </p> + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +@SuppressWarnings("unchecked") +public class JTMTopicMapReader implements TopicMapReader { + + private TopicMap _tm; + private Reader _reader; + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param reader The reader to read the JSON encoded topic map from. + * @throws IOException If an error occurs. + */ + public JTMTopicMapReader(TopicMap topicMap, Reader reader) throws IOException { + _tm = topicMap; + _reader = reader; + } + + /* (non-Javadoc) + * @see org.tinytim.mio.TopicMapReader#read() + */ + public void read() throws IOException { + Object obj = JSONValue.parse(_reader); + if (!(obj instanceof JSONObject)) { + // Nothing to do. + return; + } + JSONObject map = (JSONObject) obj; + SimpleMapHandler mapHandler = SimpleMapHandler.create(new TinyTimMapInputHandler(_tm)); + try { + mapHandler.startTopicMap(); + _handleReifier(mapHandler, map); + _handleItemIdentifiers(mapHandler, map); + _handleTopics(mapHandler, (List<JSONObject>) map.get("topics")); + _handleAssociations(mapHandler, (List<JSONObject>) map.get("associations")); + mapHandler.endTopicMap(); + } + catch (MIOException ex) { + throw new TMAPIRuntimeException(ex); + } + } + + private void _handleTopics(SimpleMapHandler mapHandler, + List<JSONObject> jsonArray) throws MIOException { + if (jsonArray == null) { + return; + } + int length = jsonArray.size(); + for (int i=0; i<length; i++) { + _handleTopic(mapHandler, jsonArray.get(i)); + } + } + + private void _handleTopic(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + boolean seenIdentity = false; + List<String> array = (List<String>) jsonObject.get("item_identifiers"); + if (array != null) { + seenIdentity = true; + mapHandler.startTopic(Ref.createItemIdentifier(array.get(0))); + int length = array.size(); + for (int i=1; i<length; i++) { + mapHandler.itemIdentifier(array.get(i)); + } + } + array = (List<String>) jsonObject.get("subject_identifiers"); + if (array != null) { + int start = 0; + if (!seenIdentity) { + seenIdentity = true; + start = 1; + mapHandler.startTopic(Ref.createSubjectIdentifier(array.get(0))); + } + int length = array.size(); + for (int i=start; i<length; i++) { + mapHandler.subjectIdentifier(array.get(i)); + } + } + array = (List<String>) jsonObject.get("subject_locators"); + if (array != null) { + int start = 0; + if (!seenIdentity) { + seenIdentity = true; + start = 1; + mapHandler.startTopic(Ref.createSubjectLocator(array.get(0))); + } + int length = array.size(); + for (int i=start; i<length; i++) { + mapHandler.subjectLocator(array.get(i)); + } + } + if (!seenIdentity) { + throw new MIOException("Topic without any identity: " + jsonObject); + } + List<JSONObject> objects = (List<JSONObject>) jsonObject.get("occurrences"); + if (objects != null) { + int length = objects.size(); + for (int i=0; i<length; i++) { + _handleOccurrence(mapHandler, objects.get(i)); + } + } + objects = (List<JSONObject>) jsonObject.get("names"); + if (objects != null) { + int length = objects.size(); + for (int i=0; i<length; i++) { + _handleName(mapHandler, objects.get(i)); + } + } + mapHandler.endTopic(); + } + + private void _handleOccurrence(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + mapHandler.startOccurrence(); + _handleType(mapHandler, jsonObject, true); + _handleScope(mapHandler, jsonObject); + _handleReifier(mapHandler, jsonObject); + _handleItemIdentifiers(mapHandler, jsonObject); + _handleValueDatatype(mapHandler, jsonObject); + mapHandler.endOccurrence(); + } + + private void _handleValueDatatype(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + String value = (String) jsonObject.get("value"); + if (value == null) { + throw new MIOException("The value must not be null: " + jsonObject); + } + String datatype = (String) jsonObject.get("datatype"); + if (datatype == null) { + throw new MIOException("The datatype must not be null: " + jsonObject); + } + mapHandler.value(value, datatype); + } + + private void _handleName(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + mapHandler.startName(); + _handleType(mapHandler, jsonObject, false); + _handleScope(mapHandler, jsonObject); + _handleReifier(mapHandler, jsonObject); + _handleItemIdentifiers(mapHandler, jsonObject); + String value = (String) jsonObject.get("value"); + if (value == null) { + throw new MIOException("The value of a name must not be null: " + jsonObject); + } + mapHandler.value(value); + List<JSONObject> variants = (List<JSONObject>) jsonObject.get("variants"); + if (variants != null) { + int length = variants.size(); + for (int i=0; i<length; i++) { + _handleVariant(mapHandler, variants.get(i)); + } + } + mapHandler.endName(); + } + + private void _handleVariant(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + mapHandler.startVariant(); + _handleScope(mapHandler, jsonObject); + _handleReifier(mapHandler, jsonObject); + _handleItemIdentifiers(mapHandler, jsonObject); + _handleValueDatatype(mapHandler, jsonObject); + mapHandler.endVariant(); + } + + private void _handleAssociations(SimpleMapHandler mapHandler, + List<JSONObject> jsonArray) throws MIOException { + if (jsonArray == null) { + return; + } + int length = jsonArray.size(); + for (int i=0; i<length; i++) { + _handleAssociation(mapHandler, jsonArray.get(i)); + } + } + + private void _handleAssociation(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + List<JSONObject> roles = (List<JSONObject>) jsonObject.get("roles"); + if (roles == null) { + throw new MIOException("No roles specified: " + jsonObject); + } + mapHandler.startAssociation(); + _handleType(mapHandler, jsonObject, true); + _handleScope(mapHandler, jsonObject); + _handleReifier(mapHandler, jsonObject); + _handleItemIdentifiers(mapHandler, jsonObject); + int length = roles.size(); + for (int i=0; i<length; i++) { + _handleRole(mapHandler, roles.get(i)); + } + mapHandler.endAssociation(); + } + + private void _handleRole(SimpleMapHandler mapHandler, + JSONObject jsonObject) throws MIOException { + mapHandler.startRole(); + _handleType(mapHandler, jsonObject, true); + _handleReifier(mapHandler, jsonObject); + _handleItemIdentifiers(mapHandler, jsonObject); + String playerIRI = (String) jsonObject.get("player"); + if (playerIRI == null) { + throw new MIOException("No player defined: " + jsonObject); + } + mapHandler.player(Ref.createItemIdentifier(playerIRI)); + mapHandler.endRole(); + } + + private void _handleScope(SimpleMapHandler mapHandler, JSONObject jsonObject) throws MIOException { + List<String> array = (List<String>) jsonObject.get("scope"); + if (array == null) { + return; + } + int length = array.size(); + mapHandler.startScope(); + for (int i=0; i<length; i++) { + mapHandler.theme(Ref.createItemIdentifier(array.get(i))); + } + mapHandler.endScope(); + } + + private void _handleType(SimpleMapHandler mapHandler, JSONObject jsonObj, boolean notNull) throws MIOException { + String typeIRI = (String) jsonObj.get("type"); + if (typeIRI != null) { + mapHandler.type(Ref.createItemIdentifier(typeIRI)); + } + else if (notNull) { + throw new MIOException("The type must not be null: " + jsonObj); + } + } + + private void _handleReifier(SimpleMapHandler mapHandler, JSONObject jsonObj) throws MIOException { + String reifierIRI = (String) jsonObj.get("reifier"); + if (reifierIRI != null) { + mapHandler.reifier(Ref.createItemIdentifier(reifierIRI)); + } + } + + private void _handleItemIdentifiers(SimpleMapHandler mapHandler, JSONObject jsonObj) throws MIOException { + List<String> iids = (List<String>)jsonObj.get("item_identifiers"); + if (iids != null) { + int length = iids.size(); + for (int i=0; i<length; i++) { + mapHandler.itemIdentifier(iids.get(i)); + } + } + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,83 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import org.tmapi.core.TopicMap; + +import com.semagia.mio.Source; +import com.semagia.mio.Syntax; + +/** + * {@link RDFTopicMapReader} implementation that is able to deserialize RDF N3. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public final class N3TopicMapReader extends AbstractRDFTopicMapReader { + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @param docIRI The document IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. + */ + public N3TopicMapReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.N3, source, docIRI); + } + + /** + * Constructs a new instance. + * <p> + * The <tt>source</tt> is converted into an absolute IRI which will be + * utilised as document IRI + * </p> + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @throws IOException If an error occurs. + */ + public N3TopicMapReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.N3, source); + } + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @param docIRI The document IRI which is used to resolve IRIs against. + */ + public N3TopicMapReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.N3, source, docIRI); + } + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the serialized topic map from. + */ + public N3TopicMapReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.N3, source); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/N3TopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,84 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import org.tmapi.core.TopicMap; + +import com.semagia.mio.Source; +import com.semagia.mio.Syntax; + +/** + * {@link RDFTopicMapReader} implementation that is able to deserialize RDF + * N-Triples. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public final class NTriplesTopicMapReader extends AbstractRDFTopicMapReader { + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @param docIRI The document IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. + */ + public NTriplesTopicMapReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.NTRIPLES, source, docIRI); + } + + /** + * Constructs a new instance. + * <p> + * The <tt>source</tt> is converted into an absolute IRI which will be + * utilised as document IRI + * </p> + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @throws IOException If an error occurs. + */ + public NTriplesTopicMapReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.NTRIPLES, source); + } + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the topic map from. + * @param docIRI The document IRI which is used to resolve IRIs against. + */ + public NTriplesTopicMapReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.NTRIPLES, source, docIRI); + } + + /** + * Constructs a new instance. + * + * @param topicMap The topic map to which the content is added to. + * @param source The source to read the serialized topic map from. + */ + public NTriplesTopicMapReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.NTRIPLES, source); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/NTriplesTopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java 2008-11-25 14:11:21 UTC (rev 235) @@ -0,0 +1,118 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.File; +import java.net.URL; + +/** + * Specialization of the {@link TopicMapReader} which provides methods to + * define an external RDF to Topic Maps (RTM) mapping source. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface RDFTopicMapReader extends TopicMapReader { + + /** + * Represents the syntax of a RTM mapping. + */ + public enum MappingSyntax { + /** + * N3 syntax. + */ + N3, + /** + * N-Triples syntax. + */ + NTRIPLES, + /** + * RDF/XML syntax. + */ + RDFXML, + /** + * TriG syntax. + */ + TRIG, + /** + * TriX syntax. + */ + TRIX, + /** + * Turtle syntax. + */ + TURTLE + }; + + /** + * Sets the file to read the RDF2TM mapping from. + * + * @see #setMappingSource(URL) + * @see #setMappingSource(String) + * + * @param file The file to read the RDF2TM mapping from. + */ + public void setMappingSource(File file); + + /** + * Sets the URL to read the RDF2TM mapping from. + * + * @see #setMappingSource(File) + * @see #setMappingSource(String) + * + * @param url The URL to read the RDF2TM mapping from. + */ + public void setMappingSource(URL url); + + /** + * Sets the URL to read the RDF2TM mapping from. + * + * @see #setMappingSource(File) + * @see #setMappingSource(URL) + * + * @param iri A string that represents an IRI / URL. + */ + public void setMappingSource(String iri); + + /** + * Returns the mapping source or <tt>null</tt> if no source is defined. + * + * @return A string representing an IRI or <tt>null</tt> if no source is defined. + */ + public String getMappingSource(); + + /** + * Sets the syntax of the mapping source. + * <p> + * By default, the reader tries to detect the syntax by the file + * extension. + * </p> + * + * @param syntax The syntax of the mapping source or <tt>null</tt> to + * let the reader autodetec... [truncated message content] |
From: <lh...@us...> - 2008-11-24 15:35:49
|
Revision: 234 http://tinytim.svn.sourceforge.net/tinytim/?rev=234&view=rev Author: lheuer Date: 2008-11-24 15:35:42 +0000 (Mon, 24 Nov 2008) Log Message: ----------- - Added a constructor to JTMTopicMapWriter to specify the encoding (default: utf-8) - Minor changes, mostly docs Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java 2008-11-23 18:17:48 UTC (rev 233) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java 2008-11-24 15:35:42 UTC (rev 234) @@ -25,7 +25,7 @@ * it is good enough to support JTM. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class JSONWriter { @@ -34,27 +34,51 @@ private int _depth; private boolean _prettify; - public JSONWriter(OutputStream out) throws IOException { - _out = new OutputStreamWriter(out, "utf-8"); + public JSONWriter(OutputStream out, String encoding) throws IOException { + _out = new OutputStreamWriter(out, encoding); } + /** + * Enables / disables newlines and indentation of JSON elements. + * (newlines and indentation is enabled by default) + * + * @param prettify <tt>true</tt> to enable prettified JSON, otherwise <tt>false</tt>. + */ public void setPrettify(boolean prettify) { _prettify = prettify; } + /** + * Returns if newlines and indentation are enabled. + * + * @return <tt>true</tt> if prettified JSON is enabled, otherwise <tt>false</tt>. + */ public boolean getPrettify() { return _prettify; } + /** + * Indicates the start of the serialization. + */ public void startDocument() { _depth = 0; } + /** + * Indicates the end of the serialization. + * + * @throws IOException If an error occurs. + */ public void endDocument() throws IOException { _out.write('\n'); _out.flush(); } + /** + * Indents a line, iff {@link #getPrettify()} is enabled. + * + * @throws IOException If an error occurs. + */ private void _indent() throws IOException { if (!_prettify) { return; @@ -70,6 +94,11 @@ _out.write(chars); } + /** + * Start of a JSON object. + * + * @throws IOException If an error occurs. + */ public void startObject() throws IOException { if (_wantComma) { _out.write(','); @@ -80,18 +109,33 @@ _wantComma = false; } + /** + * End of a JSON object. + * + * @throws IOException If an error occurs. + */ public void endObject() throws IOException { _out.write('}'); _depth--; _wantComma = true; } + /** + * Start of a JSON array. + * + * @throws IOException If an error occurs. + */ public void startArray() throws IOException { _out.write('['); _depth++; _wantComma = false; } + /** + * End of a JSON array. + * + * @throws IOException If an error occurs. + */ public void endArray() throws IOException { _out.write(']'); _depth--; @@ -103,8 +147,8 @@ * The writer assumes that the key is a valid JSON string (ensured by * by JTM) so the keys are not escaped! * - * @param key - * @throws IOException + * @param key The key to write. + * @throws IOException If an error occurs. */ public void key(String key) throws IOException { if (_wantComma) { @@ -118,6 +162,12 @@ _wantComma = false; } + /** + * The value to write. The value is written in an escaped form. + * + * @param value The value to write. + * @throws IOException If an error occurs. + */ public void value(String value) throws IOException { if (_wantComma) { _out.write(','); @@ -127,10 +177,10 @@ } /** - * + * Escapes a string value. * - * @param value - * @return + * @param value The string to escape. + * @return An escaped string, usable as JSON value. */ public static String escape(String value) { // Code adapted from JSON.org (JSONObject.quote(String)) @@ -140,12 +190,11 @@ char c = 0; char[] chars = value.toCharArray(); StringBuilder sb = new StringBuilder(chars.length + 4); - String t; sb.append('"'); - for (int i = 0; i < chars.length; i += 1) { + for (int i=0; i<chars.length; i++) { b = c; c = chars[i]; - switch (chars[i]) { + switch (c) { case '\\': case '"': sb.append('\\'); @@ -175,9 +224,10 @@ default: if (c < ' ' || (c >= '\u0080' && c < '\u00a0') || (c >= '\u2000' && c < '\u2100')) { - t = "000" + Integer.toHexString(c); - sb.append("\\u" + t.substring(t.length() - 4)); - } else { + sb.append("\\u000") + .append(Integer.toHexString(c)); + } + else { sb.append(c); } } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-23 18:17:48 UTC (rev 233) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-24 15:35:42 UTC (rev 234) @@ -59,15 +59,30 @@ private Topic _defaultNameType; /** + * Creates a JTM writer, using "utf-8" encoding. + * + * @param out The stream the JTM is written onto. + * @param baseIRI The base IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. + */ + public JTMTopicMapWriter(OutputStream out, String baseIRI) throws IOException { + this(out, baseIRI, "utf-8"); + } + + /** * Creates a JTM writer. * * @param out The stream the JTM is written onto. * @param baseIRI The base IRI which is used to resolve IRIs against. + * @param encoding The encoding to use. * @throws IOException If an error occurs. */ - public JTMTopicMapWriter(OutputStream out, String baseIRI) throws IOException { + public JTMTopicMapWriter(OutputStream out, String baseIRI, String encoding) throws IOException { + if (encoding == null) { + throw new IOException("The encoding must not be null"); + } _baseIRI = baseIRI; - _out = new JSONWriter(out); + _out = new JSONWriter(out, encoding); _out.setPrettify(true); } @@ -126,6 +141,16 @@ _out.endDocument(); } + /** + * Serializes the specified topic. + * <p> + * The default name type topic is omitted in case it carries no further + * characteristics. + * </p> + * + * @param topic The topic to serialize. + * @throws IOException If an error occurs. + */ private void _writeTopic(Topic topic) throws IOException { // Ignore the topic if it is the default name type and it has no further // characteristics @@ -165,6 +190,12 @@ _out.endObject(); } + /** + * Serializes the specified name. + * + * @param name The name to serialize. + * @throws IOException If an error occurs. + */ private void _writeName(Name name) throws IOException { _out.startObject(); _writeReifier(name); @@ -186,6 +217,12 @@ _out.endObject(); } + /** + * Serializes the specified variant. + * + * @param variant The variant to serialize. + * @throws IOException If an error occurs. + */ private void _writeVariant(Variant variant) throws IOException { _out.startObject(); _writeReifier(variant); @@ -195,6 +232,12 @@ _out.endObject(); } + /** + * Serializes the specifed occurrence. + * + * @param occ The occurrence. + * @throws IOException If an error occurs. + */ private void _writeOccurrence(Occurrence occ) throws IOException { _out.startObject(); _writeReifier(occ); @@ -205,6 +248,12 @@ _out.endObject(); } + /** + * Writes the value and datatype of an occurrence or variant. + * + * @param datatyped The datatype-aware construct. + * @throws IOException If an error occurs. + */ private void _writeDatatypeAware(DatatypeAware datatyped) throws IOException { Locator datatype = datatyped.getDatatype(); String value = XSD.ANY_URI.equals(datatype) ? datatyped.locatorValue().toExternalForm() @@ -213,10 +262,24 @@ _writeKeyValue("datatype", datatype.toExternalForm()); } + /** + * Serializes the item identifiers of the specified construct. + * + * @param construct The construct to serialize the iids from. + * @throws IOException If an error occurs. + */ private void _writeItemIdentifiers(Construct construct) throws IOException { _writeLocators("item_identifiers", construct.getItemIdentifiers()); } + /** + * Writes a set of locators under the specified name. If the set is + * empty, this method does nothing. + * + * @param name The name (item_identifiers, subject_identifiers, subject_locators) + * @param locators A (maybe empty) set of locators. + * @throws IOException If an error occurs. + */ private void _writeLocators(String name, Set<Locator> locators) throws IOException { if (locators.isEmpty()) { return; @@ -229,6 +292,12 @@ _out.endArray(); } + /** + * Serializes the specified asssociation. + * + * @param assoc The association to serialize. + * @throws IOException If an error occurs. + */ private void _writeAssociation(Association assoc) throws IOException { Set<Role> roles = assoc.getRoles(); if (roles.isEmpty()) { @@ -248,6 +317,12 @@ _out.endObject(); } + /** + * Serializes the specified role. + * + * @param role The role to serialize. + * @throws IOException If an error occurs. + */ private void _writeRole(Role role) throws IOException { _out.startObject(); _writeReifier(role); @@ -257,10 +332,22 @@ _out.endObject(); } + /** + * Writes the type of a typed construct. + * + * @param typed The typed construct. + * @throws IOException If an error occurs. + */ private void _writeType(Typed typed) throws IOException { _writeKeyValue("type", _topicRef(typed.getType())); } + /** + * Writes the scope. + * + * @param scoped The scoped construct to retrieve the scope from. + * @throws IOException If an error occurs. + */ private void _writeScope(Scoped scoped) throws IOException { IScope scope = ((IScoped) scoped).getScopeObject(); if (scope.isUnconstrained()) { @@ -303,6 +390,12 @@ _out.endObject(); } + /** + * Serializes the reifier iff the reifier is not <tt>null</tt>. + * + * @param reifiable The reifiable construct to retrieve the reifier from. + * @throws IOException If an error occurs. + */ private void _writeReifier(Reifiable reifiable) throws IOException { Topic reifier = reifiable.getReifier(); if (reifier == null) { @@ -311,6 +404,13 @@ _writeKeyValue("reifier", _topicRef(reifier)); } + /** + * Writes a key/value pair. + * + * @param key The key to write. + * @param value The value to write. + * @throws IOException If an error occurs. + */ private void _writeKeyValue(String key, String value) throws IOException { _out.key(key); _out.value(value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-23 18:18:01
|
Revision: 233 http://tinytim.svn.sourceforge.net/tinytim/?rev=233&view=rev Author: lheuer Date: 2008-11-23 18:17:48 +0000 (Sun, 23 Nov 2008) Log Message: ----------- Better link to JTM Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-23 18:17:48 UTC (rev 233) @@ -42,11 +42,11 @@ /** * A {@link TopicMapWriter} implementation that serializes a topic map into - * a <a href="http://www.cerny-online.com/topincs/">JSON Topic Maps</a> + * a <a href="http://www.cerny-online.com/topincs/technical-whitepaper">JSON Topic Maps (JTM)</a> * representation. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class JTMTopicMapWriter implements TopicMapWriter { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-23 14:50:31
|
Revision: 232 http://tinytim.svn.sourceforge.net/tinytim/?rev=232&view=rev Author: lheuer Date: 2008-11-23 14:50:27 +0000 (Sun, 23 Nov 2008) Log Message: ----------- - Added JSON Topic Maps (JTM) writer - Made prettifying XML configurable - Updated MIO XTM lib Modified Paths: -------------- tinytim-mio/trunk/CHANGES.txt tinytim-mio/trunk/build-15.xml tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3.jar tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM10TopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM20TopicMapWriter.java Added Paths: ----------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/CHANGES.txt 2008-11-23 14:50:27 UTC (rev 232) @@ -17,8 +17,9 @@ - Snello - LTM 1.3 * Moved CXTMWriter into .mio package, implements TopicMapWriter -* XTM 1.0 writer -* XTM 2.0 writer +* JSON Topic Maps (JTM) writer +* XML Topic Maps (XTM) 1.0 writer +* XML Topic Maps (XTM) 2.0 writer * Deprecated some TopicMapImporter methods which take a sax.InputSource as argument * Added docs to TopicMapImporter that it may become deprecated Modified: tinytim-mio/trunk/build-15.xml =================================================================== --- tinytim-mio/trunk/build-15.xml 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/build-15.xml 2008-11-23 14:50:27 UTC (rev 232) @@ -123,7 +123,7 @@ <target name="compile" depends="clean, prepare"> <javac destdir="${dir.build.classes}" debug="${debug}" - excludes="org/tinytim/mio/AbstractTopicMapWriter* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter*" + excludes="org/tinytim/mio/AbstractTopicMapWriter* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter* org/tinytim/mio/JTM* org/tinytim/mio/JSON*" includes="org/tinytim/mio15/** org/tinytim/mio/*TopicMapReader* org/tinytim/mio/*TopicMapImporter*" target="1.5"> <classpath> Modified: tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3.jar =================================================================== (Binary files differ) Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -29,7 +29,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -abstract class AbstractXTMWriter extends AbstractTopicMapWriter { +abstract class AbstractXTMTopicMapWriter extends AbstractTopicMapWriter { protected final AttributesImpl _attrs; @@ -42,7 +42,7 @@ * @param baseIRI The base IRI. * @throws IOException If an error occurs. */ - protected AbstractXTMWriter(final OutputStream out, final String baseIRI) + protected AbstractXTMTopicMapWriter(final OutputStream out, final String baseIRI) throws IOException { this(out, baseIRI, "utf-8"); } @@ -59,14 +59,34 @@ * @throws IOException * If an error occurs. */ - protected AbstractXTMWriter(final OutputStream out, final String baseIRI, + protected AbstractXTMTopicMapWriter(final OutputStream out, final String baseIRI, final String encoding) throws IOException { super(baseIRI); if (encoding == null) { throw new IOException("The encoding must not be null"); } _out = new XMLWriter(out, encoding); + _out.setPrettify(true); _attrs = new AttributesImpl(); } + /** + * Enables / disables newlines and indentation of XML elements. + * (newlines and indentation is enabled by default) + * + * @param prettify <tt>true</tt> to enable prettified XML, otherwise <tt>false</tt>. + */ + public void setPrettify(boolean prettify) { + _out.setPrettify(prettify); + } + + /** + * Returns if newlines and indentation are enabled. + * + * @return <tt>true</tt> if prettified XML is enabled, otherwise <tt>false</tt>. + */ + public boolean getPrettify() { + return _out.getPrettify(); + } + } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMTopicMapWriter.java 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMTopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -29,6 +29,7 @@ import java.util.Set; import java.util.logging.Logger; +import org.tinytim.internal.api.IIndexManagerAware; import org.tinytim.internal.utils.CollectionFactory; import org.tinytim.utils.DuplicateRemovalUtils; import org.tinytim.voc.TMDM; @@ -143,7 +144,7 @@ */ public void write(TopicMap topicMap) throws IOException { DuplicateRemovalUtils.removeDuplicates(topicMap); - TypeInstanceIndex typeInstanceIndex = topicMap.getIndex(TypeInstanceIndex.class); + TypeInstanceIndex typeInstanceIndex = ((IIndexManagerAware)topicMap).getIndexManager().getTypeInstanceIndex(); if (!typeInstanceIndex.isAutoUpdated()) { typeInstanceIndex.reindex(); } Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -0,0 +1,217 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; + +/** + * Simple JSON serializer. This class is not usable as a generic JSON writer + * since it is possible to create an invalid JSON representation, but + * it is good enough to support JTM. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class JSONWriter { + + private OutputStreamWriter _out; + private boolean _wantComma; + private int _depth; + private boolean _prettify; + + public JSONWriter(OutputStream out) throws IOException { + _out = new OutputStreamWriter(out, "utf-8"); + } + + public void setPrettify(boolean prettify) { + _prettify = prettify; + } + + public boolean getPrettify() { + return _prettify; + } + + public void startDocument() { + _depth = 0; + } + + public void endDocument() throws IOException { + _out.write('\n'); + _out.flush(); + } + + private void _indent() throws IOException { + if (!_prettify) { + return; + } + if (_depth > 0) { + _out.write('\n'); + } + int indent = _depth*2; + char[] chars = new char[indent]; + for (int i=0; i<indent; i++) { + chars[i] = ' '; + } + _out.write(chars); + } + + public void startObject() throws IOException { + if (_wantComma) { + _out.write(','); + } + _indent(); + _out.write('{'); + _depth++; + _wantComma = false; + } + + public void endObject() throws IOException { + _out.write('}'); + _depth--; + _wantComma = true; + } + + public void startArray() throws IOException { + _out.write('['); + _depth++; + _wantComma = false; + } + + public void endArray() throws IOException { + _out.write(']'); + _depth--; + _wantComma = true; + } + + /** + * Writes the key of a <tt>"key": value</tt> pair. + * The writer assumes that the key is a valid JSON string (ensured by + * by JTM) so the keys are not escaped! + * + * @param key + * @throws IOException + */ + public void key(String key) throws IOException { + if (_wantComma) { + _out.write(','); + _indent(); + } + _out.write('"'); + _out.write(key); + _out.write('"'); + _out.write(':'); + _wantComma = false; + } + + public void value(String value) throws IOException { + if (_wantComma) { + _out.write(','); + } + _out.write(escape(value)); + _wantComma = true; + } + + /** + * + * + * @param value + * @return + */ + public static String escape(String value) { + // Code adapted from JSON.org (JSONObject.quote(String)) + // Copyrighted by JSON.org licensed under a BSD-license, see + // complete copyright notice at the end of this file. + char b; + char c = 0; + char[] chars = value.toCharArray(); + StringBuilder sb = new StringBuilder(chars.length + 4); + String t; + sb.append('"'); + for (int i = 0; i < chars.length; i += 1) { + b = c; + c = chars[i]; + switch (chars[i]) { + case '\\': + case '"': + sb.append('\\'); + sb.append(c); + break; + case '/': + if (b == '<') { + sb.append('\\'); + } + sb.append(c); + break; + case '\b': + sb.append("\\b"); + break; + case '\t': + sb.append("\\t"); + break; + case '\n': + sb.append("\\n"); + break; + case '\f': + sb.append("\\f"); + break; + case '\r': + sb.append("\\r"); + break; + default: + if (c < ' ' || (c >= '\u0080' && c < '\u00a0') || + (c >= '\u2000' && c < '\u2100')) { + t = "000" + Integer.toHexString(c); + sb.append("\\u" + t.substring(t.length() - 4)); + } else { + sb.append(c); + } + } + } + sb.append('"'); + return sb.toString(); + } + + /* + =========================================================================== + Copyright of the JSONObject code which was used to implement the "escape" + function. + =========================================================================== + + Copyright (c) 2002 JSON.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + The Software shall be used for Good, not Evil. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JSONWriter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -0,0 +1,347 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Set; + +import org.tinytim.internal.api.IIndexManagerAware; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.IScoped; +import org.tinytim.voc.TMDM; +import org.tinytim.voc.XSD; + +import org.tmapi.core.Association; +import org.tmapi.core.Construct; +import org.tmapi.core.DatatypeAware; +import org.tmapi.core.Locator; +import org.tmapi.core.Name; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Reifiable; +import org.tmapi.core.Role; +import org.tmapi.core.Scoped; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.Typed; +import org.tmapi.core.Variant; +import org.tmapi.index.TypeInstanceIndex; + +/** + * A {@link TopicMapWriter} implementation that serializes a topic map into + * a <a href="http://www.cerny-online.com/topincs/">JSON Topic Maps</a> + * representation. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class JTMTopicMapWriter implements TopicMapWriter { + + private static final String _TMDM_TYPE_INSTANCE = TMDM.TYPE_INSTANCE.getReference(); + private static final String _TMDM_TYPE = TMDM.TYPE.getReference(); + private static final String _TMDM_INSTANCE = TMDM.INSTANCE.getReference(); + + private JSONWriter _out; + private String _baseIRI; + private Topic _defaultNameType; + + /** + * Creates a JTM writer. + * + * @param out The stream the JTM is written onto. + * @param baseIRI The base IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. + */ + public JTMTopicMapWriter(OutputStream out, String baseIRI) throws IOException { + _baseIRI = baseIRI; + _out = new JSONWriter(out); + _out.setPrettify(true); + } + + /** + * Enables / disables newlines and indentation of JSON elements. + * (newlines and indentation is enabled by default) + * + * @param prettify <tt>true</tt> to enable prettified JSON, otherwise <tt>false</tt>. + */ + public void setPrettify(boolean prettify) { + _out.setPrettify(prettify); + } + + /** + * Returns if newlines and indentation are enabled. + * + * @return <tt>true</tt> if prettified JSON is enabled, otherwise <tt>false</tt>. + */ + public boolean getPrettify() { + return _out.getPrettify(); + } + + /* (non-Javadoc) + * @see org.tinytim.mio.TopicMapWriter#write(org.tmapi.core.TopicMap) + */ + public void write(TopicMap topicMap) throws IOException { + _defaultNameType = topicMap.getTopicBySubjectIdentifier(TMDM.TOPIC_NAME); + _out.startDocument(); + _out.startObject(); + _writeReifier(topicMap); + _writeItemIdentifiers(topicMap); + _out.key("topics"); + _out.startArray(); + for (Topic topic: topicMap.getTopics()) { + _writeTopic(topic); + } + _out.endArray(); + _out.key("associations"); + _out.startArray(); + for (Association assoc: topicMap.getAssociations()) { + _writeAssociation(assoc); + } + // Write type-instance relationships + TypeInstanceIndex tiIdx = ((IIndexManagerAware) topicMap).getIndexManager().getTypeInstanceIndex(); + if (!tiIdx.isAutoUpdated()) { + tiIdx.reindex(); + } + for (Topic type: tiIdx.getTopicTypes()) { + for (Topic instance: tiIdx.getTopics(type)) { + _writeTypeInstance(type, instance); + } + } + tiIdx.close(); + _out.endArray(); + _out.endObject(); + _out.endDocument(); + } + + private void _writeTopic(Topic topic) throws IOException { + // Ignore the topic if it is the default name type and it has no further + // characteristics + if (_isDefaultNameType(topic) + && topic.getReified() == null + && topic.getSubjectIdentifiers().size() == 1 + && topic.getSubjectLocators().isEmpty() + && topic.getItemIdentifiers().isEmpty() + && topic.getRolesPlayed().isEmpty() + && topic.getTypes().isEmpty() + && topic.getNames().isEmpty() + && topic.getOccurrences().isEmpty()) { + return; + } + _out.startObject(); + _writeItemIdentifiers(topic); + _writeLocators("subject_identifiers", topic.getSubjectIdentifiers()); + _writeLocators("subject_locators", topic.getSubjectLocators()); + Set<Name> names = topic.getNames(); + if (!names.isEmpty()) { + _out.key("names"); + _out.startArray(); + for (Name name: names) { + _writeName(name); + } + _out.endArray(); + } + Set<Occurrence> occs = topic.getOccurrences(); + if (!occs.isEmpty()) { + _out.key("occurrences"); + _out.startArray(); + for (Occurrence occ: occs) { + _writeOccurrence(occ); + } + _out.endArray(); + } + _out.endObject(); + } + + private void _writeName(Name name) throws IOException { + _out.startObject(); + _writeReifier(name); + _writeItemIdentifiers(name); + if (!_isDefaultNameType(name.getType())) { + _writeType(name); + } + _writeScope(name); + _writeKeyValue("value", name.getValue()); + Set<Variant> variants = name.getVariants(); + if (!variants.isEmpty()) { + _out.key("variants"); + _out.startArray(); + for (Variant variant: variants) { + _writeVariant(variant); + } + _out.endArray(); + } + _out.endObject(); + } + + private void _writeVariant(Variant variant) throws IOException { + _out.startObject(); + _writeReifier(variant); + _writeItemIdentifiers(variant); + _writeScope(variant); + _writeDatatypeAware(variant); + _out.endObject(); + } + + private void _writeOccurrence(Occurrence occ) throws IOException { + _out.startObject(); + _writeReifier(occ); + _writeItemIdentifiers(occ); + _writeType(occ); + _writeScope(occ); + _writeDatatypeAware(occ); + _out.endObject(); + } + + private void _writeDatatypeAware(DatatypeAware datatyped) throws IOException { + Locator datatype = datatyped.getDatatype(); + String value = XSD.ANY_URI.equals(datatype) ? datatyped.locatorValue().toExternalForm() + : datatyped.getValue(); + _writeKeyValue("value", value); + _writeKeyValue("datatype", datatype.toExternalForm()); + } + + private void _writeItemIdentifiers(Construct construct) throws IOException { + _writeLocators("item_identifiers", construct.getItemIdentifiers()); + } + + private void _writeLocators(String name, Set<Locator> locators) throws IOException { + if (locators.isEmpty()) { + return; + } + _out.key(name); + _out.startArray(); + for (Locator loc: locators) { + _out.value(loc.toExternalForm()); + } + _out.endArray(); + } + + private void _writeAssociation(Association assoc) throws IOException { + Set<Role> roles = assoc.getRoles(); + if (roles.isEmpty()) { + return; + } + _out.startObject(); + _writeReifier(assoc); + _writeItemIdentifiers(assoc); + _writeType(assoc); + _writeScope(assoc); + _out.key("roles"); + _out.startArray(); + for (Role role: roles) { + _writeRole(role); + } + _out.endArray(); + _out.endObject(); + } + + private void _writeRole(Role role) throws IOException { + _out.startObject(); + _writeReifier(role); + _writeItemIdentifiers(role); + _writeType(role); + _writeKeyValue("player", _topicRef(role.getPlayer())); + _out.endObject(); + } + + private void _writeType(Typed typed) throws IOException { + _writeKeyValue("type", _topicRef(typed.getType())); + } + + private void _writeScope(Scoped scoped) throws IOException { + IScope scope = ((IScoped) scoped).getScopeObject(); + if (scope.isUnconstrained()) { + return; + } + _out.key("scope"); + _out.startArray(); + for (Topic theme: scope) { + _out.value(_topicRef(theme)); + } + _out.endArray(); + } + + /** + * Writes a type-instance association. + * <p> + * JTM provides no shortcut like "instanceOf" at the topic level to indicate + * that a topic is an instance of another topic, all type-instance + * relationships must be encoded as associations. + * </p> + * + * @param type The topic which plays the <tt>tmdm:type</tt> role. + * @param instance The topic which plays the <tt>tmdm:instance</tt> role. + * @throws IOException If an error occurs. + */ + private void _writeTypeInstance(Topic type, Topic instance) throws IOException { + _out.startObject(); + _writeKeyValue("type", _TMDM_TYPE_INSTANCE); + _out.key("roles"); + _out.startArray(); + _out.startObject(); + _writeKeyValue("type", _TMDM_TYPE); + _writeKeyValue("player", _topicRef(type)); + _out.endObject(); + _out.startObject(); + _writeKeyValue("type", _TMDM_INSTANCE); + _writeKeyValue("player", _topicRef(instance)); + _out.endObject(); + _out.endArray(); + _out.endObject(); + } + + private void _writeReifier(Reifiable reifiable) throws IOException { + Topic reifier = reifiable.getReifier(); + if (reifier == null) { + return; + } + _writeKeyValue("reifier", _topicRef(reifier)); + } + + private void _writeKeyValue(String key, String value) throws IOException { + _out.key(key); + _out.value(value); + } + + /** + * Returns an IRI which is usable to as reference to the specified topic. + * + * @param topic The topic. + * @return An IRI. + */ + private String _topicRef(Topic topic) { + Set<Locator> locs = topic.getItemIdentifiers(); + if (!locs.isEmpty()) { + return locs.iterator().next().toExternalForm(); + } + locs = topic.getSubjectIdentifiers(); + if (!locs.isEmpty()) { + return locs.iterator().next().toExternalForm(); + } + return _baseIRI + "#" + topic.getId(); + } + + /** + * Checks if the specified <tt>topic</tt> is the default TMDM name type. + * + * @param topic The topic to check, not <tt>null</tt>. + * @return <tt>true</tt> if the topic is the default name type, otherwise <tt>false</tt>. + */ + private boolean _isDefaultNameType(final Topic topic) { + return topic.equals(_defaultNameType); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -39,6 +39,7 @@ private final String _encoding; private int _depth; + private boolean _prettify; public XMLWriter(OutputStream out) throws IOException { this(out, "utf-8"); @@ -49,6 +50,14 @@ _encoding = encoding; } + public void setPrettify(boolean prettify) { + _prettify = prettify; + } + + public boolean getPrettify() { + return _prettify; + } + /** * @see org.xml.sax.DocumentHandler#startDocument() */ @@ -83,9 +92,6 @@ * @see org.xml.sax.DocumentHandler#startElement(java.lang.String, org.xml.sax.AttributeList) */ public void startElement(String name, Attributes attrs) throws IOException { - if (_depth > 0) { - _newline(); - } _indent(); _out.write('<'); _out.write(name); @@ -106,8 +112,7 @@ */ public void _endElement(String name, boolean indent) throws IOException { _depth--; - if (indent && _depth >= 0) { - _newline(); + if (indent) { _indent(); } _out.write("</"); @@ -116,9 +121,6 @@ } public void emptyElement(String name, Attributes attrs) throws IOException { - if (_depth > 0) { - _newline(); - } _indent(); _out.write('<'); _out.write(name); @@ -158,6 +160,12 @@ } private void _indent() throws IOException { + if (!_prettify) { + return; + } + if (_depth > 0) { + _newline(); + } int indent = _depth*2; char[] chars = new char[indent]; for (int i=0; i<indent; i++) { Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM10TopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM10TopicMapWriter.java 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM10TopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -49,7 +49,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class XTM10TopicMapWriter extends AbstractXTMWriter { +public class XTM10TopicMapWriter extends AbstractXTMTopicMapWriter { private static final String _XSD_ANY_URI = "http://www.w3.org/2001/XMLSchema#anyURI"; Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM20TopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM20TopicMapWriter.java 2008-11-23 14:42:02 UTC (rev 231) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM20TopicMapWriter.java 2008-11-23 14:50:27 UTC (rev 232) @@ -58,7 +58,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class XTM20TopicMapWriter extends AbstractXTMWriter { +public class XTM20TopicMapWriter extends AbstractXTMTopicMapWriter { private static final String _XSD_ANY_URI = "http://www.w3.org/2001/XMLSchema#anyURI"; private static final String _XSD_STRING = "http://www.w3.org/2001/XMLSchema#string"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-23 14:42:07
|
Revision: 231 http://tinytim.svn.sourceforge.net/tinytim/?rev=231&view=rev Author: lheuer Date: 2008-11-23 14:42:02 +0000 (Sun, 23 Nov 2008) Log Message: ----------- Aligned naming Added Paths: ----------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java Removed Paths: ------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java Copied: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java (from rev 230, tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java) =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2008-11-23 14:42:02 UTC (rev 231) @@ -0,0 +1,72 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.IOException; +import java.io.OutputStream; + +import org.xml.sax.helpers.AttributesImpl; + +/** + * Abstract superclass for XTM serializers. + * <p> + * Provides a XML writer and takes care about the encoding. + * </p> + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +abstract class AbstractXTMWriter extends AbstractTopicMapWriter { + + protected final AttributesImpl _attrs; + + protected final XMLWriter _out; + + /** + * Creates a new instance using "utf-8" encoding. + * + * @param out The output stream to write onto. + * @param baseIRI The base IRI. + * @throws IOException If an error occurs. + */ + protected AbstractXTMWriter(final OutputStream out, final String baseIRI) + throws IOException { + this(out, baseIRI, "utf-8"); + } + + /** + * Creates a new instance. + * + * @param out + * The output stream to write onto. + * @param baseIRI + * The base IRI. + * @param encoding + * The encoding to use. + * @throws IOException + * If an error occurs. + */ + protected AbstractXTMWriter(final OutputStream out, final String baseIRI, + final String encoding) throws IOException { + super(baseIRI); + if (encoding == null) { + throw new IOException("The encoding must not be null"); + } + _out = new XMLWriter(out, encoding); + _attrs = new AttributesImpl(); + } + +} Deleted: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-22 16:59:38 UTC (rev 230) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-23 14:42:02 UTC (rev 231) @@ -1,72 +0,0 @@ -/* - * Copyright 2008 Lars Heuer (heuer[at]semagia.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.tinytim.mio; - -import java.io.IOException; -import java.io.OutputStream; - -import org.xml.sax.helpers.AttributesImpl; - -/** - * Abstract superclass for XTM serializers. - * <p> - * Provides a XML writer and takes care about the encoding. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -abstract class AbstractXTMWriter extends AbstractTopicMapWriter { - - protected final AttributesImpl _attrs; - - protected final XMLWriter _out; - - /** - * Creates a new instance using "utf-8" encoding. - * - * @param out The output stream to write onto. - * @param baseIRI The base IRI. - * @throws IOException If an error occurs. - */ - protected AbstractXTMWriter(final OutputStream out, final String baseIRI) - throws IOException { - this(out, baseIRI, "utf-8"); - } - - /** - * Creates a new instance. - * - * @param out - * The output stream to write onto. - * @param baseIRI - * The base IRI. - * @param encoding - * The encoding to use. - * @throws IOException - * If an error occurs. - */ - protected AbstractXTMWriter(final OutputStream out, final String baseIRI, - final String encoding) throws IOException { - super(baseIRI); - if (encoding == null) { - throw new IOException("The encoding must not be null"); - } - _out = new XMLWriter(out, encoding); - _attrs = new AttributesImpl(); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-22 16:59:45
|
Revision: 230 http://tinytim.svn.sourceforge.net/tinytim/?rev=230&view=rev Author: lheuer Date: 2008-11-22 16:59:38 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Added examples subproject Added Paths: ----------- tinytim-examples/ tinytim-examples/branches/ tinytim-examples/tags/ tinytim-examples/trunk/ tinytim-examples/trunk/src/ tinytim-examples/trunk/src/main/ tinytim-examples/trunk/src/main/java/ tinytim-examples/trunk/src/main/java/org/ tinytim-examples/trunk/src/main/java/org/tinytim/ tinytim-examples/trunk/src/main/java/org/tinytim/examples/ tinytim-examples/trunk/src/main/java/org/tinytim/examples/tinytim/ tinytim-examples/trunk/src/main/java/org/tinytim/examples/tmapi/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-22 14:25:19
|
Revision: 229 http://tinytim.svn.sourceforge.net/tinytim/?rev=229&view=rev Author: lheuer Date: 2008-11-22 14:25:14 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Docs to describe the differences between the impl. and the official LTM spec Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java 2008-11-22 11:47:57 UTC (rev 228) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java 2008-11-22 14:25:14 UTC (rev 229) @@ -27,6 +27,22 @@ /** * {@link TopicMapReader} implementation that is able to deserialize the * <a href="http://www.ontopia.net/download/ltm.html">Linear Topic Map Notation (LTM) 1.3</a>. + * This deserializer handles LTM instances somewhat different from the official + * specification: + * <ul> + * <li>Identifiers are not limited to <tt>[A-Za-z0-9_-.]</tt>, but may + * contain Unicode characters.</li> + * <li>Roles are not postprocessed; if a role does not have a type, the type + * is set to a default role type.</li> + * <li>Multiple subject locators are allowed: If a topic contains more than + * one subject locator, the subject locator is added to the topic.</li> + * <li>Subject identifiers / locators may occur in any order: The LTM + * specification seems to mandate, that the subject identifiers must be + * specified after an subject locator (if given); this implementation + * does not mandate any order; a subject locator may be followed by an + * subject identifier etc.</li> + * </ul> + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -104,8 +120,7 @@ // * @return <tt>true</tt> if "#MERGEMAP" is ignored, otherwise <tt>false</tt>. // */ // public boolean isIgnoringMergeMap() { -// Object property = _deserializer.getProperty(Property.IGNORE_MERGEMAP); -// return property instanceof Boolean && Boolean.TRUE.equals(property); +// return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_MERGEMAP)); // } // /** @@ -128,7 +143,6 @@ // * @return <tt>true</tt> if "#INCLUDE" is ignored, otherwise <tt>false</tt>. // */ // public boolean isIgnoringInclude() { -// Object property = _deserializer.getProperty(Property.IGNORE_INCLUDE); -// return property instanceof Boolean && Boolean.TRUE.equals(property); +// return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_INCLUDE)); // } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-22 11:48:01
|
Revision: 228 http://tinytim.svn.sourceforge.net/tinytim/?rev=228&view=rev Author: lheuer Date: 2008-11-22 11:47:57 +0000 (Sat, 22 Nov 2008) Log Message: ----------- File.toURL() is deprecated, changed to File.toURI().toURL() Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2008-11-22 11:14:10 UTC (rev 227) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2008-11-22 11:47:57 UTC (rev 228) @@ -56,7 +56,7 @@ */ protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, final File source) throws IOException { - this(topicMap, syntax, source, source.toURL().toString()); + this(topicMap, syntax, source, source.toURI().toURL().toString()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-22 11:14:15
|
Revision: 227 http://tinytim.svn.sourceforge.net/tinytim/?rev=227&view=rev Author: lheuer Date: 2008-11-22 11:14:10 +0000 (Sat, 22 Nov 2008) Log Message: ----------- - Updated MIO libs, no effects on tinyTiM's API - Converted TinyTimMapInputHandler's state array from int[] to byte[] (even if Java makes no distinction) - Removed "--" from XMLWriter's comment Modified Paths: -------------- tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar tinytim-mio/trunk/lib/semagia-mio-snello-0.9.3.jar tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3.jar tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java Modified: tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar =================================================================== (Binary files differ) Modified: tinytim-mio/trunk/lib/semagia-mio-snello-0.9.3.jar =================================================================== (Binary files differ) Modified: tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3.jar =================================================================== (Binary files differ) Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2008-11-21 15:16:07 UTC (rev 226) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2008-11-22 11:14:10 UTC (rev 227) @@ -47,18 +47,14 @@ import com.semagia.mio.MIOException; /** - * Abstract {@link com.semagia.mio.IMapHandler} implementation. - * <p> - * This class utilises the <tt>.core</tt> package since some <tt>...Impl</tt> - * classes have only package visibility. - * </p> + * Implementation of a {@link com.semagia.mio.IMapHandler} for tinyTiM. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ public final class TinyTimMapInputHandler implements IMapHandler { - private static final int + private static final byte INITIAL = 1, TOPIC = 2, ASSOCIATION = 3, @@ -80,7 +76,7 @@ private final IConstructFactory _factory; private final ITopicMap _tm; private final List<Topic> _scope; - private int[] _stateStack; + private byte[] _stateStack; private int _stateSize; private IConstruct[] _constructStack; private int _constructSize; @@ -99,7 +95,7 @@ */ public void startTopicMap() throws MIOException { _constructStack = new IConstruct[_CONSTRUCT_SIZE]; - _stateStack = new int[_STATE_SIZE]; + _stateStack = new byte[_STATE_SIZE]; _constructSize = 0; _stateSize = 0; _enterState(INITIAL, _tm); @@ -386,9 +382,9 @@ * * @param state The state to push ontop of the state stack. */ - private void _enterState(int state) { + private void _enterState(byte state) { if (_stateSize >= _stateStack.length) { - int[] states = new int[_stateStack.length*2]; + byte[] states = new byte[_stateStack.length*2]; System.arraycopy(_stateStack, 0, states, 0, _stateStack.length); _stateStack = states; } @@ -402,7 +398,7 @@ * @param state The state to enter. * @param tmo The Topic Maps construct which should be pushed to the stack. */ - private void _enterState(int state, Construct tmo) { + private void _enterState(byte state, Construct tmo) { _enterState(state); if (_constructSize >= _constructStack.length) { IConstruct[] constructs = new IConstruct[_constructStack.length*2]; @@ -418,7 +414,7 @@ * @param state The state to leave. * @throws MIOException If the state is not equals to the current state. */ - private void _leaveState(int state) throws MIOException { + private void _leaveState(byte state) throws MIOException { if (state != _state()) { _reportError("Unexpected state: " + _state() + ", expected: " + state); } @@ -432,7 +428,7 @@ * @param state The state to leave. * @throws MIOException If the state is not equals to the current state. */ - private IConstruct _leaveStatePopConstruct(int state) throws MIOException { + private IConstruct _leaveStatePopConstruct(byte state) throws MIOException { _leaveState(state); final IConstruct construct = _peekConstruct(); _constructSize--; @@ -463,7 +459,7 @@ * * @return The current state. */ - private int _state() { + private byte _state() { return _stateStack[_stateSize-1]; } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-21 15:16:07 UTC (rev 226) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-22 11:14:10 UTC (rev 227) @@ -57,7 +57,7 @@ _out.write(_encoding); _out.write("\" standalone=\"yes\"?>"); _newline(); - _out.write("<!-- Generated by tinyTiM -- http://tinytim.sourceforge.net/ -->"); + _out.write("<!-- Generated by tinyTiM - http://tinytim.sourceforge.net/ -->"); _newline(); _depth = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-21 15:16:10
|
Revision: 226 http://tinytim.svn.sourceforge.net/tinytim/?rev=226&view=rev Author: lheuer Date: 2008-11-21 15:16:07 +0000 (Fri, 21 Nov 2008) Log Message: ----------- Added 1.5-specific TinyTimMapInputHandler test Added Paths: ----------- tinytim-mio/trunk/src/test/java/org/tinytim/mio15/ tinytim-mio/trunk/src/test/java/org/tinytim/mio15/TestTinyTimMapInputHandler.java Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio15/TestTinyTimMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/test/java/org/tinytim/mio15/TestTinyTimMapInputHandler.java (rev 0) +++ tinytim-mio/trunk/src/test/java/org/tinytim/mio15/TestTinyTimMapInputHandler.java 2008-11-21 15:16:07 UTC (rev 226) @@ -0,0 +1,327 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import org.tinytim.Property; +import org.tinytim.TopicMapImpl; +import org.tinytim.voc.TMDM; +import org.tmapi.core.Locator; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMapSystem; +import org.tmapi.core.TopicMapSystemFactory; +import org.tmapi.core.TopicName; + +import com.semagia.mio.MIOException; +import com.semagia.mio.helpers.Ref; + +import junit.framework.TestCase; + +/** + * Tests against the {@link TinyTimMapInputHandler}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public class TestTinyTimMapInputHandler extends TestCase { + + private static final String _XSD_STRING = "http://www.w3.org/2001/XMLSchema#string"; + private static final String _XSD_ANY_URI = "http://www.w3.org/2001/XMLSchema#anyURI"; + + private TopicMapImpl _tm; + private TinyTimMapInputHandler _handler; + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + TopicMapSystemFactory tmSysFactory = TopicMapSystemFactory.newInstance(); + tmSysFactory.setProperty(Property.XTM10_REIFICATION, "false"); + TopicMapSystem tmSys = tmSysFactory.newTopicMapSystem(); + _tm = (TopicMapImpl) tmSys.createTopicMap("http://sf.net/projects/tinytim/test"); + _handler = new TinyTimMapInputHandler(); + _handler.setTopicMap(_tm); + } + + /** + * Simple startTopicMap, followed by an endTopicMap event. + */ + public void testEmpty() throws Exception { + assertEquals(0, _tm.getTopics().size()); + assertEquals(0, _tm.getAssociations().size()); + _handler.startTopicMap(); + _handler.endTopicMap(); + assertEquals(0, _tm.getTopics().size()); + assertEquals(0, _tm.getAssociations().size()); + } + + /** + * Tests reifying a topic map. + */ + public void testTMReifier() throws Exception { + String itemIdent = "http://sf.net/projects/tinytim/test#1"; + assertEquals(0, _tm.getTopics().size()); + assertEquals(0, _tm.getAssociations().size()); + _handler.startTopicMap(); + _handler.startReifier(); + _handler.startTopic(Ref.createItemIdentifier(itemIdent)); + _handler.endTopic(); + _handler.endReifier(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + assertEquals(0, _tm.getAssociations().size()); + Topic topic = (Topic) _tm.getObjectByItemIdentifier(_tm.createLocator(itemIdent)); + assertNotNull(topic); + assertNotNull(_tm.getReifier()); + assertEquals(topic, _tm.getReifier()); + } + + /** + * Tests topic creation with an item identifier. + */ + public void testTopicIdentityItemIdentifier() throws Exception { + String itemIdent = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createItemIdentifier(itemIdent)); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Topic topic = (Topic) _tm.getObjectByItemIdentifier(_tm.createLocator(itemIdent)); + assertNotNull(topic); + } + + /** + * Tests topic creation with a subject identifier. + */ + public void testTopicIdentitySubjectIdentifier() throws Exception { + String subjIdent = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(subjIdent)); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(subjIdent)); + assertNotNull(topic); + } + + /** + * Tests topic creation with a subject locator. + */ + public void testTopicIdentitySubjectLocator() throws Exception { + String subjLoc = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectLocator(subjLoc)); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Topic topic = _tm.getTopicBySubjectLocator(_tm.createLocator(subjLoc)); + assertNotNull(topic); + } + + /** + * Tests transparent merging. + */ + public void testTopicMerging() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String itemIdent = "http://example.org/1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + // Topic in topic event + _handler.startTopic(Ref.createItemIdentifier(itemIdent)); + _handler.itemIdentifier(ref); + _handler.endTopic(); + _handler.startOccurrence(); + _handler.value("tinyTiM", _XSD_STRING); + _handler.endOccurrence(); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(ref)); + assertNotNull(topic); + assertEquals(topic, _tm.getObjectByItemIdentifier(_tm.createLocator(ref))); + assertEquals(topic, _tm.getObjectByItemIdentifier(_tm.createLocator(itemIdent))); + assertEquals(1, topic.getOccurrences().size()); + Occurrence occ = (Occurrence) topic.getOccurrences().iterator().next(); + assertEquals("tinyTiM", occ.getValue()); + } + + /** + * Tests assigning identities to a topic. + */ + public void testTopicIdentities1() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.itemIdentifier(ref); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Locator loc = _tm.createLocator(ref); + Topic topic = _tm.getTopicBySubjectIdentifier(loc); + assertNotNull(topic); + assertEquals(topic, _tm.getObjectByItemIdentifier(loc)); + } + + /** + * Tests assigning identities to a topic. + */ + public void testTopicIdentities2() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createItemIdentifier(ref)); + _handler.subjectIdentifier(ref); + _handler.endTopic(); + _handler.endTopicMap(); + assertEquals(1, _tm.getTopics().size()); + Locator loc = _tm.createLocator(ref); + Topic topic = _tm.getTopicBySubjectIdentifier(loc); + assertNotNull(topic); + assertEquals(topic, _tm.getObjectByItemIdentifier(loc)); + } + + /** + * Tests reifying the topic map. + */ + public void testTopicMapReifier() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + _handler.startTopicMap(); + _handler.startReifier(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.endTopic(); + _handler.endReifier(); + _handler.endTopicMap(); + assertNotNull(_tm.getReifier()); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(ref)); + assertNotNull(topic); + assertEquals(topic, _tm.getReifier()); + } + + /** + * Tests occurrence creation with a value of datatype xsd:string. + */ + public void testOccurrenceValueString() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String val = "tinyTiM"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.startOccurrence(); + _handler.value(val, _XSD_STRING); + _handler.endOccurrence(); + _handler.endTopic(); + _handler.endTopicMap(); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(ref)); + assertNotNull(topic); + Occurrence occ = (Occurrence) topic.getOccurrences().iterator().next(); + assertEquals(val, occ.getValue()); + } + + /** + * Tests occurrence creation with a value of datatype xsd:anyURI. + */ + public void testOccurrenceValueURI() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String val = "http://sf.net/projects/tinytim"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.startOccurrence(); + _handler.value(val, _XSD_ANY_URI); + _handler.endOccurrence(); + _handler.endTopic(); + _handler.endTopicMap(); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(ref)); + assertNotNull(topic); + Occurrence occ = (Occurrence) topic.getOccurrences().iterator().next(); + assertNull(occ.getValue()); + assertEquals(val, occ.getResource().getReference()); + } + + /** + * Tests if the name type is automatically set. + */ + public void testDefaultNameType() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String val = "tinyTiM"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.startName(); + _handler.value(val); + _handler.endName(); + _handler.endTopic(); + _handler.endTopicMap(); + Topic topic = _tm.getTopicBySubjectIdentifier(_tm.createLocator(ref)); + assertNotNull(topic); + TopicName name = (TopicName) topic.getTopicNames().iterator().next(); + assertEquals(val, name.getValue()); + assertNotNull(name.getType()); + assertTrue(name.getType().getSubjectIdentifiers().contains(TMDM.TOPIC_NAME)); + } + + /** + * Tests if a variant with no scope is reported as error. + */ + public void testVariantNoScopeError() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String val = "tinyTiM"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.startName(); + _handler.value(val); + _handler.startVariant(); + _handler.value(val, _XSD_STRING); + try { + _handler.endVariant(); + fail("A variant with no scope shouldn't be allowed"); + } + catch (MIOException ex) { + // noop. + } + } + + /** + * Tests if a variant with a scope equals to the parent's scope is rejected. + */ + public void testVariantNoScopeError2() throws Exception { + String ref = "http://sf.net/projects/tinytim/test#1"; + String theme = "http://sf.net/projects/tinytim/test#theme"; + String val = "tinyTiM"; + _handler.startTopicMap(); + _handler.startTopic(Ref.createSubjectIdentifier(ref)); + _handler.startName(); + _handler.startScope(); + _handler.startTheme(); + _handler.topicRef(Ref.createItemIdentifier(theme)); + _handler.endTheme(); + _handler.endScope(); + _handler.value(val); + + _handler.startVariant(); + _handler.value(val, _XSD_STRING); + _handler.startScope(); + _handler.startTheme(); + _handler.topicRef(Ref.createItemIdentifier(theme)); + _handler.endTheme(); + _handler.endScope(); + try { + _handler.endVariant(); + fail("A variant with a scope equals to the parent's scope shouldn't be allowed"); + } + catch (MIOException ex) { + // noop. + } + } + +} Property changes on: tinytim-mio/trunk/src/test/java/org/tinytim/mio15/TestTinyTimMapInputHandler.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: 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-11-21 14:12:54
|
Revision: 225 http://tinytim.svn.sourceforge.net/tinytim/?rev=225&view=rev Author: lheuer Date: 2008-11-21 14:12:50 +0000 (Fri, 21 Nov 2008) Log Message: ----------- Build scripts use SLF4J 1.5.6 now Modified Paths: -------------- tinytim-mio/trunk/build-15.xml tinytim-mio/trunk/build.xml Modified: tinytim-mio/trunk/build-15.xml =================================================================== --- tinytim-mio/trunk/build-15.xml 2008-11-21 14:09:38 UTC (rev 224) +++ tinytim-mio/trunk/build-15.xml 2008-11-21 14:12:50 UTC (rev 225) @@ -11,7 +11,7 @@ <property name="lib.junit" value="${dir.lib}/junit-4.5.jar"/> <property name="lib.tmapi" value="${dir.lib}/tmapi-1_0SP1.jar"/> <property name="lib.tinytim" value="${dir.lib}/tinytim-1.5.0b2.jar"/> - <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.2.jar"/> + <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.6.jar"/> <property name="lib.mio" value="${dir.lib}/semagia-mio-0.9.3.jar"/> <target name="help"> Modified: tinytim-mio/trunk/build.xml =================================================================== --- tinytim-mio/trunk/build.xml 2008-11-21 14:09:38 UTC (rev 224) +++ tinytim-mio/trunk/build.xml 2008-11-21 14:12:50 UTC (rev 225) @@ -11,7 +11,7 @@ <property name="lib.junit" value="${dir.lib}/junit-4.5.jar"/> <property name="lib.tmapi" value="${dir.lib}/tmapi-2.0a1.jar"/> <property name="lib.tinytim" value="${dir.lib}/tinytim-2.0.0a3.jar"/> - <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.2.jar"/> + <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.6.jar"/> <property name="lib.mio" value="${dir.lib}/semagia-mio-0.9.3.jar"/> <target name="help"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-21 14:09:42
|
Revision: 224 http://tinytim.svn.sourceforge.net/tinytim/?rev=224&view=rev Author: lheuer Date: 2008-11-21 14:09:38 +0000 (Fri, 21 Nov 2008) Log Message: ----------- Updated SLF4J to 1.5.6 Added Paths: ----------- tinytim-mio/trunk/lib/slf4j-api-1.5.6.jar tinytim-mio/trunk/lib/slf4j-jdk14-1.5.6.jar Removed Paths: ------------- tinytim-mio/trunk/lib/slf4j-api-1.5.2.jar tinytim-mio/trunk/lib/slf4j-jdk14-1.5.2.jar Deleted: tinytim-mio/trunk/lib/slf4j-api-1.5.2.jar =================================================================== (Binary files differ) Added: tinytim-mio/trunk/lib/slf4j-api-1.5.6.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/slf4j-api-1.5.6.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: tinytim-mio/trunk/lib/slf4j-jdk14-1.5.2.jar =================================================================== (Binary files differ) Added: tinytim-mio/trunk/lib/slf4j-jdk14-1.5.6.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/slf4j-jdk14-1.5.6.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-21 13:17:53
|
Revision: 223 http://tinytim.svn.sourceforge.net/tinytim/?rev=223&view=rev Author: lheuer Date: 2008-11-21 13:17:29 +0000 (Fri, 21 Nov 2008) Log Message: ----------- - Removed version info from XMLWriter - Added Sesame - Added backport of XTM(10|20)TopicMapWriter for 1.5 - Migrated 1.5 org.tinytim.cxtm.Canonicalizer to mio as CXTMTopicMapWriter (implements TopicMapWriter) for 1.5 - Removed datatype normalization from CXTMTopicMapWriter (1.5) Modified Paths: -------------- tinytim-mio/trunk/build-15.xml tinytim-mio/trunk/build.xml tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java Added Paths: ----------- tinytim-mio/trunk/lib/openrdf-sesame-2.2.1-onejar.jar tinytim-mio/trunk/src/main/java/org/tinytim/mio15/ tinytim-mio/trunk/src/main/java/org/tinytim/mio15/AbstractTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/CXTMTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/TinyTimMapInputHandler.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM10TopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio15/XTM20TopicMapWriter.java Removed Paths: ------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler-15.txt Modified: tinytim-mio/trunk/build-15.xml =================================================================== --- tinytim-mio/trunk/build-15.xml 2008-11-20 16:55:44 UTC (rev 222) +++ tinytim-mio/trunk/build-15.xml 2008-11-21 13:17:29 UTC (rev 223) @@ -121,11 +121,10 @@ <!-- Compile source files --> <!-- =================================================================== --> <target name="compile" depends="clean, prepare"> - <copy file="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler.java" tofile="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler-20.txt"/> - <copy file="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler-15.txt" tofile="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler.java" overwrite="true"/> <javac destdir="${dir.build.classes}" debug="${debug}" - excludes="org/tinytim/mio/XMLWriter* org/tinytim/mio/Abstract*Writer* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter*" + excludes="org/tinytim/mio/AbstractTopicMapWriter* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter*" + includes="org/tinytim/mio15/** org/tinytim/mio/*TopicMapReader* org/tinytim/mio/*TopicMapImporter*" target="1.5"> <classpath> <pathelement location="${lib.tmapi}"/> @@ -135,8 +134,6 @@ </classpath> <src path="${dir.src}"/> </javac> - <copy file="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler-20.txt" tofile="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler.java" overwrite="true"/> - <delete file="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler-20.txt"/> </target> <!-- =================================================================== --> Modified: tinytim-mio/trunk/build.xml =================================================================== --- tinytim-mio/trunk/build.xml 2008-11-20 16:55:44 UTC (rev 222) +++ tinytim-mio/trunk/build.xml 2008-11-21 13:17:29 UTC (rev 223) @@ -123,7 +123,8 @@ <target name="compile" depends="clean, prepare"> <javac destdir="${dir.build.classes}" debug="${debug}" - target="1.5"> + target="1.5" + excludes="org/tinytim/mio15/**"> <classpath> <pathelement location="${lib.tmapi}"/> <pathelement location="${lib.tinytim}"/> Added: tinytim-mio/trunk/lib/openrdf-sesame-2.2.1-onejar.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/openrdf-sesame-2.2.1-onejar.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler-15.txt =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler-15.txt 2008-11-20 16:55:44 UTC (rev 222) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler-15.txt 2008-11-21 13:17:29 UTC (rev 223) @@ -1,590 +0,0 @@ -/* - * Copyright 2008 Lars Heuer (heuer[at]semagia.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.tinytim.mio; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.logging.Logger; - -import org.tinytim.IReifiable; -import org.tinytim.ITyped; -import org.tinytim.TopicMapImpl; -import org.tinytim.TypeInstanceConverter; -import org.tinytim.voc.TMDM; -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.Locator; -import org.tmapi.core.Occurrence; -import org.tmapi.core.ScopedObject; -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; - -import com.semagia.mio.IMapHandler; -import com.semagia.mio.IRef; -import com.semagia.mio.MIOException; -import com.semagia.mio.voc.XSD; - -/** - * {@link com.semagia.mio.IMapHandler} implementation. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev: 123 $ - $Date: 2008-08-14 14:05:34 +0200 (Do, 14 Aug 2008) $ - */ -public class TinyTimMapInputHandler implements IMapHandler { - - private enum State { - INITIAL, TOPIC, ASSOCIATION, ROLE, OCCURRENCE, NAME, VARIANT, - SCOPE, THEME, REIFIER, PLAYER, ISA, TYPE; - } - - private static final Logger LOG = Logger.getLogger(TinyTimMapInputHandler.class.getName()); - - private TopicMapImpl _tm; - private List<State> _stateStack; - private List<TopicMapObject> _constructStack; - - public TinyTimMapInputHandler() { - } - - public TinyTimMapInputHandler(TopicMap topicMap) { - this(); - setTopicMap(topicMap); - } - - /** - * Sets the topic map instance to operate on. - * - * @param topicMap The topic map. - */ - public void setTopicMap(TopicMap topicMap) { - if (topicMap == null) { - throw new IllegalArgumentException("The topic map must not be null"); - } - _tm = (TopicMapImpl) topicMap; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startTopicMap() - */ - public void startTopicMap() throws MIOException { - _constructStack = new ArrayList<TopicMapObject>(); - _stateStack = new ArrayList<State>(); - _enterState(State.INITIAL, _tm); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endTopicMap() - */ - public void endTopicMap() throws MIOException { - TypeInstanceConverter.convertAssociationsToTypes(_tm); - _constructStack = null; - _stateStack = null; - _tm = null; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startTopic(com.semagia.mio.IRef) - */ - public void startTopic(IRef identity) throws MIOException { - _enterState(State.TOPIC, _createTopic(identity)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endTopic() - */ - public void endTopic() throws MIOException { - Topic topic = (Topic) _leaveStatePopConstruct(State.TOPIC); - _handleTopic(topic); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startAssociation() - */ - public void startAssociation() throws MIOException { - _enterState(State.ASSOCIATION, _tm.createAssociation()); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endAssociation() - */ - public void endAssociation() throws MIOException { - _leaveStatePopConstruct(State.ASSOCIATION); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startRole() - */ - public void startRole() throws MIOException { - assert _state() == State.ASSOCIATION; - _enterState(State.ROLE, ((Association) _peekConstruct()).createAssociationRole(null, null)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endRole() - */ - public void endRole() throws MIOException { - _leaveStatePopConstruct(State.ROLE); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startPlayer() - */ - public void startPlayer() throws MIOException { - assert _state() == State.ROLE; - _enterState(State.PLAYER); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endPlayer() - */ - public void endPlayer() throws MIOException { - _leaveState(State.PLAYER); - assert _state() == State.ROLE; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startOccurrence() - */ - public void startOccurrence() throws MIOException { - _enterState(State.OCCURRENCE, _peekTopic().createOccurrence((Locator) null, null, null)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endOccurrence() - */ - public void endOccurrence() throws MIOException { - _leaveStatePopConstruct(State.OCCURRENCE); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startName() - */ - public void startName() throws MIOException { - _enterState(State.NAME, _peekTopic().createTopicName(null, null)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endName() - */ - public void endName() throws MIOException { - TopicName name = (TopicName) _leaveStatePopConstruct(State.NAME); - if (name.getType() == null) { - name.setType(_topicBySubjectIdentifier(TMDM.TOPIC_NAME)); - } - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startVariant() - */ - public void startVariant() throws MIOException { - assert _state() == State.NAME; - _enterState(State.VARIANT, ((TopicName) _peekConstruct()).createVariant((Locator) null, null)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endVariant() - */ - @SuppressWarnings("unchecked") - public void endVariant() throws MIOException { - Variant variant = (Variant) _leaveStatePopConstruct(State.VARIANT); - Collection<Topic> scope = variant.getScope(); - if (scope.isEmpty() || variant.getTopicName().getScope().equals(scope)) { - throw new MIOException("The variant has no scope"); - } - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startType() - */ - public void startType() throws MIOException { - assert _peekConstruct() instanceof ITyped; - _enterState(State.TYPE); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endType() - */ - public void endType() throws MIOException { - _leaveState(State.TYPE); - assert _peekConstruct() instanceof ITyped; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startScope() - */ - public void startScope() throws MIOException { - assert _peekConstruct() instanceof ScopedObject; - _enterState(State.SCOPE); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endScope() - */ - public void endScope() throws MIOException { - _leaveState(State.SCOPE); - assert _peekConstruct() instanceof ScopedObject; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startTheme() - */ - public void startTheme() throws MIOException { - assert _state() == State.SCOPE; - _enterState(State.THEME); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endTheme() - */ - public void endTheme() throws MIOException { - _leaveState(State.THEME); - assert _state() == State.SCOPE; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#subjectIdentifier(java.lang.String) - */ - public void subjectIdentifier(String subjectIdentifier) throws MIOException { - Locator sid = _tm.createLocator(subjectIdentifier); - Topic topic = _peekTopic(); - Topic existing = _tm.getTopicBySubjectIdentifier(sid); - if (existing != null && !existing.equals(topic)) { - _merge(existing, topic); - } - else { - TopicMapObject tmo = _tm.getObjectByItemIdentifier(sid); - if (tmo != null && tmo instanceof Topic && !tmo.equals(topic)) { - _merge((Topic) tmo, topic); - } - } - topic.addSubjectIdentifier(sid); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#subjectLocator(java.lang.String) - */ - public void subjectLocator(String subjectLocator) throws MIOException { - Locator slo = _tm.createLocator(subjectLocator); - Topic topic = _peekTopic(); - Topic existing = _tm.getTopicBySubjectLocator(slo); - if (existing != null && !existing.equals(topic)) { - _merge(existing, topic); - } - topic.addSubjectLocator(slo); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#itemIdentifier(java.lang.String) - */ - public void itemIdentifier(String itemIdentifier) throws MIOException { - Locator iid = _tm.createLocator(itemIdentifier); - TopicMapObject tmo = _peekConstruct(); - if (_state() == State.TOPIC) { - TopicMapObject existing = _tm.getObjectByItemIdentifier(iid); - if (existing != null && existing instanceof Topic && !existing.equals(tmo)) { - _merge((Topic) existing, (Topic) tmo); - } - else { - Topic topic = _tm.getTopicBySubjectIdentifier(iid); - if (topic != null && !topic.equals(tmo)) { - _merge(topic, (Topic) tmo); - } - } - } - tmo.addSourceLocator(iid); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startIsa() - */ - public void startIsa() throws MIOException { - assert _state() == State.TOPIC; - _enterState(State.ISA); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endIsa() - */ - public void endIsa() throws MIOException { - _leaveState(State.ISA); - assert _state() == State.TOPIC; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#startReifier() - */ - public void startReifier() throws MIOException { - assert _peekConstruct() instanceof IReifiable; - _enterState(State.REIFIER); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#endReifier() - */ - public void endReifier() throws MIOException { - _leaveState(State.REIFIER); - assert _peekConstruct() instanceof IReifiable; - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#topicRef(com.semagia.mio.IRef) - */ - public void topicRef(IRef identity) throws MIOException { - _handleTopic(_createTopic(identity)); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#value(java.lang.String) - */ - public void value(String value) throws MIOException { - assert _state() == State.NAME; - ((TopicName) _peekConstruct()).setValue(value); - } - - /* (non-Javadoc) - * @see com.semagia.mio.IMapHandler#value(java.lang.String, java.lang.String) - */ - public void value(String value, String datatype) throws MIOException { - boolean isLocator = XSD.ANY_URI.equals(datatype); - if (!isLocator && !XSD.STRING.equals(datatype)) { - LOG.warning("The datatype '" + datatype + "' was converted into xsd:string"); - } - if (_state() == State.OCCURRENCE) { - Occurrence occ = (Occurrence) _peekConstruct(); - if (isLocator) { - occ.setResource(_tm.createLocator(value)); - } - else { - occ.setValue(value); - } - } - else { - assert _state() == State.VARIANT; - Variant variant = (Variant) _peekConstruct(); - if (isLocator) { - variant.setResource(_tm.createLocator(value)); - } - else { - variant.setValue(value); - } - } - } - - /** - * Enters a state. - * - * @param state The state to push ontop of the state stack. - */ - private void _enterState(State state) { - _stateStack.add(state); - } - - /** - * Enters a state and pushes the Topic Maps construct ontop of the construct - * stack. - * - * @param state The state to enter. - * @param tmo The Topic Maps construct which should be pushed to the stack. - */ - private void _enterState(State state, TopicMapObject tmo) { - _enterState(state); - _constructStack.add(tmo); - } - - /** - * Leaves a state. - * - * @param state The state to leave. - * @throws MIOException If the state is not equals to the current state. - */ - private void _leaveState(State state) throws MIOException { - State current = _stateStack.remove(_stateStack.size()-1); - if (state != current) { - _reportError("Unexpected state: " + current + ", expected: " + state); - } - } - - /** - * Leaves a state and removed the Topic Maps construct from the top of the - * construct stack. - * - * @param state The state to leave. - * @return The removed construct. - * @throws MIOException If the state is not equals to the current state. - */ - private TopicMapObject _leaveStatePopConstruct(State state) throws MIOException { - _leaveState(state); - return _constructStack.remove(_constructStack.size()-1); - } - - /** - * Returns the Topic Maps construct on top of the stack. - * - * @return The Topic Maps construct. - */ - private TopicMapObject _peekConstruct() { - return _constructStack.get(_constructStack.size()-1); - } - - /** - * Returns the topic on top of the stack. - * - * @return The topic. - */ - private Topic _peekTopic() { - return (Topic) _peekConstruct(); - } - - /** - * Returns the current state. - * - * @return The current state. - */ - private State _state() { - return _stateStack.get(_stateStack.size()-1); - } - - /** - * Handles the topic dependent on the current state. - * - * @param topic The topic to handle. - */ - private void _handleTopic(Topic topic) { - switch (_state()) { - case ISA: _peekTopic().addType(topic); break; - case TYPE: ((ITyped) _peekConstruct()).setType(topic); break; - case PLAYER: ((AssociationRole) _peekConstruct()).setPlayer(topic); break; - case THEME: ((ScopedObject) _peekConstruct()).addScopingTopic(topic); break; - case REIFIER: ((IReifiable) _peekConstruct()).setReifier(topic); break; - } - } - - /** - * Merges the <tt>source</tt> topic with the <tt>target</tt>. - * - * Further, this method ensures that the construct stack stays valid: If - * the <tt>source</tt> is part of the stack, it is replaced with - * <tt>target</tt>. - * - * @param source The source topic (will be removed). - * @param target The target topic. - */ - private void _merge(Topic source, Topic target) { - int i = _constructStack.indexOf(source); - while (i > -1) { - _constructStack.set(i, target); - i = _constructStack.indexOf(source); - } - target.mergeIn(source); - } - - /** - * Returns either an existing topic with the specified identity or creates - * a topic with the given identity. - * - * @param ref The identity of the topic. - * @return A topic instance. - * @throws MIOException - */ - private Topic _createTopic(IRef ref) throws MIOException { - Locator loc = _tm.createLocator(ref.getIRI()); - switch (ref.getType()) { - case IRef.ITEM_IDENTIFIER: return _topicByItemIdentifier(loc); - case IRef.SUBJECT_IDENTIFIER: return _topicBySubjectIdentifier(loc); - case IRef.SUBJECT_LOCATOR: return _topicBySubjectLocator(loc); - default: _reportError("Unknown reference type " + ref.getType()); - } - // Never returned, an exception was thrown - return null; - } - - /** - * Returns either an existing topic with the specified item identfier, - * or creates a topic with the given item identifier. - * - * @param iid The item identifier of the topic. - * @return A topic instance. - */ - private Topic _topicByItemIdentifier(Locator iid) { - TopicMapObject tmo = _tm.getObjectByItemIdentifier(iid); - Topic topic = (tmo instanceof Topic) ? (Topic) tmo : null; - if (topic == null) { - topic = _tm.getTopicBySubjectIdentifier(iid); - if (topic != null) { - topic.addSourceLocator(iid); - } - } - if (topic == null) { - topic = _tm.createTopic(); - topic.addSourceLocator(iid); - } - return topic; - } - - /** - * Returns either an existing topic with the specified subject identfier, - * or creates a topic with the given subject identifier. - * - * @param sid The subject identifier of the topic. - * @return A topic instance. - */ - private Topic _topicBySubjectIdentifier(Locator sid) { - Topic topic = _tm.getTopicBySubjectIdentifier(sid); - if (topic == null) { - TopicMapObject tmo = _tm.getObjectByItemIdentifier(sid); - if (tmo instanceof Topic) { - topic = (Topic) tmo; - topic.addSubjectIdentifier(sid); - } - } - if (topic == null) { - topic = _tm.createTopic(); - topic.addSubjectIdentifier(sid); - } - return topic; - } - - /** - * Returns either an existing topic with the specified subject locator, - * or creates a topic with the given subject locator. - * - * @param slo The subject locator of the topic. - * @return A topic instance. - */ - private Topic _topicBySubjectLocator(Locator slo) { - Topic topic = _tm.getTopicBySubjectLocator(slo); - if (topic == null) { - topic = _tm.createTopic(); - topic.addSubjectLocator(slo); - } - return topic; - } - - /** - * Reports an error. - * - * @param msg The error message. - * @throws MIOException Thrown in any case. - */ - private static void _reportError(String msg) throws MIOException { - throw new MIOException(msg); - } - -} Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-20 16:55:44 UTC (rev 222) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-21 13:17:29 UTC (rev 223) @@ -19,7 +19,6 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; -import org.tinytim.Version; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; @@ -58,9 +57,7 @@ _out.write(_encoding); _out.write("\" standalone=\"yes\"?>"); _newline(); - _out.write("<!-- Generated by tinyTiM v"); - _out.write(Version.RELEASE); - _out.write(" - http://tinytim.sourceforge.net/ -->"); + _out.write("<!-- Generated by tinyTiM -- http://tinytim.sourceforge.net/ -->"); _newline(); _depth = 0; } Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio15/AbstractTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio15/AbstractTopicMapWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio15/AbstractTopicMapWriter.java 2008-11-21 13:17:29 UTC (rev 223) @@ -0,0 +1,73 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.util.Set; + +import org.tmapi.core.Locator; +import org.tmapi.core.Topic; + +/** + * Common, abstract superclass for {@link TopicMapWriter} implementations. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +abstract class AbstractTopicMapWriter implements TopicMapWriter { + + protected final String _baseIRI; + + protected AbstractTopicMapWriter(final String baseIRI) { + _baseIRI = baseIRI; + } + + /** + * Returns an identifier for the topic. + * <p> + * The algorithm tries to avoid to use the internal identifier which may + * cause yet another item identifier. If the topic has an item identifier + * which starts with the specified IRI provided in the constructor, the + * algorithm tries to use the fragment identifier. + * </p> + * + * @param topic The topic to return an identifier for. + * @return An identifier, never <tt>null</tt>. + */ + protected String _getId(final Topic topic) { + String id = null; + @SuppressWarnings("unchecked") + Set<Locator> iids = topic.getSourceLocators(); + for (Locator loc: iids) { + String reference = loc.getReference(); + if (!reference.startsWith(_baseIRI)) { + continue; + } + int fragIdx = reference.indexOf('#'); + if (fragIdx < 0) { + continue; + } + id = reference.substring(fragIdx+1); + if (id.startsWith("id-")) { + id = null; + } + if (id != null) { + break; + } + } + return id != null ? id : "id-" + topic.getObjectId(); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio15/AbstractTopicMapWriter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio15/CXTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio15/CXTMTopicMapWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio15/CXTMTopicMapWriter.java 2008-11-21 13:17:29 UTC (rev 223) @@ -0,0 +1,1261 @@ +/* + * Copyright 2008 Lars Heuer (heuer[at]semagia.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.tinytim.mio; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.AbstractSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.logging.Logger; + +import org.tinytim.DuplicateRemovalUtils; +import org.tinytim.IConstruct; +import org.tinytim.IDatatypeAwareConstruct; +import org.tinytim.IReifiable; +import org.tinytim.ITyped; +import org.tinytim.TopicMapImpl; +import org.tinytim.index.ITypeInstanceIndex; +import org.tinytim.voc.TMDM; +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.DuplicateSourceLocatorException; +import org.tmapi.core.Locator; +import org.tmapi.core.MergeException; +import org.tmapi.core.ModelConstraintException; +import org.tmapi.core.Occurrence; +import org.tmapi.core.ScopedObject; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicInUseException; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicMapObject; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +import org.xml.sax.Attributes; +import org.xml.sax.helpers.AttributesImpl; + +/** + * Provides serialization of topic maps into Canonical XTM (CXTM). + * <p> + * CXTM is a format that guarantees that two equivalent Topic Maps Data Model + * instances [ISO/IEC 13250-2] will always produce byte-by-byte identical + * serializations, and that non-equivalent instances will always produce + * different serializations. + * </p> + * <p> + * See <a href="http://www.isotopicmaps.org/cxtm/">http://www.isotopicmaps.org/cxtm/</a> + * for details. + * </p> + * <p> + * <em>CAUTION</em>: This class implements the + * <a href="http://www.isotopicmaps.org/cxtm/">CXTM draft dtd. 2008-05-15</a>, + * the output may change in the future. + * </p> + * <p> + * The canonicalizer IS NOT a generic TMAPI-compatible implementation. It + * requires tinyTiM. The canonicalizer requires that the property + * {@link org.tinytim.Property#XTM10_REIFICATION} is set to <tt>false</tt> and + * that the property {@link org.tinytim.Property#INHERIT_NAME_SCOPE} is enabled + * (set to <tt>true</tt>). + * </p> + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public final class CXTMTopicMapWriter implements TopicMapWriter { + + private static final Logger LOG = Logger.getLogger(CXTMTopicMapWriter.class.getName()); + + private static final String _XSD_ANY_URI = "http://www.w3.org/2001/XMLSchema#anyURI"; + + private static final AssociationRole[] _EMPTY_ROLES = new AssociationRole[0]; + + private Topic _type; + private Topic _instance; + private Topic _typeInstance; + + private XMLC14NWriter _out; + private final String _normBase; + private Map<TopicMapObject, Integer> _construct2Id; + private Map<Topic, List<AssociationRole>> _topic2Roles; + private Map<String, String> _locator2Norm; + + private Comparator<Topic> _topicComparator; + private Comparator<Association> _assocComparator; + private Comparator<AssociationRole> _roleComparator; + private Comparator<Occurrence> _occComparator; + private Comparator<TopicName> _nameComparator; + private Comparator<Variant> _variantComparator; + private Comparator<Set<Locator>> _locSetComparator; + private Comparator<Locator> _locComparator; + private Comparator<Set<Topic>> _scopeComparator; + + private Map<Association, AssociationRole[]> _assoc2Roles; + + /** + * Creates a canonicalizer. + * + * @param out The stream the CXTM is written onto. + * @param baseLocator The base locator which is used to resolve IRIs against. + * @throws IOException If an error occurs. + */ + public CXTMTopicMapWriter(OutputStream out, String baseLocator) throws IOException { + if (baseLocator == null) { + throw new IllegalArgumentException("The base locator must not be null"); + } + _out = new XMLC14NWriter(out); + _normBase = _normalizeBaseLocator(baseLocator); + _topicComparator = new TopicComparator(); + _assocComparator = new AssociationComparator(); + _roleComparator = new RoleComparator(); + _occComparator = new OccurrenceComparator(); + _nameComparator = new NameComparator(); + _variantComparator = new VariantComparator(); + _locSetComparator = new LocatorSetComparator(); + _locComparator = new LocatorComparator(); + _scopeComparator = new ScopeComparator(); + } + + /** + * Serializes the specified <code>topicMap</code> into the CXTM format. + * <p> + * <em>CAUTION</em>: This method MAY modify the topic map since duplicate + * Topic Maps constructs (if any) are removed in advance. + * </p> + * <p> + * The topic map's base locator + * ({@link org.tmapi.core.TopicMap#getBaseLocator()}) is ignored. + * </p> + * + * @param topicMap The topic map to serialize. + * @throws IOException If an error occurs. + */ + public void write(TopicMap topicMap) throws IOException { + DuplicateRemovalUtils.removeDuplicates(topicMap); + _construct2Id = new IdentityHashMap<TopicMapObject, Integer>(); + _locator2Norm = new HashMap<String, String>(); + _assoc2Roles = new IdentityHashMap<Association, AssociationRole[]>(); + _topic2Roles = new IdentityHashMap<Topic, List<AssociationRole>>(); + ITypeInstanceIndex typeInstanceIndex = ((TopicMapImpl) topicMap).getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIndex.isAutoUpdated()) { + typeInstanceIndex.reindex(); + } + Topic[] topics = _fetchTopics(topicMap, typeInstanceIndex); + Association[] assocs = _fetchAssociations(topicMap, typeInstanceIndex); + typeInstanceIndex.close(); + _createIndex(topics, assocs); + _out.startDocument(); + AttributesImpl attrs = new AttributesImpl(); + _addReifier(attrs, (IReifiable)topicMap); + _out.startElement("topicMap", attrs); + _out.newline(); + _writeItemIdentifiers(topicMap); + for (Topic topic: topics) { + _writeTopic(topic); + } + for (Association assoc: assocs) { + _writeAssociation(assoc); + } + _out.endElement("topicMap"); + _out.newline(); + _out.endDocument(); + _out = null; + _construct2Id = null; + _locator2Norm = null; + _assoc2Roles = null; + _topic2Roles = null; + } + + /** + * Returns an unsorted array of topics which should be included into + * the output. + * + * This method may return more topics than {@link TopicMap#getTopics()} + * since this method creates virtual topics to model type-instance + * relationships properly. + * + * @param topicMap The topic map from which the topic should be serialized. + * @param idx A (upto date) type instance index. + * @return All topics which must be included into the output. + */ + @SuppressWarnings("unchecked") + private Topic[] _fetchTopics(TopicMap topicMap, ITypeInstanceIndex idx) { + Collection<Topic> types = idx.getTopicTypes(); + if (types.isEmpty()) { + Set<Topic> topics = topicMap.getTopics(); + return topics.toArray(new Topic[topics.size()]); + } + else { + List<Topic> topics = new ArrayList<Topic>(topicMap.getTopics()); + TopicMapImpl tm = (TopicMapImpl) topicMap; + _typeInstance = _getTopicBySubjectIdentifier(tm, topics, TMDM.TYPE_INSTANCE); + _type = _getTopicBySubjectIdentifier(tm, topics, TMDM.TYPE); + _instance = _getTopicBySubjectIdentifier(tm, topics, TMDM.INSTANCE); + return topics.toArray(new Topic[topics.size()]); + } + } + + /** + * Returns a topic by its subject identifier. If the topic is null, a + * {@link TypeInstanceTopic} is created, added to the <code>topics</code> + * and returned. + * + * @param tm The topic map to fetch the topic from. + * @param topics A modifiable collection of topics. + * @param sid The subject identifier. + * @return A topic with the specified subject identifier. + */ + private Topic _getTopicBySubjectIdentifier(TopicMapImpl tm, Collection<Topic> topics, Locator sid) { + Topic topic = tm.getTopicBySubjectIdentifier(sid); + if (topic == null) { + topic = new TypeInstanceTopic(sid); + topics.add(topic); + } + return topic; + } + + /** + * Returns an unsorted array of associations which should be serialized. + * + * This method may return more association than {@link TopicMap#getAssociations()} + * since this method may create virtual associations which are used to + * model type-instance relationships properly. + * + * @param tm The topic map from which the associations should be serialized. + * @param idx A (upto date) type instance index. + * @return An unsorted array of associations which must be included into the output. + */ + @SuppressWarnings("unchecked") + private Association[] _fetchAssociations(TopicMap tm, ITypeInstanceIndex idx) { + Collection<Topic> types = idx.getTopicTypes(); + if (types.isEmpty()) { + Set<Association> assocs = tm.getAssociations(); + return assocs.toArray(new Association[assocs.size()]); + } + else { + List<Association> assocs = new ArrayList<Association>(tm.getAssociations()); + for (Topic type: types) { + for (Topic instance: idx.getTopics(type)) { + assocs.add(new TypeInstanceAssociation(type, instance)); + } + } + return assocs.toArray(new Association[assocs.size()]); + } + } + + /** + * Creates the index on which the canonicalizer operates. + * + * As sideeffect, the provided topic and association arrays get sorted. + * + * @param topics An array of topics. + * @param assocs An array of associations. + */ + @SuppressWarnings("unchecked") + private void _createIndex(Topic[] topics, Association[] assocs) { + Arrays.sort(topics, _topicComparator); + Topic topic = null; + for (int i=0; i < topics.length; i++) { + topic = topics[i]; + _construct2Id.put(topic, Integer.valueOf(i+1)); + } + Arrays.sort(assocs, _assocComparator); + Association assoc = null; + for (int i=0; i < assocs.length; i++) { + assoc = assocs[i]; + _construct2Id.put(assoc, Integer.valueOf(i+1)); + Set<AssociationRole> roles_ = assoc.getAssociationRoles(); + AssociationRole[] roles = roles_.toArray(new AssociationRole[roles_.size()]); + Arrays.sort(roles, _roleComparator); + _assoc2Roles.put(assoc, roles); + for (int j=0; j < roles.length; j++) { + _construct2Id.put(roles[j], Integer.valueOf(j+1)); + } + } + } + + /** + * Returns a sorted array of roles of the provided association. + * + * @param assoc The association to retrieve the roles from. + * @return A (maybe empty) sorted array of roles. + */ + private AssociationRole[] _getRoles(Association assoc) { + AssociationRole[] roles = _assoc2Roles.get(assoc); + return roles != null ? roles : _EMPTY_ROLES; + } + + /** + * Returns a sorted array of names of the provided topic. + * + * @param topic The topic to retrieve the names from. + * @return A (maybe empty) sorted array of names. + */ + @SuppressWarnings("unchecked") + private TopicName[] _getNames(Topic topic) { + Set<TopicName> names_ = topic.getTopicNames(); + TopicName[] names = names_.toArray(new TopicName[names_.size()]); + Arrays.sort(names, _nameComparator); + return names; + } + + /** + * Returs a sorted array of variants of the provided name. + * + * @param name The name to retrieve the variants from. + * @return A (maybe empty) sorted array of variants. + */ + @SuppressWarnings("unchecked") + private Variant[] _getVariants(TopicName name) { + Set<Variant> variants_ = name.getVariants(); + Variant[] variants = variants_.toArray(new Variant[variants_.size()]); + Arrays.sort(variants, _variantComparator); + return variants; + } + + /** + * Returns a sorted array of occurrences of the provided topic. + * + * @param topic The topic to retrieve the occurrences from. + * @return A (maybe emtpy) sorted array of occurrences. + */ + @SuppressWarnings("unchecked") + private Occurrence[] _getOccurrences(Topic topic) { + Set<Occurrence> occs_ = topic.getOccurrences(); + Occurrence[] occs = occs_.toArray(new Occurrence[occs_.size()]); + Arrays.sort(occs, _occComparator); + return occs; + } + + /** + * Returns the index of the provided Topic Maps construct. + * + * The "index" is <cite>"[...] the string encoding of the position of this + * information item in the canonically ordered list of the values from + * that set".</cite> (CXTM 3.20 Constructing the number attribute). + * + * @param tmo The Topic Maps construct to return the index of. + * @return The index of the Topic Maps construct. + */ + private int _indexOf(TopicMapObject tmo) { + return _construct2Id.get(tmo).intValue(); + } + + /** + * Serializes the <code>topic</code>. + * + * @param topic The topic to serialize. + * @throws IOException If an error occurs. + */ + @SuppressWarnings("unchecked") + private void _writeTopic(Topic topic) throws IOException { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "number", null, null, "" +_indexOf(topic)); + _out.startElement("topic", attrs); + _out.newline(); + _writeLocatorSet("subjectIdentifiers", topic.getSubjectIdentifiers()); + _writeLocatorSet("subjectLocators", topic.getSubjectLocators()); + _writeItemIdentifiers(topic); + TopicName[] names = _getNames(topic); + for (int i=0; i < names.length; i++) { + _writeName(names[i], i+1); + } + Occurrence[] occs = _getOccurrences(topic); + for (int i=0; i < occs.length; i++) { + _writeOccurrence(occs[i], i+1); + } + Set<AssociationRole> roles_ = new HashSet<AssociationRole>(topic.getRolesPlayed()); + List<AssociationRole> alienRoles = _topic2Roles.get(topic); + if (alienRoles != null) { + roles_.addAll(alienRoles); + } + AssociationRole[] roles = roles_.toArray(new AssociationRole[roles_.size()]); + Arrays.sort(roles, _roleComparator); + AttributesImpl roleAttrs = new AttributesImpl(); + StringBuilder sb = new StringBuilder(); + for (int i=0; i < roles.length; i++) { + sb.append("association.") + .append(_indexOf(roles[i].getAssociation())) + .append(".role.") + .append(_indexOf(roles[i])); + roleAttrs.addAttribute("", "ref", null, null, sb.toString()); + _out.startElement("rolePlayed", roleAttrs); + _out.endElement("rolePlayed"); + _out.newline(); + sb.setLength(0); + roleAttrs.clear(); + } + _out.endElement("topic"); + _out.newline(); + } + + /** + * Serializes an association. + * + * @param assoc The association to serialize. + * @throws IOException If an error occurs. + */ + @SuppressWarnings("unchecked") + private void _writeAssociation(Association assoc) throws IOException { + _out.startElement("association", _attributes(assoc, _indexOf(assoc))); + _out.newline(); + _writeType((ITyped) assoc); + for (AssociationRole role: _getRoles(assoc)) { + _out.startElement("role", _attributes(role, _indexOf(role))); + _out.newline(); + _out.startElement("player", _topicRef(role.getPlayer())); + _out.endElement("player"); + _out.newline(); + _writeType((ITyped) role); + _writeItemIdentifiers(role); + _out.endElement("role"); + _out.newline(); + } + _writeScope(assoc); + _writeItemIdentifiers(assoc); + _out.endElement("association"); + _out.newline(); + } + + /** + * Serializes an occurrence. + * + * @param occ The occurrence to serialize. + * @throws IOException If an error occurs. + */ + private void _writeOccurrence(Occurrence occ, int pos) throws IOException { + _out.startElement("occurrence", _attributes(occ, pos)); + _out.newline(); + _writeDatatyped((IDatatypeAwareConstruct) occ); + _writeType((ITyped) occ); + _writeScope(occ); + _writeItemIdentifiers(occ); + _out.endElement("occurrence"); + _out.newline(); + } + + /** + * Writes the value/datatype pair of an occurrence or variant. + * + * @param obj The construct to serialize. + * @throws IOException If an error occurs. + */ + private void _writeDatatyped(IDatatypeAwareConstruct obj) throws IOException { + String value = obj.getValue2(); + String datatype = obj.getDatatype().getReference(); + //TODO: Handle xsd:decimal, xsd:integer, xsd:date, xsd:dateTime xsd:anyType(?!?) + if (_XSD_ANY_URI.equals(datatype)) { + value = _normalizeLocator(value); + } + _out.startElement("value"); + _out.characters(value); + _out.endElement("value"); + _out.newline(); + _out.startElement("datatype"); + _out.characters(datatype); + _out.endElement("datatype"); + _out.newline(); + } + + /** + * Serializes a topic name. + * + * @param name The name to serialize. + * @throws IOException If an error occurs. + */ + private void _writeName(TopicName name, int pos) throws IOException { + _out.startElement("name", _attributes(name, pos)); + _out.newline(); + _out.startElement("value"); + _out.characters(name.getValue()); + _out.endElement("value"); + _out.newline(); + _writeType((ITyped) name); + _writeScope(name); + Variant[] variants = _getVariants(name); + Variant variant = null; + for (int i=0; i<variants.length; i++) { + variant = variants[i]; + _out.startElement("variant", _attributes(variant, i+1)); + _out.newline(); + _writeDatatyped((IDatatypeAwareConstruct) variant); + _writeScope(variant); + _writeItemIdentifiers(variant); + _out.endElement("variant"); + _out.newline(); + } + _writeItemIdentifiers(name); + _out.endElement("name"); + _out.newline(); + } + + /** + * Serializes the type of a typed Topic Maps construct. + * + * @param typed The typed Topic Maps construct from which the type should be + * serialized. + * @throws IOException If an error occurs. + */ + private void _writeType(ITyped typed) throws IOException { + Topic type = typed.getType(); + if (type == null) { + _reportInvalid("The type of " + typed + " is null"); + } + _out.startElement("type", _topicRef(typed.getType())); + _out.endElement("type"); + _out.newline(); + } + + /** + * Serializes the scope of a scoped Topic Maps construct. + * + * If the scope is unconstrained, this method does nothing. + * + * @param scoped The scoped Topic Maps construct. + * @throws IOException If an error occurs. + */ + @SuppressWarnings("unchecked") + private void _writeScope(ScopedObject scoped) throws IOException { + Set<Topic> scope = scoped.getScope(); + if (scope.isEmpty()) { + return; + } + _out.startElement("scope"); + _out.newline(); + Topic[] themes = scope.toArray(new Topic[scope.size()]); + Arrays.sort(themes, _topicComparator); + for (int i=0; i < themes.length; i++) { + _out.startElement("scopingTopic", _topicRef(themes[i])); + _out.endElement("scopingTopic"); + _out.newline(); + } + _out.endElement("scope"); + _out.newline(); + } + + /** + * Serializes a locator. + * + * A normalized locator value is created which is serialized. + * + * @param loc The locator to serialize. + * @throws IOException If an error occurs. + */ + private void _writeLocator(Locator loc) throws IOException { + _out.startElement("locator"); + _out.characters(_normalizeLocator(loc.getReference())); + _out.endElement("locator"); + _out.newline(); + } + + /** + * Serializes the item identifiers of the specified Topic Maps construct. + * + * @param tmo The Topic Maps construct to take the item identifiers from. + * @throws IOException If an error occurs. + */ + @SuppressWarnings("unchecked") + private void _writeItemIdentifiers(TopicMapObject tmo) throws IOException { + _writeLocatorSet("itemIdentifiers", tmo.getSourceLocators()); + } + + /** + * Serializes the <code>locators</code> using the <code>localName</code> as + * element name. + * + * If the set of <code>locators</code> is empty, this method does nothing. + * + * @param localName The element's name. + * @param locators The locators to serialize. + * @throws IOException If an error occurs. + */ + private void _writeLocatorSet(String localName, Set<Locator> locators) throws IOException { + if (locators.isEmpty()) { + return; + } + Locator[] locs = locators.toArray(new Locator[locators.size()]); + Arrays.sort(locs, _locComparator); + _out.startElement(localName); + _out.newline(); + for (int i=0; i < locs.length; i++) { + _writeLocator(locs[i]); + } + _out.endElement(localName); + _out.newline(); + } + + /** + * Returns attributes which contains a reference to the provided topic. + * + * @param topic The topic to which the reference should point to. + * @return Attributes with a topic reference. + */ + private Attributes _topicRef(Topic topic) { + if (topic == null) { + _reportInvalid("The topic reference is null"); + return XMLC14NWriter.EMPTY_ATTRS; + } + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "topicref", null, null, ""+_indexOf(topic)); + return attrs; + } + + /** + * Returns attributes which contain the reifier (if any) and the number + * of the provided Topic Maps construct (not a topic). + * + * @param reifiable The Topic Maps construct. + * @return Attributes which contain a reference to the reifier (if any) and + * the number of the provided Topic Maps construct. + */ + private Attributes _attributes(TopicMapObject reifiable, int i) { + AttributesImpl attrs = new AttributesImpl(); + _addReifier(attrs, (IReifiable)reifiable); + attrs.addAttribute("", "number", null, null, "" + i); + return attrs; + } + + /** + * Adds a reference to the reifier of the Topic Maps construct to the + * provided attributes. If the Topic Maps construct has no reifier, the + * provided attributes are not modified. + * + * @param attrs The attributes. + * @param reifiable The reifiable Topic Maps construct. + */ + private void _addReifier(AttributesImpl attrs, IReifiable reifiable) { + Topic reifier = reifiable.getReifier(); + if (reifier != null) { + attrs.addAttribute("", "reifier", null, null, "" + _indexOf(reifier)); + } + } + + /** + * Normalizes the locator according to CXTM 3.19. + * + * @param locator The locator to normalize. + * @return A normalized representation of the locator. + */ + private String _normalizeLocator(String locator) { + String normLoc = _locator2Norm.get(locator); + if (normLoc != null) { + return normLoc; + } + normLoc = locator; + if (locator.startsWith(_normBase)) { + normLoc = locator.substring(_normBase.length()); + } + else { + int i = 0; + int slashPos = -1; + final int max = _normBase.length() < locator.length() ? _normBase.length() + : locator.length(); + while(i < max && _normBase.charAt(i) == locator.charAt(i)) { + if (_normBase.charAt(i) == '/') { + slashPos = i; + } + i++; + } + if (slashPos > -1) { + normLoc = locator.substring(slashPos); + } + } + if (normLoc.startsWith("/")) { + normLoc = normLoc.substring(1); + } + _locator2Norm.put(locator, normLoc); + return normLoc; + } + + /** + * Normalizes the base locator according to the following procedure + * (CXTM 3.19 - 1.): + * <cite>[...] the base locator with any fragment identifier and query + * removed and any trailing "/" character removed.[...]</cite> + * + * @param baseLocator + * @return + */ + private static String _normalizeBaseLocator(String baseLocator) { + String loc = baseLocator; + int i = loc.indexOf('#'); + if (i > 0) { + loc = loc.substring(0, i); + } + i = loc.indexOf('?'); + if (i > 0) { + loc = loc.substring(0, i); + } + if (loc.endsWith("/")) { + loc = loc.substring(0, loc.length()-1); + } + return loc; + } + + /** + * Writes a warning msg to the log. + * + * This method is used to inform the user that the serialized topic map + * is not valid acc. to CXTM. + * + * @param msg The warning message. + */ + private static void _reportInvalid(String msg) { + LOG.warning("Invalid CXTM: '" + msg + "'"); + } + + + /* + * Comparators. + */ + + private final class TopicComparator implements Comparator<Topic> { + + @SuppressWarnings("unchecked") + public int compare(Topic o1, Topic o2) { + if (o1 == o2) { + return 0; + } + if (o1 != null && o2 == null) { + _reportInvalid("Comparing topics where one topic is null"); + return +1; + } + else if (o1 == null && o2 != null) { + _reportInvalid("Comparing topics where one topic is null"); + return -1; + } + int res = _locSetComparator.compare(o1.getSubjectIdentifiers(), o2.getSubjectIdentifiers()); + if (res == 0) { + res = _locSetComparator.compare(o1.getSubjectLocators(), o2.getSubjectLocators()); + if (res == 0) { + res = _locSetComparator.compare(o1.getSourceLocators(), o2.getSourceLocators()); + } + } + return res; + } + } + + /** + * Abstract comparator that provides some utility methods which handle common + * comparisons. + */ + private abstract class AbstractComparator<T> implements Comparator<T> { + int compareString(String o1, String o2) { + if (o1 == null && o2 != null) { + _reportInvalid("The first string value is null"); + return -1; + } + if (o1 != null && o2 == null) { + _reportInvalid("The second string value is null"); + return +1; + } + return o1.compareTo(o2); + } + /** + * Extracts the type of the typed Topic Maps constructs and compares + * the topics. + * + * @param o1 The first typed Topic Maps construct. + * @param o2 The second typed Topic Maps construct. + * @return A negative integer, zero, or a positive integer as the + * first argument is less than, equal to, or greater than the + * second. + */ + int compareType(ITyped o1, ITyped o2) { + return _topicComparator.compare(o1.getType(), o2.getType()); + } + /** + * Extracts the scope of the scoped Topic Maps constructs and compares + * them. + * + * @param o1 The first scoped Topic Maps construct. + * @param o2 The second scoped Topic Maps construct. + * @return A negative integer, zero, or a positive integer as the + * first argument is less than, equal to, or greater than the + * second. + */ + @SuppressWarnings("unchecked") + int compareScope(ScopedObject o1, ScopedObject o2) { + return _scopeComparator.compare(o1.getScope(), o2.getScope()); + } + } + + /** + * Enhances the {@link AbstractComparator} with a method to compare the + * value and datatype of an occurrence or variant. + */ + private abstract class AbstractDatatypeAwareComparator<T> extends AbstractComparator<T> { + /** + * Compares the value and datatype of the occurrences / variants. + * + * @param o1 The first occurrence / variant. + * @param o2 The second occurrence / variant. + * @return A negative integer, zero, or a positive integer as the + * first argument is less than, equal to, or greater than the + * second. + */ + int _compareValueDatatype(IDatatypeAwareConstruct o1, IDatatypeAwareConstruct o2) { + int res = compareString(o1.getValue2(), o2.getValue2()); + if (res == 0) { + res = compareString(o1.getDatatype().getReference(), o2.getDatatype().getReference()); + } + return res; + } + } + + /** + * Canonical sort order: + * 1. [type] + * 2. [roles] + * 3. [scope] + * 4. [parent] + */ + private final class AssociationComparator extends AbstractComparator<Association> { + + private Comparator<Set<AssociationRole>> _roleSetComparator; + + AssociationComparator() { + _roleSetComparator = new RoleSetComparator(); + } + + @SuppressWarnings("unchecked") + public int compare(Association o1, Association o2) { + if (o1 == o2) { + return 0; + } + int res = compareType((ITyped) o1, (ITyped) o2); + if (res == 0) { + res = _roleSetComparator.compare(o1.getAssociationRoles(), o2.getAssociationRoles()); + if (res == 0) { + res = compareScope(o1, o2); + } + } + return res; + } ... [truncated message content] |
From: <lh...@us...> - 2008-11-20 16:55:49
|
Revision: 222 http://tinytim.svn.sourceforge.net/tinytim/?rev=222&view=rev Author: lheuer Date: 2008-11-20 16:55:44 +0000 (Thu, 20 Nov 2008) Log Message: ----------- - Update to tinytim-1.5.0b2 - Added interface TopicMapWriter to the 1.5 build, implementation are still excluded Modified Paths: -------------- tinytim-mio/trunk/build-15.xml Added Paths: ----------- tinytim-mio/trunk/lib/tinytim-1.5.0b2.jar Removed Paths: ------------- tinytim-mio/trunk/lib/tinytim-1.5.0beta.jar Modified: tinytim-mio/trunk/build-15.xml =================================================================== --- tinytim-mio/trunk/build-15.xml 2008-11-20 16:08:28 UTC (rev 221) +++ tinytim-mio/trunk/build-15.xml 2008-11-20 16:55:44 UTC (rev 222) @@ -10,7 +10,7 @@ <property name="lib.junit" value="${dir.lib}/junit-4.5.jar"/> <property name="lib.tmapi" value="${dir.lib}/tmapi-1_0SP1.jar"/> - <property name="lib.tinytim" value="${dir.lib}/tinytim-1.5.0beta.jar"/> + <property name="lib.tinytim" value="${dir.lib}/tinytim-1.5.0b2.jar"/> <property name="lib.logging" value="${dir.lib}/slf4j-api-1.5.2.jar"/> <property name="lib.mio" value="${dir.lib}/semagia-mio-0.9.3.jar"/> @@ -125,7 +125,7 @@ <copy file="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler-15.txt" tofile="${dir.src}/org/tinytim/mio/TinyTimMapInputHandler.java" overwrite="true"/> <javac destdir="${dir.build.classes}" debug="${debug}" - excludes="org/tinytim/mio/**Writer.*" + excludes="org/tinytim/mio/XMLWriter* org/tinytim/mio/Abstract*Writer* org/tinytim/mio/CXTMTopicMapWriter* org/tinytim/mio/XTM*TopicMapWriter*" target="1.5"> <classpath> <pathelement location="${lib.tmapi}"/> Added: tinytim-mio/trunk/lib/tinytim-1.5.0b2.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/tinytim-1.5.0b2.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: tinytim-mio/trunk/lib/tinytim-1.5.0beta.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-20 16:08:33
|
Revision: 221 http://tinytim.svn.sourceforge.net/tinytim/?rev=221&view=rev Author: lheuer Date: 2008-11-20 16:08:28 +0000 (Thu, 20 Nov 2008) Log Message: ----------- Fixed bug #2270475 Prepared release Modified Paths: -------------- tinytim/tags/release-1_5_0b2/CHANGES.txt tinytim/tags/release-1_5_0b2/build.properties tinytim/tags/release-1_5_0b2/src/main/java/org/tinytim/TopicUtils.java tinytim/tags/release-1_5_0b2/src/test/java/org/tinytim/TestTopicUtils.java Modified: tinytim/tags/release-1_5_0b2/CHANGES.txt =================================================================== --- tinytim/tags/release-1_5_0b2/CHANGES.txt 2008-11-20 16:04:19 UTC (rev 220) +++ tinytim/tags/release-1_5_0b2/CHANGES.txt 2008-11-20 16:08:28 UTC (rev 221) @@ -2,6 +2,13 @@ Changes Log =========== +1.5.0 b2 (20.11.2008) +----------------------- +Bugfixes: +--------- +* Bug #2270475 -- Topic types are not considered as dependency + + 1.5.0 beta (08.08.2008) ----------------------- Bugfixes: Modified: tinytim/tags/release-1_5_0b2/build.properties =================================================================== --- tinytim/tags/release-1_5_0b2/build.properties 2008-11-20 16:04:19 UTC (rev 220) +++ tinytim/tags/release-1_5_0b2/build.properties 2008-11-20 16:08:28 UTC (rev 221) @@ -1,4 +1,4 @@ version=1.5.0 -version_suffix=beta +version_suffix=b2 debug=off optimize=on Modified: tinytim/tags/release-1_5_0b2/src/main/java/org/tinytim/TopicUtils.java =================================================================== --- tinytim/tags/release-1_5_0b2/src/main/java/org/tinytim/TopicUtils.java 2008-11-20 16:04:19 UTC (rev 220) +++ tinytim/tags/release-1_5_0b2/src/main/java/org/tinytim/TopicUtils.java 2008-11-20 16:08:28 UTC (rev 221) @@ -84,7 +84,8 @@ boolean removable = typeInstanceIdx.getAssociations(topic).isEmpty() && typeInstanceIdx.getRoles(topic).isEmpty() && typeInstanceIdx.getOccurrences(topic).isEmpty() - && typeInstanceIdx.getNames(topic).isEmpty(); + && typeInstanceIdx.getNames(topic).isEmpty() + && typeInstanceIdx.getTopics(topic).isEmpty(); typeInstanceIdx.close(); if (removable) { IScopedIndex scopedIdx = idxMan.getScopedIndex(); Modified: tinytim/tags/release-1_5_0b2/src/test/java/org/tinytim/TestTopicUtils.java =================================================================== --- tinytim/tags/release-1_5_0b2/src/test/java/org/tinytim/TestTopicUtils.java 2008-11-20 16:04:19 UTC (rev 220) +++ tinytim/tags/release-1_5_0b2/src/test/java/org/tinytim/TestTopicUtils.java 2008-11-20 16:08:28 UTC (rev 221) @@ -61,6 +61,12 @@ ((IReifiable) assoc).setReifier(null); assertTrue(TopicUtils.isRemovable(topic)); assertTrue(TopicUtils.isRemovable(topic, true)); + // Topic type + Topic topic2 = _tm.createTopic(); + topic2.addType(topic); + assertFalse(TopicUtils.isRemovable(topic)); + topic2.removeType(topic); + 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-11-20 16:04:22
|
Revision: 220 http://tinytim.svn.sourceforge.net/tinytim/?rev=220&view=rev Author: lheuer Date: 2008-11-20 16:04:19 +0000 (Thu, 20 Nov 2008) Log Message: ----------- Tagged 1.5b2 Added Paths: ----------- tinytim/tags/release-1_5_0b2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |