From: <lh...@us...> - 2009-03-04 14:25:27
|
Revision: 277 http://tinytim.svn.sourceforge.net/tinytim/?rev=277&view=rev Author: lheuer Date: 2009-03-04 14:25:20 +0000 (Wed, 04 Mar 2009) Log Message: ----------- - The JTMWriter omits the default name type topic if it has no further characteristics - The name type is omitted if it is the default name type Modified Paths: -------------- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java =================================================================== --- tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2009-03-03 15:00:25 UTC (rev 276) +++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/JTMTopicMapWriter.java 2009-03-04 14:25:20 UTC (rev 277) @@ -56,6 +56,7 @@ private JSONWriter _out; private String _baseIRI; + private Topic _defaultNameType; /** * Creates a JTM writer, using "utf-8" encoding. @@ -109,6 +110,7 @@ */ @Override public void write(TopicMap topicMap) throws IOException { + _defaultNameType = topicMap.getTopicBySubjectIdentifier(TMDM.TOPIC_NAME); _out.startDocument(); _out.startObject(); _writeKeyValue("version", "1.0"); @@ -153,6 +155,19 @@ * @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 (topic.equals(_defaultNameType) + && 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()); @@ -188,7 +203,9 @@ _out.startObject(); _writeReifier(name); _writeItemIdentifiers(name); - _writeType(name); + if (!name.getType().equals(_defaultNameType)) { + _writeType(name); + } _writeScope(name); _writeKeyValue("value", name.getValue()); Set<Variant> variants = name.getVariants(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |