|
From: <lh...@us...> - 2009-03-10 14:27:17
|
Revision: 284
http://tinytim.svn.sourceforge.net/tinytim/?rev=284&view=rev
Author: lheuer
Date: 2009-03-10 14:27:07 +0000 (Tue, 10 Mar 2009)
Log Message:
-----------
- XMLWriter adds newline even even if depth == 0 if prettify is enabled
- AbstractTopicMapReader: added method which gets called if parsing was successful
- LTMTopicMapReader: Added configurable reifier handling, added docs
- LTM lib: Added configurable reifier handling
- XTM lib: Fixed XTM 1.0 mergeMap bug (mergeMap works now)
- MIO lib: Changed some internals but it is binary compatible to 0.9.3
Modified Paths:
--------------
tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java
tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java
Added Paths:
-----------
tinytim-mio/trunk/lib/semagia-mio-0.9.4.jar
tinytim-mio/trunk/lib/semagia-mio-ltm-0.9.4.jar
tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.4.jar
Removed Paths:
-------------
tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar
tinytim-mio/trunk/lib/semagia-mio-ltm-0.9.3.jar
tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3-sp1.jar
Deleted: tinytim-mio/trunk/lib/semagia-mio-0.9.3.jar
===================================================================
(Binary files differ)
Added: tinytim-mio/trunk/lib/semagia-mio-0.9.4.jar
===================================================================
(Binary files differ)
Property changes on: tinytim-mio/trunk/lib/semagia-mio-0.9.4.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: tinytim-mio/trunk/lib/semagia-mio-ltm-0.9.3.jar
===================================================================
(Binary files differ)
Added: tinytim-mio/trunk/lib/semagia-mio-ltm-0.9.4.jar
===================================================================
(Binary files differ)
Property changes on: tinytim-mio/trunk/lib/semagia-mio-ltm-0.9.4.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.3-sp1.jar
===================================================================
(Binary files differ)
Added: tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.4.jar
===================================================================
(Binary files differ)
Property changes on: tinytim-mio/trunk/lib/semagia-mio-xtm-0.9.4.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2009-03-09 13:59:35 UTC (rev 283)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/AbstractTopicMapReader.java 2009-03-10 14:27:07 UTC (rev 284)
@@ -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.
@@ -129,6 +129,7 @@
public void read() throws IOException {
try {
_deserializer.parse(_source);
+ postProcess();
}
catch (MIOException ex) {
if (ex.getException() instanceof IOException) {
@@ -142,4 +143,14 @@
_deserializer = null;
}
}
+
+ /**
+ * Called if parsing has been finished without errors, does nothing by default.
+ * <p>
+ * The {@link #_deserializer} is still available.
+ * </p>
+ */
+ protected void postProcess() {
+ // noop.
+ }
}
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java 2009-03-09 13:59:35 UTC (rev 283)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/LTMTopicMapReader.java 2009-03-10 14:27:07 UTC (rev 284)
@@ -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.
@@ -21,6 +21,7 @@
import org.tmapi.core.TopicMap;
+import com.semagia.mio.Property;
import com.semagia.mio.Source;
import com.semagia.mio.Syntax;
@@ -41,6 +42,10 @@
* specified after an subject locator (if given); this implementation
* does not mandate any order; a subject locator may be followed by an
* subject identifier etc.</li>
+ * <li>Reification is handled directly without adding an additional item
+ * identifier to the reified construct and without adding an additional
+ * subject identifier to the reifier (unless this "feature" is enabled
+ * explicitely; c.f. {@link #setLegacyReifierHandling(boolean)}</li>
* </ul>
* </p>
*
@@ -100,49 +105,31 @@
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() {
-// return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_MERGEMAP));
-// }
+ /**
+ * Indicates if reified construct should receive an item identifier of the
+ * form <tt>uri-of-file#--reified--id</tt> and the reifying topic should
+ * receive a subject identifier of the same form.
+ * <p>
+ * By default this "feature" is disabled; the parser sets [reifier] property
+ * of the reified construct and does not add any additional IRIs. To be
+ * conform to the LTM specification, this feature has to be enabled even if
+ * it adds no value.
+ * </p>
+ *
+ * @param enable <tt>true</tt> to enable the legacy mode, otherwise <tt>false</tt>.
+ */
+ public void setLegacyReifierHandling(boolean enable) {
+ _deserializer.setProperty(Property.XTM_10_LEGACY, Boolean.valueOf(enable));
+ }
-// /**
-// * 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() {
-// return Boolean.TRUE.equals(_deserializer.getProperty(Property.IGNORE_INCLUDE));
-// }
+ /**
+ * Indicates if the parser handles the reification of constructs in a legacy
+ * way.
+ *
+ * @return <tt>true</tt> if the parser is in legacy mode, otherwise <tt>false</tt>.
+ */
+ public boolean getLegacyReifierHandling() {
+ return Boolean.TRUE.equals(_deserializer.getProperty(Property.XTM_10_LEGACY));
+ }
+
}
Modified: tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java
===================================================================
--- tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2009-03-09 13:59:35 UTC (rev 283)
+++ tinytim-mio/trunk/src/main/java/org/tinytim/mio/XMLWriter.java 2009-03-10 14:27:07 UTC (rev 284)
@@ -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.
@@ -68,7 +68,9 @@
_out.write("\" standalone=\"yes\"?>");
_newline();
_out.write("<!-- Generated by tinyTiM - http://tinytim.sourceforge.net/ -->");
- _newline();
+ if (!_prettify) {
+ _newline();
+ }
_depth = 0;
}
@@ -85,6 +87,9 @@
}
}
+ /**
+ * Writes an element start with no attributes.
+ */
public void startElement(String name) throws IOException {
startElement(name, EMPTY_ATTRS);
}
@@ -108,10 +113,7 @@
_endElement(name, true);
}
- /**
- * @see org.xml.sax.DocumentHandler#endElement(java.lang.String)
- */
- public void _endElement(String name, boolean indent) throws IOException {
+ private void _endElement(String name, boolean indent) throws IOException {
_depth--;
if (indent) {
_indent();
@@ -139,7 +141,7 @@
_endElement(name, false);
}
- public void _writeAttributes(Attributes attrs) throws IOException {
+ private void _writeAttributes(Attributes attrs) throws IOException {
char[] chars;
for (int i=0; i < attrs.getLength(); i++) {
_out.write(' ');
@@ -164,9 +166,7 @@
if (!_prettify) {
return;
}
- if (_depth > 0) {
- _newline();
- }
+ _newline();
int indent = _depth*2;
char[] chars = new char[indent];
for (int i=0; i<indent; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|