|
From: <lh...@us...> - 2009-02-24 13:56:56
|
Revision: 267
http://tinytim.svn.sourceforge.net/tinytim/?rev=267&view=rev
Author: lheuer
Date: 2009-02-24 13:56:47 +0000 (Tue, 24 Feb 2009)
Log Message:
-----------
- Added Override annotation (Java 6)
- Switched to semagia-mio-jtm for the JTMTopicMapReader (json_simple.jar is not required anymore)
- Adapted JTM 1.0 for JTMTopicMapWriter
Modified Paths:
--------------
tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLTopicMapReader.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/XTM10TopicMapWriter.java
Added Paths:
-----------
tinytim-mio/trunk/lib/semagia-mio-jtm-0.9.3.jar
Removed Paths:
-------------
tinytim-mio/trunk/lib/json_simple.jar
Deleted: tinytim-mio/trunk/lib/json_simple.jar
===================================================================
(Binary files differ)
Added: tinytim-mio/trunk/lib/semagia-mio-jtm-0.9.3.jar
===================================================================
(Binary files differ)
Property changes on: tinytim-mio/trunk/lib/semagia-mio-jtm-0.9.3.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractRDFTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -32,7 +32,7 @@
* Common superclass for {@link RDFTopicMapReader}s.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
abstract class AbstractRDFTopicMapReader extends AbstractTopicMapReader
implements RDFTopicMapReader {
@@ -65,6 +65,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.io.File)
*/
+ @Override
public void setMappingSource(File file) {
try {
setMappingSource(file.toURI().toURL());
@@ -77,6 +78,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.net.URL)
*/
+ @Override
public void setMappingSource(URL url) {
setMappingSource(url.toExternalForm());
}
@@ -84,6 +86,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#setMappingSource(java.lang.String)
*/
+ @Override
public void setMappingSource(String iri) {
_deserializer.setProperty(Property.RDF2TM_MAPPING_IRI, iri);
}
@@ -91,6 +94,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#getMappingSource()
*/
+ @Override
public String getMappingSource() {
return (String) _deserializer.getProperty(Property.RDF2TM_MAPPING_IRI);
}
@@ -98,6 +102,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#getMappingSourceSyntax()
*/
+ @Override
public MappingSyntax getMappingSourceSyntax() {
Syntax syntax = (Syntax) _deserializer.getProperty(Property.RDF2TM_MAPPING_SYNTAX);
return _toMappingSyntax(syntax);
@@ -106,10 +111,17 @@
/* (non-Javadoc)
* @see org.tinytim.mio.RDFTopicMapReader#setMappingSourceSyntax(org.tinytim.mio.RDFTopicMapReader.MappingSyntax)
*/
+ @Override
public void setMappingSourceSyntax(MappingSyntax syntax) {
_deserializer.setProperty(Property.RDF2TM_MAPPING_SYNTAX, _fromMappingSyntax(syntax));
}
+ /**
+ * Returns the {@link MappingSyntax} equivalent for the provided mio.Syntax.
+ *
+ * @param syntax The syntax to convert.
+ * @return The MappingSyntax instance.
+ */
private static MappingSyntax _toMappingSyntax(Syntax syntax) {
if (syntax == null) {
return null;
@@ -136,6 +148,12 @@
}
+ /**
+ * Returns the mio.Syntax equivalent for the provided {@link MappingSyntax}.
+ *
+ * @param syntax The syntax to translate.
+ * @return The translated syntax.
+ */
private static Syntax _fromMappingSyntax(MappingSyntax syntax) {
if (syntax == null) {
return null;
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -125,6 +125,7 @@
/* (non-Javadoc)
* @see org.tinytim.mio.ITopicMapReader#read()
*/
+ @Override
public void read() throws IOException {
try {
_deserializer.parse(_source);
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -70,7 +70,7 @@
* @param ignore <tt>true</tt> to ignore mergeMap elements, otherwise <tt>false</tt>.
*/
public void setIgnoreMergeMap(boolean ignore) {
- _deserializer.setProperty(Property.IGNORE_MERGEMAP, ignore);
+ _deserializer.setProperty(Property.IGNORE_MERGEMAP, Boolean.valueOf(ignore));
}
/**
@@ -94,7 +94,7 @@
* disable validation.
*/
public void setValidation(boolean validate) {
- _deserializer.setProperty(Property.VALIDATE, validate);
+ _deserializer.setProperty(Property.VALIDATE, Boolean.valueOf(validate));
}
/**
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractXTMTopicMapWriter.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -66,7 +66,7 @@
throw new IOException("The encoding must not be null");
}
_out = new XMLWriter(out, encoding);
- _out.setPrettify(true);
+ _out.setPrettify(false);
_attrs = new AttributesImpl();
}
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ * Copyright 2008 - 2009 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.
@@ -15,282 +15,83 @@
*/
package org.tinytim.mio;
+import java.io.File;
import java.io.IOException;
-import java.io.Reader;
-import java.util.List;
+import java.io.InputStream;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.tmapi.core.TMAPIRuntimeException;
import org.tmapi.core.TopicMap;
-import com.semagia.mio.MIOException;
-import com.semagia.mio.helpers.Ref;
-import com.semagia.mio.helpers.SimpleMapHandler;
+import com.semagia.mio.Source;
+import com.semagia.mio.Syntax;
/**
* {@link TopicMapReader} implementation that deserializes
* <a href="http://www.cerny-online.com/jtm/">JSON Topic Maps (JTM)</a>.
* <p>
- * The reader does not accept fragments, i.e. only a topic in a JSON document;
- * each JTM instance must start with a topic map container, i.e.
- * <tt>{"topics":[...]"}</tt>. The TMDM constructs must provide all
- * properties, i.e. it is not allowed to omit the type of an association. The
- * only exception are topic names: If the "type" property is not provided, the
- * default topic name type is automatically assigned.
+ * This reader rejects JTM instances which contain just a single role or
+ * variant even if they are valid according to the JTM specification.
* </p>
+ * <p>
+ * Further the reader expects that at least one identity of a topic
+ * (item identifier, subject identifier, subject locator) occurs before any
+ * occurrence / name. Fragments must start with a "version" property followed
+ * by the "item_type" property before any further properties are specified.
+ * </p>
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev:$ - $Date:$
*/
-@SuppressWarnings("unchecked")
-public class JTMTopicMapReader implements TopicMapReader {
+public final class JTMTopicMapReader extends AbstractTopicMapReader {
- private TopicMap _tm;
- private Reader _reader;
-
/**
* Constructs a new instance.
*
* @param topicMap The topic map to which the content is added to.
- * @param reader The reader to read the JSON encoded topic map from.
- * @throws IOException If an error occurs.
+ * @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 JTMTopicMapReader(TopicMap topicMap, Reader reader) throws IOException {
- _tm = topicMap;
- _reader = reader;
+ public JTMTopicMapReader(final TopicMap topicMap, final File source,
+ final String docIRI) throws IOException {
+ super(topicMap, Syntax.JTM, source, docIRI);
}
- /* (non-Javadoc)
- * @see org.tinytim.mio.TopicMapReader#read()
+ /**
+ * 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 void read() throws IOException {
- Object obj = JSONValue.parse(_reader);
- if (!(obj instanceof JSONObject)) {
- // Nothing to do.
- return;
- }
- JSONObject map = (JSONObject) obj;
- SimpleMapHandler mapHandler = SimpleMapHandler.create(new TinyTimMapInputHandler(_tm));
- try {
- mapHandler.startTopicMap();
- _handleReifier(mapHandler, map);
- _handleItemIdentifiers(mapHandler, map);
- _handleTopics(mapHandler, (List<JSONObject>) map.get("topics"));
- _handleAssociations(mapHandler, (List<JSONObject>) map.get("associations"));
- mapHandler.endTopicMap();
- }
- catch (MIOException ex) {
- throw new TMAPIRuntimeException(ex);
- }
+ public JTMTopicMapReader(final TopicMap topicMap, final File source)
+ throws IOException {
+ super(topicMap, Syntax.JTM, source);
}
- private void _handleTopics(SimpleMapHandler mapHandler,
- List<JSONObject> jsonArray) throws MIOException {
- if (jsonArray == null) {
- return;
- }
- int length = jsonArray.size();
- for (int i=0; i<length; i++) {
- _handleTopic(mapHandler, jsonArray.get(i));
- }
+ /**
+ * 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 JTMTopicMapReader(final TopicMap topicMap, final InputStream source,
+ final String docIRI) {
+ super(topicMap, Syntax.JTM, source, docIRI);
}
- private void _handleTopic(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- boolean seenIdentity = false;
- List<String> array = (List<String>) jsonObject.get("item_identifiers");
- if (array != null) {
- seenIdentity = true;
- mapHandler.startTopic(Ref.createItemIdentifier(array.get(0)));
- int length = array.size();
- for (int i=1; i<length; i++) {
- mapHandler.itemIdentifier(array.get(i));
- }
- }
- array = (List<String>) jsonObject.get("subject_identifiers");
- if (array != null) {
- int start = 0;
- if (!seenIdentity) {
- seenIdentity = true;
- start = 1;
- mapHandler.startTopic(Ref.createSubjectIdentifier(array.get(0)));
- }
- int length = array.size();
- for (int i=start; i<length; i++) {
- mapHandler.subjectIdentifier(array.get(i));
- }
- }
- array = (List<String>) jsonObject.get("subject_locators");
- if (array != null) {
- int start = 0;
- if (!seenIdentity) {
- seenIdentity = true;
- start = 1;
- mapHandler.startTopic(Ref.createSubjectLocator(array.get(0)));
- }
- int length = array.size();
- for (int i=start; i<length; i++) {
- mapHandler.subjectLocator(array.get(i));
- }
- }
- if (!seenIdentity) {
- throw new MIOException("Topic without any identity: " + jsonObject);
- }
- List<JSONObject> objects = (List<JSONObject>) jsonObject.get("occurrences");
- if (objects != null) {
- int length = objects.size();
- for (int i=0; i<length; i++) {
- _handleOccurrence(mapHandler, objects.get(i));
- }
- }
- objects = (List<JSONObject>) jsonObject.get("names");
- if (objects != null) {
- int length = objects.size();
- for (int i=0; i<length; i++) {
- _handleName(mapHandler, objects.get(i));
- }
- }
- mapHandler.endTopic();
+ /**
+ * 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 JTMTopicMapReader(final TopicMap topicMap, final Source source) {
+ super(topicMap, Syntax.JTM, source);
}
- private void _handleOccurrence(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- mapHandler.startOccurrence();
- _handleType(mapHandler, jsonObject, true);
- _handleScope(mapHandler, jsonObject);
- _handleReifier(mapHandler, jsonObject);
- _handleItemIdentifiers(mapHandler, jsonObject);
- _handleValueDatatype(mapHandler, jsonObject);
- mapHandler.endOccurrence();
- }
-
- private void _handleValueDatatype(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- String value = (String) jsonObject.get("value");
- if (value == null) {
- throw new MIOException("The value must not be null: " + jsonObject);
- }
- String datatype = (String) jsonObject.get("datatype");
- if (datatype == null) {
- throw new MIOException("The datatype must not be null: " + jsonObject);
- }
- mapHandler.value(value, datatype);
- }
-
- private void _handleName(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- mapHandler.startName();
- _handleType(mapHandler, jsonObject, false);
- _handleScope(mapHandler, jsonObject);
- _handleReifier(mapHandler, jsonObject);
- _handleItemIdentifiers(mapHandler, jsonObject);
- String value = (String) jsonObject.get("value");
- if (value == null) {
- throw new MIOException("The value of a name must not be null: " + jsonObject);
- }
- mapHandler.value(value);
- List<JSONObject> variants = (List<JSONObject>) jsonObject.get("variants");
- if (variants != null) {
- int length = variants.size();
- for (int i=0; i<length; i++) {
- _handleVariant(mapHandler, variants.get(i));
- }
- }
- mapHandler.endName();
- }
-
- private void _handleVariant(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- mapHandler.startVariant();
- _handleScope(mapHandler, jsonObject);
- _handleReifier(mapHandler, jsonObject);
- _handleItemIdentifiers(mapHandler, jsonObject);
- _handleValueDatatype(mapHandler, jsonObject);
- mapHandler.endVariant();
- }
-
- private void _handleAssociations(SimpleMapHandler mapHandler,
- List<JSONObject> jsonArray) throws MIOException {
- if (jsonArray == null) {
- return;
- }
- int length = jsonArray.size();
- for (int i=0; i<length; i++) {
- _handleAssociation(mapHandler, jsonArray.get(i));
- }
- }
-
- private void _handleAssociation(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- List<JSONObject> roles = (List<JSONObject>) jsonObject.get("roles");
- if (roles == null) {
- throw new MIOException("No roles specified: " + jsonObject);
- }
- mapHandler.startAssociation();
- _handleType(mapHandler, jsonObject, true);
- _handleScope(mapHandler, jsonObject);
- _handleReifier(mapHandler, jsonObject);
- _handleItemIdentifiers(mapHandler, jsonObject);
- int length = roles.size();
- for (int i=0; i<length; i++) {
- _handleRole(mapHandler, roles.get(i));
- }
- mapHandler.endAssociation();
- }
-
- private void _handleRole(SimpleMapHandler mapHandler,
- JSONObject jsonObject) throws MIOException {
- mapHandler.startRole();
- _handleType(mapHandler, jsonObject, true);
- _handleReifier(mapHandler, jsonObject);
- _handleItemIdentifiers(mapHandler, jsonObject);
- String playerIRI = (String) jsonObject.get("player");
- if (playerIRI == null) {
- throw new MIOException("No player defined: " + jsonObject);
- }
- mapHandler.player(Ref.createItemIdentifier(playerIRI));
- mapHandler.endRole();
- }
-
- private void _handleScope(SimpleMapHandler mapHandler, JSONObject jsonObject) throws MIOException {
- List<String> array = (List<String>) jsonObject.get("scope");
- if (array == null) {
- return;
- }
- int length = array.size();
- mapHandler.startScope();
- for (int i=0; i<length; i++) {
- mapHandler.theme(Ref.createItemIdentifier(array.get(i)));
- }
- mapHandler.endScope();
- }
-
- private void _handleType(SimpleMapHandler mapHandler, JSONObject jsonObj, boolean notNull) throws MIOException {
- String typeIRI = (String) jsonObj.get("type");
- if (typeIRI != null) {
- mapHandler.type(Ref.createItemIdentifier(typeIRI));
- }
- else if (notNull) {
- throw new MIOException("The type must not be null: " + jsonObj);
- }
- }
-
- private void _handleReifier(SimpleMapHandler mapHandler, JSONObject jsonObj) throws MIOException {
- String reifierIRI = (String) jsonObj.get("reifier");
- if (reifierIRI != null) {
- mapHandler.reifier(Ref.createItemIdentifier(reifierIRI));
- }
- }
-
- private void _handleItemIdentifiers(SimpleMapHandler mapHandler, JSONObject jsonObj) throws MIOException {
- List<String> iids = (List<String>)jsonObj.get("item_identifiers");
- if (iids != null) {
- int length = iids.size();
- for (int i=0; i<length; i++) {
- mapHandler.itemIdentifier(iids.get(i));
- }
- }
- }
-
}
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -56,7 +56,6 @@
private JSONWriter _out;
private String _baseIRI;
- private Topic _defaultNameType;
/**
* Creates a JTM writer, using "utf-8" encoding.
@@ -108,8 +107,8 @@
/* (non-Javadoc)
* @see org.tinytim.mio.TopicMapWriter#write(org.tmapi.core.TopicMap)
*/
+ @Override
public void write(TopicMap topicMap) throws IOException {
- _defaultNameType = topicMap.getTopicBySubjectIdentifier(TMDM.TOPIC_NAME);
_out.startDocument();
_out.startObject();
_writeReifier(topicMap);
@@ -152,19 +151,6 @@
* @throws IOException If an error occurs.
*/
private void _writeTopic(Topic topic) throws IOException {
- // Ignore the topic if it is the default name type and it has no further
- // characteristics
- if (_isDefaultNameType(topic)
- && topic.getReified() == null
- && topic.getSubjectIdentifiers().size() == 1
- && topic.getSubjectLocators().isEmpty()
- && topic.getItemIdentifiers().isEmpty()
- && topic.getRolesPlayed().isEmpty()
- && topic.getTypes().isEmpty()
- && topic.getNames().isEmpty()
- && topic.getOccurrences().isEmpty()) {
- return;
- }
_out.startObject();
_writeItemIdentifiers(topic);
_writeLocators("subject_identifiers", topic.getSubjectIdentifiers());
@@ -200,9 +186,7 @@
_out.startObject();
_writeReifier(name);
_writeItemIdentifiers(name);
- if (!_isDefaultNameType(name.getType())) {
- _writeType(name);
- }
+ _writeType(name);
_writeScope(name);
_writeKeyValue("value", name.getValue());
Set<Variant> variants = name.getVariants();
@@ -425,23 +409,17 @@
private String _topicRef(Topic topic) {
Set<Locator> locs = topic.getItemIdentifiers();
if (!locs.isEmpty()) {
- return locs.iterator().next().toExternalForm();
+ return "ii:" + locs.iterator().next().toExternalForm();
}
locs = topic.getSubjectIdentifiers();
if (!locs.isEmpty()) {
- return locs.iterator().next().toExternalForm();
+ return "si:" + locs.iterator().next().toExternalForm();
}
- return _baseIRI + "#" + topic.getId();
+ locs = topic.getSubjectLocators();
+ if (!locs.isEmpty()) {
+ return "sl:" + locs.iterator().next().toExternalForm();
+ }
+ return "ii:" + _baseIRI + "#" + topic.getId();
}
- /**
- * Checks if the specified <tt>topic</tt> is the default TMDM name type.
- *
- * @param topic The topic to check, not <tt>null</tt>.
- * @return <tt>true</tt> if the topic is the default name type, otherwise <tt>false</tt>.
- */
- private boolean _isDefaultNameType(final Topic topic) {
- return topic.equals(_defaultNameType);
- }
-
}
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/RDFTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -23,7 +23,7 @@
* define an external RDF to Topic Maps (RTM) mapping source.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public interface RDFTopicMapReader extends TopicMapReader {
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLTopicMapReader.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TMXMLTopicMapReader.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -96,7 +96,7 @@
* disable validation.
*/
public void setValidation(boolean validate) {
- _deserializer.setProperty(Property.VALIDATE, validate);
+ _deserializer.setProperty(Property.VALIDATE, Boolean.valueOf(validate));
}
/**
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/TinyTimMapInputHandler.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -216,7 +216,7 @@
IVariant variant = (IVariant) _leaveStatePopConstruct(VARIANT);
IName name = (IName) _peekConstruct();
IScope scope = variant.getScopeObject();
- if (scope.isUnconstrained() || name.getScopeObject() == scope) {
+ if (scope.isUnconstrained() || name.getScopeObject().equals(scope)) {
_reportError("The variant has no scope");
}
}
@@ -277,7 +277,7 @@
Locator sid = _tm.createLocator(subjectIdentifier);
ITopic topic = _peekTopic();
Topic existing = _tm.getTopicBySubjectIdentifier(sid);
- if (existing != null && !(existing == topic)) {
+ if (existing != null && !(existing.equals(topic))) {
_merge(existing, topic);
}
else {
@@ -296,7 +296,7 @@
Locator slo = _tm.createLocator(subjectLocator);
ITopic topic = _peekTopic();
Topic existing = _tm.getTopicBySubjectLocator(slo);
- if (existing != null && !(existing == topic)) {
+ if (existing != null && !(existing.equals(topic))) {
_merge(existing, topic);
}
topic.addSubjectLocator(slo);
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -39,6 +39,7 @@
private final String _encoding;
private int _depth;
+
private boolean _prettify;
public XMLWriter(OutputStream out) throws IOException {
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java 2009-02-20 13:05:54 UTC (rev 266)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XTM10TopicMapWriter.java 2009-02-24 13:56:47 UTC (rev 267)
@@ -80,25 +80,11 @@
super(out, baseIRI, encoding);
}
- private String _getId(Reifiable reifiable) {
- assert reifiable.getReifier() != null;
- return "reifier-id-" + reifiable.getReifier().getId();
- }
-
- private void _addId(AttributesImpl attrs, final Reifiable reifiable) {
- if (reifiable.getReifier() == null) {
- return;
- }
- attrs.addAttribute("", "id", "", "CDATA", _getId(reifiable));
- }
-
- private void _addLocator(AttributesImpl attrs, Locator loc) {
- attrs.addAttribute("", "xlink:href", "", "CDATA", loc.toExternalForm());
- }
-
+
/* (non-Javadoc)
* @see org.tinytim.mio.ITopicMapWriter#write(org.tmapi.core.TopicMap)
*/
+ @Override
public void write(final TopicMap topicMap) throws IOException {
_out.startDocument();
_attrs.clear();
@@ -116,6 +102,22 @@
_out.endDocument();
}
+ private String _getId(Reifiable reifiable) {
+ assert reifiable.getReifier() != null;
+ return "reifier-id-" + reifiable.getReifier().getId();
+ }
+
+ private void _addId(AttributesImpl attrs, final Reifiable reifiable) {
+ if (reifiable.getReifier() == null) {
+ return;
+ }
+ attrs.addAttribute("", "id", "", "CDATA", _getId(reifiable));
+ }
+
+ private void _addLocator(AttributesImpl attrs, Locator loc) {
+ attrs.addAttribute("", "xlink:href", "", "CDATA", loc.toExternalForm());
+ }
+
protected void _writeTopic(final Topic topic) throws IOException {
_attrs.clear();
_attrs.addAttribute("", "id", "", "CDATA", _getId(topic));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|