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-11-14 15:44:05
|
Revision: 194 http://tinytim.svn.sourceforge.net/tinytim/?rev=194&view=rev Author: lheuer Date: 2008-11-14 15:44:03 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Tag for 2.0.0a3 Added Paths: ----------- tinytim/tags/release-2_0_0a3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-14 15:42:30
|
Revision: 193 http://tinytim.svn.sourceforge.net/tinytim/?rev=193&view=rev Author: lheuer Date: 2008-11-14 15:42:28 +0000 (Fri, 14 Nov 2008) Log Message: ----------- - Simplified Version.java - Preparation for release 2.0.0a3 Modified Paths: -------------- tinytim/trunk/build.properties tinytim/trunk/build.xml tinytim/trunk/src/main/java/org/tinytim/Version.java Modified: tinytim/trunk/build.properties =================================================================== --- tinytim/trunk/build.properties 2008-11-14 14:10:29 UTC (rev 192) +++ tinytim/trunk/build.properties 2008-11-14 15:42:28 UTC (rev 193) @@ -1,4 +1,5 @@ version=2.0.0 -version_suffix=a3-snapshot +version_suffix=a3 +#release_type= debug=off optimize=on Modified: tinytim/trunk/build.xml =================================================================== --- tinytim/trunk/build.xml 2008-11-14 14:10:29 UTC (rev 192) +++ tinytim/trunk/build.xml 2008-11-14 15:42:28 UTC (rev 193) @@ -1,6 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <project name="tinyTiM" default="jar" basedir="."> <property file="build.properties"/> + <tstamp/> + <property name="release_type" value="-snapshot-${DSTAMP}${TSTAMP}"/> <property name="dir.src" value="${basedir}/src/main/java"/> <property name="dir.test" value="${basedir}/src/test/java"/> @@ -42,7 +44,7 @@ </target> <target name="init"> - <property name="dist.version" value="${version}${version_suffix}"/> + <property name="dist.version" value="${version}${version_suffix}${release_type}"/> <property name="dist.name" value="tinytim-${dist.version}"/> <property name="tinytim.jar" value="${dist.name}.jar"/> @@ -146,6 +148,7 @@ <!-- Compile source files --> <!-- =================================================================== --> <target name="compile" depends="clean, prepare"> + <replace file="${dir.src}/org/tinytim/Version.java" token="@RELEASE@" value="${dist.version}"/> <javac destdir="${dir.build.classes}" debug="${debug}" target="1.5"> @@ -155,6 +158,7 @@ </classpath> <src path="${dir.src}"/> </javac> + <replace file="${dir.src}/org/tinytim/Version.java" token="${dist.version}" value="@RELEASE@"/> </target> <!-- =================================================================== --> @@ -175,10 +179,11 @@ <exclude name="org/tinytim/core/**"/> <exclude name="org/tinytim/index/**"/> <exclude name="org/tinytim/internal/**"/> + <exclude name="org/tinytim/utils/Property.*"/> </fileset> <!-- <doclet name="net.gleamynode.apiviz.APIviz" - path="${dir.lib}/apiviz-1.1.3.jar"> + path="${dir.lib}/apiviz-1.2.4.GA.jar"> </doclet> --> <link href="http://www.tmapi.org/2.0/api/"/> @@ -199,7 +204,7 @@ <manifest> <attribute name="Implementation-Title" value="tinyTiM"/> <attribute name="Implementation-Version" value="${dist.version}"/> - <attribute name="Implementation-URL" value="http://sourceforge.net/projects/tinytim"/> + <attribute name="Implementation-URL" value="http://tinytim.sourceforge.net/"/> </manifest> </jar> </target> @@ -215,7 +220,7 @@ <manifest> <attribute name="Implementation-Title" value="tinyTiM Tests"/> <attribute name="Implementation-Version" value="${dist.version}"/> - <attribute name="Implementation-URL" value="http://sourceforge.net/projects/tinytim"/> + <attribute name="Implementation-URL" value="http://tinytim.sourceforge.net/"/> </manifest> </jar> </target> @@ -232,6 +237,7 @@ <copy todir="${dir.dist}/src"> <fileset dir="${dir.src}"/> </copy> + <replace file="${dir.dist}/src/org/tinytim/Version.java" token="@RELEASE@" value="${dist.version}"/> <copy todir="${dir.dist}/test"> <fileset dir="${dir.test}"/> </copy> @@ -239,8 +245,10 @@ <fileset dir="${dir.lib}"> <include name="tmapi*"/> <include name="junit*"/> + <include name="trove*"/> + <include name="LICENSE.tmapi*"/> <include name="LICENSE.junit*"/> - <include name="LICENSE.tmapi*"/> + <include name="LICENSE.trove*"/> </fileset> </copy> Modified: tinytim/trunk/src/main/java/org/tinytim/Version.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/Version.java 2008-11-14 14:10:29 UTC (rev 192) +++ tinytim/trunk/src/main/java/org/tinytim/Version.java 2008-11-14 15:42:28 UTC (rev 193) @@ -23,16 +23,14 @@ */ public class Version { - private static final String _MAJOR = "@MAJOR@"; - private static final String _MINOR = "@MINOR@"; - private static final String _MICRO = "@MICRO@"; - private static final String _STATE ="@STATE@"; - private static final String _DATE = "@DATE@"; + private Version() { + // noop. + } /** * The release information. */ // Not final since Java compilers copy the string into classes - public static String RELEASE = _MAJOR + "." + _MINOR + "." + _MICRO + _STATE + _DATE; + public static String RELEASE = "@RELEASE@"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-14 14:10:36
|
Revision: 192 http://tinytim.svn.sourceforge.net/tinytim/?rev=192&view=rev Author: lheuer Date: 2008-11-14 14:10:29 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Replaced ""+long with String.valueOf(long) Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 13:59:23 UTC (rev 191) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 14:10:29 UTC (rev 192) @@ -107,7 +107,7 @@ private void _register(IConstruct construct) { ConstructImpl c = (ConstructImpl) construct; if (c._id == null) { - c._id = ("" + IdGenerator.nextId()).intern(); + c._id = String.valueOf(IdGenerator.nextId()).intern(); } if (!_id2Construct.containsKey(c._id)) { _id2Construct.put(c._id, c); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-14 13:59:25
|
Revision: 191 http://tinytim.svn.sourceforge.net/tinytim/?rev=191&view=rev Author: lheuer Date: 2008-11-14 13:59:23 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Switch back to interned construct ids Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 13:39:21 UTC (rev 190) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 13:59:23 UTC (rev 191) @@ -50,7 +50,7 @@ private final Map<String, IConstruct> _id2Construct; IdentityManager(MemoryTopicMap tm) { - _id2Construct = CollectionFactory.createMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE); + _id2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE); _sid2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SID2TOPIC_SIZE); _slo2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SLO2TOPIC_SIZE); _iid2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_IID2CONSTRUCT_SIZE); @@ -106,13 +106,11 @@ */ private void _register(IConstruct construct) { ConstructImpl c = (ConstructImpl) construct; - String id = c._id; - if (id == null) { - id = "" + IdGenerator.nextId(); + if (c._id == null) { + c._id = ("" + IdGenerator.nextId()).intern(); } - if (!_id2Construct.containsKey(id)) { - _id2Construct.put(id, c); - c._id = id; + if (!_id2Construct.containsKey(c._id)) { + _id2Construct.put(c._id, c); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-14 13:39:26
|
Revision: 190 http://tinytim.svn.sourceforge.net/tinytim/?rev=190&view=rev Author: lheuer Date: 2008-11-14 13:39:21 +0000 (Fri, 14 Nov 2008) Log Message: ----------- - Fixed #2276392 -- Prettify XML (XTM) output - XTM10Writer didn't used xlink:href for topicRefs. Fixed. - Added logger to XTM10Writer / XTM20Writer - Associations with no roles are omitted now (1.0 and 2.0) Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 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-14 13:35:18 UTC (rev 189) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-14 13:39:21 UTC (rev 190) @@ -39,6 +39,9 @@ private final String _encoding; + private int _depth; + + public XMLWriter(OutputStream out) throws IOException { this(out, "utf-8"); } @@ -55,18 +58,18 @@ _out.write("<?xml version=\"1.0\" encoding=\""); _out.write(_encoding); _out.write("\" standalone=\"yes\"?>"); - newline(); + _newline(); _out.write("<!-- Generated by tinyTiM v"); _out.write(Version.RELEASE); _out.write(" - http://tinytim.sourceforge.net/ -->"); - newline(); + _newline(); } /** * @see org.xml.sax.DocumentHandler#endDocument() */ public void endDocument() throws IOException { - newline(); + _newline(); try { _out.flush(); } @@ -83,22 +86,43 @@ * @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); _writeAttributes(attrs); _out.write('>'); + _depth++; } /** * @see org.xml.sax.DocumentHandler#endElement(java.lang.String) */ public void endElement(String name) throws IOException { + _endElement(name, true); + } + + /** + * @see org.xml.sax.DocumentHandler#endElement(java.lang.String) + */ + public void _endElement(String name, boolean indent) throws IOException { + _depth--; + if (indent && _depth >= 0) { + _newline(); + _indent(); + } _out.write("</"); _out.write(name); _out.write('>'); } public void emptyElement(String name, Attributes attrs) throws IOException { + if (_depth > 0) { + _newline(); + } + _indent(); _out.write('<'); _out.write(name); _writeAttributes(attrs); @@ -112,7 +136,7 @@ public void dataElement(String name, Attributes attrs, String data) throws IOException { startElement(name, attrs); characters(data); - endElement(name); + _endElement(name, false); } public void _writeAttributes(Attributes attrs) throws IOException { @@ -132,10 +156,18 @@ * * @throws IOException If an error occurs. */ - public void newline() throws IOException { + private void _newline() throws IOException { _out.write(_NL); } + private void _indent() throws IOException { + char[] indent = new char[_depth*2]; + for (int i=0; i<indent.length; i++) { + indent[i] = ' '; + } + _out.write(indent); + } + /** * Writes the specified characters to the output. * Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-14 13:35:18 UTC (rev 189) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-14 13:39:21 UTC (rev 190) @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Set; +import java.util.logging.Logger; import org.tinytim.internal.api.IScope; import org.tinytim.internal.api.IScoped; @@ -48,8 +49,9 @@ */ public class XTM10Writer extends AbstractXTMWriter { + private static final Logger LOG = Logger.getLogger(XTM10Writer.class.getName()); + //TODO: Export iids, - // warn if len(slos) > 1, // warn if name.type != default name type, // warn if datatype not in (xsd:string, xsd:anyURI) @@ -120,50 +122,45 @@ _out.startElement("topic", _attrs); _writeIdentities(topic); for (Topic type: topic.getTypes()) { - _out.newline(); _out.startElement("instanceOf"); _writeTopicRef(type); _out.endElement("instanceOf"); - _out.newline(); } for (Name name: topic.getNames()) { - _out.newline(); _writeName(name); - _out.newline(); } for (Occurrence occ: topic.getOccurrences()) { - _out.newline(); _writeOccurrence(occ); - _out.newline(); } _out.endElement("topic"); - _out.newline(); } protected void _writeAssociation(final Association assoc) throws IOException { + Set<Role> roles = assoc.getRoles(); + if (roles.isEmpty()) { + LOG.info("Omitting association id " + assoc.getId() + " since it has no roles"); + return; + } _attrs.clear(); _addId(_attrs, assoc); _out.startElement("association", _attrs); _writeType(assoc); _writeScope(assoc); - for (Role role: assoc.getRoles()) { + for (Role role: roles) { _writeRole(role); } _out.endElement("association"); - _out.newline(); } protected void _writeRole(final Role role) throws IOException { _attrs.clear(); _addId(_attrs, role); - _out.newline(); _out.startElement("member", _attrs); _out.startElement("roleSpec"); _writeTopicRef(role.getType()); _out.endElement("roleSpec"); _writeTopicRef(role.getPlayer()); _out.endElement("member"); - _out.newline(); } protected void _writeName(final Name name) throws IOException { @@ -173,9 +170,7 @@ _writeScope(name); _out.dataElement("baseNameString", name.getValue()); for (Variant variant: name.getVariants()) { - _out.newline(); _writeVariant(variant); - _out.newline(); } _out.endElement("baseName"); } @@ -184,13 +179,11 @@ _attrs.clear(); _addId(_attrs, variant); _out.startElement("variant", _attrs); - _out.newline(); _out.startElement("parameters"); for (Topic theme: variant.getScope()) { _writeTopicRef(theme); } _out.endElement("parameters"); - _out.newline(); _writeDatatypeAware(variant); _out.endElement("variant"); } @@ -218,18 +211,14 @@ private void _writeTopicRef(final Topic topic) throws IOException { _attrs.clear(); - _attrs.addAttribute("", "href", "", "CDATA", "#" + _getId(topic)); - _out.newline(); + _attrs.addAttribute("", "xlink:href", "", "CDATA", "#" + _getId(topic)); _out.emptyElement("topicRef", _attrs); - _out.newline(); } private void _writeType(final Typed typed) throws IOException { - _out.newline(); _out.startElement("type"); _writeTopicRef(typed.getType()); _out.endElement("type"); - _out.newline(); } private void _writeScope(final Scoped scoped) throws IOException { @@ -237,13 +226,11 @@ if (scope.isUnconstrained()) { return; } - _out.newline(); _out.startElement("scope"); for (Topic theme: scope) { _writeTopicRef(theme); } _out.endElement("scope"); - _out.newline(); } protected void _writeIdentities(final Topic topic) throws IOException { @@ -256,8 +243,10 @@ return; } _out.startElement("subjectIdentity"); - _out.newline(); if (!slos.isEmpty()) { + if (slos.size() > 1) { + LOG.warning("The topic " + topic.getId() + " has more than one subject locator, exporting just one"); + } // Choose one subject locator Locator slo = slos.iterator().next(); _attrs.clear(); @@ -275,7 +264,6 @@ _out.emptyElement("subjectIndicatorRef", _attrs); } _out.endElement("subjectIdentity"); - _out.newline(); } } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-14 13:35:18 UTC (rev 189) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-14 13:39:21 UTC (rev 190) @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Set; +import java.util.logging.Logger; import org.tinytim.internal.api.IConstruct; import org.tinytim.internal.api.IScope; @@ -53,6 +54,8 @@ */ public class XTM20Writer extends AbstractXTMWriter { + private static final Logger LOG = Logger.getLogger(XTM20Writer.class.getName()); + /** * Creates a XTM 2.0 writer using "utf-8" encoding. * @@ -92,11 +95,9 @@ _writeItemIdentifiers(topicMap); for (Topic topic: topicMap.getTopics()) { _writeTopic(topic); - _out.newline(); } for (Association assoc: topicMap.getAssociations()) { _writeAssociation(assoc); - _out.newline(); } _out.endElement("topicMap"); _out.endDocument(); @@ -116,23 +117,25 @@ } for (Name name: topic.getNames()) { _writeName(name); - _out.newline(); } for (Occurrence occ: topic.getOccurrences()) { _writeOccurrence(occ); - _out.newline(); } _out.endElement("topic"); } protected void _writeAssociation(final Association assoc) throws IOException { + Set<Role> roles = assoc.getRoles(); + if (roles.isEmpty()) { + LOG.info("Omitting association id " + assoc.getId() + " since it has no roles"); + return; + } _out.startElement("association", _reifier(assoc)); _writeItemIdentifiers(assoc); _writeType(assoc); _writeScope(assoc); - for (Role role: assoc.getRoles()) { + for (Role role: roles) { _writeRole(role); - _out.newline(); } _out.endElement("association"); } @@ -142,7 +145,6 @@ _writeItemIdentifiers(role); _writeType(role); _writeTopicRef(role.getPlayer()); - _out.newline(); _out.endElement("role"); } @@ -154,7 +156,6 @@ _out.dataElement("value", name.getValue()); for (Variant variant: name.getVariants()) { _writeVariant(variant); - _out.newline(); } _out.endElement("name"); } @@ -178,7 +179,6 @@ private void _writeDatatypeAware(final DatatypeAware datatyped) throws IOException { _attrs.clear(); - _out.newline(); if (XSD.ANY_URI.equals(datatyped.getDatatype())) { _attrs.addAttribute("", "href", "", "CDATA", datatyped.locatorValue().toExternalForm()); _out.emptyElement("resourceRef", _attrs); @@ -190,7 +190,6 @@ } _out.dataElement("resourceData", _attrs, datatyped.getValue()); } - _out.newline(); } /** @@ -226,11 +225,9 @@ && type.getSubjectIdentifiers().contains(TMDM.TOPIC_NAME)) { return; } - _out.newline(); _out.startElement("type"); _writeTopicRef(type); _out.endElement("type"); - _out.newline(); } private void _writeScope(final Scoped scoped) throws IOException { @@ -238,13 +235,11 @@ if (scope.isUnconstrained()) { return; } - _out.newline(); _out.startElement("scope"); for (Topic theme: scope) { _writeTopicRef(theme); } _out.endElement("scope"); - _out.newline(); } private void _writeItemIdentifiers(final Construct construct) throws IOException { @@ -255,9 +250,7 @@ for (Locator loc: locs) { _attrs.clear(); _attrs.addAttribute("", "href", "", "CDATA", loc.toExternalForm()); - _out.newline(); _out.emptyElement(name, _attrs); - _out.newline(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-14 13:35:25
|
Revision: 189 http://tinytim.svn.sourceforge.net/tinytim/?rev=189&view=rev Author: lheuer Date: 2008-11-14 13:35:18 +0000 (Fri, 14 Nov 2008) Log Message: ----------- - Moved IIndexManager into internal.api - Removed remove(Topic/Association) from ITopicMap and added AbstractTopicMap instead - Added BooleanLiteral - More docs - Minor changes Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java tinytim/trunk/src/main/java/org/tinytim/core/Scope.java tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IIndexManagerAware.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IName.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IOccurrence.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopic.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopicMap.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IVariant.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/CollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/MergeUtils.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/TroveCollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/utils/Property.java tinytim/trunk/src/main/java/org/tinytim/utils/TopicUtils.java tinytim/trunk/src/main/java/org/tinytim/utils/TypeInstanceConverter.java tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java tinytim/trunk/src/test/java/org/tinytim/core/TinyTimTestCase.java tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java Added Paths: ----------- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IIndexManager.java Removed Paths: ------------- tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java Added: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java 2008-11-14 13:35:18 UTC (rev 189) @@ -0,0 +1,38 @@ +/* + * 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.core; + +import org.tinytim.internal.api.ITopicMap; +import org.tmapi.core.Association; +import org.tmapi.core.Topic; + +/** + * + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +abstract class AbstractTopicMap extends ConstructImpl implements ITopicMap { + + protected AbstractTopicMap() { + super(null); + } + + abstract void removeAssociation(Association assoc); + + abstract void removeTopic(Topic topic); + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -154,7 +154,7 @@ * @see org.tmapi.core.TopicMapObject#remove() */ public void remove() { - _tm.removeAssociation(this); + ((AbstractTopicMap) _tm).removeAssociation(this); for (Role role: CollectionFactory.createList(_roles)) { role.remove(); } Modified: tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -42,7 +42,7 @@ protected Construct _parent; private Set<Locator> _iids; - ConstructImpl(ITopicMap topicMap) { + protected ConstructImpl(ITopicMap topicMap) { _tm = topicMap; } @@ -147,49 +147,49 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isAssociation() + * @see org.tinytim.internal.api.IConstruct#isAssociation() */ public boolean isAssociation() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isName() + * @see org.tinytim.internal.api.IConstruct#isName() */ public boolean isName() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isOccurrence() + * @see org.tinytim.internal.api.IConstruct#isOccurrence() */ public boolean isOccurrence() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isRole() + * @see org.tinytim.internal.api.IConstruct#isRole() */ public boolean isRole() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isTopic() + * @see org.tinytim.internal.api.IConstruct#isTopic() */ public boolean isTopic() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isTopicMap() + * @see org.tinytim.internal.api.IConstruct#isTopicMap() */ public boolean isTopicMap() { return false; } /* (non-Javadoc) - * @see org.tinytim.core.IConstruct#isVariant() + * @see org.tinytim.internal.api.IConstruct#isVariant() */ public boolean isVariant() { return false; Modified: tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-14 13:35:18 UTC (rev 189) @@ -42,11 +42,11 @@ private ILiteral _literal; - DatatypeAwareConstruct(ITopicMap tm) { + protected DatatypeAwareConstruct(ITopicMap tm) { super(tm); } - DatatypeAwareConstruct(ITopicMap topicMap, Topic type, ILiteral literal, IScope scope) { + protected DatatypeAwareConstruct(ITopicMap topicMap, Topic type, ILiteral literal, IScope scope) { super(topicMap, type, scope); _literal = literal; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-14 13:35:18 UTC (rev 189) @@ -28,7 +28,7 @@ */ final class IdGenerator { - private static final AtomicLong _COUNTER = new AtomicLong(); + private static final AtomicLong _COUNTER = new AtomicLong(1); /** * Returns the next identifier. Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 13:35:18 UTC (rev 189) @@ -44,13 +44,13 @@ */ final class IdentityManager implements IEventPublisherAware { - private Map<Locator, Topic> _sid2Topic; - private Map<Locator, Topic> _slo2Topic; - private Map<Locator, IConstruct> _iid2Construct; - private Map<String, IConstruct> _id2Construct; + private final Map<Locator, Topic> _sid2Topic; + private final Map<Locator, Topic> _slo2Topic; + private final Map<Locator, IConstruct> _iid2Construct; + private final Map<String, IConstruct> _id2Construct; IdentityManager(MemoryTopicMap tm) { - _id2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE); + _id2Construct = CollectionFactory.createMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE); _sid2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SID2TOPIC_SIZE); _slo2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SLO2TOPIC_SIZE); _iid2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_IID2CONSTRUCT_SIZE); @@ -59,7 +59,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) + * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher) */ public void subscribe(IEventPublisher publisher) { IEventHandler handler = new TopicMapsConstructAddHandler(); @@ -93,7 +93,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IEventPublisherAware#unsubscribe(org.tinytim.core.IEventPublisher) + * @see org.tinytim.internal.api.IEventPublisherAware#unsubscribe(org.tinytim.internal.api.IEventPublisher) */ public void unsubscribe(IEventPublisher publisher) { // noop. @@ -106,17 +106,18 @@ */ private void _register(IConstruct construct) { ConstructImpl c = (ConstructImpl) construct; - if (c._id == null) { - String id = "" + IdGenerator.nextId(); - c._id = id.intern(); + String id = c._id; + if (id == null) { + id = "" + IdGenerator.nextId(); } - if (!_id2Construct.containsKey(c._id)) { - _id2Construct.put(c._id, c); + if (!_id2Construct.containsKey(id)) { + _id2Construct.put(id, c); + c._id = id; } } /** - * Unregisteres the specified <code>construct</code>. + * Unregisteres the specified <tt>construct</tt>. * * @param construct The Topic Maps construct to unregister. */ @@ -128,7 +129,7 @@ * Returns a Topic Maps construct by its identifier. * * @param id The identifier. - * @return A Topic Maps construct with the <code>id</code> or <code>null</code>. + * @return A Topic Maps construct with the <tt>id</tt> or <tt>null</tt>. */ public Construct getConstructById(String id) { return _id2Construct.get(id); @@ -138,7 +139,7 @@ * Returns a topic by its subject identifier. * * @param sid The subject identifier. - * @return A topic with the <code>sid</code> or <code>null</code>. + * @return A topic with the <tt>sid</tt> or <tt>null</tt>. */ public Topic getTopicBySubjectIdentifier(Locator sid) { return _sid2Topic.get(sid); @@ -148,7 +149,7 @@ * Returns a topic by its subject locator. * * @param slo The subject locator. - * @return A topic with the <code>slo</code> or <code>null</code>. + * @return A topic with the <tt>slo</tt> or <tt>null</tt>. */ public Topic getTopicBySubjectLocator(Locator slo) { return _slo2Topic.get(slo); @@ -158,17 +159,17 @@ * Returns a Topic Maps construct by its item identifier. * * @param iid The item identifier. - * @return A Topic Maps construct with the <code>iid</code> or <code>null</code>. + * @return A Topic Maps construct with the <tt>iid</tt> or <tt>null</tt>. */ public Construct getConstructByItemIdentifier(Locator iid) { return _iid2Construct.get(iid); } public void close() { - _id2Construct = null; - _iid2Construct = null; - _sid2Topic = null; - _slo2Topic = null; + _id2Construct.clear(); + _iid2Construct.clear(); + _sid2Topic.clear(); + _slo2Topic.clear(); } private class TopicMapsConstructAddHandler implements IEventHandler { Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-14 13:35:18 UTC (rev 189) @@ -29,7 +29,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class MemoryConstructFactory implements IConstructFactory { Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-14 13:35:18 UTC (rev 189) @@ -18,19 +18,17 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Set; import org.tinytim.core.value.Literal; import org.tinytim.index.IndexManager; -import org.tinytim.index.IIndexManager; import org.tinytim.internal.api.Event; import org.tinytim.internal.api.IConstant; import org.tinytim.internal.api.IConstruct; import org.tinytim.internal.api.IConstructFactory; import org.tinytim.internal.api.IEventHandler; -import org.tinytim.internal.api.IEventPublisher; +import org.tinytim.internal.api.IIndexManager; import org.tinytim.internal.api.ITopicMap; import org.tinytim.internal.utils.Check; import org.tinytim.internal.utils.CollectionFactory; @@ -55,8 +53,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -final class MemoryTopicMap extends ConstructImpl implements ITopicMap, - IEventHandler, IEventPublisher { +final class MemoryTopicMap extends AbstractTopicMap implements ITopicMap { private final IConstructFactory _factory; private final IdentityManager _identityManager; @@ -66,11 +63,11 @@ private final Set<Association> _assocs; private AbstractTopicMapSystem _sys; private Topic _reifier; - private final Map<Event, List<IEventHandler>> _evtHandlers; + private final Map<Event, Collection<IEventHandler>> _evtHandlers; private EventMultiplier _eventMultiplier; MemoryTopicMap(AbstractTopicMapSystem sys, Locator locator) { - super(null); + super(); super._tm = this; _factory = new MemoryConstructFactory(this); _sys = sys; @@ -118,19 +115,10 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ITopicMap#createTopicWithoutIdentity() - */ - public TopicImpl createTopicWithoutIdentity() { - TopicImpl topic = new TopicImpl(this); - addTopic(topic); - return topic; - } - - /* (non-Javadoc) * @see org.tmapi.core.TopicMap#createTopic() */ public Topic createTopic() { - Topic topic = createTopicWithoutIdentity(); + Topic topic = _factory.createTopic(); topic.addItemIdentifier(Literal.createIRI("urn:x-tinytim:" + IdGenerator.nextId())); return topic; } @@ -156,7 +144,7 @@ return topic; } } - TopicImpl topic = createTopicWithoutIdentity(); + Topic topic = _factory.createTopic(); topic.addItemIdentifier(iid); return topic; } @@ -180,11 +168,14 @@ return topic; } } - topic = createTopicWithoutIdentity(); + topic = _factory.createTopic(); topic.addSubjectIdentifier(sid); return topic; } + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#createTopicBySubjectLocator(org.tmapi.core.Locator) + */ public Topic createTopicBySubjectLocator(Locator slo) { if (slo == null) { throw new ModelConstraintException(null, "The subject locator must not be null"); @@ -193,7 +184,7 @@ if (topic != null) { return topic; } - topic = createTopicWithoutIdentity(); + topic = _factory.createTopic(); topic.addSubjectLocator(slo); return topic; } @@ -207,12 +198,13 @@ if (topic._parent == this) { return; } + assert topic._parent == null; _fireEvent(Event.ADD_TOPIC, null, topic); topic._parent = this; _topics.add(topic); } - public void removeTopic(Topic topic_) { + void removeTopic(Topic topic_) { TopicImpl topic = (TopicImpl) topic_; if (topic._parent != this) { return; @@ -252,7 +244,7 @@ _assocs.add(assoc); } - public void removeAssociation(Association assoc_) { + void removeAssociation(Association assoc_) { AssociationImpl assoc = (AssociationImpl) assoc_; if (assoc._parent != this) { return; @@ -304,7 +296,7 @@ } /* (non-Javadoc) - * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic) + * @see org.tmapi.core.Reifiable#setReifier(org.tmapi.core.Topic) */ public void setReifier(Topic reifier) { if (_reifier == reifier) { @@ -382,14 +374,14 @@ } /* (non-Javadoc) - * @see org.tinytim.IEventHandler#handleEvent(org.tinytim.Event, org.tinytim.IConstruct, java.lang.Object, java.lang.Object) + * @see org.tinytim.internal.api.IEventHandler#handleEvent(org.tinytim.internal.api.Event, org.tinytim.internal.api.IConstruct, java.lang.Object, java.lang.Object) */ public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue) { if (!_evtHandlers.containsKey(evt)) { _eventMultiplier.handleEvent(evt, sender, oldValue, newValue); return; } - List<IEventHandler> handlers = _evtHandlers.get(evt); + Collection<IEventHandler> handlers = _evtHandlers.get(evt); for (IEventHandler handler: handlers) { handler.handleEvent(evt, sender, oldValue, newValue); } @@ -400,7 +392,7 @@ * @see org.tinytim.IEventPublisher#subscribe(org.tinytim.Event, org.tinytim.IEventHandler) */ public void subscribe(Event event, IEventHandler handler) { - List<IEventHandler> handlers = _evtHandlers.get(event); + Collection<IEventHandler> handlers = _evtHandlers.get(event); if (handlers == null) { handlers = CollectionFactory.createList(); _evtHandlers.put(event, handlers); @@ -409,15 +401,18 @@ } /* (non-Javadoc) - * @see org.tinytim.IEventPublisher#unsubscribe(org.tinytim.Event, org.tinytim.IEventHandler) + * @see org.tinytim.internal.api.IEventPublisher#unsubscribe(org.tinytim.internal.api.Event, org.tinytim.internal.api.IEventHandler) */ public void unsubscribe(Event event, IEventHandler handler) { - List<IEventHandler> handlers = _evtHandlers.get(event); + Collection<IEventHandler> handlers = _evtHandlers.get(event); if (handlers != null) { handlers.remove(handler); } } + /* (non-Javadoc) + * @see org.tinytim.internal.api.IIndexManagerAware#getIndexManager() + */ public IIndexManager getIndexManager() { return _indexManager; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java 2008-11-14 13:35:18 UTC (rev 189) @@ -64,7 +64,7 @@ } /* (non-Javadoc) - * @see org.tmapi.core.TopicMapSystem#getBaseLocators() + * @see org.tmapi.core.TopicMapSystem#getLocators() */ public Set<Locator> getLocators() { return Collections.unmodifiableSet(_topicMaps.keySet()); Modified: tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -65,14 +65,14 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteralAware#getLiteral() + * @see org.tinytim.internal.api.ILiteralAware#getLiteral() */ public ILiteral getLiteral() { return _literal; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteralAware#setLiteral(org.tinytim.core.ILiteral) + * @see org.tinytim.internal.api.ILiteralAware#setLiteral(org.tinytim.internal.api.ILiteral) */ public void setLiteral(ILiteral literal) { assert literal != null; @@ -81,7 +81,7 @@ } /* (non-Javadoc) - * @see org.tmapi.core.TopicName#getValue() + * @see org.tmapi.core.Name#getValue() */ public String getValue() { return _literal.getValue(); @@ -128,7 +128,7 @@ } /* (non-Javadoc) - * @see org.tmapi.core.TopicName#getVariants() + * @see org.tmapi.core.Name#getVariants() */ public Set<Variant> getVariants() { return _variants == null ? Collections.<Variant>emptySet() @@ -214,30 +214,30 @@ attachVariant(v); } - void removeVariant(Variant variant) { - VariantImpl v = (VariantImpl) variant; - if (v._parent != this) { - return; - } - _fireEvent(Event.REMOVE_VARIANT, v, null); - detachVariant(v); - } + void removeVariant(Variant variant) { + VariantImpl v = (VariantImpl) variant; + if (v._parent != this) { + return; + } + _fireEvent(Event.REMOVE_VARIANT, v, null); + detachVariant(v); + } - void attachVariant(VariantImpl variant) { - if (_variants == null) { - _variants = CollectionFactory.createIdentitySet(IConstant.NAME_VARIANT_SIZE); - } - variant._parent = this; - _variants.add(variant); - } + void attachVariant(VariantImpl variant) { + if (_variants == null) { + _variants = CollectionFactory.createIdentitySet(IConstant.NAME_VARIANT_SIZE); + } + variant._parent = this; + _variants.add(variant); + } - void detachVariant(VariantImpl variant) { - _variants.remove(variant); - variant._parent = null; - } + void detachVariant(VariantImpl variant) { + _variants.remove(variant); + variant._parent = null; + } /* (non-Javadoc) - * @see org.tinytim.core.IMovable#moveTo(org.tmapi.core.Construct) + * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct) */ public void moveTo(Topic newParent) { ((TopicImpl) _parent).detachName(this, true); Modified: tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -47,7 +47,7 @@ } /* (non-Javadoc) - * @see org.tinytim.IMovable#moveTo(java.lang.Object) + * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct) */ public void moveTo(Topic newParent) { ((TopicImpl) _parent).detachOccurrence(this, true); Modified: tinytim/trunk/src/main/java/org/tinytim/core/Scope.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-14 13:35:18 UTC (rev 189) @@ -84,7 +84,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IScope#asSet() + * @see org.tinytim.internal.api.IScope#asSet() */ public Set<Topic> asSet() { // _set is immutable @@ -92,21 +92,21 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IScope#contains(org.tmapi.core.Topic) + * @see org.tinytim.internal.api.IScope#contains(org.tmapi.core.Topic) */ public boolean contains(Topic theme) { return _set.contains(theme); } /* (non-Javadoc) - * @see org.tinytim.core.IScope#containsAll(java.util.Collection) + * @see org.tinytim.internal.api.IScope#containsAll(java.util.Collection) */ public boolean containsAll(Collection<Topic> scope) { return _set.containsAll(scope); } /* (non-Javadoc) - * @see org.tinytim.core.IScope#add(org.tmapi.core.Topic) + * @see org.tinytim.internal.api.IScope#add(org.tmapi.core.Topic) */ public IScope add(Topic theme) { if (_set.contains(theme)) { @@ -118,7 +118,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IScope#remove(org.tmapi.core.Topic) + * @see org.tinytim.internal.api.IScope#remove(org.tmapi.core.Topic) */ public IScope remove(Topic theme) { if (!_set.contains(theme)) { @@ -137,14 +137,14 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IScope#isUnconstrained() + * @see org.tinytim.internal.api.IScope#isUnconstrained() */ public boolean isUnconstrained() { return this == UCS; } /* (non-Javadoc) - * @see org.tinytim.core.IScope#size() + * @see org.tinytim.internal.api.IScope#size() */ public int size() { return _set.size(); Modified: tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -49,14 +49,14 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IScoped#getScopeObject() + * @see org.tinytim.internal.api.IScoped#getScopeObject() */ public IScope getScopeObject() { return _scope; } /* (non-Javadoc) - * @see org.tinytim.core.IScoped#setScopeObject(org.tinytim.core.IScope) + * @see org.tinytim.internal.api.IScoped#setScopeObject(org.tinytim.internal.api.IScope) */ public void setScopeObject(IScope scope) { if (_scope == scope) { @@ -67,14 +67,14 @@ } /* (non-Javadoc) - * @see org.tmapi.core.ScopedObject#getScope() + * @see org.tmapi.core.Scoped#getScope() */ public Set<Topic> getScope() { return _scope.asSet(); } /* (non-Javadoc) - * @see org.tmapi.Scoped#removeTheme(org.tmapi.core.Topic) + * @see org.tmapi.core.Scoped#addTheme(org.tmapi.core.Topic) */ public void addTheme(Topic theme) { if (theme == null) { @@ -84,7 +84,7 @@ } /* (non-Javadoc) - * @see org.tmapi.Scoped#removeTheme(org.tmapi.core.Topic) + * @see org.tmapi.core.Scoped#removeTheme(org.tmapi.core.Topic) */ public void removeTheme(Topic theme) { setScopeObject(_scope.remove(theme)); Modified: tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -251,7 +251,7 @@ } /* (non-Javadoc) - * @see org.tmapi.core.Topic#getTopicNames() + * @see org.tmapi.core.Topic#getNames() */ public Set<Name> getNames() { return Collections.unmodifiableSet(_names); @@ -483,7 +483,7 @@ } /* (non-Javadoc) - * @see org.tmapi.core.TopicMapObject#remove() + * @see org.tmapi.core.Construct#remove() */ public void remove() throws TopicInUseException { if (!TopicUtils.isRemovable(this, true)) { @@ -492,7 +492,7 @@ if (_reified != null) { _reified.setReifier(null); } - _tm.removeTopic(this); + ((AbstractTopicMap) _tm).removeTopic(this); _sids.clear(); _slos = null; _types = null; @@ -523,5 +523,4 @@ return sb.toString(); } - } Modified: tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -54,8 +54,8 @@ return _type; } - /* (non-Javadoc) - * @see org.tinytim.ITyped#setType(org.tmapi.core.Topic) + /* + * @see org.tmapi.core.Typed#setType(org.tmapi.core.Topic) */ public void setType(Topic type) { Check.typeNotNull(this, type); @@ -67,14 +67,14 @@ } /* (non-Javadoc) - * @see org.tmapi.core.IReifiable#getReifier() + * @see org.tmapi.core.Reifiable#getReifier() */ public Topic getReifier() { return _reifier; } /* (non-Javadoc) - * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic) + * @see org.tmapi.core.Reifiable#setReifier(org.tmapi.core.Topic) */ public void setReifier(Topic reifier) { if (_reifier == reifier) { @@ -91,7 +91,7 @@ } /* (non-Javadoc) - * @see org.tinytim.Construct#dispose() + * @see org.tinytim.core.ConstructImpl#dispose() */ @Override protected void dispose() { Modified: tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -52,7 +52,7 @@ } /* (non-Javadoc) - * @see org.tinytim.IMovable#moveTo(java.lang.Object) + * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct) */ public void moveTo(Name newParent) { ((NameImpl) _parent).detachVariant(this); Added: tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java 2008-11-14 13:35:18 UTC (rev 189) @@ -0,0 +1,110 @@ +/* + * 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.core.value; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import org.tinytim.internal.api.ILiteral; +import org.tinytim.voc.XSD; +import org.tmapi.core.Locator; + +/** + * + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class BooleanLiteral implements ILiteral { + + public static final ILiteral TRUE = new BooleanLiteral(true); + public static final ILiteral FALSE = new BooleanLiteral(false); + + private final boolean _value; + + private BooleanLiteral(boolean value) { + _value = value; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#decimalValue() + */ + public BigDecimal decimalValue() { + return _value == true ? BigDecimal.ONE : BigDecimal.ZERO; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#floatValue() + */ + public float floatValue() { + return _value == true ? 1.0F : 0.0F; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#getDatatype() + */ + public Locator getDatatype() { + return XSD.BOOLEAN; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#getValue() + */ + public String getValue() { + return _value == true ? "true" : "false"; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#intValue() + */ + public int intValue() { + return _value == true ? 1 : 0; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#integerValue() + */ + public BigInteger integerValue() { + return _value == true ? BigInteger.ONE : BigInteger.ZERO; + } + + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#longValue() + */ + public long longValue() { + return intValue(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + return (obj instanceof BooleanLiteral) && _value == ((BooleanLiteral) obj)._value; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return _value == true ? 1 : 0; + } + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java 2008-11-14 13:35:18 UTC (rev 189) @@ -48,49 +48,49 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#decimalValue() + * @see org.tinytim.internal.api.ILiteral#decimalValue() */ public BigDecimal decimalValue() { return _decimal; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#floatValue() + * @see org.tinytim.internal.api.ILiteral#floatValue() */ public float floatValue() { return _decimal.floatValue(); } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() + * @see org.tinytim.internal.api.ILiteral#getDatatype() */ public Locator getDatatype() { return XSD.DECIMAL; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() + * @see org.tinytim.internal.api.ILiteral#getValue() */ public String getValue() { return _lexicalForm; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#intValue() + * @see org.tinytim.internal.api.ILiteral#intValue() */ public int intValue() { return _decimal.intValue(); } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#integerValue() + * @see org.tinytim.internal.api.ILiteral#integerValue() */ public BigInteger integerValue() { return _decimal.toBigInteger(); } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#longValue() + * @see org.tinytim.internal.api.ILiteral#longValue() */ public long longValue() { return _decimal.longValue(); Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java 2008-11-14 13:35:18 UTC (rev 189) @@ -49,7 +49,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#decimalValue() + * @see org.tinytim.internal.api.ILiteral#decimalValue() */ public BigDecimal decimalValue() { if (_decimal == null) { @@ -59,42 +59,42 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#floatValue() + * @see org.tinytim.internal.api.ILiteral#floatValue() */ public float floatValue() { return _integer.floatValue(); } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() + * @see org.tinytim.internal.api.ILiteral#getDatatype() */ public Locator getDatatype() { return XSD.INTEGER; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() + * @see org.tinytim.internal.api.ILiteral#getValue() */ public String getValue() { return _lexicalForm; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#intValue() + * @see org.tinytim.internal.api.ILiteral#intValue() */ public int intValue() { return _integer.intValue(); } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#integerValue() + * @see org.tinytim.internal.api.ILiteral#integerValue() */ public BigInteger integerValue() { return _integer; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#longValue() + * @see org.tinytim.internal.api.ILiteral#longValue() */ public long longValue() { return _integer.longValue(); 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-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java 2008-11-14 13:35:18 UTC (rev 189) @@ -23,6 +23,7 @@ import org.tinytim.internal.api.ILocator; import org.tinytim.internal.utils.WeakObjectRegistry; import org.tinytim.voc.XSD; +import static org.tinytim.core.value.LiteralNormalizer.normalizeBoolean; import org.tmapi.core.Locator; @@ -53,14 +54,14 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() + * @see org.tinytim.internal.api.ILiteral#getDatatype() */ public Locator getDatatype() { return _datatype; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() + * @see org.tinytim.internal.api.ILiteral#getValue() */ public String getValue() { return _value; @@ -90,6 +91,10 @@ if (XSD.STRING.equals(datatype)) { return get(value); } + if (XSD.BOOLEAN.equals(datatype)) { + return normalizeBoolean(value).equals("true") ? BooleanLiteral.TRUE + : BooleanLiteral.FALSE; + } return _OTHERS.get(new Literal(value, datatype)); } @@ -122,6 +127,9 @@ if (XSD.INTEGER.equals(datatype)) { return createInteger(value); } + if (XSD.BOOLEAN.equals(datatype)) { + return createBoolean(value); + } return _registerIfAbsent(_OTHERS, new Literal(value, datatype)); } @@ -191,6 +199,11 @@ return _registerIfAbsent(_OTHERS, new IntegerLiteral(value)); } + public static ILiteral createBoolean(String value) { + return normalizeBoolean(value).equals("true") ? BooleanLiteral.TRUE + : BooleanLiteral.FALSE; + } + public BigDecimal decimalValue() { return new BigDecimal(_value); } @@ -211,11 +224,17 @@ return Long.valueOf(_value); } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return _value.hashCode(); } + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object obj) { if (this == obj) { Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java 2008-11-14 13:35:18 UTC (rev 189) @@ -42,15 +42,15 @@ * @return A normalized value. */ public static String normalize(final String value, final Locator datatype) { - if (XSD.BOOLEAN.equals(datatype)) { - return normalizeBoolean(value); - } - else if (XSD.INTEGER.equals(datatype)) { + if (XSD.INTEGER.equals(datatype)) { return normalizeInteger(value); } else if (XSD.DECIMAL.equals(datatype)) { return normalizeDecimal(value); } + else if (XSD.BOOLEAN.equals(datatype)) { + return normalizeBoolean(value); + } return 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-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -68,35 +68,50 @@ } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() + * @see org.tinytim.internal.api.ILiteral#getDatatype() */ public Locator getDatatype() { return XSD.ANY_URI; } /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() + * @see org.tinytim.internal.api.ILiteral#getValue() */ public String getValue() { return _reference; } + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#decimalValue() + */ public BigDecimal decimalValue() { throw new NumberFormatException(); } + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#floatValue() + */ public float floatValue() { throw new NumberFormatException(); } + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#integerValue() + */ public BigInteger integerValue() { throw new NumberFormatException(); } + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#intValue() + */ public int intValue() { throw new NumberFormatException(); } + /* (non-Javadoc) + * @see org.tinytim.internal.api.ILiteral#longValue() + */ public long longValue() { throw new NumberFormatException(); } Modified: tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java 2008-11-14 13:35:18 UTC (rev 189) @@ -20,8 +20,7 @@ import org.tmapi.index.Index; /** - * Abstract base class for {@link org.tmapi.index.Index} implementation which - * are autoupdated. + * Abstract base class for {@link Index} implementations which are autoupdated. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -70,4 +69,9 @@ // noop. } + /** + * Clears the index. + */ + abstract void clear(); + } Deleted: tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java 2008-11-14 13:35:18 UTC (rev 189) @@ -1,57 +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.index; - -import org.tinytim.internal.api.IEventPublisherAware; -import org.tmapi.index.LiteralIndex; -import org.tmapi.index.ScopedIndex; -import org.tmapi.index.TypeInstanceIndex; - -/** - * The index manager provides access to the tinyTiM-specific indexes. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IIndexManager extends IEventPublisherAware { - - /** - * Returns the {@link TypeInstanceIndex}. - * - * @return A {@link TypeInstanceIndex} instance. - */ - public TypeInstanceIndex getTypeInstanceIndex(); - - /** - * Returns the {@link ScopedIndex}. - * - * @return A {@link ScopedIndex} instance. - */ - public ScopedIndex getScopedIndex(); - - /** - * Returns the {@link LiteralIndex}. - * - * @return A {@link LiteralIndex} instance. - */ - public LiteralIndex getLiteralIndex(); - - /** - * Closes this index manager. - */ - public void close(); - -} Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-11-14 13:35:18 UTC (rev 189) @@ -16,6 +16,8 @@ package org.tinytim.index; import org.tinytim.internal.api.IEventPublisher; +import org.tinytim.internal.api.IIndexManager; + import org.tmapi.index.LiteralIndex; import org.tmapi.index.ScopedIndex; import org.tmapi.index.TypeInstanceIndex; @@ -40,7 +42,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) + * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher) */ public void subscribe(final IEventPublisher publisher) { _typeInstanceIndex.subscribe(publisher); @@ -49,7 +51,7 @@ } /* (non-Javadoc) - * @see org.tinytim.core.IEventPublisherAware#unsubscribe(org.tinytim.core.IEventPublisher) + * @see org.tinytim.internal.api.IEventPublisherAware#unsubscribe(org.tinytim.internal.api.IEventPublisher) */ public void unsubscribe(IEventPublisher publisher) { _typeInstanceIndex.unsubscribe(publisher); @@ -58,26 +60,29 @@ } /* (non-Javadoc) - * @see org.tinytim.index.IIndexManager#getTypeInstanceIndex() + * @see org.tinytim.internal.api.IIndexManager#getTypeInstanceIndex() */ public TypeInstanceIndex getTypeInstanceIndex() { return _typeInstanceIndex; } /* (non-Javadoc) - * @see org.tinytim.index.IIndexManager#getScopedIndex() + * @see org.tinytim.internal.api.IIndexManager#getScopedIndex() */ public ScopedIndex getScopedIndex() { return _scopedIndex; } /* (non-Javadoc) - * @see org.tinytim.index.IIndexManager#getLiteralIndex() + * @see org.tinytim.internal.api.IIndexManager#getLiteralIndex() */ public LiteralIndex getLiteralIndex() { return _literalIndex; } + /* (non-Javadoc) + * @see org.tinytim.internal.api.IIndexManager#close() + */ public void close() { _typeInstanceIndex.clear(); _scopedIndex.clear(); Modified: tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -42,21 +42,21 @@ */ public class LiteralIndexImpl extends AbstractIndex implements LiteralIndex { - private Map<ILiteral, List<Name>> _lit2Names; - private Map<ILiteral, List<Occurrence>> _lit2Occs; - private Map<ILiteral, List<Variant>> _lit2Variants; + private final Map<ILiteral, List<Name>> _lit2Names; + private final Map<ILiteral, List<Occurrence>> _lit2Occs; + private final Map<ILiteral, List<Variant>> _lit2Variants; public LiteralIndexImpl() { super(); + _lit2Names = CollectionFactory.createIdentityMap(); + _lit2Occs = CollectionFactory.createIdentityMap(); + _lit2Variants = CollectionFactory.createIdentityMap(); } /* (non-Javadoc) - * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) + * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher) */ public void subscribe(IEventPublisher publisher) { - _lit2Names = CollectionFactory.createIdentityMap(); - _lit2Occs = CollectionFactory.createIdentityMap(); - _lit2Variants = CollectionFactory.createIdentityMap(); publisher.subscribe(Event.SET_LITERAL, new LiteralHandler()); IEventHandler handler = new AddLiteralAwareHandler(); publisher.subscribe(Event.ATTACHED_OCCURRENCE, handler); @@ -75,6 +75,12 @@ return _getNames(Literal.get(value)); } + /** + * + * + * @param literal + * @return + */ private Collection<Name> _getNames(ILiteral literal) { if (literal == null) { return Collections.<Name>emptySet(); @@ -108,6 +114,12 @@ return _getOccurrences(Literal.get(value, datatype)); } + /** + * + * + * @param literal + * @return + */ private Collection<Occurrence> _getOccurrences(ILiteral literal) { if (literal == null) { return Collections.<Occurrence>emptySet(); @@ -141,6 +153,12 @@ return _getVariants(Literal.get(value, datatype)); } + /** + * + * + * @param literal + * @return + */ private Collection<Variant> _getVariants(ILiteral literal) { if (literal == null) { return Collections.<Variant>emptySet(); @@ -150,6 +168,9 @@ : CollectionFactory.createList(variants); } + /* (non-Javadoc) + * @see org.tinytim.index.AbstractIndex#clear() + */ public void clear() { _lit2Names.clear(); _lit2Occs.clear(); Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -44,23 +44,23 @@ */ public class ScopedIndexImpl extends AbstractIndex implements ScopedIndex { - private Map<Topic, Set<Association>> _theme2Assocs; - private Map<Topic, Set<Occurrence>> _theme2Occs; - private Map<Topic, Set<Name>> _theme2Names; - private Map<Topic, Set<Variant>> _theme2Variants; + private final Map<Topic, Set<Association>> _theme2Assocs; + private final Map<Topic, Set<Occurrence>> _theme2Occs; + private final Map<Topic, Set<Name>> _theme2Names; + private final Map<Topic, Set<Variant>> _theme2Variants; public ScopedIndexImpl() { super(); + _theme2Assocs = CollectionFactory.createIdentityMap(); + _theme2Occs = CollectionFactory.createIdentityMap(); + _theme2Names = CollectionFactory.createIdentityMap(); + _theme2Variants = CollectionFactory.createIdentityMap(); } /* (non-Javadoc) * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) */ public void subscribe(IEventPublisher publisher) { - _theme2Assocs = CollectionFactory.createIdentityMap(); - _theme2Occs = CollectionFactory.createIdentityMap(); - _theme2Names = CollectionFactory.createIdentityMap(); - _theme2Variants = CollectionFactory.createIdentityMap(); publisher.subscribe(Event.SET_SCOPE, new SetScopeHandler()); IEventHandler handler = new AddScopedHandler(); publisher.subscribe(Event.ADD_ASSOCIATION, handler); @@ -239,15 +239,14 @@ return themes; } + /* (non-Javadoc) + * @see org.tinytim.index.AbstractIndex#clear() + */ void clear() { _theme2Assocs.clear(); - _theme2Assocs = null; _theme2Occs.clear(); - _theme2Occs = null; _theme2Names.clear(); - _theme2Names = null; _theme2Variants.clear(); - _theme2Variants = null; } private void _unindex(Map<Topic, Set<Scoped>> map, Scoped scoped, IScope scope) { Modified: tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189) @@ -42,25 +42,25 @@ */ public class TypeInstanceIndexImpl extends AbstractIndex implements TypeInstanceIndex { - private Map<Topic, Set<Topic>> _type2Topics; - private Map<Topic, List<Association>> _type2Assocs; - private Map<Topic, List<Role>> _type2Roles; - private Map<Topic, List<Occurrence>> _type2Occs; - private Map<Topic, List<Name>> _type2Names; + private final Map<Topic, Set<Topic>> _type2Topics; + private final Map<Topic, List<Association>> _type2Assocs; + private final Map<Topic, List<Role>> _type2Roles; + private final Map<Topic, List<Occurrence>> _type2Occs; + private final Map<Topic, List<Name>> _type2Names; public TypeInstanceIndexImpl() { super(); + _type2Topics = CollectionFactory.createIdentityMap(); + _type2Assocs = CollectionFactory.createIdentityMap(); + _type2Roles = CollectionFactory.createIdentityMap(); + _type2Occs = CollectionFactory.createIdentityMap(); + _type2Names = CollectionFactory.createIdentityMap(); } /* (non-Javadoc) * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) */ public void subscribe(IEventPublisher publisher) { - _type2Topics = CollectionFactory.createIdentityMap(); - _type2Assocs = CollectionFactory.createIdentityMap(); - _type2Roles = CollectionFactory.createIdentityMap(); - _type2Occs = CollectionFactory.createIdentityMap(); - _type2Names = CollectionFactory.createIdentityMap(); IEventHandler handler = new TopicTypeHandler(); publisher.subscribe(Event.ADD_TYPE, handler); publisher.subscribe(Event.REMOVE_TYPE, handler); @@ -352,16 +352,14 @@ } } + /* (non-Javadoc) + * @see org.tinytim.index.AbstractIndex#clear() + */ void clear() { _type2Topics.clear(); - _type2Topics = null; _type2Assocs.clear(); - _type2Assocs = null; _type2Roles.clear(); - _type2Roles = null; _type2Occs.clear(); - _type2Occs = null; _type2Names.clear(); - _type2Names = null; } } Modified: tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java 2008-11-13 18:10:28 UTC (rev 188) +++ tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java 2008-11-14 13:35:18 UTC (rev 189) @@ -26,83 +26,83 @@ */ public interface IConstant { /** - * Initial size of the {@link MemoryTopicMap} topic set + * Initial size of the topic set */ public static final int TM_TOPIC_SIZE = 100; /** - * Initial size of the {@link MemoryTopicMap} association set + * Initial size of the association set */ public static final int TM_ASSOCIATION_SIZE = 100; /** - * Initial size of the {@link ConstructImpl} item identifier set. + * Initial size of the item identifier set. */ public static final int CONSTRUCT_IID_SIZE = 4; /** - * Initial size of the {@link TopicImpl} subject identifier set. + * Initial size of the subject identifier set. */ public static final int TOPIC_SID_SIZE = 4; /** - * Initial size of the {@link TopicImpl} subject locator set. + * Initial size of the subject locator set. */ public static final int TOPIC_SLO_SIZE = 2; /** - * Initial size of the {@link TopicImpl} types set. + * Initial size of the topic types set. */ public static final int TOPIC_TYPE_SIZE = 2; /** - * Initial size of the {@link TopicImpl} name set. + * Initial size of the name set. */ public static final int TOPIC_NAME_SIZE = 2; /** - * Initial size of the {@link TopicImpl} occurrence set. + * Initial size of the occurrence set. */ public static final int TOPIC_OCCURRENCE_SIZE = 2; /** - * Initial size ... [truncated message content] |
From: <lh...@us...> - 2008-11-13 18:10:32
|
Revision: 188 http://tinytim.svn.sourceforge.net/tinytim/?rev=188&view=rev Author: lheuer Date: 2008-11-13 18:10:28 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Removed wrong assertion Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 18:00:03 UTC (rev 187) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 18:10:28 UTC (rev 188) @@ -217,7 +217,6 @@ if (topic._parent != this) { return; } - assert topic._parent == null; _fireEvent(Event.REMOVE_TOPIC, topic, null); _topics.remove(topic); topic._parent = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 18:00:09
|
Revision: 187 http://tinytim.svn.sourceforge.net/tinytim/?rev=187&view=rev Author: lheuer Date: 2008-11-13 18:00:03 +0000 (Thu, 13 Nov 2008) Log Message: ----------- - Added test case for IConstructFactory - Modified MemoryConstructFactory accordingly Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java Added Paths: ----------- tinytim/trunk/src/test/java/org/tinytim/core/TestIConstructFactory.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 15:33:33 UTC (rev 186) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 18:00:03 UTC (rev 187) @@ -43,14 +43,18 @@ * @see org.tinytim.internal.api.IConstructFactory#createTopic() */ public ITopic createTopic() { - return new TopicImpl(_tm); + TopicImpl topic = new TopicImpl(_tm); + _tm.addTopic(topic); + return topic; } /* (non-Javadoc) * @see org.tinytim.internal.api.IConstructFactory#createAssociation() */ public Association createAssociation() { - return new AssociationImpl(_tm); + AssociationImpl assoc = new AssociationImpl(_tm); + _tm.addAssociation(assoc); + return assoc; } /* (non-Javadoc) Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 15:33:33 UTC (rev 186) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 18:00:03 UTC (rev 187) @@ -243,7 +243,7 @@ return assoc; } - public void addAssociation(Association assoc_) { + void addAssociation(Association assoc_) { AssociationImpl assoc = (AssociationImpl) assoc_; if (assoc._parent == this) { return; Modified: tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-11-13 15:33:33 UTC (rev 186) +++ tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-11-13 18:00:03 UTC (rev 187) @@ -42,6 +42,7 @@ suite.addTestSuite(TestDuplicateRemovalUtils.class); suite.addTestSuite(TestLocatorImpl.class); suite.addTestSuite(TestIConstruct.class); + suite.addTestSuite(TestIConstructFactory.class); suite.addTestSuite(TestScope.class); suite.addTestSuite(TestLiteral.class); suite.addTestSuite(TestLiteralNormalizer.class); Added: tinytim/trunk/src/test/java/org/tinytim/core/TestIConstructFactory.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/core/TestIConstructFactory.java (rev 0) +++ tinytim/trunk/src/test/java/org/tinytim/core/TestIConstructFactory.java 2008-11-13 18:00:03 UTC (rev 187) @@ -0,0 +1,172 @@ +/* + * 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.core; + +import org.tinytim.internal.api.IConstructFactory; +import org.tinytim.internal.api.IName; +import org.tinytim.internal.api.IOccurrence; +import org.tinytim.internal.api.ITopic; +import org.tinytim.internal.api.IVariant; + +import org.tmapi.core.Association; +import org.tmapi.core.Role; +import org.tmapi.core.Topic; + +/** + * Tests against {@link IConstructFactory}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public class TestIConstructFactory extends TinyTimTestCase { + + private IConstructFactory _factory; + + /* (non-Javadoc) + * @see org.tinytim.core.TinyTimTestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + _factory = _tm.getConstructFactory(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.TinyTimTestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception { + super.tearDown(); + _factory = null; + } + + /** + * Tests topic creatation. + */ + public void testTopicCreation() { + final Topic topic = _factory.createTopic(); + assertNotNull(topic.getId()); + assertTrue(topic.getItemIdentifiers().isEmpty()); + assertTrue(topic.getSubjectIdentifiers().isEmpty()); + assertTrue(topic.getSubjectLocators().isEmpty()); + assertTrue(topic.getTypes().isEmpty()); + assertTrue(topic.getOccurrences().isEmpty()); + assertTrue(topic.getNames().isEmpty()); + assertTrue(topic.getRolesPlayed().isEmpty()); + assertEquals(topic, _tm.getConstructById(topic.getId())); + assertEquals(_tm, topic.getParent()); + assertEquals(_tm, topic.getTopicMap()); + } + + /** + * Tests association creatation. + */ + public void testAssociationCreation() { + final Association assoc = _factory.createAssociation(); + assertNotNull(assoc.getId()); + assertNull(assoc.getType()); + assertTrue(assoc.getItemIdentifiers().isEmpty()); + assertTrue(assoc.getRoles().isEmpty()); + assertTrue(assoc.getScope().isEmpty()); + assertEquals(assoc, _tm.getConstructById(assoc.getId())); + assertEquals(_tm, assoc.getParent()); + assertEquals(_tm, assoc.getTopicMap()); + } + + /** + * Tests role creation. + */ + public void testRoleCreation() { + final Association assoc = createAssociation(); + final Role role = _factory.createRole(assoc); + assertNotNull(role.getId()); + assertNull(role.getType()); + assertNull(role.getPlayer()); + assertTrue(role.getItemIdentifiers().isEmpty()); + assertEquals(role, _tm.getConstructById(role.getId())); + assertEquals(assoc, role.getParent()); + assertEquals(_tm, assoc.getTopicMap()); + } + + /** + * Tests occurrence creation. + */ + public void testOccurrenceCreation() { + final ITopic topic = (ITopic) createTopic(); + final IOccurrence occ = _factory.createOccurrence(topic); + assertNotNull(occ.getId()); + assertNull(occ.getType()); + assertTrue(occ.getItemIdentifiers().isEmpty()); + assertNull(occ.getLiteral()); + assertTrue(occ.getScope().isEmpty()); + assertEquals(occ, _tm.getConstructById(occ.getId())); + assertEquals(topic, occ.getParent()); + assertEquals(_tm, occ.getTopicMap()); + } + + /** + * Tests name creation. + */ + public void testNameCreation() { + final ITopic topic = (ITopic) createTopic(); + final IName name = _factory.createName(topic); + assertNotNull(name.getId()); + assertNull(name.getType()); + assertTrue(name.getItemIdentifiers().isEmpty()); + assertNull(name.getLiteral()); + assertTrue(name.getScope().isEmpty()); + assertEquals(name, _tm.getConstructById(name.getId())); + assertEquals(topic, name.getParent()); + assertEquals(_tm, name.getTopicMap()); + } + + /** + * Tests variant creation. + */ + public void testVariantCreation() { + final IName name = (IName) createName(); + final IVariant variant = _factory.createVariant(name); + assertNotNull(variant.getId()); + assertTrue(variant.getItemIdentifiers().isEmpty()); + assertNull(variant.getLiteral()); + assertTrue(variant.getScope().isEmpty()); + assertEquals(variant, _tm.getConstructById(variant.getId())); + assertEquals(name, variant.getParent()); + assertEquals(_tm, variant.getTopicMap()); + } + + /** + * Tests variant creation with a scoped name. + */ + public void testVariantCreationScope() { + final IName name = (IName) createName(); + final Topic theme1 = createTopic(); + final Topic theme2 = createTopic(); + name.addTheme(theme1); + name.addTheme(theme2); + final IVariant variant = _factory.createVariant(name); + assertNotNull(variant.getId()); + assertTrue(variant.getItemIdentifiers().isEmpty()); + assertNull(variant.getLiteral()); + assertEquals(2, variant.getScope().size()); + assertTrue(variant.getScope().contains(theme1)); + assertTrue(variant.getScope().contains(theme2)); + assertEquals(variant, _tm.getConstructById(variant.getId())); + assertEquals(name, variant.getParent()); + assertEquals(_tm, variant.getTopicMap()); + } + +} Property changes on: tinytim/trunk/src/test/java/org/tinytim/core/TestIConstructFactory.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-13 15:33:37
|
Revision: 186 http://tinytim.svn.sourceforge.net/tinytim/?rev=186&view=rev Author: lheuer Date: 2008-11-13 15:33:33 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Docs for the IConstructFactory Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java Modified: tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java 2008-11-13 15:26:33 UTC (rev 185) +++ tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java 2008-11-13 15:33:33 UTC (rev 186) @@ -19,23 +19,62 @@ import org.tmapi.core.Role; /** + * Factory for {@link IConstruct}s. + * <p> + * This interface is not meant to be used outside of the tinyTiM package. + * </p> * - * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev:$ - $Date:$ */ public interface IConstructFactory { + /** + * Creates a topic attached to the topic map this factory belongs to. + * + * @return A topic with no identity. + */ + public ITopic createTopic(); + + /** + * Creates an association attached to the topic map this + * factory belongs to. + * + * @return An association with no type, scope, and roles. + */ public Association createAssociation(); + /** + * Creates a role attached to the specified <tt>parent</tt>. + * + * @param parent The parent of the role. + * @return A role with no type and player. + */ public Role createRole(Association parent); - public IVariant createVariant(IName parent); - + /** + * Creates an occurrence attached to the specified <tt>parent</tt>. + * + * @param parent The parent of the occurrence. + * @return An occurrence with no type, literal, and scope. + */ public IOccurrence createOccurrence(ITopic parent); + /** + * Creates a name attached to the specified <tt>parent</tt>. + * + * @param parent The parent of the name. + * @return A name with no type, literal, and scope. + */ public IName createName(ITopic parent); - public ITopic createTopic(); + /** + * Creates a variant attached to the specified <tt>parent</tt>. + * + * @param parent The parent of the variant. + * @return A variant with the parent's scope, but no own scope and + * no literal. + */ + public IVariant createVariant(IName parent); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 15:26:42
|
Revision: 185 http://tinytim.svn.sourceforge.net/tinytim/?rev=185&view=rev Author: lheuer Date: 2008-11-13 15:26:33 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Name's scope copied to the variant Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 15:00:21 UTC (rev 184) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 15:26:33 UTC (rev 185) @@ -20,8 +20,10 @@ import org.tinytim.internal.api.IOccurrence; import org.tinytim.internal.api.ITopic; import org.tinytim.internal.api.IVariant; + import org.tmapi.core.Association; import org.tmapi.core.Role; +import org.tmapi.core.Topic; /** * @@ -83,6 +85,9 @@ */ public IVariant createVariant(IName parent) { VariantImpl variant = new VariantImpl(_tm); + for (Topic theme: parent.getScope()) { + variant._addNameTheme(theme); + } ((NameImpl) parent).addVariant(variant); return variant; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 15:00:23
|
Revision: 184 http://tinytim.svn.sourceforge.net/tinytim/?rev=184&view=rev Author: lheuer Date: 2008-11-13 15:00:21 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Made underlying set immutable in the constructor Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/Scope.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-13 14:15:37 UTC (rev 183) +++ tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-13 15:00:21 UTC (rev 184) @@ -46,8 +46,9 @@ } private Scope(Collection<Topic> themes) { - _set = CollectionFactory.createIdentitySet(themes.size()); - _set.addAll(themes); + Set<Topic> set = CollectionFactory.createIdentitySet(themes.size()); + set.addAll(themes); + _set = Collections.unmodifiableSet(set); } /* (non-Javadoc) @@ -86,7 +87,8 @@ * @see org.tinytim.core.IScope#asSet() */ public Set<Topic> asSet() { - return Collections.unmodifiableSet(_set); + // _set is immutable + return _set; } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 14:15:47
|
Revision: 183 http://tinytim.svn.sourceforge.net/tinytim/?rev=183&view=rev Author: lheuer Date: 2008-11-13 14:15:37 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Removed references to 1.5, more detailed CHANGES Modified Paths: -------------- tinytim-mio/trunk/CHANGES.txt Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-13 14:13:53 UTC (rev 182) +++ tinytim-mio/trunk/CHANGES.txt 2008-11-13 14:15:37 UTC (rev 183) @@ -1,25 +1,24 @@ -=========== -Changes Log -=========== - -2.0.0 a3 (xx.11.2008) -------------------------- -* Adapted MIO to tinyTiM 2.0.0 -* Changed license to Apache License 2.0 -* Introduced TopicMapReader/TopicMapWriter interfaces -* Added dedicated, syntax-specific TopicMapReader implementations -* Moved CXTMWriter into .mio package, implements TopicMapWriter -* XTM 1.0/2.0 serializers -* Deprecated some TopicMapImporter methods which take a xml.InputSource - as argument - - -1.5.0 beta (13.08.2008) -------------------------- -* Renamed ``org.tinyim.io`` to ``org.tinytim.mio`` -* Aligned version numbering scheme - - -1.0.0 alpha1 (08.05.2008) -------------------------- -* Initial tinyTiM I/O release +=========== +Changes Log +=========== + +2.0.0 a3 (xx.11.2008) +--------------------- +* Initial .mio release for tinyTiM 2.x +* Changed license to Apache License 2.0 +* Introduced TopicMapReader / TopicMapWriter interfaces +* Added dedicated, syntax-specific TopicMapReader implementations: + - XTM reader which supports 1.0 and 2.0 + - XTM 1.0 reader (does not support mergeMap) + - XTM 2.0 reader + - CTM reader which implements draft dtd. 2008-05-15 + (does not suppot %include and %mergemap) + - TM/XML + - Snello + - LTM 1.3 +* Moved CXTMWriter into .mio package, implements TopicMapWriter +* XTM 1.0 writer +* XTM 2.0 writer +* Deprecated some TopicMapImporter methods which take a sax.InputSource + as argument +* Added docs to TopicMapImporter that it may become deprecated This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 14:14:00
|
Revision: 182 http://tinytim.svn.sourceforge.net/tinytim/?rev=182&view=rev Author: lheuer Date: 2008-11-13 14:13:53 +0000 (Thu, 13 Nov 2008) Log Message: ----------- Removed references to 1.5 Modified Paths: -------------- tinytim/trunk/CHANGES.txt Modified: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt 2008-11-13 13:22:47 UTC (rev 181) +++ tinytim/trunk/CHANGES.txt 2008-11-13 14:13:53 UTC (rev 182) @@ -6,6 +6,7 @@ --------------------- * Moved to Apache License 2.0 * Internal code refactoring +* Added more tests Bugfixes: --------- @@ -13,52 +14,15 @@ * Bug #2221024 -- Merging topic maps causes an autom. generated topic iid + 2.0.0 a2 (08.09.2008) --------------------- * Internal code refactoring * Better duplicate literal suppression + 2.0.0 a1 (26.08.2008) --------------------- * Implementation of the TMAPI 2.0 interfaces * Internal code refactoring - - -1.5.0 beta (08.08.2008) ------------------------ -Bugfixes: ---------- -* Bug #1970502 (Locator impl does no reference unescaping) -* Bug #2038853 (Subject locators are not removable) - - -1.5.0 alpha2 (05.05.2008) -------------------------- -Bugfixes: --------- -* ``DatatypeAwareConstruct`` sent wrong event. Fixed -* All indexes return copies of their collections to avoid - concurrent modification exceptions. - -Features: ---------- -* ``voc`` package added which provides access to common PSIs. -* ``DuplicateRemovalUtils`` added. Used to remove - duplicate Topic Maps constructs from topic maps, topics, - associations, and names -* ``TypeInstanceConverter`` added. Used to convert - type-instance associations into the topic's [types] - property. -* ``tmapi.TopicNamesIndex``, ``tmapi.OccurrenceIndex`` - and ``tmapi.VarinatsIndex`` use an optimized reindex - algorithm. -* Property to let ``Variant`` instances return the union - of their 'own' scope and the parent's scope. - - -1.5.0 alpha1 (25.04.2008) -------------------------- -* Initial 1.5.x release -* New code base -* Java 1.5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-13 13:22:58
|
Revision: 181 http://tinytim.svn.sourceforge.net/tinytim/?rev=181&view=rev Author: lheuer Date: 2008-11-13 13:22:47 +0000 (Thu, 13 Nov 2008) Log Message: ----------- - TinyTimMapInputHandler uses the new IConstructFactory instead of concrete classes - XTM 1.0 / XTM 2.0 writer do not swallow the IOException but raise it in the constructor Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Reader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Reader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTMReader.java tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTinyTimMapInputHandler.java Removed Paths: ------------- tinytim-mio/trunk/src/main/java/org/tinytim/core/ 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-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -48,34 +48,35 @@ /** * - * + * * @param topicMap * @param syntax * @param source * @throws IOException */ - protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, - final File source) throws IOException { + protected AbstractTopicMapReader(final TopicMap topicMap, + final Syntax syntax, final File source) throws IOException { this(topicMap, syntax, source, source.toURL().toString()); } /** * - * + * * @param topicMap * @param syntax * @param source * @param docIRI * @throws IOException */ - protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, - final File source, final String docIRI) throws IOException { + protected AbstractTopicMapReader(final TopicMap topicMap, + final Syntax syntax, final File source, final String docIRI) + throws IOException { this(topicMap, syntax, new Source(new FileInputStream(source), docIRI)); } /** * - * + * * @param topicMap * @param syntax * @param source @@ -86,17 +87,32 @@ this(topicMap, syntax, new Source(source, docIRI)); } - protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, - final Source source) { + /** + * + * + * @param topicMap + * @param syntax + * @param source + */ + protected AbstractTopicMapReader(final TopicMap topicMap, + final Syntax syntax, final Source source) { this(new TinyTimMapInputHandler(topicMap), syntax, source); } - protected AbstractTopicMapReader(final IMapHandler handler, final Syntax syntax, - final Source source) { + /** + * + * + * @param handler + * @param syntax + * @param source + */ + protected AbstractTopicMapReader(final IMapHandler handler, + final Syntax syntax, final Source source) { this(handler, DeserializerRegistry.createDeserializer(syntax), source); } - protected AbstractTopicMapReader(final IMapHandler handler, final IDeserializer deserializer, final Source source) { + protected AbstractTopicMapReader(final IMapHandler handler, + final IDeserializer deserializer, final Source source) { if (_deserializer == null) { throw new IllegalArgumentException("Deserializer not found"); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java 2008-11-13 13:22:47 UTC (rev 181) @@ -19,8 +19,8 @@ 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$ */ @@ -32,9 +32,21 @@ _baseIRI = baseIRI; } - protected String _getId(Topic tmo) { + /** + * 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; - for (Locator loc: tmo.getItemIdentifiers()) { + for (Locator loc: topic.getItemIdentifiers()) { String reference = loc.getReference(); if (!reference.startsWith(_baseIRI)) { continue; @@ -51,6 +63,7 @@ break; } } - return id != null ? id : "id-" + tmo.getId(); + return id != null ? id : "id-" + topic.getId(); } + } 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-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -31,7 +31,7 @@ * to configure the reader. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class AbstractXTMTopicMapReader extends AbstractTopicMapReader { @@ -79,7 +79,8 @@ * @return <tt>true</tt> if mergeMap is ignored, otherwise <tt>false</tt>. */ public boolean isIgnoringMergeMap() { - return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_MERGEMAP)); + return Boolean.TRUE.equals(_deserializer + .getProperty(Property.IGNORE_MERGEMAP)); } /** @@ -102,6 +103,8 @@ * @return <tt>true</tt> if this reader validates the source, otherwise <tt>false</tt>. */ public boolean isValidating() { - return Boolean.TRUE.equals(_deserializer.getProperty(Property.VALIDATE)); + return Boolean.TRUE + .equals(_deserializer.getProperty(Property.VALIDATE)); } + } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-13 13:22:47 UTC (rev 181) @@ -18,31 +18,55 @@ import java.io.IOException; import java.io.OutputStream; -import org.tmapi.core.TMAPIRuntimeException; -import org.xml.sax.Attributes; 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 Attributes _EMPTY_ATTRS = XMLWriter.EMPTY_ATTRS; - - protected AttributesImpl _attrs; - protected XMLWriter _out; + protected final AttributesImpl _attrs; - public AbstractXTMWriter(final OutputStream out, final String baseIRI) { + 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); - try { - _out = new XMLWriter(out); + if (encoding == null) { + throw new IOException("The encoding must not be null"); } - catch (IOException ex) { - throw new TMAPIRuntimeException(ex); - } + _out = new XMLWriter(out, encoding); + _attrs = new AttributesImpl(); } } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -44,7 +44,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public CTMReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public CTMReader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.CTM, source, docIRI); } @@ -59,7 +60,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public CTMReader(final TopicMap topicMap, final File source) throws IOException { + public CTMReader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.CTM, source); } @@ -70,7 +72,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public CTMReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public CTMReader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.CTM, source, docIRI); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -41,7 +41,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public LTMReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public LTMReader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.LTM, source, docIRI); } @@ -56,7 +57,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public LTMReader(final TopicMap topicMap, final File source) throws IOException { + public LTMReader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.LTM, source); } @@ -67,7 +69,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public LTMReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public LTMReader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.LTM, source, docIRI); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -41,7 +41,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public SnelloReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public SnelloReader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.SNELLO, source, docIRI); } @@ -56,7 +57,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public SnelloReader(final TopicMap topicMap, final File source) throws IOException { + public SnelloReader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.SNELLO, source); } @@ -67,7 +69,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public SnelloReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public SnelloReader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.SNELLO, source, docIRI); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -42,7 +42,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public TMXMLReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public TMXMLReader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.TMXML, source, docIRI); } @@ -57,7 +58,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public TMXMLReader(final TopicMap topicMap, final File source) throws IOException { + public TMXMLReader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.TMXML, source); } @@ -68,7 +70,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public TMXMLReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public TMXMLReader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.TMXML, source, docIRI); } 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-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2008-11-13 13:22:47 UTC (rev 181) @@ -15,24 +15,520 @@ */ package org.tinytim.mio; -import org.tinytim.core.AbstractMapInputHandler; +import java.util.List; + +import org.tinytim.core.Scope; +import org.tinytim.core.value.Literal; +import org.tinytim.internal.api.IConstruct; +import org.tinytim.internal.api.IConstructFactory; +import org.tinytim.internal.api.ILiteralAware; +import org.tinytim.internal.api.IName; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.IScoped; +import org.tinytim.internal.api.ITopic; +import org.tinytim.internal.api.ITopicMap; +import org.tinytim.internal.api.IVariant; +import org.tinytim.internal.utils.CollectionFactory; +import org.tinytim.utils.TypeInstanceConverter; +import org.tinytim.voc.TMDM; + +import org.tmapi.core.Association; +import org.tmapi.core.Construct; +import org.tmapi.core.Locator; +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 com.semagia.mio.IMapHandler; +import com.semagia.mio.IRef; +import com.semagia.mio.MIOException; + /** - * {@link com.semagia.mio.IMapHandler} implementation. + * 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> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public final class TinyTimMapInputHandler extends AbstractMapInputHandler { +public final class TinyTimMapInputHandler implements IMapHandler { + private static final int + INITIAL = 1, + TOPIC = 2, + ASSOCIATION = 3, + ROLE = 4, + OCCURRENCE = 5, + NAME = 6, + VARIANT = 7, + SCOPE = 8, + THEME = 9, + REIFIER = 10, + PLAYER = 11, + ISA = 12, + TYPE = 13; + + private static final int _CONSTRUCT_SIZE = 6; + private static final int _STATE_SIZE = 10; + private static final int _SCOPE_SIZE = 6; + + private final IConstructFactory _factory; + private final ITopicMap _tm; + private final List<Topic> _scope; + private int[] _stateStack; + private int _stateSize; + private IConstruct[] _constructStack; + private int _constructSize; + + protected TinyTimMapInputHandler(TopicMap topicMap) { + if (topicMap == null) { + throw new IllegalArgumentException("The topic map must not be null"); + } + _tm = (ITopicMap) topicMap; + _factory = _tm.getConstructFactory(); + _scope = CollectionFactory.createList(_SCOPE_SIZE); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startTopicMap() + */ + public void startTopicMap() throws MIOException { + _constructStack = new IConstruct[_CONSTRUCT_SIZE]; + _stateStack = new int[_STATE_SIZE]; + _constructSize = 0; + _stateSize = 0; + _enterState(INITIAL, _tm); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endTopicMap() + */ + public void endTopicMap() throws MIOException { + TypeInstanceConverter.convertAssociationsToTypes(_tm); + _constructStack = null; + _stateStack = null; + _scope.clear(); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startTopic(com.semagia.mio.IRef) + */ + public void startTopic(IRef identity) throws MIOException { + _enterState(TOPIC, _createTopic(identity)); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endTopic() + */ + public void endTopic() throws MIOException { + _handleTopic((Topic) _leaveStatePopConstruct(TOPIC)); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startAssociation() + */ + public void startAssociation() throws MIOException { + _enterState(ASSOCIATION, _factory.createAssociation()); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endAssociation() + */ + public void endAssociation() throws MIOException { + _leaveStatePopConstruct(ASSOCIATION); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startRole() + */ + public void startRole() throws MIOException { + assert _state() == ASSOCIATION; + _enterState(ROLE, _factory.createRole((Association) _peekConstruct())); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endRole() + */ + public void endRole() throws MIOException { + _leaveStatePopConstruct(ROLE); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startPlayer() + */ + public void startPlayer() throws MIOException { + assert _state() == ROLE; + _enterState(PLAYER); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endPlayer() + */ + public void endPlayer() throws MIOException { + _leaveState(PLAYER); + assert _state() == ROLE; + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startOccurrence() + */ + public void startOccurrence() throws MIOException { + _enterState(OCCURRENCE, _factory.createOccurrence(_peekTopic())); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endOccurrence() + */ + public void endOccurrence() throws MIOException { + _leaveStatePopConstruct(OCCURRENCE); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startName() + */ + public void startName() throws MIOException { + _enterState(NAME, _factory.createName(_peekTopic())); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endName() + */ + public void endName() throws MIOException { + IName name = (IName) _leaveStatePopConstruct(NAME); + if (name.getType() == null) { + name.setType(_tm.createTopicBySubjectIdentifier(TMDM.TOPIC_NAME)); + } + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startVariant() + */ + public void startVariant() throws MIOException { + assert _state() == NAME; + _enterState(VARIANT, _factory.createVariant((IName) _peekConstruct())); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endVariant() + */ + public void endVariant() throws MIOException { + IVariant variant = (IVariant) _leaveStatePopConstruct(VARIANT); + IName name = (IName) _peekConstruct(); + IScope scope = variant.getScopeObject(); + if (scope.isUnconstrained() || name.getScopeObject() == scope) { + _reportError("The variant has no scope"); + } + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startType() + */ + public void startType() throws MIOException { + assert _peekConstruct() instanceof Typed; + _enterState(TYPE); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endType() + */ + public void endType() throws MIOException { + _leaveState(TYPE); + assert _peekConstruct() instanceof Typed; + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startScope() + */ + public void startScope() throws MIOException { + assert _peekConstruct() instanceof Scoped; + _enterState(SCOPE); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endScope() + */ + public void endScope() throws MIOException { + _leaveState(SCOPE); + ((IScoped) _peekConstruct()).setScopeObject(Scope.create(_scope)); + _scope.clear(); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startTheme() + */ + public void startTheme() throws MIOException { + assert _state() == SCOPE; + _enterState(THEME); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endTheme() + */ + public void endTheme() throws MIOException { + _leaveState(THEME); + assert _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); + ITopic topic = _peekTopic(); + Topic existing = _tm.getTopicBySubjectIdentifier(sid); + if (existing != null && !(existing == topic)) { + _merge(existing, topic); + } + else { + IConstruct tmo = (IConstruct) _tm.getConstructByItemIdentifier(sid); + if (tmo != null && tmo.isTopic() && !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); + ITopic topic = _peekTopic(); + Topic existing = _tm.getTopicBySubjectLocator(slo); + if (existing != null && !(existing == 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); + IConstruct tmo = _peekConstruct(); + if (_state() == TOPIC) { + IConstruct existing = (IConstruct) _tm.getConstructByItemIdentifier(iid); + if (existing != null && existing.isTopic() && !existing.equals(tmo)) { + _merge((Topic) existing, (ITopic) tmo); + } + else { + Topic topic = _tm.getTopicBySubjectIdentifier(iid); + if (topic != null && !topic.equals(tmo)) { + _merge(topic, (ITopic) tmo); + } + } + } + tmo.addItemIdentifier(iid); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startIsa() + */ + public void startIsa() throws MIOException { + assert _state() == TOPIC; + _enterState(ISA); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endIsa() + */ + public void endIsa() throws MIOException { + _leaveState(ISA); + assert _state() == TOPIC; + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#startReifier() + */ + public void startReifier() throws MIOException { + assert _peekConstruct() instanceof Reifiable; + _enterState(REIFIER); + } + + /* (non-Javadoc) + * @see com.semagia.mio.IMapHandler#endReifier() + */ + public void endReifier() throws MIOException { + _leaveState(REIFIER); + assert _peekConstruct() instanceof Reifiable; + } + + /* (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() == NAME; + ((IName) _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 { + ((ILiteralAware) _peekConstruct()).setLiteral(Literal.create(value, datatype)); + } + /** - * Intitializes a new instance with the specified <tt>topicMap</tt>. + * Enters a state. * - * @param topicMap The {@link TopicMap} instance. + * @param state The state to push ontop of the state stack. */ - public TinyTimMapInputHandler(TopicMap topicMap) { - super(topicMap); + private void _enterState(int state) { + if (_stateSize >= _stateStack.length) { + int[] states = new int[_stateStack.length*2]; + System.arraycopy(_stateStack, 0, states, 0, _stateStack.length); + _stateStack = states; + } + _stateStack[_stateSize++] = 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(int state, Construct tmo) { + _enterState(state); + if (_constructSize >= _constructStack.length) { + IConstruct[] constructs = new IConstruct[_constructStack.length*2]; + System.arraycopy(_constructStack, 0, constructs, 0, _constructStack.length); + _constructStack = constructs; + } + _constructStack[_constructSize++] = (IConstruct) 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(int state) throws MIOException { + if (state != _state()) { + _reportError("Unexpected state: " + _state() + ", expected: " + state); + } + _stateSize--; + } + + /** + * Leaves a state and removed the Topic Maps construct from the top of the + * construct stack. + * + * @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 { + _leaveState(state); + final IConstruct construct = _peekConstruct(); + _constructStack[_constructSize] = null; + _constructSize--; + return construct; + } + + /** + * Returns the Topic Maps construct on top of the stack. + * + * @return The Topic Maps construct. + */ + private IConstruct _peekConstruct() { + return _constructStack[_constructSize-1]; + } + + /** + * Returns the topic on top of the stack. + * + * @return The topic. + */ + private ITopic _peekTopic() { + return (ITopic) _peekConstruct(); + } + + /** + * Returns the current state. + * + * @return The current state. + */ + private int _state() { + return _stateStack[_stateSize-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: ((Typed) _peekConstruct()).setType(topic); break; + case PLAYER: ((Role) _peekConstruct()).setPlayer(topic); break; + case THEME: _scope.add(topic); break; + case REIFIER: ((Reifiable) _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, ITopic target) { + for (int i=0; i <_constructSize; i++) { + if (_constructStack[i] == source) { + _constructStack[i] = target; + } + } + 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 ITopic _createTopic(IRef ref) throws MIOException { + Locator loc = _tm.createLocator(ref.getIRI()); + switch (ref.getType()) { + case IRef.ITEM_IDENTIFIER: return (ITopic) _tm.createTopicByItemIdentifier(loc); + case IRef.SUBJECT_IDENTIFIER: return (ITopic) _tm.createTopicBySubjectIdentifier(loc); + case IRef.SUBJECT_LOCATOR: return (ITopic) _tm.createTopicBySubjectLocator(loc); + default: _reportError("Unknown reference type " + ref.getType()); + } + // Never returned, an exception was thrown + return null; + } + + /** + * 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-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2008-11-13 13:22:47 UTC (rev 181) @@ -27,7 +27,7 @@ * Simple SAX-alike XML writer. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class XMLWriter { @@ -38,17 +38,17 @@ private OutputStreamWriter _out; private final String _encoding; - - XMLWriter(OutputStream out) throws IOException { + + public XMLWriter(OutputStream out) throws IOException { this(out, "utf-8"); } - XMLWriter(OutputStream out, String encoding) throws IOException { + public XMLWriter(OutputStream out, String encoding) throws IOException { _out = new OutputStreamWriter(out, encoding); _encoding = encoding; } - /* (non-Javadoc) + /** * @see org.xml.sax.DocumentHandler#startDocument() */ public void startDocument() throws IOException { @@ -62,7 +62,7 @@ newline(); } - /* (non-Javadoc) + /** * @see org.xml.sax.DocumentHandler#endDocument() */ public void endDocument() throws IOException { @@ -79,7 +79,7 @@ startElement(name, EMPTY_ATTRS); } - /* (non-Javadoc) + /** * @see org.xml.sax.DocumentHandler#startElement(java.lang.String, org.xml.sax.AttributeList) */ public void startElement(String name, Attributes attrs) throws IOException { @@ -89,7 +89,7 @@ _out.write('>'); } - /* (non-Javadoc) + /** * @see org.xml.sax.DocumentHandler#endElement(java.lang.String) */ public void endElement(String name) throws IOException { @@ -138,8 +138,6 @@ /** * Writes the specified characters to the output. - * - * The data is written according to the rules of canonicalized XML. * * @param data The data to write. * @throws IOException If an error occurs. @@ -149,7 +147,7 @@ characters(chars, 0, chars.length); } - /* (non-Javadoc) + /** * @see org.xml.sax.DocumentHandler#characters(char[], int, int) */ public void characters(char[] chars, int start, int length) throws IOException { Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Reader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Reader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Reader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -45,7 +45,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public XTM10Reader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public XTM10Reader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.XTM_10, source, docIRI); } @@ -60,7 +61,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public XTM10Reader(final TopicMap topicMap, final File source) throws IOException { + public XTM10Reader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.XTM_10, source); } @@ -71,7 +73,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public XTM10Reader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public XTM10Reader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.XTM_10, source, docIRI); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-13 13:22:47 UTC (rev 181) @@ -19,6 +19,8 @@ import java.io.OutputStream; import java.util.Set; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.IScoped; import org.tinytim.voc.Namespace; import org.tinytim.voc.XSD; @@ -52,14 +54,30 @@ // warn if datatype not in (xsd:string, xsd:anyURI) /** - * + * Creates a XTM 1.0 writer using "utf-8" encoding. * - * @param baseIRI + * @param out The stream the XTM is written onto. + * @param baseIRI The base IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. */ - public XTM10Writer(final OutputStream out, final String baseIRI) { + public XTM10Writer(final OutputStream out, final String baseIRI) + throws IOException { super(out, baseIRI); } + /** + * Creates a XTM 1.0 writer. + * + * @param out The stream the XTM 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 XTM10Writer(final OutputStream out, final String baseIRI, + final String encoding) throws IOException { + super(out, baseIRI, encoding); + } + private String _getId(Reifiable reifiable) { assert reifiable.getReifier() != null; return "reifier-id-" + reifiable.getReifier().getId(); @@ -99,7 +117,6 @@ protected void _writeTopic(final Topic topic) throws IOException { _attrs.clear(); _attrs.addAttribute("", "id", "", "CDATA", _getId(topic)); - _out.newline(); _out.startElement("topic", _attrs); _writeIdentities(topic); for (Topic type: topic.getTypes()) { @@ -126,7 +143,6 @@ protected void _writeAssociation(final Association assoc) throws IOException { _attrs.clear(); _addId(_attrs, assoc); - _out.newline(); _out.startElement("association", _attrs); _writeType(assoc); _writeScope(assoc); @@ -217,8 +233,8 @@ } private void _writeScope(final Scoped scoped) throws IOException { - final Set<Topic> scope = scoped.getScope(); - if (scope.isEmpty()) { + final IScope scope = ((IScoped) scoped).getScopeObject(); + if (scope.isUnconstrained()) { return; } _out.newline(); @@ -242,6 +258,7 @@ _out.startElement("subjectIdentity"); _out.newline(); if (!slos.isEmpty()) { + // Choose one subject locator Locator slo = slos.iterator().next(); _attrs.clear(); _addLocator(_attrs, slo); Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Reader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Reader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Reader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -45,7 +45,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public XTM20Reader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public XTM20Reader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.XTM_20, source, docIRI); } @@ -60,7 +61,8 @@ * @param source The source to read the topic map from. * @throws IOException If an error occurs. */ - public XTM20Reader(final TopicMap topicMap, final File source) throws IOException { + public XTM20Reader(final TopicMap topicMap, final File source) + throws IOException { super(topicMap, Syntax.XTM_20, source); } @@ -71,7 +73,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public XTM20Reader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public XTM20Reader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.XTM_20, source, docIRI); } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-13 13:22:47 UTC (rev 181) @@ -19,7 +19,9 @@ import java.io.OutputStream; import java.util.Set; -import org.tinytim.core.IConstruct; +import org.tinytim.internal.api.IConstruct; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.IScoped; import org.tinytim.voc.Namespace; import org.tinytim.voc.TMDM; import org.tinytim.voc.XSD; @@ -52,14 +54,30 @@ public class XTM20Writer extends AbstractXTMWriter { /** - * + * Creates a XTM 2.0 writer using "utf-8" encoding. * - * @param baseIRI + * @param out The stream the XTM is written onto. + * @param baseIRI The base IRI which is used to resolve IRIs against. + * @throws IOException If an error occurs. */ - public XTM20Writer(final OutputStream out, final String baseIRI) { + public XTM20Writer(final OutputStream out, final String baseIRI) + throws IOException { super(out, baseIRI); } + /** + * Creates a XTM 2.0 writer. + * + * @param out The stream the XTM 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 XTM20Writer(final OutputStream out, final String baseIRI, + final String encoding) throws IOException { + super(out, baseIRI, encoding); + } + /* (non-Javadoc) * @see org.tinytim.mio.ITopicMapWriter#write(org.tmapi.core.TopicMap) */ @@ -73,12 +91,10 @@ _out.startElement("topicMap", _attrs); _writeItemIdentifiers(topicMap); for (Topic topic: topicMap.getTopics()) { - _out.newline(); _writeTopic(topic); _out.newline(); } for (Association assoc: topicMap.getAssociations()) { - _out.newline(); _writeAssociation(assoc); _out.newline(); } @@ -99,12 +115,10 @@ _out.endElement("instanceOf"); } for (Name name: topic.getNames()) { - _out.newline(); _writeName(name); _out.newline(); } for (Occurrence occ: topic.getOccurrences()) { - _out.newline(); _writeOccurrence(occ); _out.newline(); } @@ -117,7 +131,6 @@ _writeType(assoc); _writeScope(assoc); for (Role role: assoc.getRoles()) { - _out.newline(); _writeRole(role); _out.newline(); } @@ -129,6 +142,7 @@ _writeItemIdentifiers(role); _writeType(role); _writeTopicRef(role.getPlayer()); + _out.newline(); _out.endElement("role"); } @@ -139,7 +153,6 @@ _writeScope(name); _out.dataElement("value", name.getValue()); for (Variant variant: name.getVariants()) { - _out.newline(); _writeVariant(variant); _out.newline(); } @@ -194,7 +207,7 @@ _addReifier(_attrs, reifier); return _attrs; } - return _EMPTY_ATTRS; + return XMLWriter.EMPTY_ATTRS; } private void _addReifier(final AttributesImpl attrs, final Topic reifier) { @@ -221,8 +234,8 @@ } private void _writeScope(final Scoped scoped) throws IOException { - final Set<Topic> scope = scoped.getScope(); - if (scope.isEmpty()) { + final IScope scope = ((IScoped) scoped).getScopeObject(); + if (scope.isUnconstrained()) { return; } _out.newline(); Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTMReader.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTMReader.java 2008-11-13 13:22:47 UTC (rev 181) @@ -45,7 +45,8 @@ * @param docIRI The document IRI which is used to resolve IRIs against. * @throws IOException If an error occurs. */ - public XTMReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + public XTMReader(final TopicMap topicMap, final File source, + final String docIRI) throws IOException { super(topicMap, Syntax.XTM, source, docIRI); } @@ -71,7 +72,8 @@ * @param source The source to read the topic map from. * @param docIRI The document IRI which is used to resolve IRIs against. */ - public XTMReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + public XTMReader(final TopicMap topicMap, final InputStream source, + final String docIRI) { super(topicMap, Syntax.XTM, source, docIRI); } Modified: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTinyTimMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTinyTimMapInputHandler.java 2008-11-13 13:19:39 UTC (rev 180) +++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTinyTimMapInputHandler.java 2008-11-13 13:22:47 UTC (rev 181) @@ -27,7 +27,7 @@ import com.semagia.mio.helpers.Ref; /** - * Tests against the {@link org.tinytim.core.AbstractMapInputHandler}. + * Tests against the {@link org.tinytim.mio.TinyTimMapInputHandler}. * * @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-13 13:19:45
|
Revision: 180 http://tinytim.svn.sourceforge.net/tinytim/?rev=180&view=rev Author: lheuer Date: 2008-11-13 13:19:39 +0000 (Thu, 13 Nov 2008) Log Message: ----------- - Package reorg - Introduced more internal interfaces - Simplified ITopicMap - Utility classes work on interfaces and rely not on implementations (changed casts to internal interfaces, not implementations) Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/Version.java tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java tinytim/trunk/src/main/java/org/tinytim/core/RoleImpl.java tinytim/trunk/src/main/java/org/tinytim/core/Scope.java tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TopicMapSystemFactoryImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/utils/DuplicateRemovalUtils.java tinytim/trunk/src/main/java/org/tinytim/utils/Property.java tinytim/trunk/src/main/java/org/tinytim/utils/TopicUtils.java tinytim/trunk/src/main/java/org/tinytim/utils/TypeInstanceConverter.java tinytim/trunk/src/main/java/org/tinytim/voc/Namespace.java tinytim/trunk/src/main/java/org/tinytim/voc/Vocabulary.java tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java tinytim/trunk/src/test/java/org/tinytim/core/TestScope.java tinytim/trunk/src/test/java/org/tinytim/core/TinyTimTestCase.java Added Paths: ----------- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java tinytim/trunk/src/main/java/org/tinytim/core/value/ tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ tinytim/trunk/src/main/java/org/tinytim/internal/api/Event.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstruct.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IEventHandler.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IEventPublisher.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IEventPublisherAware.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IIndexManagerAware.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ILiteral.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ILiteralAware.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ILocator.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IMovable.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IName.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IOccurrence.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IScope.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IScoped.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopic.java tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopicMap.java tinytim/trunk/src/main/java/org/tinytim/internal/api/IVariant.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/CopyUtils.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/MergeUtils.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/SignatureGenerator.java tinytim/trunk/src/test/java/org/tinytim/core/value/ tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteralNormalizer.java tinytim/trunk/src/test/java/org/tinytim/core/value/TestLocatorImpl.java tinytim/trunk/src/test/java/org/tinytim/internal/ tinytim/trunk/src/test/java/org/tinytim/internal/utils/ tinytim/trunk/src/test/java/org/tinytim/internal/utils/TestSignatureGenerator.java Removed Paths: ------------- tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/Event.java tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java tinytim/trunk/src/main/java/org/tinytim/core/IScope.java tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/Literal.java tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java tinytim/trunk/src/main/java/org/tinytim/core/MergeUtils.java tinytim/trunk/src/main/java/org/tinytim/core/SignatureGenerator.java tinytim/trunk/src/test/java/org/tinytim/core/TestItemIdentifierConstraint.java tinytim/trunk/src/test/java/org/tinytim/core/TestLiteral.java tinytim/trunk/src/test/java/org/tinytim/core/TestLiteralNormalizer.java tinytim/trunk/src/test/java/org/tinytim/core/TestLocatorImpl.java tinytim/trunk/src/test/java/org/tinytim/core/TestSignatureGenerator.java Modified: tinytim/trunk/src/main/java/org/tinytim/Version.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/Version.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/Version.java 2008-11-13 13:19:39 UTC (rev 180) @@ -19,7 +19,7 @@ * Provides the version information. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class Version { @@ -32,6 +32,7 @@ /** * The release information. */ - public static final String RELEASE = _MAJOR + "." + _MINOR + "." + _MICRO + _STATE + _DATE; + // Not final since Java compilers copy the string into classes + public static String RELEASE = _MAJOR + "." + _MINOR + "." + _MICRO + _STATE + _DATE; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java 2008-11-13 13:19:39 UTC (rev 180) @@ -17,6 +17,8 @@ import java.util.Map; +import org.tinytim.core.value.Literal; + import org.tmapi.core.FeatureNotRecognizedException; import org.tmapi.core.Locator; import org.tmapi.core.TMAPIException; @@ -28,7 +30,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class AbstractTopicMapSystem implements TopicMapSystem { Modified: tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-13 13:19:39 UTC (rev 180) @@ -18,8 +18,13 @@ import java.util.Collections; import java.util.Set; +import org.tinytim.internal.api.Event; +import org.tinytim.internal.api.IConstant; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.ITopicMap; import org.tinytim.internal.utils.Check; import org.tinytim.internal.utils.CollectionFactory; + import org.tmapi.core.Association; import org.tmapi.core.Role; import org.tmapi.core.Topic; Modified: tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-13 13:19:39 UTC (rev 180) @@ -18,7 +18,12 @@ import java.util.Collections; import java.util.Set; +import org.tinytim.internal.api.Event; +import org.tinytim.internal.api.IConstant; +import org.tinytim.internal.api.IConstruct; +import org.tinytim.internal.api.ITopicMap; import org.tinytim.internal.utils.CollectionFactory; + import org.tmapi.core.Construct; import org.tmapi.core.Locator; import org.tmapi.core.ModelConstraintException; Deleted: tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,375 +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.core; - -import java.util.Map; -import java.util.Set; - -import org.tinytim.internal.utils.CollectionFactory; -import org.tinytim.internal.utils.IIntObjectMap; -import org.tmapi.core.Association; -import org.tmapi.core.Construct; -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; - -/** - * This class provides methods to copy Topic Maps constructs from one - * topic map to another without creating duplicates. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -final class CopyUtils { - - private CopyUtils() { - // noop. - } - - /** - * Copies the topics and associations from the <tt>source</tt> to the - * <tt>target</tt> topic map. - * - * @param source The topic map to take the topics and associations from. - * @param target The topic map which should receive the topics and associations. - */ - public static void copy(TopicMap source, TopicMap target) { - _copy(source, (ITopicMap) target); - } - - /** - * @see #copy(TopicMap, TopicMap) - */ - private static void _copy(TopicMap source, ITopicMap target) { - if (source == null || target == null) { - throw new IllegalArgumentException("Neither the source topic map nor the target topic map must be null"); - } - if (source == target) { - return; - } - Map<Topic, Topic> mergeMap = CollectionFactory.createIdentityMap(); - Topic existing = null; - Construct existingConstruct = null; - for (Topic topic: source.getTopics()) { - for (Locator slo: topic.getSubjectLocators()) { - existing = target.getTopicBySubjectLocator(slo); - if (existing != null) { - _addMerge(topic, existing, mergeMap); - } - } - for (Locator sid: topic.getSubjectIdentifiers()) { - existing = target.getTopicBySubjectIdentifier(sid); - if (existing != null) { - _addMerge(topic, existing, mergeMap); - } - existingConstruct = target.getConstructByItemIdentifier(sid); - if (existingConstruct instanceof Topic) { - _addMerge(topic, (Topic) existingConstruct, mergeMap); - } - } - for (Locator iid: topic.getItemIdentifiers()) { - existingConstruct = target.getConstructByItemIdentifier(iid); - if (existingConstruct instanceof Topic) { - _addMerge(topic, (Topic) existingConstruct, mergeMap); - } - existing = target.getTopicBySubjectIdentifier(iid); - if (existing != null) { - _addMerge(topic, existing, mergeMap); - } - } - } - if (source.getReifier() != null && target.getReifier() != null) { - _addMerge(source.getReifier(), target.getReifier(), mergeMap); - } - for (Topic topic: source.getTopics()) { - if (!mergeMap.containsKey(topic)) { - _copyTopic(topic, target, mergeMap); - } - } - for (Topic topic: mergeMap.keySet()) { - Topic targetTopic = mergeMap.get(topic); - _copyIdentities(topic, targetTopic); - _copyTypes(topic, targetTopic, mergeMap); - _copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap); - } - _copyAssociations(source, target, mergeMap); - } - - /** - * Copies the <tt>topic</tt> to the <tt>target</tt> topic map. - * - * @param topic The topic to copy. - * @param target The target topic map. - * @param mergeMap The map which holds the merge mappings. - * @return The newly created topic in the target topic map. - */ - private static Topic _copyTopic(Topic topic, ITopicMap target, - Map<Topic, Topic> mergeMap) { - Topic targetTopic = target.createTopicWithoutIdentity(); - _copyIdentities(topic, targetTopic); - _copyTypes(topic, targetTopic, mergeMap); - _copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap); - return targetTopic; - } - - /** - * Copies the identities (item identifiers, subject identifiers and subject - * locators) from the <tt>source/tt> to the <tt>targetTopic</tt>. - * - * @param topic The topic to take the identities from. - * @param targetTopic The topic which gets the identities. - */ - private static void _copyIdentities(Topic topic, Topic targetTopic) { - for(Locator sid: topic.getSubjectIdentifiers()) { - targetTopic.addSubjectIdentifier(sid); - } - for(Locator slo: topic.getSubjectLocators()) { - targetTopic.addSubjectLocator(slo); - } - _copyItemIdentifiers(topic, targetTopic); - } - - /** - * Copies the types from the <tt>topic</tt> to the <tt>targetTopic</tt>. - * - * @param topic The topic to take the types from. - * @param targetTopic The topic which receives the types. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _copyTypes(Topic topic, Topic targetTopic, - Map<Topic, Topic> mergeMap) { - for (Topic type: topic.getTypes()) { - Topic targetType = mergeMap.get(type); - if (targetType == null) { - targetType = _copyTopic(type, (ITopicMap) targetTopic.getTopicMap(), mergeMap); - } - targetTopic.addType(targetType); - } - } - - /** - * Copies the occurrences and names from <tt>topic</tt> to the - * <tt>targetTopic</tt>. - * - * @param topic The topic to take the characteristics from. - * @param targetTopic The target topic which gets the charateristics. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _copyCharacteristics(Topic topic, TopicImpl targetTopic, - Map<Topic, Topic> mergeMap) { - IIntObjectMap<Reifiable> sigs = CollectionFactory.createIntObjectMap(); - for (Occurrence occ: targetTopic.getOccurrences()) { - sigs.put(SignatureGenerator.generateSignature(occ), occ); - } - Reifiable existing = null; - final TopicMap tm = targetTopic.getTopicMap(); - Topic type = null; - Set<Topic> scope = null; - Occurrence targetOcc = null; - for (Occurrence occ: topic.getOccurrences()) { - type = _copyType(occ, tm, mergeMap); - scope = _copyScope(occ, tm, mergeMap); - targetOcc = targetTopic._createOccurrence(type, ((ILiteralAware) occ).getLiteral(), scope); - existing = sigs.get(SignatureGenerator.generateSignature(targetOcc)); - if (existing != null) { - targetOcc.remove(); - targetOcc = (Occurrence)existing; - } - _copyReifier(occ, targetOcc, mergeMap); - _copyItemIdentifiers(occ, targetOcc); - } - sigs.clear(); - for (Name name: targetTopic.getNames()) { - sigs.put(SignatureGenerator.generateSignature(name), name); - } - - for (Name name: topic.getNames()) { - type = _copyType(name, tm, mergeMap); - scope = _copyScope(name, tm, mergeMap); - Name targetName = targetTopic._createName(type, ((ILiteralAware) name).getLiteral(), scope); - existing = sigs.get(SignatureGenerator.generateSignature(targetName)); - if (existing != null) { - targetName.remove(); - targetName = (Name) existing; - } - _copyReifier(name, targetName, mergeMap); - _copyItemIdentifiers(name, targetName); - _copyVariants(name, (NameImpl)targetName, mergeMap); - } - } - - /** - * Copies the variants from <tt>source</tt> to the <tt>target</tt>. - * - * @param source The name to take the variants from. - * @param target The target name which receives the variants. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _copyVariants(Name source, NameImpl target, - Map<Topic, Topic> mergeMap) { - IIntObjectMap<Variant> sigs = CollectionFactory.createIntObjectMap(); - for (Variant variant: target.getVariants()) { - sigs.put(SignatureGenerator.generateSignature(variant), variant); - } - final TopicMap tm = target.getTopicMap(); - Variant existing = null; - Set<Topic> scope = null; - for (Variant variant: source.getVariants()) { - scope = _copyScope( variant, tm, mergeMap); - Variant targetVar = target._createVariant(((ILiteralAware) variant).getLiteral(), scope); - existing = sigs.get(SignatureGenerator.generateSignature(targetVar)); - if (existing != null) { - targetVar.remove(); - targetVar = existing; - } - _copyReifier(variant, targetVar, mergeMap); - _copyItemIdentifiers(variant, targetVar); - } - } - - /** - * Copies the reifier of <tt>source</tt> (if any) to the <tt>target</tt>. - * - * @param source The reifiable Topic Maps construct to take the reifier from. - * @param target The target Topic Maps construct. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _copyReifier(Reifiable source, Reifiable target, - Map<Topic, Topic> mergeMap) { - Topic sourceReifier = source.getReifier(); - if (sourceReifier == null) { - return; - } - Topic reifier = mergeMap.containsKey(sourceReifier) ? mergeMap.get(sourceReifier) - : _copyTopic(sourceReifier, (ITopicMap) target.getTopicMap(), mergeMap); - target.setReifier(reifier); - } - - /** - * Copies the type of the <tt>source</tt> (if any) to the <tt>target</tt>. - * - * @param source The Topic Maps construct to take the type from. - * @param target The Topic Maps construct which receives the type. - * @param mergeMap The map which holds the merge mappings. - */ - private static Topic _copyType(Typed source, TopicMap tm, - Map<Topic, Topic> mergeMap) { - Topic sourceType = source.getType(); - return mergeMap.containsKey(sourceType) ? mergeMap.get(sourceType) - : _copyTopic(sourceType, (ITopicMap) tm, mergeMap); - } - - /** - * Copies all themes from the <tt>source</tt> scoped Topic Maps construct - * to the <tt>target</tt>. - * - * @param source The source to take the scope from. - * @param target The target which receives the scope. - * @param mergeMap The map which holds the merge mappings. - */ - private static Set<Topic>_copyScope(Scoped source, TopicMap tm, - Map<Topic, Topic> mergeMap) { - Set<Topic> themes = CollectionFactory.createIdentitySet(source.getScope().size()); - Topic theme = null; - for (Topic sourceTheme: source.getScope()) { - theme = mergeMap.containsKey(sourceTheme) ? mergeMap.get(sourceTheme) - : _copyTopic(sourceTheme, (ITopicMap) tm, mergeMap); - themes.add(theme); - } - return themes; - } - - /** - * Copies the item identifiers from <tt>source</tt> to <tt>target</tt>. - * - * @param source The source Topic Maps construct. - * @param target The target Topic Maps construct. - */ - private static void _copyItemIdentifiers(Construct source, Construct target) { - for(Locator iid: source.getItemIdentifiers()) { - target.addItemIdentifier(iid); - } - } - - /** - * Copies the associations from the <tt>source</tt> topic map to the - * <tt>target</tt> topic map. - * - * @param source The topic map to take the associations from. - * @param target The topic map which receives the associations. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _copyAssociations(TopicMap source, - TopicMap target, Map<Topic, Topic> mergeMap) { - Set<Association> assocs = target.getAssociations(); - IIntObjectMap<Association> sigs = CollectionFactory.createIntObjectMap(assocs.size()); - for (Association assoc: assocs) { - sigs.put(SignatureGenerator.generateSignature(assoc), assoc); - } - Association existing = null; - Topic type = null; - Set<Topic> scope = null; - for (Association assoc: source.getAssociations()) { - type = _copyType(assoc, target, mergeMap); - scope = _copyScope(assoc, target, mergeMap); - Association targetAssoc = target.createAssociation(type, scope); - for (Role role: assoc.getRoles()) { - Role targetRole = targetAssoc.createRole(role.getType(), role.getPlayer()); - _copyItemIdentifiers(role, targetRole); - _copyReifier(role, targetRole, mergeMap); - } - existing = sigs.get(SignatureGenerator.generateSignature(targetAssoc)); - if (existing != null) { - MergeUtils.moveRoleCharacteristics(targetAssoc, existing); - targetAssoc.remove(); - targetAssoc = existing; - } - _copyReifier(assoc, targetAssoc, mergeMap); - _copyItemIdentifiers(assoc, targetAssoc); - } - } - - /** - * Adds a mapping from <tt>source</tt> to <tt>target</tt> into the - * <tt>mergeMap</tt>. - * - * If <tt>source</tt> has already a mapping to another target topic, - * <tt>target</tt> is merged with the existing target topic. - * - * @param source The source topic. - * @param target The target topic. - * @param mergeMap The map which holds the merge mappings. - */ - private static void _addMerge(Topic source, Topic target, Map<Topic, Topic> mergeMap) { - Topic prevTarget = mergeMap.get(source); - if (prevTarget != null) { - if (!prevTarget.equals(target)) { - MergeUtils.merge(target, prevTarget); - } - } - else { - mergeMap.put(source, target); - } - } - -} Modified: tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-13 13:19:39 UTC (rev 180) @@ -18,8 +18,15 @@ import java.math.BigDecimal; import java.math.BigInteger; +import org.tinytim.core.value.Literal; +import org.tinytim.internal.api.Event; +import org.tinytim.internal.api.ILiteral; +import org.tinytim.internal.api.ILiteralAware; +import org.tinytim.internal.api.IScope; +import org.tinytim.internal.api.ITopicMap; import org.tinytim.internal.utils.Check; import org.tinytim.voc.XSD; + import org.tmapi.core.DatatypeAware; import org.tmapi.core.Locator; import org.tmapi.core.Topic; Deleted: tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,110 +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.core; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.tinytim.voc.XSD; -import org.tmapi.core.Locator; - -/** - * - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ - */ -final class DecimalLiteral implements ILiteral { - - private final BigDecimal _decimal; - private final String _lexicalForm; - - public DecimalLiteral(BigDecimal decimal) { - _decimal = decimal; - _lexicalForm = LiteralNormalizer.normalizeDecimal(decimal.toPlainString()); - } - - public DecimalLiteral(String value) { - _lexicalForm = LiteralNormalizer.normalizeDecimal(value); - _decimal = new BigDecimal(_lexicalForm); - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#decimalValue() - */ - public BigDecimal decimalValue() { - return _decimal; - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#floatValue() - */ - public float floatValue() { - return _decimal.floatValue(); - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() - */ - public Locator getDatatype() { - return XSD.DECIMAL; - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() - */ - public String getValue() { - return _lexicalForm; - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#intValue() - */ - public int intValue() { - return _decimal.intValue(); - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#integerValue() - */ - public BigInteger integerValue() { - return _decimal.toBigInteger(); - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#longValue() - */ - public long longValue() { - return _decimal.longValue(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return _decimal.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return this == obj || (obj instanceof DecimalLiteral) && ((DecimalLiteral) obj)._lexicalForm.equals(_lexicalForm); - } - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/Event.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Event.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/Event.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,158 +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.core; - -/** - * Event constants. - * <p> - * All events are sent before a change happens. This allows to check - * some constraints. - * </p> - * <p> - * This class is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public enum Event { - - /** - * Notification that a topic should be added. - */ - ADD_TOPIC, - /** - * Notification that a topic should be removed. - */ - REMOVE_TOPIC, - /** - * Notification that an association should be added. - */ - ADD_ASSOCIATION, - /** - * Notification that an association should be removed. - */ - REMOVE_ASSOCIATION, - /** - * Notification that a role should be added. - */ - ADD_ROLE, - /** - * Notification that a role should be removed. - */ - REMOVE_ROLE, - /** - * Notification that an occurrence should be added. - */ - ADD_OCCURRENCE, - /** - * Notification that an occurrence should be removed. - */ - REMOVE_OCCURRENCE, - /** - * Notification that a name should be added. - */ - ADD_NAME, - /** - * Notification that a name should be removed. - */ - REMOVE_NAME, - /** - * Notification that a variant should be added. - */ - ADD_VARIANT, - /** - * Notification that a variant should be removed. - */ - REMOVE_VARIANT, - - - /** - * Notification that a subject identifier should be added. - */ - ADD_SID, - /** - * Notification that a subject identifier should be removed. - */ - REMOVE_SID, - /** - * Notification that a subject locator should be added. - */ - ADD_SLO, - /** - * Notification that a subject locator should be removed. - */ - REMOVE_SLO, - /** - * Notification that an item identifier should be added. - */ - ADD_IID, - /** - * Notification that an item identifier should be removed. - */ - REMOVE_IID, - - /** - * Notification that a type should be added to a topic. - */ - ADD_TYPE, - /** - * Notification that a type should be removed from a topic. - */ - REMOVE_TYPE, - /** - * Notification that the type of a {@link ITyped} construct should be set. - */ - SET_TYPE, - - /** - * Notification that the scope is changed. - */ - SET_SCOPE, - - /** - * Notification that the player of a role should be set. - */ - SET_PLAYER, - - /** - * Notification that the reifier of a {@link IReifiable} construct - * should be set. - */ - SET_REIFIER, - - /** - * Notification that the literal value of a name, an occurrence or variant - * should be set. - */ - SET_LITERAL, - - /** - * Notification that an occurrence should be moved from one topic to another. - */ - MOVED_OCCURRENCE, - /** - * Notification that a name should be moved from one topic to another. - */ - MOVED_NAME, - /** - * Notification that a variant should be moved from one name to another. - */ - MOVED_VARIANT, - - ATTACHED_NAME, DETACHED_NAME, ATTACHED_OCCURRENCE, DETACHED_OCCURRENCE, - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,107 +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.core; - -/** - * Provides constants. - * - * This interface is not meant to be used outside of the tinyTiM package. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -interface IConstant { - /** - * Initial size of the {@link MemoryTopicMap} topic set - */ - public static final int TM_TOPIC_SIZE = 100; - /** - * Initial size of the {@link MemoryTopicMap} association set - */ - public static final int TM_ASSOCIATION_SIZE = 100; - /** - * Initial size of the {@link ConstructImpl} item identifier set. - */ - public static final int CONSTRUCT_IID_SIZE = 4; - /** - * Initial size of the {@link TopicImpl} subject identifier set. - */ - public static final int TOPIC_SID_SIZE = 4; - /** - * Initial size of the {@link TopicImpl} subject locator set. - */ - public static final int TOPIC_SLO_SIZE = 2; - /** - * Initial size of the {@link TopicImpl} types set. - */ - public static final int TOPIC_TYPE_SIZE = 2; - /** - * Initial size of the {@link TopicImpl} name set. - */ - public static final int TOPIC_NAME_SIZE = 2; - /** - * Initial size of the {@link TopicImpl} occurrence set. - */ - public static final int TOPIC_OCCURRENCE_SIZE = 2; - /** - * Initial size of the {@link TopicImpl} roles-played set. - */ - public static final int TOPIC_ROLE_SIZE = 2; - /** - * Initial size of the {@link AssociationImpl} roles set. - */ - public static final int ASSOC_ROLE_SIZE = 2; - /** - * Initial size of the {@link NameImpl} variants set. - */ - public static final int NAME_VARIANT_SIZE = 2; - /** - * Initial size of the {@link IdentityManager} id->construct map. - */ - public static final int IDENTITY_ID2CONSTRUCT_SIZE = 200; - /** - * Initial size of the {@link IdentityManager} item identifier->construct map. - */ - public static final int IDENTITY_IID2CONSTRUCT_SIZE = 50; - /** - * Initial size of the {@link IdentityManager} subject identifier->topic map. - */ - public static final int IDENTITY_SID2TOPIC_SIZE = 50; - /** - * Initial size of the {@link IdentityManager} subject locator -> topic map. - */ - public static final int IDENTITY_SLO2TOPIC_SIZE = 20; - /** - * Initial size of the {@link Literal}'s IRI registry. - */ - public static final int LITERAL_IRI_SIZE = 100; - /** - * Initial size of the {@link Literal}'s String registry. - */ - public static final int LITERAL_STRING_SIZE = 50; - /** - * Initial size of the {@link Literal}'s literal (!= String/IRI) registry. - */ - public static final int LITERAL_OTHER_SIZE = 50; - /** - * Initial size of the {@link Scope}'s scope registry. - */ - public static final int SCOPE_SCOPES_SIZE = 10; - /** - * Initial size of the {@link MemoryTopicMapSystem} topic map map. - */ - public static final int SYSTEM_TM_SIZE = 4; -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,83 +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.core; - -import org.tmapi.core.Construct; - -/** - * Enhancement of the {@link org.tmapi.core.Construct} interface. - * <p> - * Avoids <tt>foo instanceof Bar</tt> checks. Each construct knows its type. - * </p> - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IConstruct extends Construct { - - /** - * Returns <tt>true</tt> if this is a topic map. - * - * @return <tt>true</tt> if this is a topic map, <tt>false</tt> otherwise. - */ - public boolean isTopicMap(); - - /** - * Returns <tt>true</tt> if this is a topic. - * - * @return <tt>true</tt> if this is a topic, <tt>false</tt> otherwise. - */ - public boolean isTopic(); - - /** - * Returns <tt>true</tt> if this is an association. - * - * @return <tt>true</tt> if this is an association, <tt>false</tt> otherwise. - */ - public boolean isAssociation(); - - /** - * Returns <tt>true</tt> if this is a role. - * - * @return <tt>true</tt> if this is a role, <tt>false</tt> otherwise. - */ - public boolean isRole(); - - /** - * Returns <tt>true</tt> if this is an occurrence. - * - * @return <tt>true</tt> if this is an occurrence, <tt>false</tt> otherwise. - */ - public boolean isOccurrence(); - - /** - * Returns <tt>true</tt> if this is a name. - * - * @return <tt>true</tt> if this is a name, <tt>false</tt> otherwise. - */ - public boolean isName(); - - /** - * Returns <tt>true</tt> if this is a variant. - * - * @return <tt>true</tt> if this is a variant, <tt>false</tt> otherwise. - */ - public boolean isVariant(); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,43 +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.core; - -/** - * Event handler that is able to handle Topic Maps events. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IEventHandler { - - /** - * Callback method if a {@link IEventPublisher} sends an event to which - * this handler is subscribed to. - * - * @param evt The event. - * @param sender The sender of the event (this is not necessarily the - * publisher). - * @param oldValue The old value or <code>null</code> if the old value - * is not available or was <code>null</code>. - * @param newValue The new value or <code>null</code> if the new value - * is not available or should become <code>null</code>. - */ - public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,45 +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.core; - -/** - * Publisher for Topic Maps events. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IEventPublisher { - - /** - * Subscribes the handler for the specified event. - * - * @param event The event of interesst. - * @param handler The event handler. - */ - public void subscribe(Event event, IEventHandler handler); - - /** - * Removes the handler from the publisher. - * - * @param event The event. - * @param handler The event handler. - */ - public void unsubscribe(Event event, IEventHandler handler); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,48 +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.core; - -/** - * Something that subscribes and unsubscribes itself to an - * {org.tinytim.core.IEventPublisher}. - * <p> - * Implementations MUST have a default (public) constructor. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ - */ -public interface IEventPublisherAware { - - /** - * Subscribes this instance to the specified <tt>publisher</tt>. - * - * @param publisher An event publisher. - */ - public void subscribe(IEventPublisher publisher); - - /** - * Unsubscribes this instance from the specified <tt>publisher</tt>. - * <p> - * This method is only invoked if this instance has been subscribed to - * the <tt>publisher</tt>. - * </p> - * - * @param publisher The publisher to unsubscribe from. - */ - public void unsubscribe(IEventPublisher publisher); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,30 +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.core; - -import org.tinytim.index.IIndexManager; - -/** - * - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ - */ -public interface IIndexManagerAware { - - IIndexManager getIndexManager(); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,83 +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.core; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.tmapi.core.Locator; - -/** - * Represents an immutable value with a datatype. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface ILiteral { - - /** - * Returns the string value. - * - * @return The string value. - */ - public String getValue(); - - /** - * Returns the datatype. - * - * @return The datatype. - */ - public Locator getDatatype(); - - /** - * Returns the BigDecimal value. - * - * @return BigDecimal value. - */ - public BigDecimal decimalValue(); - - /** - * Returns the float value. - * - * @return Float value. - */ - public float floatValue(); - - /** - * Returns the BigInteger value. - * - * @return BigInteger value. - */ - public BigInteger integerValue(); - - /** - * Returns the int value. - * - * @return Int value. - */ - public int intValue(); - - /** - * Returns the long value. - * - * @return Long value. - */ - public long longValue(); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,43 +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.core; - -/** - * Indicates that a literal can be attached to a construct. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface ILiteralAware { - - /** - * Returns the literal. - * - * @return The literal. - */ - public ILiteral getLiteral(); - - /** - * Sets the literal. - * - * @param literal The literal. - */ - public void setLiteral(ILiteral literal); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,32 +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.core; - -import org.tmapi.core.Locator; - -/** - * Marker interface which unifies the {@link org.tmapi.core.Locator} and - * tinyTiM's {@link ILiteral}. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface ILocator extends ILiteral, Locator { - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,39 +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.core; - -import org.tmapi.core.Construct; - -/** - * Indicates that a Topic Maps construct is able to be detached from the - * current parent and attached to another parent. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -interface IMovable<T extends Construct> { - - /** - * Moves this Topic Maps construct to the new parent. - * - * @param newParent The parent to move this construct to. - */ - public void moveTo(T newParent); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IScope.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,92 +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.core; - -import java.util.Collection; -import java.util.Set; - -import org.tmapi.core.Topic; - -/** - * Represents an immutable set of {@link org.tmapi.core.Topic}s. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IScope extends Iterable<Topic> { - - /** - * Returns the scope as set of topics. - * - * @return A set of topics. - */ - public Set<Topic> asSet(); - - /** - * Returns <tt>true</tt> if the theme is part of this scope. - * - * @param theme A topic. - * @return <tt>true</tt> if the theme is part of this scope, otherwise <tt>false</tt>. - */ - public boolean contains(Topic theme); - - /** - * Returns <tt>true</tt> if all themes of the other <tt>scope</tt> are part - * of this scope. - * - * @param scope A collection of themes. - * @return <tt>true</tt> if all themes are part of this scope, otherwise <tt>false</tt>. - */ - public boolean containsAll(Collection<Topic> scope); - - /** - * Returns a <tt>IScope</tt> consisting of all themes contained in this - * scope and the <tt>theme</tt>. - * - * @param theme The theme to add. - * @return A scope instance which is contains all themes of this scope plus - * the specified <tt>theme</tt>. - */ - public IScope add(Topic theme); - - /** - * Returns a <tt>IScope</tt> where the <tt>theme</tt> is removed from this - * set of themes.. - * - * @param theme The theme to remove. - * @return A scope instance which is contains all themes of this scope minus - * the specified <tt>theme</tt>. - */ - public IScope remove(Topic theme); - - /** - * Returns if this scope is unconstrained (empty). - * - * @return <tt>true</tt> if the scope is unconstrained, <tt>false</tt> otherwise. - */ - public boolean isUnconstrained(); - - /** - * Returns the number of themes contained in this scope. - * - * @return Number of themes. - */ - public int size(); - -} Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java 2008-11-12 15:26:11 UTC (rev 179) +++ tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java 2008-11-13 13:19:39 UTC (rev 180) @@ -1,46 +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.core; - -import org.tmapi.core.Scoped; - -/** - * Enhancement of the {@link org.tmapi.core.Scoped} interface which is - * {@link IScope} aware. - * <p> - * This interface is not meant to be used outside of the tinyTiM package. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface IScoped extends Scoped, IConstruct { - - /** - * Returns the scope. - * - * @return The scope. - */ - public IScope getScopeObject(); - - /** - * Sets the scope. - * - * @param scope The scope. - */ - public void setScopeObject(IScope scope); - -} Deleted: tinytim/trunk/src/main/ja... [truncated message content] |
From: <lh...@us...> - 2008-11-12 15:26:18
|
Revision: 179 http://tinytim.svn.sourceforge.net/tinytim/?rev=179&view=rev Author: lheuer Date: 2008-11-12 15:26:11 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Updated changes and readme Modified Paths: -------------- tinytim/trunk/CHANGES.txt tinytim/trunk/README.txt Modified: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt 2008-11-12 15:09:23 UTC (rev 178) +++ tinytim/trunk/CHANGES.txt 2008-11-12 15:26:11 UTC (rev 179) @@ -2,11 +2,17 @@ Changes Log =========== -2.0.0 a3 (xx.10.2008) +2.0.0 a3 (xx.11.2008) --------------------- * Moved to Apache License 2.0 +* Internal code refactoring +Bugfixes: +--------- +* Bug #2269551 -- Topic types are not considered as dependency +* Bug #2221024 -- Merging topic maps causes an autom. generated topic iid + 2.0.0 a2 (08.09.2008) --------------------- * Internal code refactoring Modified: tinytim/trunk/README.txt =================================================================== --- tinytim/trunk/README.txt 2008-11-12 15:09:23 UTC (rev 178) +++ tinytim/trunk/README.txt 2008-11-12 15:26:11 UTC (rev 179) @@ -4,14 +4,14 @@ What is tinyTiM? ---------------- -tinyTiM is a tiny Topic Maps engine which keeps topic maps in-memory. +tinyTiM is a tiny Topic Maps engine with a small jar footprint. This Topic Maps engine is meant to be used together with the TMAPI interfaces, see <http://www.tmapi.org/2.0/> for details. Installation ------------ -No real installation needed, simply put the ``tinytim-2.0.0a2.jar`` and +No real installation needed, simply put the ``tinytim-2.0.0a3.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. @@ -24,7 +24,7 @@ Latest Version -------------- -Visit tinyTiM's homepage <http://sourceforge.net/projects/tinytim> for the +Visit tinyTiM's homepage <http://tinytim.sourceforge.net/> for the latest version. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-12 15:09:25
|
Revision: 178 http://tinytim.svn.sourceforge.net/tinytim/?rev=178&view=rev Author: lheuer Date: 2008-11-12 15:09:23 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Updated changes and readme Modified Paths: -------------- tinytim-mio/trunk/CHANGES.txt tinytim-mio/trunk/README.txt Modified: tinytim-mio/trunk/CHANGES.txt =================================================================== --- tinytim-mio/trunk/CHANGES.txt 2008-11-12 14:48:00 UTC (rev 177) +++ tinytim-mio/trunk/CHANGES.txt 2008-11-12 15:09:23 UTC (rev 178) @@ -2,10 +2,16 @@ Changes Log =========== -2.0.0 a1 (xx.10.2008) +2.0.0 a3 (xx.11.2008) ------------------------- * Adapted MIO to tinyTiM 2.0.0 * Changed license to Apache License 2.0 +* Introduced TopicMapReader/TopicMapWriter interfaces +* Added dedicated, syntax-specific TopicMapReader implementations +* Moved CXTMWriter into .mio package, implements TopicMapWriter +* XTM 1.0/2.0 serializers +* Deprecated some TopicMapImporter methods which take a xml.InputSource + as argument 1.5.0 beta (13.08.2008) Modified: tinytim-mio/trunk/README.txt =================================================================== --- tinytim-mio/trunk/README.txt 2008-11-12 14:48:00 UTC (rev 177) +++ tinytim-mio/trunk/README.txt 2008-11-12 15:09:23 UTC (rev 178) @@ -2,13 +2,13 @@ tinyTiM - The tiny Topic Maps engine ==================================== -What is tinyTiM I/O? +What is tinyTiM MIO? -------------------- -tinyTiM is a tiny Topic Maps engine which keeps topic maps in-memory. +tinyTiM is a tiny Topic Maps engine with a small jar footprint. This Topic Maps engine is meant to be used together with the TMAPI interfaces, see <http://www.tmapi.org/> for details. -The I/O package provides an API to import serialized topic maps. It depends +The MIO package provides an API to import serialized topic maps. It depends on Semagia MIO which provides a streaming Topic Maps API implementation. Note: Semagia MIO uses another license than tinyTiM, see @@ -18,12 +18,10 @@ Installation ------------ -Put the ``tinytim-io-<VERSION>.jar`` together with the ``tinytim-<VERSION>.jar``, -and ``tmapi-1_0SP1.jar`` into the classpath. +Put the ``tinytim-mio-<VERSION>.jar`` together with the ``tinytim-<VERSION>.jar``, +and ``tmapi-2.0.0.jar`` into the classpath. Further, the ``semagia-mio-<VERSION>.jar`` and one or more ``semagia-mio-<SYNTAX-NAME>-<VERSION>.jar`` are needed in the classpath. -The standard tinyTiM I/O distribution offers the ``semagia-mio-xtm-<VERSION>.jar`` -which is used to import XML Topic Maps (XTM) version 1.0 and 2.0. Note, that ``Semagia MIO`` needs the ``Simple Logging Facade for Java`` (SLF4J), so ``slf4j-api-<VERSION>.jar`` and one of the ``slf4j-<TYPE>-<VERSION>.jar`` from the SLF4J project must be in the classpath; @@ -33,14 +31,14 @@ Latest Version -------------- -Visit tinyTiM's homepage <http://sourceforge.net/projects/tinytim> for the +Visit tinyTiM's homepage <http://tinytim.sourceforge.net/> for the latest version. Mailing list ------------ -The mailing list for tinyTiM is located here -<http://sourceforge.net/mailarchive/forum.php?forum_name=tinytim-discuss>. +The mailing list for tinyTiM is located at +<http://tinytim.sourceforge.net/mailinglist>. Feel free to ask any question about tinyTiM. :) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-12 14:48:06
|
Revision: 177 http://tinytim.svn.sourceforge.net/tinytim/?rev=177&view=rev Author: lheuer Date: 2008-11-12 14:48:00 +0000 (Wed, 12 Nov 2008) Log Message: ----------- - Fixed bug #2269551 -- Topic types are not considered as dependency - Fixed bug #2221024 -- Merging topic maps causes an autom. generated topic iid - Introduced ITopicMap - Renamed TopicMapImpl to MemoryTopicMap - Renamed TopicMapSystemImpl to MemoryTopicMapSystem Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/Event.java tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java tinytim/trunk/src/main/java/org/tinytim/core/IScope.java tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/Literal.java tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java tinytim/trunk/src/main/java/org/tinytim/core/MergeUtils.java tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java tinytim/trunk/src/main/java/org/tinytim/core/RoleImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/SignatureGenerator.java tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TopicMapSystemFactoryImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/CollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/internal/utils/ICollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/utils/DuplicateRemovalUtils.java tinytim/trunk/src/main/java/org/tinytim/utils/Feature.java tinytim/trunk/src/main/java/org/tinytim/utils/TopicUtils.java tinytim/trunk/src/main/java/org/tinytim/utils/TypeInstanceConverter.java tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java tinytim/trunk/src/main/java/org/tinytim/voc/XSD.java tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java tinytim/trunk/src/test/java/org/tinytim/core/AbstractTMAPITestSuite.java tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java tinytim/trunk/src/test/java/org/tinytim/core/TinyTimTestCase.java tinytim/trunk/src/test/java/org/tinytim/utils/TestTopicUtils.java Added Paths: ----------- tinytim/trunk/src/main/java/org/tinytim/Version.java tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/utils/Property.java tinytim/trunk/src/main/java/org/tinytim/voc/Namespace.java tinytim/trunk/src/test/java/org/tinytim/core/TestLocatorImpl.java Removed Paths: ------------- tinytim/trunk/src/main/java/org/tinytim/core/IRI.java tinytim/trunk/src/main/java/org/tinytim/core/TopicMapImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TopicMapSystemImpl.java tinytim/trunk/src/test/java/org/tinytim/core/TestIRI.java Added: tinytim/trunk/src/main/java/org/tinytim/Version.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/Version.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/Version.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Provides the version information. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class Version { + + private static final String _MAJOR = "@MAJOR@"; + private static final String _MINOR = "@MINOR@"; + private static final String _MICRO = "@MICRO@"; + private static final String _STATE ="@STATE@"; + private static final String _DATE = "@DATE@"; + + /** + * The release information. + */ + public static final String RELEASE = _MAJOR + "." + _MINOR + "." + _MICRO + _STATE + _DATE; + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/Version.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,92 @@ +/* + * 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.core; + +import java.util.Map; + +import org.tmapi.core.FeatureNotRecognizedException; +import org.tmapi.core.Locator; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicMapExistsException; +import org.tmapi.core.TopicMapSystem; + +/** + * + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +abstract class AbstractTopicMapSystem implements TopicMapSystem { + + protected final Map<String, Boolean> _features; + protected final Map<String, Object> _properties; + + AbstractTopicMapSystem(Map<String, Boolean> features, Map<String, Object> properties) throws TMAPIException { + _features = features; + _properties = properties; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#getFeature(java.lang.String) + */ + public boolean getFeature(String featureName) throws FeatureNotRecognizedException { + final Boolean supported = _features.get(featureName); + if (supported == null) { + TopicMapSystemFactoryImpl.reportFeatureNotRecognized(featureName); + } + return supported; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#getProperty(java.lang.String) + */ + public Object getProperty(String propertyName) { + return _properties.get(propertyName); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#createLocator(java.lang.String) + */ + public Locator createLocator(String reference) { + return Literal.createIRI(reference); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#getTopicMap(java.lang.String) + */ + public TopicMap getTopicMap(String reference) { + return getTopicMap(createLocator(reference)); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#createTopicMap(java.lang.String) + */ + public TopicMap createTopicMap(String reference) throws TopicMapExistsException { + return createTopicMap(createLocator(reference)); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMapSystem#close() + */ + public void close() { + _features.clear(); + _properties.clear(); + } + + abstract void removeTopicMap(MemoryTopicMap tm); + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-12 14:48:00 UTC (rev 177) @@ -35,12 +35,12 @@ private Set<Role> _roles; - AssociationImpl(TopicMapImpl tm) { + AssociationImpl(ITopicMap tm) { super(tm); _roles = CollectionFactory.createIdentitySet(IConstant.ASSOC_ROLE_SIZE); } - AssociationImpl(TopicMapImpl topicMap, Topic type, IScope scope) { + AssociationImpl(ITopicMap topicMap, Topic type, IScope scope) { super(topicMap, type, scope); _roles = CollectionFactory.createIdentitySet(IConstant.ASSOC_ROLE_SIZE); } Modified: tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-12 14:48:00 UTC (rev 177) @@ -33,11 +33,11 @@ abstract class ConstructImpl implements IConstruct { protected String _id; - protected TopicMapImpl _tm; + protected ITopicMap _tm; protected Construct _parent; private Set<Locator> _iids; - ConstructImpl(TopicMapImpl topicMap) { + ConstructImpl(ITopicMap topicMap) { _tm = topicMap; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/CopyUtils.java 2008-11-12 14:48:00 UTC (rev 177) @@ -54,13 +54,13 @@ * @param target The topic map which should receive the topics and associations. */ public static void copy(TopicMap source, TopicMap target) { - _copy(source, (TopicMapImpl) target); + _copy(source, (ITopicMap) target); } /** * @see #copy(TopicMap, TopicMap) */ - private static void _copy(TopicMap source, TopicMapImpl target) { + private static void _copy(TopicMap source, ITopicMap target) { if (source == null || target == null) { throw new IllegalArgumentException("Neither the source topic map nor the target topic map must be null"); } @@ -123,9 +123,9 @@ * @param mergeMap The map which holds the merge mappings. * @return The newly created topic in the target topic map. */ - private static Topic _copyTopic(Topic topic, TopicMap target, + private static Topic _copyTopic(Topic topic, ITopicMap target, Map<Topic, Topic> mergeMap) { - Topic targetTopic = target.createTopic(); + Topic targetTopic = target.createTopicWithoutIdentity(); _copyIdentities(topic, targetTopic); _copyTypes(topic, targetTopic, mergeMap); _copyCharacteristics(topic, (TopicImpl)targetTopic, mergeMap); @@ -161,7 +161,7 @@ for (Topic type: topic.getTypes()) { Topic targetType = mergeMap.get(type); if (targetType == null) { - targetType = _copyTopic(type, targetTopic.getTopicMap(), mergeMap); + targetType = _copyTopic(type, (ITopicMap) targetTopic.getTopicMap(), mergeMap); } targetTopic.addType(targetType); } @@ -261,7 +261,7 @@ return; } Topic reifier = mergeMap.containsKey(sourceReifier) ? mergeMap.get(sourceReifier) - : _copyTopic(sourceReifier, target.getTopicMap(), mergeMap); + : _copyTopic(sourceReifier, (ITopicMap) target.getTopicMap(), mergeMap); target.setReifier(reifier); } @@ -276,7 +276,7 @@ Map<Topic, Topic> mergeMap) { Topic sourceType = source.getType(); return mergeMap.containsKey(sourceType) ? mergeMap.get(sourceType) - : _copyTopic(sourceType, tm, mergeMap); + : _copyTopic(sourceType, (ITopicMap) tm, mergeMap); } /** @@ -293,7 +293,7 @@ Topic theme = null; for (Topic sourceTheme: source.getScope()) { theme = mergeMap.containsKey(sourceTheme) ? mergeMap.get(sourceTheme) - : _copyTopic(sourceTheme, tm, mergeMap); + : _copyTopic(sourceTheme, (ITopicMap) tm, mergeMap); themes.add(theme); } return themes; @@ -320,7 +320,7 @@ * @param mergeMap The map which holds the merge mappings. */ private static void _copyAssociations(TopicMap source, - TopicMapImpl target, Map<Topic, Topic> mergeMap) { + TopicMap target, Map<Topic, Topic> mergeMap) { Set<Association> assocs = target.getAssociations(); IIntObjectMap<Association> sigs = CollectionFactory.createIntObjectMap(assocs.size()); for (Association assoc: assocs) { Modified: tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-12 14:48:00 UTC (rev 177) @@ -35,11 +35,11 @@ private ILiteral _literal; - DatatypeAwareConstruct(TopicMapImpl tm) { + DatatypeAwareConstruct(ITopicMap tm) { super(tm); } - DatatypeAwareConstruct(TopicMapImpl topicMap, Topic type, ILiteral literal, IScope scope) { + DatatypeAwareConstruct(ITopicMap topicMap, Topic type, ILiteral literal, IScope scope) { super(topicMap, type, scope); _literal = literal; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java 2008-11-12 14:48:00 UTC (rev 177) @@ -25,7 +25,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ + * @version $Rev:$ - $Date:$ */ final class DecimalLiteral implements ILiteral { Modified: tinytim/trunk/src/main/java/org/tinytim/core/Event.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Event.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/Event.java 2008-11-12 14:48:00 UTC (rev 177) @@ -17,11 +17,13 @@ /** * Event constants. - * + * <p> * All events are sent before a change happens. This allows to check * some constraints. - * + * </p> + * <p> * This class is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -76,6 +78,7 @@ * Notification that a variant should be removed. */ REMOVE_VARIANT, + /** * Notification that a subject identifier should be added. @@ -137,8 +140,19 @@ */ SET_LITERAL, - MOVE_OCCURRENCE, - MOVE_NAME, - MOVE_VARIANT + /** + * Notification that an occurrence should be moved from one topic to another. + */ + MOVED_OCCURRENCE, + /** + * Notification that a name should be moved from one topic to another. + */ + MOVED_NAME, + /** + * Notification that a variant should be moved from one name to another. + */ + MOVED_VARIANT, + + ATTACHED_NAME, DETACHED_NAME, ATTACHED_OCCURRENCE, DETACHED_OCCURRENCE, } Modified: tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IConstant.java 2008-11-12 14:48:00 UTC (rev 177) @@ -25,11 +25,11 @@ */ interface IConstant { /** - * Initial size of the {@link TopicMapImpl} topic set + * Initial size of the {@link MemoryTopicMap} topic set */ public static final int TM_TOPIC_SIZE = 100; /** - * Initial size of the {@link TopicMapImpl} association set + * Initial size of the {@link MemoryTopicMap} association set */ public static final int TM_ASSOCIATION_SIZE = 100; /** @@ -101,7 +101,7 @@ */ public static final int SCOPE_SCOPES_SIZE = 10; /** - * Initial size of the {@link TopicMapSystemImpl} topic map map. + * Initial size of the {@link MemoryTopicMapSystem} topic map map. */ public static final int SYSTEM_TM_SIZE = 4; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IConstruct.java 2008-11-12 14:48:00 UTC (rev 177) @@ -19,20 +19,65 @@ /** * Enhancement of the {@link org.tmapi.core.Construct} interface. - * + * <p> + * Avoids <tt>foo instanceof Bar</tt> checks. Each construct knows its type. + * </p> + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ public interface IConstruct extends Construct { + /** + * Returns <tt>true</tt> if this is a topic map. + * + * @return <tt>true</tt> if this is a topic map, <tt>false</tt> otherwise. + */ public boolean isTopicMap(); + + /** + * Returns <tt>true</tt> if this is a topic. + * + * @return <tt>true</tt> if this is a topic, <tt>false</tt> otherwise. + */ public boolean isTopic(); + + /** + * Returns <tt>true</tt> if this is an association. + * + * @return <tt>true</tt> if this is an association, <tt>false</tt> otherwise. + */ public boolean isAssociation(); + + /** + * Returns <tt>true</tt> if this is a role. + * + * @return <tt>true</tt> if this is a role, <tt>false</tt> otherwise. + */ public boolean isRole(); + + /** + * Returns <tt>true</tt> if this is an occurrence. + * + * @return <tt>true</tt> if this is an occurrence, <tt>false</tt> otherwise. + */ public boolean isOccurrence(); + + /** + * Returns <tt>true</tt> if this is a name. + * + * @return <tt>true</tt> if this is a name, <tt>false</tt> otherwise. + */ public boolean isName(); + + /** + * Returns <tt>true</tt> if this is a variant. + * + * @return <tt>true</tt> if this is a variant, <tt>false</tt> otherwise. + */ public boolean isVariant(); } Modified: tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventHandler.java 2008-11-12 14:48:00 UTC (rev 177) @@ -17,8 +17,9 @@ /** * Event handler that is able to handle Topic Maps events. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisher.java 2008-11-12 14:48:00 UTC (rev 177) @@ -17,8 +17,9 @@ /** * Publisher for Topic Maps events. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -40,4 +41,5 @@ * @param handler The event handler. */ public void unsubscribe(Event event, IEventHandler handler); + } Added: tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,48 @@ +/* + * 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.core; + +/** + * Something that subscribes and unsubscribes itself to an + * {org.tinytim.core.IEventPublisher}. + * <p> + * Implementations MUST have a default (public) constructor. + * </p> + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IEventPublisherAware { + + /** + * Subscribes this instance to the specified <tt>publisher</tt>. + * + * @param publisher An event publisher. + */ + public void subscribe(IEventPublisher publisher); + + /** + * Unsubscribes this instance from the specified <tt>publisher</tt>. + * <p> + * This method is only invoked if this instance has been subscribed to + * the <tt>publisher</tt>. + * </p> + * + * @param publisher The publisher to unsubscribe from. + */ + public void unsubscribe(IEventPublisher publisher); + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/IEventPublisherAware.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,30 @@ +/* + * 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.core; + +import org.tinytim.index.IIndexManager; + +/** + * + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IIndexManagerAware { + + IIndexManager getIndexManager(); + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/IIndexManagerAware.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILiteral.java 2008-11-12 14:48:00 UTC (rev 177) @@ -22,8 +22,9 @@ /** * Represents an immutable value with a datatype. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILiteralAware.java 2008-11-12 14:48:00 UTC (rev 177) @@ -17,8 +17,9 @@ /** * Indicates that a literal can be attached to a construct. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/ILocator.java 2008-11-12 14:48:00 UTC (rev 177) @@ -20,8 +20,9 @@ /** * Marker interface which unifies the {@link org.tmapi.core.Locator} and * tinyTiM's {@link ILiteral}. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IMovable.java 2008-11-12 14:48:00 UTC (rev 177) @@ -20,8 +20,9 @@ /** * Indicates that a Topic Maps construct is able to be detached from the * current parent and attached to another parent. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Deleted: tinytim/trunk/src/main/java/org/tinytim/core/IRI.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IRI.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IRI.java 2008-11-12 14:48:00 UTC (rev 177) @@ -1,138 +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.core; - -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.URI; -import java.net.URLDecoder; - -import org.tinytim.voc.XSD; -import org.tmapi.core.Locator; -import org.tmapi.core.TMAPIRuntimeException; - -/** - * Immutable representation of an IRI. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -final class IRI implements ILocator { - - private final URI _uri; - private final String _reference; - - IRI(String reference) { - try { - _reference = URLDecoder.decode(reference, "utf-8"); - } - catch (UnsupportedEncodingException ex) { - throw new TMAPIRuntimeException(ex); - } - _uri = URI.create(_reference.replace(" ", "%20")); - } - - private IRI(URI uri) { - try { - _reference = URLDecoder.decode(uri.toString(), "utf-8"); - } - catch (UnsupportedEncodingException ex) { - throw new TMAPIRuntimeException(ex); - } - _uri = uri; - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getDatatype() - */ - public Locator getDatatype() { - return XSD.ANY_URI; - } - - /* (non-Javadoc) - * @see org.tinytim.core.ILiteral#getValue() - */ - public String getValue() { - return _reference; - } - - public BigDecimal decimalValue() { - throw new NumberFormatException(); - } - - public float floatValue() { - throw new NumberFormatException(); - } - - public BigInteger integerValue() { - throw new NumberFormatException(); - } - - public int intValue() { - throw new NumberFormatException(); - } - - public long longValue() { - throw new NumberFormatException(); - } - - /* (non-Javadoc) - * @see org.tmapi.core.Locator#getReference() - */ - public String getReference() { - return _reference; - } - - /* (non-Javadoc) - * @see org.tmapi.core.Locator#resolve(java.lang.String) - */ - public Locator resolve(String reference) { - return new IRI(_uri.resolve(reference)); - } - - /* (non-Javadoc) - * @see org.tmapi.core.Locator#toExternalForm() - */ - public String toExternalForm() { - return _uri.toASCIIString(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return this == obj || (obj instanceof IRI && _reference.equals(((IRI) obj)._reference)); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return _reference.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return _uri.toString(); - } - -} Modified: tinytim/trunk/src/main/java/org/tinytim/core/IScope.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-11-12 14:48:00 UTC (rev 177) @@ -22,8 +22,9 @@ /** * Represents an immutable set of {@link org.tmapi.core.Topic}s. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IScoped.java 2008-11-12 14:48:00 UTC (rev 177) @@ -20,8 +20,9 @@ /** * Enhancement of the {@link org.tmapi.core.Scoped} interface which is * {@link IScope} aware. - * + * <p> * This interface is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -41,4 +42,5 @@ * @param scope The scope. */ public void setScopeObject(IScope scope); + } Added: tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,54 @@ +/* + * 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.core; + +import org.tmapi.core.Association; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; + +/** + * + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +interface ITopicMap extends TopicMap, IEventHandler, IConstruct, IIndexManagerAware { + + /** + * + * + * @return + */ + Topic getDefaultTopicNameType(); + + void removeTopic(Topic topic); + + void removeAssociation(Association association); + + void addAssociation(Association assoc); + + /** + * Returns a topic without any identity. + * <p> + * The topic won't have an item identifier, subject identifier, or subject + * locator, just an internal identifier. + * </p> + * + * @return A topic without any identity. + */ + public Topic createTopicWithoutIdentity(); + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/ITopicMap.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-12 14:48:00 UTC (rev 177) @@ -19,8 +19,9 @@ /** * Class used to generate identifiers. - * + * <p> * This class is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-12 14:48:00 UTC (rev 177) @@ -28,34 +28,33 @@ /** * The identity manager takes care about the TMDM identity constraints and * provides an index to get Topic Maps constructs by their identity. - * + * <p> * This class is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -final class IdentityManager { +final class IdentityManager implements IEventPublisherAware { private Map<Locator, Topic> _sid2Topic; private Map<Locator, Topic> _slo2Topic; private Map<Locator, IConstruct> _iid2Construct; private Map<String, IConstruct> _id2Construct; - IdentityManager(TopicMapImpl tm) { + IdentityManager(MemoryTopicMap tm) { _id2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE); _sid2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SID2TOPIC_SIZE); _slo2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SLO2TOPIC_SIZE); _iid2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_IID2CONSTRUCT_SIZE); - _subscribe(tm); + subscribe(tm); _register(tm); } - /** - * Subscribes itself to the specified event publisher. - * - * @param publisher The publisher to subscribe to. + /* (non-Javadoc) + * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher) */ - private void _subscribe(IEventPublisher publisher) { + public void subscribe(IEventPublisher publisher) { IEventHandler handler = new TopicMapsConstructAddHandler(); publisher.subscribe(Event.ADD_TOPIC, handler); publisher.subscribe(Event.ADD_ASSOCIATION, handler); @@ -86,6 +85,13 @@ publisher.subscribe(Event.SET_REIFIER, handler); } + /* (non-Javadoc) + * @see org.tinytim.core.IEventPublisherAware#unsubscribe(org.tinytim.core.IEventPublisher) + */ + public void unsubscribe(IEventPublisher publisher) { + // noop. + } + /** * Registeres a Topic Maps construct and, if necessary, gives it an id. * Modified: tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java 2008-11-12 14:48:00 UTC (rev 177) @@ -25,7 +25,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ + * @version $Rev:$ - $Date:$ */ final class IntegerLiteral implements ILiteral { Modified: tinytim/trunk/src/main/java/org/tinytim/core/Literal.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-11-12 14:48:00 UTC (rev 177) @@ -24,15 +24,16 @@ /** * - * + * <p> * This class is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ public final class Literal implements ILiteral { - private static final WeakObjectRegistry<IRI> _IRIS = new WeakObjectRegistry<IRI>(IConstant.LITERAL_IRI_SIZE); + 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); @@ -69,7 +70,7 @@ if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - return _IRIS.get(new IRI(value)); + return _IRIS.get(new LocatorImpl(value)); } public static synchronized ILiteral get(String value, Locator datatype) { @@ -155,7 +156,7 @@ if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - return _registerIfAbsent(_IRIS, new IRI(value)); + return _registerIfAbsent(_IRIS, new LocatorImpl(value)); } public static synchronized ILiteral createDecimal(String value) { Modified: tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java 2008-11-12 14:23:22 UTC (rev 176) +++ tinytim/trunk/src/main/java/org/tinytim/core/LiteralNormalizer.java 2008-11-12 14:48:00 UTC (rev 177) @@ -20,8 +20,9 @@ /** * Normalizes literal values. - * + * <p> * This class is not meant to be used outside of the tinyTiM package. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ Added: tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,143 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.core; + +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URI; +import java.net.URLDecoder; + +import org.tinytim.voc.XSD; +import org.tmapi.core.Locator; +import org.tmapi.core.TMAPIRuntimeException; + +/** + * Immutable representation of an IRI. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +final class LocatorImpl implements ILocator { + + private final URI _uri; + private final String _reference; + + LocatorImpl(String reference) { + try { + _reference = URLDecoder.decode(reference, "utf-8"); + } + catch (UnsupportedEncodingException ex) { + throw new TMAPIRuntimeException(ex); + } + _uri = URI.create(_reference.replace(" ", "%20")); + } + + private LocatorImpl(URI uri) { + try { + _reference = URLDecoder.decode(uri.toString(), "utf-8"); + } + catch (UnsupportedEncodingException ex) { + throw new TMAPIRuntimeException(ex); + } + _uri = uri; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getDatatype() + */ + public Locator getDatatype() { + return XSD.ANY_URI; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getValue() + */ + public String getValue() { + return _reference; + } + + public BigDecimal decimalValue() { + throw new NumberFormatException(); + } + + public float floatValue() { + throw new NumberFormatException(); + } + + public BigInteger integerValue() { + throw new NumberFormatException(); + } + + public int intValue() { + throw new NumberFormatException(); + } + + public long longValue() { + throw new NumberFormatException(); + } + + /* (non-Javadoc) + * @see org.tmapi.core.Locator#getReference() + */ + public String getReference() { + return _reference; + } + + /* (non-Javadoc) + * @see org.tmapi.core.Locator#resolve(java.lang.String) + */ + public Locator resolve(String reference) { + return new LocatorImpl(_uri.resolve(reference)); + } + + /* (non-Javadoc) + * @see org.tmapi.core.Locator#toExternalForm() + */ + public String toExternalForm() { + return _uri.toASCIIString(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return this == obj || (obj instanceof LocatorImpl && _reference.equals(((LocatorImpl) obj)._reference)); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return _reference.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return _uri.toString(); + } + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/LocatorImpl.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-12 14:48:00 UTC (rev 177) @@ -0,0 +1,521 @@ +/* + * 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.core; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.tinytim.index.IndexManager; +import org.tinytim.index.IIndexManager; +import org.tinytim.internal.utils.Check; +import org.tinytim.internal.utils.CollectionFactory; +import org.tinytim.voc.TMDM; +import org.tmapi.core.Association; +import org.tmapi.core.IdentityConstraintException; +import org.tmapi.core.ModelConstraintException; +import org.tmapi.core.Role; +import org.tmapi.core.Locator; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.Construct; +import org.tmapi.core.Name; +import org.tmapi.core.Variant; +import org.tmapi.index.Index; + +/** + * {@link org.tmapi.core.TopicMap} implementation. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +final class MemoryTopicMap extends ConstructImpl implements ITopicMap, + IEventHandler, IEventPublisher { + + private IdentityManager _identityManager; + private IIndexManager _indexManager; + private Locator _locator; + private Set<Topic> _topics; + private Set<Association> _assocs; + private AbstractTopicMapSystem _sys; + private Topic _reifier; + private Map<Event, List<IEventHandler>> _evtHandlers; + private EventMultiplier _eventMultiplier; + + MemoryTopicMap(AbstractTopicMapSystem sys, Locator locator) { + super(null); + super._tm = this; + _sys = sys; + _locator = locator; + _topics = CollectionFactory.createIdentitySet(IConstant.TM_TOPIC_SIZE); + _assocs = CollectionFactory.createIdentitySet(IConstant.TM_ASSOCIATION_SIZE); + _evtHandlers = CollectionFactory.createIdentityMap(); + _identityManager = new IdentityManager(this); + _indexManager = new IndexManager(); + _indexManager.subscribe(this); + _eventMultiplier = new EventMultiplier(this); + } + + Locator getLocator() { + return _locator; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ConstructImpl#getTopicMap() + */ + @Override + public TopicMap getTopicMap() { + return this; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#createLocator(java.lang.String) + */ + public Locator createLocator(String reference) { + return Literal.createIRI(reference); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getTopics() + */ + public Set<Topic> getTopics() { + return Collections.unmodifiableSet(_topics); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ITopicMap#createTopicWithoutIdentity() + */ + public TopicImpl createTopicWithoutIdentity() { + TopicImpl topic = new TopicImpl(this); + addTopic(topic); + return topic; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#createTopic() + */ + public Topic createTopic() { + Topic topic = createTopicWithoutIdentity(); + topic.addItemIdentifier(Literal.createIRI("urn:x-tinytim:" + IdGenerator.nextId())); + return topic; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#createTopicByItemIdentifier(org.tmapi.core.Locator) + */ + public Topic createTopicByItemIdentifier(Locator iid) { + if (iid == null) { + throw new ModelConstraintException(null, "The item identifier must not be null"); + } + Construct construct = getConstructByItemIdentifier(iid); + if (construct != null) { + if (construct instanceof Topic) { + return (Topic) construct; + } + throw new IdentityConstraintException(null, construct, iid, "A construct with the item identifier '" + iid.getReference() + "' already exists"); + } + else { + Topic topic = getTopicBySubjectIdentifier(iid); + if (topic != null) { + topic.addItemIdentifier(iid); + return topic; + } + } + TopicImpl topic = createTopicWithoutIdentity(); + topic.addItemIdentifier(iid); + return topic; + } + + public Topic getDefaultTopicNameType() { + return createTopicBySubjectIdentifier(TMDM.TOPIC_NAME); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#createTopicBySubjectIdentifier(org.tmapi.core.Locator) + */ + public Topic createTopicBySubjectIdentifier(Locator sid) { + if (sid == null) { + throw new ModelConstraintException(null, "The subject identifier must not be null"); + } + Topic topic = getTopicBySubjectIdentifier(sid); + if (topic != null) { + return topic; + } + else { + Construct construct = getConstructByItemIdentifier(sid); + if (construct != null && construct instanceof Topic) { + topic = (Topic) construct; + topic.addSubjectIdentifier(sid); + return topic; + } + } + topic = createTopicWithoutIdentity(); + topic.addSubjectIdentifier(sid); + return topic; + } + + public Topic createTopicBySubjectLocator(Locator slo) { + if (slo == null) { + throw new ModelConstraintException(null, "The subject locator must not be null"); + } + Topic topic = getTopicBySubjectLocator(slo); + if (topic != null) { + return topic; + } + topic = createTopicWithoutIdentity(); + topic.addSubjectLocator(slo); + return topic; + } + + /** + * Adds a topic to the topics property. + * + * @param topic The topic to add. + */ + void addTopic(TopicImpl topic) { + if (topic._parent == this) { + return; + } + _fireEvent(Event.ADD_TOPIC, null, topic); + topic._parent = this; + _topics.add(topic); + } + + public void removeTopic(Topic topic_) { + TopicImpl topic = (TopicImpl) topic_; + if (topic._parent != this) { + return; + } + assert topic._parent == null; + _fireEvent(Event.REMOVE_TOPIC, topic, null); + _topics.remove(topic); + topic._parent = null; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getAssociations() + */ + public Set<Association> getAssociations() { + return Collections.unmodifiableSet(_assocs); + } + + public Association createAssociation(Topic type, Topic... scope) { + Check.scopeNotNull(this, scope); + return createAssociation(type, Arrays.asList(scope)); + } + + public Association createAssociation(Topic type, Collection<Topic> scope) { + Check.typeNotNull(this, type); + Check.scopeNotNull(this, scope); + AssociationImpl assoc = new AssociationImpl(this, type, Scope.create(scope)); + addAssociation(assoc); + return assoc; + } + + public void addAssociation(Association assoc_) { + AssociationImpl assoc = (AssociationImpl) assoc_; + if (assoc._parent == this) { + return; + } + _fireEvent(Event.ADD_ASSOCIATION, null, assoc); + assoc._parent = this; + _assocs.add(assoc); + } + + public void removeAssociation(Association assoc_) { + AssociationImpl assoc = (AssociationImpl) assoc_; + if (assoc._parent != this) { + return; + } + _fireEvent(Event.REMOVE_ASSOCIATION, assoc, null); + for (Role role: assoc.getRoles()) { + TopicImpl player = (TopicImpl) role.getPlayer(); + if (player != null) { + player.removeRolePlayed(role); + } + } + _assocs.remove(assoc); + assoc._parent = null; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getConstructById(java.lang.String) + */ + public Construct getConstructById(String id) { + return _identityManager.getConstructById(id); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getTopicBySubjectIdentifier(org.tmapi.core.Locator) + */ + public Topic getTopicBySubjectIdentifier(Locator subjectIdentifier) { + return _identityManager.getTopicBySubjectIdentifier(subjectIdentifier); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getTopicBySubjectLocator(org.tmapi.core.Locator) + */ + public Topic getTopicBySubjectLocator(Locator subjectLocator) { + return _identityManager.getTopicBySubjectLocator(subjectLocator); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getConstructByItemIdentifier(org.tmapi.core.Locator) + */ + public Construct getConstructByItemIdentifier(Locator itemIdentifier) { + return _identityManager.getConstructByItemIdentifier(itemIdentifier); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getReifier() + */ + public Topic getReifier() { + return _reifier; + } + + /* (non-Javadoc) + * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic) + */ + public void setReifier(Topic reifier) { + if (_reifier == reifier) { + return; + } + _fireEvent(Event.SET_REIFIER, _reifier, reifier); + if (_reifier != null) { + ((TopicImpl) _reifier)._reified = null; + } + _reifier = reifier; + if (reifier != null) { + ((TopicImpl) reifier)._reified = this; + } + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#getIndex(java.lang.Class) + */ + @SuppressWarnings("unchecked") + public <I extends Index> I getIndex(Class<I> indexInterface) { + if (indexInterface.getName().equals("org.tmapi.index.TypeInstanceIndex")) { + return (I) _indexManager.getTypeInstanceIndex(); + } + if (indexInterface.getName().equals("org.tmapi.index.ScopedIndex")) { + return (I) _indexManager.getScopedIndex(); + } + if (indexInterface.getName().equals("org.tmapi.index.LiteralIndex")) { + return (I) _indexManager.getLiteralIndex(); + } + throw new UnsupportedOperationException("Index '" + indexInterface.getName() + "' is unknown"); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#mergeIn(org.tmapi.core.TopicMap) + */ + public void mergeIn(TopicMap other) { + MergeUtils.merge(other, this); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#close() + */ + public void close() { + remove(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ConstructImpl#isTopicMap() + */ + @Override + public boolean isTopicMap() { + return true; + } + + /* (non-Javadoc) + * @see org.tmapi.core.TopicMap#remove() + */ + public void remove() { + _sys.removeTopicMap(this); + _sys = null; + _locator = null; + _topics = null; + _assocs = null; + _indexManager.close(); + _indexManager = null; + _identityManager.close(); + _identityManager = null; + _eventMultiplier = null; + super.dispose(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ConstructImpl#_fireEvent(org.tinytim.core.Event, java.lang.Object, java.lang.Object) + */ + @Override + protected final void _fireEvent(Event evt, Object oldValue, Object newValue) { + handleEvent(evt, this, oldValue, newValue); + } + + /* (non-Javadoc) + * @see org.tinytim.IEventHandler#handleEvent(org.tinytim.Event, org.tinytim.IConstruct, java.lang.Object, java.lang.Object) + */ + public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue) { + if (!_evtHandlers.containsKey(evt)) { + _eventMultiplier.handleEvent(evt, sender, oldValue, newValue); + return; + ... [truncated message content] |
From: <lh...@us...> - 2008-11-12 14:23:25
|
Revision: 176 http://tinytim.svn.sourceforge.net/tinytim/?rev=176&view=rev Author: lheuer Date: 2008-11-12 14:23:22 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Added latest version of the *experimental* XTM writers Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java 2008-11-12 14:03:27 UTC (rev 175) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java 2008-11-12 14:23:22 UTC (rev 176) @@ -22,7 +22,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class AbstractTopicMapWriter implements TopicMapWriter { Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-12 14:03:27 UTC (rev 175) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-12 14:23:22 UTC (rev 176) @@ -15,6 +15,10 @@ */ package org.tinytim.mio; +import java.io.IOException; +import java.io.OutputStream; + +import org.tmapi.core.TMAPIRuntimeException; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; @@ -22,7 +26,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class AbstractXTMWriter extends AbstractTopicMapWriter { @@ -30,13 +34,15 @@ protected AttributesImpl _attrs; protected XMLWriter _out; - /** - * - * - * @param baseIRI - */ - public AbstractXTMWriter(String baseIRI) { + + public AbstractXTMWriter(final OutputStream out, final String baseIRI) { super(baseIRI); + try { + _out = new XMLWriter(out); + } + catch (IOException ex) { + throw new TMAPIRuntimeException(ex); + } } } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-12 14:03:27 UTC (rev 175) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java 2008-11-12 14:23:22 UTC (rev 176) @@ -16,6 +16,7 @@ package org.tinytim.mio; import java.io.IOException; +import java.io.OutputStream; import java.util.Set; import org.tinytim.voc.Namespace; @@ -41,7 +42,7 @@ * a <a href="http://www.topicmaps.org/xtm/1.0/">XTM 1.0</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 XTM10Writer extends AbstractXTMWriter { @@ -55,8 +56,8 @@ * * @param baseIRI */ - public XTM10Writer(String baseIRI) { - super(baseIRI); + public XTM10Writer(final OutputStream out, final String baseIRI) { + super(out, baseIRI); } private String _getId(Reifiable reifiable) { Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-12 14:03:27 UTC (rev 175) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java 2008-11-12 14:23:22 UTC (rev 176) @@ -16,6 +16,7 @@ package org.tinytim.mio; import java.io.IOException; +import java.io.OutputStream; import java.util.Set; import org.tinytim.core.IConstruct; @@ -46,7 +47,7 @@ * representation. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class XTM20Writer extends AbstractXTMWriter { @@ -55,8 +56,8 @@ * * @param baseIRI */ - public XTM20Writer(String baseIRI) { - super(baseIRI); + public XTM20Writer(final OutputStream out, final String baseIRI) { + super(out, baseIRI); } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-12 14:03:31
|
Revision: 175 http://tinytim.svn.sourceforge.net/tinytim/?rev=175&view=rev Author: lheuer Date: 2008-11-12 14:03:27 +0000 (Wed, 12 Nov 2008) Log Message: ----------- - Switched back to int[] and IConstruct[] arrays in AbstractMapInputHandler - Added various topic map importers - Added *experimental* XTM writers - Renamed ITopicMapReader to TopicMapReader and reduced the methods to read() - Renamed ITopicMapWriter to TopicMapWriter Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLC14NWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTMReader.java Added Paths: ----------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Reader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10Writer.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Reader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM20Writer.java Removed Paths: ------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/BTMReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapReader.java tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapWriter.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-12 14:03:27 UTC (rev 175) @@ -46,7 +46,7 @@ */ public abstract class AbstractMapInputHandler implements IMapHandler { - private final int + private static final int INITIAL = 1, TOPIC = 2, ASSOCIATION = 3, @@ -61,13 +61,15 @@ ISA = 12, TYPE = 13; - private final int _CONSTRUCT_SIZE = 6; - private final int _STATE_SIZE = 10; - private final int _SCOPE_SIZE = 6; + private static final int _CONSTRUCT_SIZE = 6; + private static final int _STATE_SIZE = 10; + private static final int _SCOPE_SIZE = 6; - private TopicMapImpl _tm; - private List<Integer> _stateStack; - private List<IConstruct> _constructStack; + private ITopicMap _tm; + private int[] _stateStack; + private int _stateSize; + private IConstruct[] _constructStack; + private int _constructSize; private List<Topic> _scope; protected AbstractMapInputHandler(TopicMap topicMap) { @@ -83,15 +85,17 @@ if (topicMap == null) { throw new IllegalArgumentException("The topic map must not be null"); } - _tm = (TopicMapImpl) topicMap; + _tm = (ITopicMap) topicMap; } /* (non-Javadoc) * @see com.semagia.mio.IMapHandler#startTopicMap() */ public final void startTopicMap() throws MIOException { - _constructStack = CollectionFactory.createList(_CONSTRUCT_SIZE); - _stateStack = CollectionFactory.createList(_STATE_SIZE); + _constructStack = new IConstruct[_CONSTRUCT_SIZE]; + _stateStack = new int[_STATE_SIZE]; + _constructSize = 0; + _stateSize = 0; _scope = CollectionFactory.createList(_SCOPE_SIZE); _enterState(INITIAL, _tm); } @@ -217,7 +221,7 @@ NameImpl name = (NameImpl) _peekConstruct(); IScope scope = variant.getScopeObject(); if (scope.isUnconstrained() || name.getScopeObject() == scope) { - throw new MIOException("The variant has no scope"); + _reportError("The variant has no scope"); } name.addVariant(variant); } @@ -384,7 +388,12 @@ * @param state The state to push ontop of the state stack. */ private void _enterState(int state) { - _stateStack.add(state); + if (_stateSize >= _stateStack.length) { + int[] states = new int[_stateStack.length*2]; + System.arraycopy(_stateStack, 0, states, 0, _stateStack.length); + _stateStack = states; + } + _stateStack[_stateSize++] = state; } /** @@ -396,7 +405,12 @@ */ private void _enterState(int state, IConstruct tmo) { _enterState(state); - _constructStack.add(tmo); + if (_constructSize >= _constructStack.length) { + IConstruct[] constructs = new IConstruct[_constructStack.length*2]; + System.arraycopy(_constructStack, 0, constructs, 0, _constructStack.length); + _constructStack = constructs; + } + _constructStack[_constructSize++] = tmo; } /** @@ -406,10 +420,10 @@ * @throws MIOException If the state is not equals to the current state. */ private void _leaveState(int state) throws MIOException { - final int current = _stateStack.remove(_stateStack.size()-1); - if (state != current) { - _reportError("Unexpected state: " + current + ", expected: " + state); + if (state != _state()) { + _reportError("Unexpected state: " + _state() + ", expected: " + state); } + _stateSize--; } /** @@ -421,7 +435,10 @@ */ private IConstruct _leaveStatePopConstruct(int state) throws MIOException { _leaveState(state); - return _constructStack.remove(_constructStack.size()-1); + final IConstruct construct = _peekConstruct(); + _constructStack[_constructSize] = null; + _constructSize--; + return construct; } /** @@ -430,7 +447,7 @@ * @return The Topic Maps construct. */ private IConstruct _peekConstruct() { - return _constructStack.get(_constructStack.size()-1); + return _constructStack[_constructSize-1]; } /** @@ -448,7 +465,7 @@ * @return The current state. */ private int _state() { - return _stateStack.get(_stateStack.size()-1); + return _stateStack[_stateSize-1]; } /** @@ -477,9 +494,9 @@ * @param target The target topic. */ private void _merge(Topic source, TopicImpl target) { - for (int i=0; i<_constructStack.size(); i++) { - if (_constructStack.get(i) == source) { - _constructStack.set(i, target); + for (int i=0; i <_constructSize; i++) { + if (_constructStack[i] == source) { + _constructStack[i] = target; } } target.mergeIn(source); 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-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -22,54 +22,95 @@ import org.tmapi.core.TMAPIRuntimeException; import org.tmapi.core.TopicMap; -import org.xml.sax.InputSource; import com.semagia.mio.DeserializerRegistry; import com.semagia.mio.IDeserializer; +import com.semagia.mio.IMapHandler; import com.semagia.mio.MIOException; +import com.semagia.mio.Property; +import com.semagia.mio.Source; import com.semagia.mio.Syntax; /** - * Base class for {@link ITopicMapReader} implementations. - * + * Base class for {@link TopicMapReader} implementations. + * <p> * This class provides a layer to <tt>com.semagia.mio</tt> and handles * the discovery of an appropriate deserializer transparently. + * </p> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -abstract class AbstractTopicMapReader implements ITopicMapReader { +abstract class AbstractTopicMapReader implements TopicMapReader { protected IDeserializer _deserializer; + private final Source _source; - AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax) { - _deserializer = DeserializerRegistry.createDeserializer(syntax); - if (_deserializer == null) { - throw new TMAPIRuntimeException("Appropriate deserializer not found for syntax " + syntax.getName()); - } - _deserializer.setMapHandler(new TinyTimMapInputHandler(topicMap)); + /** + * + * + * @param topicMap + * @param syntax + * @param source + * @throws IOException + */ + protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, + final File source) throws IOException { + this(topicMap, syntax, source, source.toURL().toString()); } - /* (non-Javadoc) - * @see org.tinytim.mio.ITopicMapReader#read(java.io.File, java.lang.String) + /** + * + * + * @param topicMap + * @param syntax + * @param source + * @param docIRI + * @throws IOException */ - public void read(File source, String baseIRI) throws IOException { - read(new FileInputStream(source), baseIRI); + protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, + final File source, final String docIRI) throws IOException { + this(topicMap, syntax, new Source(new FileInputStream(source), docIRI)); } - /* (non-Javadoc) - * @see org.tinytim.mio.ITopicMapReader#read(java.io.InputStream, java.lang.String) + /** + * + * + * @param topicMap + * @param syntax + * @param source + * @param docIRI */ - public void read(InputStream source, String baseIRI) throws IOException { - read(new InputSource(source), baseIRI); + protected AbstractTopicMapReader(TopicMap topicMap, Syntax syntax, + InputStream source, String docIRI) { + this(topicMap, syntax, new Source(source, docIRI)); } + protected AbstractTopicMapReader(final TopicMap topicMap, final Syntax syntax, + final Source source) { + this(new TinyTimMapInputHandler(topicMap), syntax, source); + } + + protected AbstractTopicMapReader(final IMapHandler handler, final Syntax syntax, + final Source source) { + this(handler, DeserializerRegistry.createDeserializer(syntax), source); + } + + protected AbstractTopicMapReader(final IMapHandler handler, final IDeserializer deserializer, final Source source) { + if (_deserializer == null) { + throw new IllegalArgumentException("Deserializer not found"); + } + _deserializer.setProperty(Property.VALIDATE, Boolean.FALSE); + _deserializer.setMapHandler(handler); + _source = source; + } + /* (non-Javadoc) - * @see org.tinytim.mio.ITopicMapReader#read(org.xml.sax.InputSource, java.lang.String) + * @see org.tinytim.mio.ITopicMapReader#read() */ - public void read(InputSource source, String baseIRI) throws IOException { + public void read() throws IOException { try { - _deserializer.parse(source, baseIRI); + _deserializer.parse(_source); } catch (MIOException ex) { if (ex.getException() instanceof IOException) { @@ -83,5 +124,4 @@ _deserializer = null; } } - } Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java 2008-11-12 14:03:27 UTC (rev 175) @@ -0,0 +1,56 @@ +/* + * 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.tmapi.core.Locator; +import org.tmapi.core.Topic; + +/** + * + * + * @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; + } + + protected String _getId(Topic tmo) { + String id = null; + for (Locator loc: tmo.getItemIdentifiers()) { + 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-" + tmo.getId(); + } +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapWriter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -0,0 +1,107 @@ +/* + * 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.IMapHandler; +import com.semagia.mio.Property; +import com.semagia.mio.Source; +import com.semagia.mio.Syntax; + +/** + * Common superclass for all XTM readers which provides some additional methods + * to configure the reader. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +abstract class AbstractXTMTopicMapReader extends AbstractTopicMapReader { + + public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + File source) throws IOException { + super(topicMap, syntax, source); + } + + public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + File source, String docIRI) throws IOException { + super(topicMap, syntax, source, docIRI); + } + + public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + InputStream source, String docIRI) { + super(topicMap, syntax, source, docIRI); + } + + public AbstractXTMTopicMapReader(TopicMap topicMap, Syntax syntax, + Source source) { + super(topicMap, syntax, source); + } + + public AbstractXTMTopicMapReader(IMapHandler handler, Syntax syntax, + Source source) { + super(handler, syntax, source); + } + + /** + * Enables / disables processing of the "mergeMap" element. + * <p> + * The reader won't deserialize topic maps referenced by mergeMap if + * this feature is enabled (disabled by default). + * </p> + * + * @param ignore <tt>true</tt> to ignore mergeMap elements, otherwise <tt>false</tt>. + */ + public void setIgnoreMergeMap(boolean ignore) { + _deserializer.setProperty(Property.IGNORE_MERGEMAP, ignore); + } + + /** + * Returns if this reader ignores mergeMap elements. + * + * @return <tt>true</tt> if mergeMap is ignored, otherwise <tt>false</tt>. + */ + public boolean isIgnoringMergeMap() { + return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_MERGEMAP)); + } + + /** + * Enables / disables validation of the source. + * <p> + * The reader validates the XML document if this feature is enabled + * (disabled by default). + * </p> + * + * @param validate <tt>true</tt> to enable validation, <tt>false</tt> to + * disable validation. + */ + public void setValidation(boolean validate) { + _deserializer.setProperty(Property.VALIDATE, validate); + } + + /** + * Returns if this reader validates the source. + * + * @return <tt>true</tt> if this reader validates the source, otherwise <tt>false</tt>. + */ + public boolean isValidating() { + return Boolean.TRUE.equals(_deserializer.getProperty(Property.VALIDATE)); + } +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java 2008-11-12 14:03:27 UTC (rev 175) @@ -0,0 +1,42 @@ +/* + * 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.xml.sax.Attributes; +import org.xml.sax.helpers.AttributesImpl; + +/** + * + * + * @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 Attributes _EMPTY_ATTRS = XMLWriter.EMPTY_ATTRS; + + protected AttributesImpl _attrs; + protected XMLWriter _out; + /** + * + * + * @param baseIRI + */ + public AbstractXTMWriter(String baseIRI) { + super(baseIRI); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMWriter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Deleted: tinytim-mio/trunk/src/main/java/org/tinytim/mio/BTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/BTMReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/BTMReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -1,40 +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 org.tmapi.core.TopicMap; - -import com.semagia.mio.Syntax; - -/** - * {@link ITopicMapReader} implementation that is able to deserialize - * <a href="http://www.semagia.com/tr/btm/1.0/">Binary Topic Maps (BTM) 1.0</a>. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public final class BTMReader extends AbstractTopicMapReader { - - /** - * Constructs a new instance. - * - * @param topicMap The topic map to which the content is added to. - */ - public BTMReader(final TopicMap topicMap) { - super(topicMap, Syntax.BTM); - } - -} Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/CTMReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -15,13 +15,18 @@ */ 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 ITopicMapReader} implementation that is able to deserialize - * <a href="http://www.isotopicmaps.org/ctm">Compact Topic Maps (CTM) 1.0</a>. + * {@link TopicMapReader} implementation that is able to deserialize + * <a href="http://www.isotopicmaps.org/ctm/">Compact Topic Maps (CTM) 1.0</a>. * <p> * Note that this reader implements the CTM draft dtd. 2008-05-15. * </p> @@ -35,9 +40,48 @@ * 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 CTMReader(final TopicMap topicMap) { - super(topicMap, Syntax.CTM); + public CTMReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.CTM, 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 CTMReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.CTM, 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 CTMReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.CTM, 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 CTMReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.CTM, source); + } + } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMWriter.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/CXTMWriter.java 2008-11-12 14:03:27 UTC (rev 175) @@ -29,7 +29,6 @@ import java.util.Set; import java.util.logging.Logger; -import org.tinytim.core.TopicMapImpl; import org.tinytim.internal.utils.CollectionFactory; import org.tinytim.utils.DuplicateRemovalUtils; import org.tinytim.voc.TMDM; @@ -74,36 +73,35 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public final class CXTMWriter implements ITopicMapWriter { +public final class CXTMWriter implements TopicMapWriter { private static final Logger LOG = Logger.getLogger(CXTMWriter.class.getName()); private static final Role[] _EMPTY_ROLES = new Role[0]; - private AttributesImpl _attrs; + private final AttributesImpl _attrs; private Topic _type; private Topic _instance; private Topic _typeInstance; - private XMLC14NWriter _out; + private final XMLC14NWriter _out; private final String _normBase; - private Map<Construct, Integer> _construct2Id; - private Map<Topic, List<Role>> _topic2Roles; - private Map<Locator, String> _locator2Norm; + private final Map<Construct, Integer> _construct2Id; + private final Map<Topic, List<Role>> _topic2Roles; + private final Map<Locator, String> _locator2Norm; + private final Map<Association, Role[]> _assoc2Roles; - private Comparator<Topic> _topicComparator; - private Comparator<Association> _assocComparator; - private Comparator<Role> _roleComparator; - private Comparator<Occurrence> _occComparator; - private Comparator<Name> _nameComparator; - private Comparator<Variant> _variantComparator; - private Comparator<Set<Locator>> _locSetComparator; - private Comparator<Locator> _locComparator; - private Comparator<Set<Topic>> _scopeComparator; + private final Comparator<Topic> _topicComparator; + private final Comparator<Association> _assocComparator; + private final Comparator<Role> _roleComparator; + private final Comparator<Occurrence> _occComparator; + private final Comparator<Name> _nameComparator; + private final Comparator<Variant> _variantComparator; + private final Comparator<Set<Locator>> _locSetComparator; + private final Comparator<Locator> _locComparator; + private final Comparator<Set<Topic>> _scopeComparator; - private Map<Association, Role[]> _assoc2Roles; - /** * Creates a canonicalizer. * @@ -118,6 +116,10 @@ _out = new XMLC14NWriter(out); _attrs = new AttributesImpl(); _normBase = _normalizeBaseLocator(baseLocator); + _construct2Id = CollectionFactory.createIdentityMap(); + _locator2Norm = CollectionFactory.createIdentityMap(); + _assoc2Roles = CollectionFactory.createIdentityMap(); + _topic2Roles = CollectionFactory.createIdentityMap(); _topicComparator = new TopicComparator(); _assocComparator = new AssociationComparator(); _roleComparator = new RoleComparator(); @@ -141,11 +143,7 @@ */ public void write(TopicMap topicMap) throws IOException { DuplicateRemovalUtils.removeDuplicates(topicMap); - _construct2Id = CollectionFactory.createIdentityMap(); - _locator2Norm = CollectionFactory.createIdentityMap(); - _assoc2Roles = CollectionFactory.createIdentityMap(); - _topic2Roles = CollectionFactory.createIdentityMap(); - TypeInstanceIndex typeInstanceIndex = ((TopicMapImpl) topicMap).getIndexManager().getTypeInstanceIndex(); + TypeInstanceIndex typeInstanceIndex = topicMap.getIndex(TypeInstanceIndex.class); if (!typeInstanceIndex.isAutoUpdated()) { typeInstanceIndex.reindex(); } @@ -168,22 +166,22 @@ _out.endElement("topicMap"); _out.newline(); _out.endDocument(); - _out = null; - _attrs = null; - _construct2Id = null; - _locator2Norm = null; - _assoc2Roles = null; - _topic2Roles = null; + _attrs.clear(); + _construct2Id.clear(); + _topic2Roles.clear(); + _locator2Norm.clear(); + _assoc2Roles.clear(); } /** * Returns an unsorted array of topics which should be included into * the output. - * + * <p> * This method may return more topics than {@link TopicMap#getTopics()} * since this method creates virtual topics to model type-instance * relationships properly. - * + * </p> + * * @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. @@ -555,9 +553,10 @@ /** * Serializes the <tt>locators</tt> using the <tt>localName</tt> as * element name. - * + * <p> * If the set of <tt>locators</tt> is empty, this method does nothing. - * + * </p> + * * @param localName The element's name. * @param locators The locators to serialize. * @throws IOException If an error occurs. Deleted: tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -1,66 +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.File; -import java.io.IOException; -import java.io.InputStream; - -import org.xml.sax.InputSource; - -/** - * This interface represents a reader to deserialize a topic map from a source. - * <p> - * The reader is not meant to be reused and should be thrown away once one - * of the <tt>read</tt> methods were invoked. - * </p> - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface ITopicMapReader { - - /** - * Reads a topic map from <tt>source</tt> using the provided <tt>docIRI</tt> - * to resolve IRIs against. - * - * @param source The source to read the serialized topic map from. - * @param docIRI The IRI which is used to resolve IRIs against. - * @throws IOException If an error occurs. - */ - public void read(InputSource source, String docIRI) throws IOException; - - /** - * Reads a topic map from <tt>source</tt> using the provided <tt>docIRI</tt> - * to resolve IRIs against. - * - * @param source The file to read the serialized topic map from. - * @param docIRI The IRI which is used to resolve IRIs against. - * @throws IOException If an error occurs. - */ - public void read(File source, String docIRI)throws IOException; - - /** - * Reads a topic map from <tt>source</tt> using the provided <tt>docIRI</tt> - * to resolve IRIs against. - * - * @param source The stream to read the serialized topic map from. - * @param docIRI The IRI which is used to resolve IRIs against. - * @throws IOException If an error occurs. - */ - public void read(InputStream source, String docIRI)throws IOException; - -} Deleted: tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapWriter.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/ITopicMapWriter.java 2008-11-12 14:03:27 UTC (rev 175) @@ -1,31 +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 org.tmapi.core.TopicMap; - -/** - * - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public interface ITopicMapWriter { - - public void write(TopicMap topicMap) throws IOException; -} Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -15,12 +15,17 @@ */ 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 ITopicMapReader} implementation that is able to deserialize the + * {@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>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> @@ -32,9 +37,95 @@ * 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 LTMReader(final TopicMap topicMap) { - super(topicMap, Syntax.LTM); + public LTMReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.LTM, 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 LTMReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.LTM, 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 LTMReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.LTM, 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 LTMReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.LTM, source); + } + +// /** +// * Enables / disables processing of the "#MERGEMAP" directive. +// * <p> +// * The reader won't deserialize topic maps referenced by mergeMap if +// * this feature is enabled (disabled by default). +// * </p> +// * +// * @param ignore <tt>true</tt> to ignore "#MERGEMAP" directives, +// * otherwise <tt>false</tt>. +// */ +// public void setIgnoreMergeMap(boolean ignore) { +// _deserializer.setProperty(Property.IGNORE_MERGEMAP, ignore); +// } +// +// /** +// * Returns if this reader ignores "#MERGEMAP" directives. +// * +// * @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); +// } + +// /** +// * Enables / disables processing of the "#INCLUDE" directive. +// * <p> +// * The reader won't deserialize topic maps referenced by "#INCLUDE" if +// * this feature is enabled (disabled by default). +// * </p> +// * +// * @param ignore <tt>true</tt> to ignore "#INCLUDE" directives, +// * otherwise <tt>false</tt>. +// */ +// public void setIgnoreInclude(boolean ignore) { +// _deserializer.setProperty(Property.IGNORE_INCLUDE, ignore); +// } +// +// /** +// * Returns if this reader ignores "#INCLUDE" directives. +// * +// * @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); +// } } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/SnelloReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -15,12 +15,17 @@ */ 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 ITopicMapReader} implementation that is able to deserialize + * {@link TopicMapReader} implementation that is able to deserialize * <a href="http://www.semagia.com/tr/snello/1.0/">Snello Topic Maps (STM) 1.0</a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> @@ -32,9 +37,48 @@ * 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 SnelloReader(final TopicMap topicMap) { - super(topicMap, Syntax.SNELLO); + public SnelloReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.SNELLO, 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 SnelloReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.SNELLO, 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 SnelloReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.SNELLO, 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 SnelloReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.SNELLO, source); + } + } Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java 2008-11-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -15,13 +15,20 @@ */ 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.Property; +import com.semagia.mio.Source; import com.semagia.mio.Syntax; /** + * {@link TopicMapReader} implementation that is able to deserialize + * <a href="http://www.ontopia.net/topicmaps/tmxml.html">TM/XML</a> topic maps. * - * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ @@ -31,9 +38,71 @@ * 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 TMXMLReader(TopicMap topicMap) { - super(topicMap, Syntax.TMXML); + public TMXMLReader(final TopicMap topicMap, final File source, final String docIRI) throws IOException { + super(topicMap, Syntax.TMXML, 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 TMXMLReader(final TopicMap topicMap, final File source) throws IOException { + super(topicMap, Syntax.TMXML, 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 TMXMLReader(final TopicMap topicMap, final InputStream source, final String docIRI) { + super(topicMap, Syntax.TMXML, 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 TMXMLReader(final TopicMap topicMap, final Source source) { + super(topicMap, Syntax.TMXML, source); + } + + /** + * Enables / disables validation of the source. + * <p> + * The reader validates the XML document if this feature is enabled + * (disabled by default). + * </p> + * + * @param validate <tt>true</tt> to enable validation, <tt>false</tt> to + * disable validation. + */ + public void setValidation(boolean validate) { + _deserializer.setProperty(Property.VALIDATE, validate); + } + + /** + * Returns if this reader validates the source. + * + * @return <tt>true</tt> if this reader validates the source, otherwise <tt>false</tt>. + */ + public boolean isValidating() { + return Boolean.TRUE.equals(_deserializer.getProperty(Property.VALIDATE)); + } + } 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-11 14:38:30 UTC (rev 174) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2008-11-12 14:03:27 UTC (rev 175) @@ -27,12 +27,11 @@ public final class TinyTimMapInputHandler extends AbstractMapInputHandler { /** - * Intitializes a new <tt>MapInputHandler</tt> instance with the specified - * <tt>topicMap</tt>. + * Intitializes a new instance with the specified <tt>topicMap</tt>. * * @param topicMap The {@link TopicMap} instance. */ - public TinyTimMapInputHandler(final TopicMap topicMap) { + public TinyTimMapInputHandler(TopicMap topicMap) { super(topicMap); } Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java 2008-11-12 14:03:27 UTC (rev 175) @@ -0,0 +1,274 @@ +/* + * 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.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +import org.tmapi.core.TopicMap; +import org.xml.sax.InputSource; + +import com.semagia.mio.Source; +import com.semagia.mio.Syntax; + +/** + * Functions to import serialized topic maps. + * <p> + * This class is kept for backward compatibility, some methods are already + * deprectated, maybe the whole class will be deprecated in the near future; + * use {@link TopicMapReader} and its implementations. Actually, this class has + * become a wrapper around different {@link TopicMapReader} implementations. + * </p> + * <p> + * This class may be deprected since it provides a high-level view on + * {@link TopicMapReader}s. A {@link TopicMapReader} instance may provide + * methods to configure its behaviour while this class does not support any + * configuration. + * </p> + * <p> + * Applications which use this class should possibly implement something + * equivalent or a smarter utility class since this class will never support + * any configuration of {@link TopicMapReader}s. + * </p> + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public final class TopicMapImporter { + + private TopicMapImporter() { + // noop. + } + + /** + * Reads a XML topic map from <tt>input</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param input The stream to read the serialized topic map from. + * @throws IOException If an error occurs. + */ + public static void importInto(TopicMap topicMap, String docIRI, InputStream input) throws IOException { + _import(Syntax.XTM, topicMap, docIRI, input); + } + + /** + * Reads a topic map from <tt>file</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * + * The syntax of the serialized topic map is guessed by the file name. If + * the file extension gives no indication of the used syntax, XTM is + * assumed. + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param file The file to read the serialized topic map from. + * @throws IOException If an error occurs. + */ + public static void importInto(TopicMap topicMap, String docIRI, File file) throws IOException { + _import(_guessSyntax(file), topicMap, docIRI, new FileInputStream(file)); + } + + /** + * Reads a topic map from <tt>file</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * + * The <tt>syntax</tt> is a string with the abbreviated Topic Maps syntax + * name; i.e. "xtm", "ltm", "ctm". The name is matched case-insensitve, that + * means "xtm" is the same as "xTm", "XTM" etc. + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param file The file to read the serialized topic map from. + * @param syntax The name of the syntax of the encoded topic map. I.e. "xtm". + * @throws IOException If an error occurs. + */ + public static void importInto(TopicMap topicMap, String docIRI, File file, String syntax) throws IOException { + importInto(topicMap, docIRI, new FileInputStream(file), syntax); + } + + /** + * Reads a topic map from <tt>input</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * + * The <tt>syntax</tt> is a string with the abbreviated Topic Maps syntax + * name; i.e. "xtm", "ltm", "ctm". The name is matched case-insensitve, that + * means "xtm" is the same as "xTm", "XTM" etc. + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param input The stream to read the serialized topic map from. + * @param syntax The name of the syntax of the encoded topic map. I.e. "xtm". + * @throws IOException If an error occurs. + */ + public static void importInto(TopicMap topicMap, String docIRI, InputStream input, String syntax) throws IOException { + Syntax syntax_ = Syntax.valueOf(syntax); + if (syntax_ == null) { + throw new RuntimeException("The syntax '" + syntax + "' is unknown"); + } + _import(syntax_, topicMap, docIRI, input); + } + + /** + * Returns a {@link Syntax} instance. + * + * @param file The file to guess the syntax from. + * @return A syntax which matches the file extension or {@link Syntax#XTM} + * if the file extension is not available or gives no indication + * about the used syntax. + */ + private static Syntax _guessSyntax(File file) { + String name = file.getName(); + int i = name.lastIndexOf('.'); + return i == -1 ? Syntax.XTM + : Syntax.forFileExtension(name.substring(i+1), Syntax.XTM); + } + + /** + * Reads a topic map from <tt>input</tt> and adds the content to the + * <tt>topicMap</tt>. + * + * @param syntax A syntax instance. + * @param topicMap A topic map instance. + * @param docIRI The IRI which is used to resolve locators against. + * @param input The source to read the topic map from. + * @throws IOException If an error occurs. + */ + private static void _import(Syntax syntax, TopicMap topicMap, String docIRI, + InputStream input) throws IOException { + _import(syntax, topicMap, new Source(input, docIRI)); + } + + /** + * Reads a topic map from <tt>input</tt> and adds the content to the + * <tt>topicMap</tt>. + * + * @param syntax A syntax instance. + * @param topicMap A topic map instance. + * @param docIRI The IRI which is used to resolve locators against. + * @param input The source to read the topic map from. + * @throws IOException If an error occurs. + */ + private static void _import(Syntax syntax, TopicMap topicMap, Source input) throws IOException { + TopicMapReader tmReader = null; + if (Syntax.XTM.equals(syntax)) { + tmReader = new XTMReader(topicMap, input); + } + else if (Syntax.CTM.equals(syntax)) { + tmReader = new CTMReader(topicMap, input); + } + else if (Syntax.LTM.equals(syntax)) { + tmReader = new LTMReader(topicMap, input); + } + else if (Syntax.TMXML.equals(syntax)) { + tmReader = new TMXMLReader(topicMap, input); + } + else if (Syntax.SNELLO.equals(syntax)) { + tmReader = new SnelloReader(topicMap, input); + } + else if (Syntax.BTM.equals(syntax)) { + tmReader = new BTMReader(topicMap, input); + } + if (tmReader == null) { + throw new IOException("Unknown syntax " + syntax.getName()); + } + tmReader.read(); + } + + /** + * Reads a XML topic map from <tt>input</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param input The source to read the serialized topic map from. + * @throws IOException If an error occurs. + */ + @Deprecated + public static void importInto(TopicMap topicMap, String docIRI, InputSource input) throws IOException { + _import(Syntax.XTM, topicMap, docIRI, input); + } + + /** + * Reads a topic map from <tt>input</tt> and adds the content to the + * specified <tt>topicMap</tt>. The <tt>docIRI</tt> is used to + * resolve IRIs against. + * <p> + * The <tt>syntax</tt> is a string with the abbreviated Topic Maps syntax + * name; i.e. "xtm", "ltm", "ctm". The name is matched case-insensitve, that + * means "xtm" is the same as "xTm", "XTM" etc. + * </p> + * + * @param topicMap The topic map instance which receives the + * Topic Maps constructs. + * @param docIRI The IRI which is used to resolve IRIs against. + * @param input The source to read the serialized topic map from. + * @param syntax The name of the syntax of the encoded topic map. I.e. "xtm". + * @throws IOException If an error occurs. + */ + @Deprecated + public static void importInto(TopicMap topicMap, String docIRI, InputSource input, String syntax) throws IOException { + Syntax syntax_ = Syntax.valueOf(syntax); + if (syntax_ == null) { + throw new RuntimeException("The syntax '" + syntax + "' is unknown"); + } + _import(syntax_, topicMap, docIRI, input); + } + + /** + * Reads a topic map from <tt>input</tt> and adds the content to the + * <tt>topicMap</tt>. + * + * @param syntax A syntax instance. + * @param topicMap A topic map instance. + * @param docIRI The IRI which is used to resolve locators against. + * @param input The source to read the topic map from. + * @throws IOException If an error occurs. + */ + @Deprecated + private static void _import(Syntax syntax, TopicMap topicMap, + String docIRI, InputSource input) throws IOException { + Source src = null; + if (input.getByteStream() != null) { + src = new Source(input.getByteStream(), docIRI, input.getEncoding()); + } + else { + Reader reader = input.getCharacterStream(); + if (reader != null) { + src = new Source(reader, docIRI, input.getEncoding()); + } + else { + src = new Source(input.getSystemId()); + } + } + _import(syntax, topicMap, src); + } + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapImporter.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapReader.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapReader.java (rev 0) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapReader.java 2008-11-12 14:03:27 UTC (rev 175) @@ -0,0 +1,39 @@ +/* + * 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; + +/** + * This interface represents a reader to deserialize a topic map from a source. + * <p> + * The reader is not meant to be reused and should be thrown away once the + * {@link #read()} method was invoked. + * </p> + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public interface TopicMapReader { + + /** + * Reads a topic map. + * + * @throws IOException If an error occurs. + */ + public void read() throws IOException; + +} Property changes on: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapReader.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TopicMapWrit... [truncated message content] |
From: <lh...@us...> - 2008-11-11 14:38:43
|
Revision: 174 http://tinytim.svn.sourceforge.net/tinytim/?rev=174&view=rev Author: lheuer Date: 2008-11-11 14:38:30 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Removed unused import Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-11 14:35:15 UTC (rev 173) +++ tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-11 14:38:30 UTC (rev 174) @@ -15,7 +15,6 @@ */ package org.tinytim.core; -import java.util.ArrayList; import java.util.List; import org.tinytim.internal.utils.CollectionFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-11 14:35:24
|
Revision: 173 http://tinytim.svn.sourceforge.net/tinytim/?rev=173&view=rev Author: lheuer Date: 2008-11-11 14:35:15 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Switching back to lists for stacks Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-10 16:29:42 UTC (rev 172) +++ tinytim-mio/trunk/src/main/java/org/tinytim/core/AbstractMapInputHandler.java 2008-11-11 14:35:15 UTC (rev 173) @@ -15,6 +15,7 @@ */ package org.tinytim.core; +import java.util.ArrayList; import java.util.List; import org.tinytim.internal.utils.CollectionFactory; @@ -36,6 +37,10 @@ /** * 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> * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ @@ -57,15 +62,13 @@ ISA = 12, TYPE = 13; - private final int _CONSTRUCTS = 6; - private final int _STATES = 10; - private final int _SCOPE = 6; + private final int _CONSTRUCT_SIZE = 6; + private final int _STATE_SIZE = 10; + private final int _SCOPE_SIZE = 6; private TopicMapImpl _tm; - private int[] _stateStack; - private int _stateSize = -1; - private IConstruct[] _constructStack; - private int _constructSize = -1; + private List<Integer> _stateStack; + private List<IConstruct> _constructStack; private List<Topic> _scope; protected AbstractMapInputHandler(TopicMap topicMap) { @@ -88,9 +91,9 @@ * @see com.semagia.mio.IMapHandler#startTopicMap() */ public final void startTopicMap() throws MIOException { - _constructStack = new IConstruct[_CONSTRUCTS]; - _stateStack = new int[_STATES]; - _scope = CollectionFactory.createList(_SCOPE); + _constructStack = CollectionFactory.createList(_CONSTRUCT_SIZE); + _stateStack = CollectionFactory.createList(_STATE_SIZE); + _scope = CollectionFactory.createList(_SCOPE_SIZE); _enterState(INITIAL, _tm); } @@ -382,13 +385,7 @@ * @param state The state to push ontop of the state stack. */ private void _enterState(int state) { - if (_stateSize + 1 > _stateStack.length) { - int[] states = new int[Math.min(_stateSize*2, Integer.MAX_VALUE)]; - System.arraycopy(_stateStack, 0, states, 0, _stateSize); - _stateStack = states; - } - _stateSize++; - _stateStack[_stateSize] = state; + _stateStack.add(state); } /** @@ -400,13 +397,7 @@ */ private void _enterState(int state, IConstruct tmo) { _enterState(state); - if (_constructSize + 1 > _constructStack.length) { - IConstruct[] constructs = new IConstruct[Math.min(_constructSize*2, Integer.MAX_VALUE)]; - System.arraycopy(_constructStack, 0, constructs, 0, _constructSize); - _constructStack = constructs; - } - _constructSize++; - _constructStack[_constructSize] = tmo; + _constructStack.add(tmo); } /** @@ -416,11 +407,10 @@ * @throws MIOException If the state is not equals to the current state. */ private void _leaveState(int state) throws MIOException { - final int current = _stateStack[_stateSize]; + final int current = _stateStack.remove(_stateStack.size()-1); if (state != current) { _reportError("Unexpected state: " + current + ", expected: " + state); } - _stateSize--; } /** @@ -432,10 +422,7 @@ */ private IConstruct _leaveStatePopConstruct(int state) throws MIOException { _leaveState(state); - final IConstruct construct = _peekConstruct(); - _constructStack[_constructSize] = null; - _constructSize--; - return construct; + return _constructStack.remove(_constructStack.size()-1); } /** @@ -444,7 +431,7 @@ * @return The Topic Maps construct. */ private IConstruct _peekConstruct() { - return _constructStack[_constructSize]; + return _constructStack.get(_constructStack.size()-1); } /** @@ -462,7 +449,7 @@ * @return The current state. */ private int _state() { - return _stateStack[_stateSize]; + return _stateStack.get(_stateStack.size()-1); } /** @@ -491,9 +478,9 @@ * @param target The target topic. */ private void _merge(Topic source, TopicImpl target) { - for (int i=0; i<_constructSize; i++) { - if (_constructStack[i] == source) { - _constructStack[i] = target; + for (int i=0; i<_constructStack.size(); i++) { + if (_constructStack.get(i) == source) { + _constructStack.set(i, target); } } target.mergeIn(source); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-10 16:29:45
|
Revision: 172 http://tinytim.svn.sourceforge.net/tinytim/?rev=172&view=rev Author: lheuer Date: 2008-11-10 16:29:42 +0000 (Mon, 10 Nov 2008) Log Message: ----------- Removed unused subproject (tinyTiM's support for TMShare will go into another subproject) Removed Paths: ------------- tinytim-ws-atomico/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-10 16:27:01
|
Revision: 171 http://tinytim.svn.sourceforge.net/tinytim/?rev=171&view=rev Author: lheuer Date: 2008-11-10 16:26:55 +0000 (Mon, 10 Nov 2008) Log Message: ----------- Removed unused subproject Removed Paths: ------------- tinytim-io/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-10 16:23:00
|
Revision: 170 http://tinytim.svn.sourceforge.net/tinytim/?rev=170&view=rev Author: lheuer Date: 2008-11-10 16:22:51 +0000 (Mon, 10 Nov 2008) Log Message: ----------- - Updated libs (tinyTiM and JUnit) Added Paths: ----------- tinytim-mio/trunk/lib/junit-4.5.jar tinytim-mio/trunk/lib/tinytim-2.0.0a2-tests.jar tinytim-mio/trunk/lib/tinytim-2.0.0a2.jar Removed Paths: ------------- tinytim-mio/trunk/lib/junit-4.4.jar tinytim-mio/trunk/lib/tinytim-2.0.0a1-tests.jar tinytim-mio/trunk/lib/tinytim-2.0.0a1.jar Deleted: tinytim-mio/trunk/lib/junit-4.4.jar =================================================================== (Binary files differ) Added: tinytim-mio/trunk/lib/junit-4.5.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/junit-4.5.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: tinytim-mio/trunk/lib/tinytim-2.0.0a1-tests.jar =================================================================== (Binary files differ) Deleted: tinytim-mio/trunk/lib/tinytim-2.0.0a1.jar =================================================================== (Binary files differ) Added: tinytim-mio/trunk/lib/tinytim-2.0.0a2-tests.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/tinytim-2.0.0a2-tests.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: tinytim-mio/trunk/lib/tinytim-2.0.0a2.jar =================================================================== (Binary files differ) Property changes on: tinytim-mio/trunk/lib/tinytim-2.0.0a2.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. |