You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by mo...@apache.org on 2012/01/10 17:32:33 UTC
svn commit: r1229627 [3/5] - in /incubator/any23/trunk: ./ any23-core/
any23-core/bin/ any23-core/src/main/java/org/deri/any23/
any23-core/src/main/java/org/deri/any23/cli/
any23-core/src/main/java/org/deri/any23/eval/
any23-core/src/main/java/org/deri...
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/Vocabulary.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/Vocabulary.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/Vocabulary.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/Vocabulary.java Tue Jan 10 16:32:28 2012
@@ -19,10 +19,17 @@ package org.deri.any23.vocab;
import org.deri.any23.rdf.RDFUtils;
import org.openrdf.model.URI;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.reflect.Field;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
* Base class for the definition of a vocabulary.
*
@@ -32,6 +39,16 @@ import java.util.Map;
public abstract class Vocabulary {
/**
+ * Allows to add comments to <code>namespaces</code>,
+ * <code>classes</code> and <code>properties</code>.
+ */
+ @Target({FIELD})
+ @Retention(RUNTIME)
+ @interface Comment {
+ String value();
+ }
+
+ /**
* Vocabulary namespace.
*/
private final URI namespace;
@@ -39,7 +56,7 @@ public abstract class Vocabulary {
/**
* Map of vocabulary resources.
*/
- private Map<String,URI> resources;
+ private Map<String,URI> classes;
/**
* Map of vocabulary properties.
@@ -47,6 +64,11 @@ public abstract class Vocabulary {
private Map<String,URI> properties;
/**
+ * Map any resource with the relative comment.
+ */
+ private Map<URI,String> resourceToCommentMap;
+
+ /**
* Constructor.
*
* @param namespace the namespace URI prefix.
@@ -67,13 +89,13 @@ public abstract class Vocabulary {
}
/**
- * Returns a resource defined within this vocabulary.
+ * Returns a class defined within this vocabulary.
*
- * @param name resource name.
+ * @param name class name.
* @return the URI associated to such resource.
*/
- public URI getResource(String name) {
- URI res = resources.get(name);
+ public URI getClass(String name) {
+ URI res = classes.get(name);
if (null == res) {
throw new IllegalArgumentException("Unknown resource name '" + name + "'");
}
@@ -118,7 +140,7 @@ public abstract class Vocabulary {
* @param property property name.
* @return property URI.
*/
- public URI getPropertyCamelized(String property) {
+ public URI getPropertyCamelCase(String property) {
String[] names = property.split("\\W");
String camelCase = names[0];
for (int i = 1; i < names.length; i++) {
@@ -129,13 +151,13 @@ public abstract class Vocabulary {
}
/**
- * @return the list of all defined resources.
+ * @return the list of all defined classes.
*/
- public URI[] getResources() {
- if(resources == null) {
+ public URI[] getClasses() {
+ if(classes == null) {
return new URI[0];
}
- final Collection<URI> uris = resources.values();
+ final Collection<URI> uris = classes.values();
return uris.toArray( new URI[ uris.size() ] );
}
@@ -151,6 +173,28 @@ public abstract class Vocabulary {
}
/**
+ * Returns all the defined comments for resources.
+ *
+ * @return unmodifiable list of comments.
+ */
+ public Map<URI,String> getComments() {
+ fillResourceToCommentMap();
+ return Collections.unmodifiableMap(resourceToCommentMap);
+ }
+
+ /**
+ * Returns the comment for the given resource.
+ *
+ * @param resource input resource to have a comment.
+ * @return the human readable comment associated to the
+ * given resource.
+ */
+ public String getCommentFor(URI resource) {
+ fillResourceToCommentMap();
+ return resourceToCommentMap.get(resource);
+ }
+
+ /**
* Creates a URI.
*
* @param uriStr the URI string
@@ -161,18 +205,18 @@ public abstract class Vocabulary {
}
/**
- * Creates a resource and register it to the {@link #resources} map.
+ * Creates a resource and register it to the {@link #classes} map.
*
* @param namespace vocabulary namespace.
* @param resource name of the resource.
* @return the created resource URI.
*/
- protected URI createResource(String namespace, String resource) {
+ protected URI createClass(String namespace, String resource) {
URI res = createURI(namespace, resource);
- if(resources == null) {
- resources = new HashMap<String, URI>(10);
+ if(classes == null) {
+ classes = new HashMap<String, URI>(10);
}
- resources.put(resource, res);
+ classes.put(resource, res);
return res;
}
@@ -203,4 +247,21 @@ public abstract class Vocabulary {
return RDFUtils.uri(namespace, localName);
}
+ private void fillResourceToCommentMap() {
+ if(resourceToCommentMap != null) return;
+ final Map<URI,String> newMap = new HashMap<URI, String>();
+ for (Field field : this.getClass().getFields()) {
+ try {
+ final Object value = field.get(this);
+ if(value instanceof URI) {
+ final Comment comment = field.getAnnotation(Comment.class);
+ if(comment != null) newMap.put((URI) value, comment.value());
+ }
+ } catch (IllegalAccessException iae) {
+ throw new RuntimeException("Error while creating resource to comment map.", iae);
+ }
+ }
+ resourceToCommentMap = newMap;
+ }
+
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/WO.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/WO.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/WO.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/vocab/WO.java Tue Jan 10 16:32:28 2012
@@ -42,24 +42,24 @@ public class WO extends Vocabulary {
/**
* The namespace of the vocabulary as a URI.
*/
- public final URI NAMESPACE = createResource(NS);
+ public final URI NAMESPACE = createURI(NS);
/**
* Generic class defining a biological species
*/
public final URI species = createProperty("species");
- public final URI kingdomClass = createResource("Kingdom");
+ public final URI kingdomClass = createClass("Kingdom");
- public final URI divisionClass = createResource("Division");
+ public final URI divisionClass = createClass("Division");
- public final URI phylumClass = createResource("Phylum");
+ public final URI phylumClass = createClass("Phylum");
- public final URI orderClass = createResource("Order");
+ public final URI orderClass = createClass("Order");
- public final URI genusClass = createResource("Genus");
+ public final URI genusClass = createClass("Genus");
- public final URI classClass = createResource("Class");
+ public final URI classClass = createClass("Class");
/**
* A family is a scientific grouping of closely related organisms.
@@ -67,7 +67,7 @@ public class WO extends Vocabulary {
* A family can have a lot of members or only a few.
* Examples of families include the cats (Felidae), the gulls (Laridae) and the grasses (Poaceae).
*/
- public final URI family = createResource("Family");
+ public final URI family = createClass("Family");
/**
* associates a taxon rank with a family
@@ -121,8 +121,8 @@ public class WO extends Vocabulary {
public final URI clazzName = createProperty("className");
- private URI createResource(String name) {
- return createResource(NS, name);
+ private URI createClass(String name) {
+ return createClass(NS, name);
}
private URI createProperty(String name) {
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/FormatWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/FormatWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/FormatWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/FormatWriter.java Tue Jan 10 16:32:28 2012
@@ -17,15 +17,24 @@
package org.deri.any23.writer;
/**
- * Base interface used for the definition of <i>formatted writers</i>.
+ * Base interface used for the definition of <i>RDF format writers</i>.
*/
public interface FormatWriter extends TripleHandler {
/**
- * The MIME type used by the writer.
+ * If <code>true</code> then the produced <b>RDF</b> is annotated with
+ * the extractors used to generate the specific statements.
*
- * @return a MIME type.
+ * @return the annotation flag value.
*/
- String getMIMEType();
-
+ boolean isAnnotated();
+
+ /**
+ * Sets the <i>annotation</i> flag.
+ *
+ * @param f If <code>true</code> then the produced <b>RDF</b> is annotated with
+ * the extractors used to generate the specific statements.
+ */
+ void setAnnotated(boolean f);
+
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/JSONWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/JSONWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/JSONWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/JSONWriter.java Tue Jan 10 16:32:28 2012
@@ -32,6 +32,7 @@ import java.io.PrintStream;
*
* @author Michele Mostarda (mostarda@fbk.eu)
*/
+@Writer(identifier = "json", mimeType = "text/json" )
public class JSONWriter implements FormatWriter {
private final PrintStream ps;
@@ -48,10 +49,6 @@ public class JSONWriter implements Forma
this.ps = new PrintStream(new BufferedOutputStream(os));
}
- public String getMIMEType() {
- return "text/json";
- }
-
public void startDocument(URI documentURI) throws TripleHandlerException {
if(documentStarted) {
throw new IllegalStateException("Document already started.");
@@ -217,4 +214,14 @@ public class JSONWriter implements Forma
ps.print("null");
}
}
+
+ @Override
+ public boolean isAnnotated() {
+ return false; // TODO: add annotation support.
+ }
+
+ @Override
+ public void setAnnotated(boolean f) {
+ // Empty.
+ }
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NQuadsWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NQuadsWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NQuadsWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NQuadsWriter.java Tue Jan 10 16:32:28 2012
@@ -23,14 +23,11 @@ import java.io.OutputStream;
*
* @author Michele Mostarda (mostarda@fbk.eu)
*/
+@Writer(identifier = "nquads", mimeType = "text/plain")
public class NQuadsWriter extends RDFWriterTripleHandler implements FormatWriter {
public NQuadsWriter(OutputStream os) {
- super( new org.deri.any23.parser.NQuadsWriter(os) );
- }
-
- public String getMIMEType() {
- return "text/plain";
+ super( new org.deri.any23.io.nquads.NQuadsWriter(os) );
}
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NTriplesWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NTriplesWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NTriplesWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/NTriplesWriter.java Tue Jan 10 16:32:28 2012
@@ -21,14 +21,11 @@ import java.io.OutputStream;
/**
* <i>N3</i> triples writer.
*/
+@Writer(identifier = "ntriples", mimeType = "text/plain")
public class NTriplesWriter extends RDFWriterTripleHandler implements FormatWriter {
public NTriplesWriter(OutputStream out) {
super(new org.openrdf.rio.ntriples.NTriplesWriter(out));
}
- public String getMIMEType() {
- return "text/plain";
- }
-
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFWriterTripleHandler.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFWriterTripleHandler.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFWriterTripleHandler.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFWriterTripleHandler.java Tue Jan 10 16:32:28 2012
@@ -21,7 +21,6 @@ import org.deri.any23.rdf.RDFUtils;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
-import org.openrdf.model.impl.ValueFactoryImpl;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFWriter;
@@ -31,13 +30,19 @@ import org.openrdf.rio.RDFWriter;
* eg for serialization using one of Sesame's writers.
*
* @author Richard Cyganiak (richard@cyganiak.de)
+ * @author Michele Mostarda (mostarda@fbk.eu)
*/
-class RDFWriterTripleHandler implements TripleHandler {
+public abstract class RDFWriterTripleHandler implements FormatWriter, TripleHandler {
private final RDFWriter writer;
private boolean closed = false;
+ /**
+ * The annotation flag.
+ */
+ private boolean annotated = false;
+
RDFWriterTripleHandler(RDFWriter destination) {
writer = destination;
try {
@@ -47,14 +52,39 @@ class RDFWriterTripleHandler implements
}
}
+ /**
+ * If <code>true</code> then the produced <b>RDF</b> is annotated with
+ * the extractors used to generate the specific statements.
+ *
+ * @return the annotation flag value.
+ */
+ @Override
+ public boolean isAnnotated() {
+ return annotated;
+ }
+
+ /**
+ * Sets the <i>annotation</i> flag.
+ *
+ * @param f If <code>true</code> then the produced <b>RDF</b> is annotated with
+ * the extractors used to generate the specific statements.
+ */
+ @Override
+ public void setAnnotated(boolean f) {
+ annotated = f;
+ }
+
+ @Override
public void startDocument(URI documentURI) throws TripleHandlerException {
// Empty.
}
+ @Override
public void openContext(ExtractionContext context) throws TripleHandlerException {
- // Empty.
+ handleComment( String.format("BEGIN: " + context) );
}
+ @Override
public void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context)
throws TripleHandlerException {
final URI graph = g == null ? context.getDocumentURI() : g;
@@ -69,6 +99,7 @@ class RDFWriterTripleHandler implements
}
}
+ @Override
public void receiveNamespace(String prefix, String uri, ExtractionContext context)
throws TripleHandlerException {
try {
@@ -80,10 +111,12 @@ class RDFWriterTripleHandler implements
}
}
+ @Override
public void closeContext(ExtractionContext context) throws TripleHandlerException {
- // Empty.
+ handleComment( String.format("END: " + context) );
}
+ @Override
public void close() throws TripleHandlerException {
if (closed) return;
closed = true;
@@ -94,12 +127,23 @@ class RDFWriterTripleHandler implements
}
}
+ @Override
public void endDocument(URI documentURI) throws TripleHandlerException {
// Empty.
}
+ @Override
public void setContentLength(long contentLength) {
// Empty.
}
-
+
+ private void handleComment(String comment) throws TripleHandlerException {
+ if( !annotated ) return;
+ try {
+ writer.handleComment(comment);
+ } catch (RDFHandlerException rdfhe) {
+ throw new TripleHandlerException("Error while handing comment.", rdfhe);
+ }
+ }
+
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFXMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFXMLWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFXMLWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/RDFXMLWriter.java Tue Jan 10 16:32:28 2012
@@ -21,14 +21,11 @@ import java.io.OutputStream;
/**
* <i>RDF/XML</i> writer implementation.
*/
+@Writer(identifier = "rdfxml", mimeType = "application/rdf+xml")
public class RDFXMLWriter extends RDFWriterTripleHandler implements FormatWriter {
public RDFXMLWriter(OutputStream out) {
super( new org.openrdf.rio.rdfxml.RDFXMLWriter(out) );
}
- public String getMIMEType() {
- return "application/rdf+xml";
- }
-
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/ReportingTripleHandler.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/ReportingTripleHandler.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/ReportingTripleHandler.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/ReportingTripleHandler.java Tue Jan 10 16:32:28 2012
@@ -58,6 +58,13 @@ public class ReportingTripleHandler impl
return totalDocuments;
}
+ /**
+ * @return a human readable report.
+ */
+ public String printReport() {
+ return String.format("Total Documents: %d, Total Triples: %d", getTotalDocuments(), getTotalTriples());
+ }
+
public void startDocument(URI documentURI) throws TripleHandlerException {
totalDocuments++;
wrapped.startDocument(documentURI);
Added: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TriXWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TriXWriter.java?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TriXWriter.java (added)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TriXWriter.java Tue Jan 10 16:32:28 2012
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008-2010 Digital Enterprise Research Institute (DERI)
+ *
+ * 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.deri.any23.writer;
+
+import java.io.OutputStream;
+
+/**
+ * <a href="http://www.w3.org/2004/03/trix/">TriX</a> format writer implementation.
+ *
+ * @author Michele Mostarda (mostarda@fbk.eu)
+ */
+@Writer(identifier = "trix", mimeType = "application/trix")
+public class TriXWriter extends RDFWriterTripleHandler implements FormatWriter {
+
+ public TriXWriter(OutputStream out) {
+ super( new org.openrdf.rio.trix.TriXWriter(out) );
+ }
+
+}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TurtleWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TurtleWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TurtleWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/TurtleWriter.java Tue Jan 10 16:32:28 2012
@@ -21,26 +21,16 @@ import java.io.OutputStream;
/**
* <i>N3</i> notation writer.
*/
+@Writer(identifier = "turtle", mimeType = "text/turtle")
public class TurtleWriter extends RDFWriterTripleHandler implements FormatWriter {
- private final boolean useN3;
-
/**
* Constructor.
*
* @param out stream to write on.
*/
public TurtleWriter(OutputStream out) {
- this(out, false);
- }
-
- public TurtleWriter(OutputStream out, boolean useN3) {
super(new org.openrdf.rio.turtle.TurtleWriter(out));
- this.useN3 = useN3;
}
- public String getMIMEType() {
- return useN3 ? "text/rdf+n3;charset=utf-8" : "text/turtle";
- }
-
}
Modified: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/URIListWriter.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/URIListWriter.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/URIListWriter.java (original)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/URIListWriter.java Tue Jan 10 16:32:28 2012
@@ -32,6 +32,7 @@ import java.util.List;
*
* @author Davide Palmisano (palmisano@fbk.eu)
*/
+@Writer(identifier = "uri", mimeType = "text/plain")
public class URIListWriter implements FormatWriter {
private List<Resource> resources;
@@ -47,10 +48,6 @@ public class URIListWriter implements Fo
this.printStream = new PrintStream(outputStream);
}
- public String getMIMEType() {
- return "text/plain";
- }
-
public void startDocument(URI documentURI) throws TripleHandlerException {}
public void openContext(ExtractionContext context) throws TripleHandlerException {
@@ -86,4 +83,14 @@ public class URIListWriter implements Fo
public void close() throws TripleHandlerException {
this.printStream.close();
}
+
+ @Override
+ public boolean isAnnotated() {
+ return false;
+ }
+
+ @Override
+ public void setAnnotated(boolean f) {
+ // Empty.
+ }
}
Added: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/Writer.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/Writer.java?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/Writer.java (added)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/Writer.java Tue Jan 10 16:32:28 2012
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2008-2010 Digital Enterprise Research Institute (DERI)
+ *
+ * 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.deri.any23.writer;
+
+/**
+ * This annotation describes {@link FormatWriter} metadata.
+ *
+ * @author Michele Mostarda (mostarda@fbk.eu)
+ */
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE})
+public @interface Writer {
+
+ /**
+ * The mnemonic identifier for the format.
+ *
+ * @return a not <code>null</code> identifier.
+ */
+ String identifier();
+
+ /**
+ * The MIME type used by the writer.
+ *
+ * @return a not <code>null</code> MIME type.
+ */
+ String mimeType();
+
+}
Added: incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/WriterRegistry.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/WriterRegistry.java?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/WriterRegistry.java (added)
+++ incubator/any23/trunk/any23-core/src/main/java/org/deri/any23/writer/WriterRegistry.java Tue Jan 10 16:32:28 2012
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2008-2010 Digital Enterprise Research Institute (DERI)
+ *
+ * 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.deri.any23.writer;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Registry class for {@link FormatWriter}s.
+ *
+ * @author Michele Mostarda (mostarda@fbk.eu)
+ */
+public class WriterRegistry {
+
+ /**
+ * Singleton instance.
+ */
+ private static WriterRegistry instance;
+
+ /**
+ * List of registered writers.
+ */
+ private final List<Class<? extends FormatWriter>> writers =
+ new ArrayList<Class<? extends FormatWriter>>();
+
+ /**
+ * MIME Type to {@link FormatWriter} class.
+ */
+ private final Map<String,List<Class<? extends FormatWriter>>> mimeToWriter =
+ new HashMap<String, List<Class<? extends FormatWriter>>>();
+
+ /**
+ * Identifier to {@link FormatWriter} class.
+ */
+ private final Map<String,Class<? extends FormatWriter>> idToWriter =
+ new HashMap<String, Class<? extends FormatWriter>>();
+
+ /**
+ * Reads the identifier specified for the given {@link FormatWriter}.
+ *
+ * @param writerClass writer class.
+ * @return identifier.
+ */
+ public static String getIdentifier(Class<? extends FormatWriter> writerClass) {
+ return getWriterAnnotation(writerClass).identifier();
+ }
+
+ /**
+ * Reads the <i>MIME Type</i> specified for the given {@link FormatWriter}.
+ *
+ * @param writerClass writer class.
+ * @return MIME type.
+ */
+ public static String getMimeType(Class<? extends FormatWriter> writerClass) {
+ return getWriterAnnotation(writerClass).mimeType();
+ }
+
+ /**
+ * @return the {@link WriterRegistry} singleton instance.
+ */
+ public synchronized static WriterRegistry getInstance() {
+ if(instance == null) {
+ instance = new WriterRegistry();
+ }
+ return instance;
+ }
+
+ /**
+ * Reads the annotation associated to the given {@link FormatWriter}.
+ *
+ * @param writerClass input class.
+ * @return associated annotation.
+ * @throws IllegalArgumentException if the annotation is not declared.
+ */
+ private static Writer getWriterAnnotation(Class<? extends FormatWriter> writerClass) {
+ final Writer writer = writerClass.getAnnotation(Writer.class);
+ if(writer == null)
+ throw new IllegalArgumentException(
+ String.format("Class %s must be annotated with %s .",writerClass, Writer.class)
+ );
+ return writer;
+ }
+
+ private WriterRegistry() {
+ register(TurtleWriter.class);
+ register(RDFXMLWriter.class);
+ register(NTriplesWriter.class);
+ register(NQuadsWriter.class);
+ register(TriXWriter.class);
+ register(JSONWriter.class);
+ register(URIListWriter.class);
+ }
+
+ /**
+ * Registers a new {@link FormatWriter} to the registry.
+ *
+ * @param writerClass the class of the writer to be registered.
+ * @throws IllegalArgumentException if the id or the mimetype are null
+ * or empty strings or if the identifier has been already defined.
+ */
+ public synchronized void register(Class<? extends FormatWriter> writerClass) {
+ if(writerClass == null) throw new NullPointerException("writerClass cannot be null.");
+ final Writer writer = getWriterAnnotation(writerClass);
+ final String id = writer.identifier();
+ final String mimeType = writer.mimeType();
+ if(id == null || id.trim().length() == 0) {
+ throw new IllegalArgumentException("Invalid identifier returned by writer " + writer);
+ }
+ if(mimeType == null || mimeType.trim().length() == 0) {
+ throw new IllegalArgumentException("Invalid MIME type returned by writer " + writer);
+ }
+ if(idToWriter.containsKey(id))
+ throw new IllegalArgumentException("The writer identifier is already declared.");
+
+ writers.add(writerClass);
+ List<Class<? extends FormatWriter>> writerClasses = mimeToWriter.get(mimeType);
+ if(writerClasses == null) {
+ writerClasses = new ArrayList<Class<? extends FormatWriter>>();
+ mimeToWriter.put(mimeType, writerClasses);
+ }
+ writerClasses.add(writerClass);
+ idToWriter.put(id, writerClass);
+ }
+
+ /**
+ * Verifies if a {@link FormatWriter} with given <code>id</code> identifier has been registered.
+ *
+ * @param id identifier.
+ * @return <code>true</code> if the identifier has been registered, <code>false</code> otherwise.
+ */
+ public synchronized boolean hasIdentifier(String id) {
+ return idToWriter.containsKey(id);
+ }
+
+ /**
+ * @return the list of all the specified identifiers.
+ */
+ public synchronized String[] getIdentifiers() {
+ final String[] ids = new String[writers.size()];
+ for (int i = 0; i < ids.length; i++) {
+ ids[i] = getIdentifier( writers.get(i) );
+ }
+ return ids;
+ }
+
+ /**
+ * @return the list of MIME types covered by the registered {@link FormatWriter}s.
+ */
+ public synchronized String[] getMimeTypes() {
+ return mimeToWriter.keySet().toArray( new String[mimeToWriter.keySet().size()] );
+ }
+
+ /**
+ * @return the list of all the registered {@link FormatWriter}s.
+ */
+ @SuppressWarnings("unchecked")
+ public synchronized Class<? extends FormatWriter>[] getWriters() {
+ return writers.toArray( new Class[ writers.size() ] );
+ }
+
+ /**
+ * Returns the {@link FormatWriter} identified by <code>id</code>.
+ *
+ * @param id the writer identifier.
+ * @return the class of the {@link FormatWriter} matching the <code>id</code>
+ * or <code>null</code> if not found.s
+ */
+ public synchronized Class<? extends FormatWriter> getWriterByIdentifier(String id) {
+ return idToWriter.get(id);
+ }
+
+ /**
+ * Returns all the writers matching the specified <code>mimeType</code>.
+ *
+ * @param mimeType a MIMEType.
+ * @return a list of matching writers or an empty list.
+ */
+ @SuppressWarnings("unchecked")
+ public synchronized Class<? extends FormatWriter>[] getWritersByMimeType(String mimeType) {
+ final List<Class<? extends FormatWriter>> writerClasses = mimeToWriter.get(mimeType);
+ return writerClasses.toArray( new Class[writerClasses.size()] );
+ }
+
+ /**
+ * Returns an instance of {@link FormatWriter} ready to write on the given <code>os</code>
+ * {@link OutputStream}.
+ *
+ * @param id the identifier of the {@link FormatWriter} to crate an instance.
+ * @param os the output stream.
+ * @return the not <code>null</code> {@link FormatWriter} instance.
+ * @throws NullPointerException if the <code>id</code> doesn't match any registered writer.
+ */
+ public synchronized FormatWriter getWriterInstanceByIdentifier(String id, OutputStream os) {
+ final Class<? extends FormatWriter> writerClazz = getWriterByIdentifier(id);
+ if(writerClazz == null)
+ throw new NullPointerException(
+ String.format("Cannot find writer with id '%s' .", id)
+ );
+ return createWriter(writerClazz, os);
+ }
+
+ /**
+ * Crates a writer instance.
+ *
+ * @param clazz class to instantiate.
+ * @param os output stream to pass as constructor argument.
+ * @return created instance.
+ * @throws IllegalArgumentException if an error occurs during instantiation.
+ */
+ private FormatWriter createWriter(Class<? extends FormatWriter> clazz, OutputStream os) {
+ try {
+ return clazz.getConstructor(OutputStream.class).newInstance(os);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Error while initializing format writer " + clazz + " .");
+ }
+ }
+
+}
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/csv/example-csv.csv
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/csv/example-csv.csv?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/csv/example-csv.csv (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/csv/example-csv.csv Tue Jan 10 16:32:28 2012
@@ -0,0 +1,3 @@
+Year,Make,Model,Length
+1997,Ford,E350,2.34
+2000,Mercury,Cougar,2.38
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-head-link.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-head-link.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-head-link.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-head-link.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,8 @@
+<html>
+<head>
+ <title>Head Link Document Example</title>
+ <link type="application/turtle" href="myfile1.ttl" rel="alternate" />
+ <link type="application/rdf+xml" href="myfile2.rdfxml" rel="alternate" />
+</head>
+<body>Document Content</body>
+</html>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-icbm.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-icbm.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-icbm.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-icbm.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,9 @@
+<html>
+<head>
+ <title>ICBM Document Example</title>
+ <meta name="geo.position" content="50.167958;-97.133185">
+ <meta name="geo.placename" content="Rockwood Rural Municipality, Manitoba, Canada">
+ <meta name="geo.region" content="ca-mb">
+</head>
+<body>Document Content</body>
+</html>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-adr.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-adr.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-adr.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-adr.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,8 @@
+<div class="adr">
+ <div class="street-address">665 3rd St.</div>
+ <div class="extended-address">Suite 207</div>
+ <span class="locality">San Francisco</span>,
+ <span class="region">CA</span>
+ <span class="postal-code">94107</span>
+ <div class="country-name">U.S.A.</div>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-geo.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-geo.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-geo.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-geo.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,4 @@
+<div class="geo">
+ <abbr class="latitude" title="37.408183">N 37° 24.491</abbr>
+ <abbr class="longitude" title="-122.13855">W 122° 08.313</abbr>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcalendar.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcalendar.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcalendar.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcalendar.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,9 @@
+<div class="vevent">
+ <h3 class="summary">XYZ Project Review</h3>
+ <p class="description">Project XYZ Review Meeting</p>
+ <p>To be held on <abbr class="dtstart" title="1998-03-12T08:30:00-05:00">12 March 1998 from 8:30am EST</abbr>
+ until <abbr class="dtend" title="1998-03-12T09:30:00-05:00">9:30am EST</abbr></p>
+ <p>Location: <span class="location">1CP Conference Room 4350</span></p>
+ <small>Booked by: <span class="uid">guid-1.host1.com</span> on
+ <abbr class="dtstamp" title="19980309T231000Z">9 Mar 1998 6:00pm</abbr></small>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcard.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcard.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcard.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hcard.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,20 @@
+<div class="vcard">
+ <a class="fn org url" href="http://www.commerce.net/">CommerceNet</a>
+ <div class="adr">
+ <span class="type">Work</span>:
+ <div class="street-address">169 University Avenue</div>
+ <span class="locality">Palo Alto</span>,
+ <abbr class="region" title="California">CA</abbr>
+ <span class="postal-code">94301</span>
+ <div class="country-name">USA</div>
+ </div>
+ <div class="tel">
+ <span class="type">Work</span> +1-650-289-4040
+ </div>
+ <div class="tel">
+ <span class="type">Fax</span> +1-650-289-4041
+ </div>
+ <div>Email:
+ <span class="email">info@commerce.net</span>
+ </div>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hlisting.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hlisting.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hlisting.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hlisting.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,24 @@
+<div class="hlisting">
+ <p>
+ <span class="item">
+ <span class="fn">Parking space</span>
+ </span>
+ <span class="offer rent">for rent</span>
+ (<abbr class="dtlisted" title="20060202">2/2/06</abbr>)
+ </p>
+ <p class="description">
+ 2 compact car spaces in a secure underground garage at:
+ <div class="location adr">
+ <span class="street-address">1738 Elm St.</span>
+ <span class="locality">Somewhere</span>, <span class="region">ED</span>
+ <span class="postal-code">34567</span> <span class="country">ISA</span>
+ </div>
+ Available in <abbr class="dtexpired" title="20060401">April 2006</abbr>
+ for <span class="price">$215/qtr</span>
+ </p>
+ <div class="lister vcard">
+ Please contact <span class="fn">John Broker</span> at
+ <span class="tel"><span class="value">(110) 555-1212</span>
+ (<abbr class="type" title="cell">C</abbr>)</span>
+ </div>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hrecipe.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hrecipe.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hrecipe.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hrecipe.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,53 @@
+<div class="hrecipe">
+ <h1 class="fn">Pommes Frites</h1>
+ <p class="summary">
+ Pommes frites originate in outer space. They are served hot.<br/>
+ This recipe is only an example. Don't try this at home!
+ </p>
+ <p>
+ Contributed by <span class="author">CJ Tom</span> and the
+ <span class="author vcard"><a class="url fn" href="http://example.com">Cooky Gang</a></span>.
+ </p>
+ <p>Published <span class="published"><span class="value-title" title="2008-10-14T10:05:37-01:00"> </span>14. Oct 2008</span>
+ </p>
+ <img src="/img/pommes.png" class="photo" width="100" height="100" alt="Pommes Frites"/>
+ <h2>Ingredients</h2>
+ <ul>
+ <li class="ingredient">
+ <span class="value">500</span>
+ <span class="type">gramme</span> potatoes, hard cooking.
+ </li>
+ <li class="ingredient">
+ <span class="value">1</span> <span class="type">spoonful</span> of salt
+ </li>
+ <li>
+ You may want to provide some
+ <span class="ingredient">Ketchup and Mayonnaise</span>
+ as well.
+ </li>
+ </ul>
+ <h2>Instructions</h2>
+ <ul class="instructions">
+ <li>First wash the potatoes.</li>
+ <li>Then slice and dice them and put them in boiling fat.</li>
+ <li>After a few minutes take them out again.</li>
+ </ul>
+ <h2>Further details</h2>
+ <p>Enough for <span class="yield">12 children</span>.</p>
+ <p>Preparation time is approximately
+ <span class="duration"><span class="value-title" title="PT1H30M"> </span>90 min</span>
+ </p>
+ <p>Add <span class="duration"><span class="value-title" title="PT30M"></span>half an hour</span> to prepare your
+ homemade Ketchup.</p>
+ <p>This recipe is <a href="http://www.example.com/tags/difficulty/easy" rel="tag">easy</a> and <a
+ href="http://www.example.com/tags/tastyness/delicious" rel="tag">delicious</a>.</p>
+ <p>
+ <span class="nutrition">
+ Pommes Frites have more than
+ <span class="value">1000</span>
+ <span class="type">Joule</span>
+ Energy</span>,
+ while Ketchup and Mayonnaise have
+ <span class="nutrition">0 vitamins</span>.
+ </p>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hresume.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hresume.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hresume.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hresume.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,58 @@
+<div class="hresume">
+ <div class="contact vcard">
+ <img src="/images/personal/emilyLewis.jpg" width="150" height="203" class="photo" alt="Emily Lewis"/>
+
+ <h2 class="fn n" id="emily-hcard-name"><span class="given-name">Emily</span> <span
+ class="additional-name">Paige</span> <span class="family-name">Lewis</span></h2>
+
+ <p class="adr"><span class="locality">Albuquerque</span>, <abbr class="region" title="New Mexico">NM</abbr>
+ <abbr> <span class="postal-code">87106</span></abbr>
+ <abbr class="country-name" title="United States of America">USA</abbr>
+ </p>
+ <ul>
+ <li><a href="mailto:eplewis@gmail.com" class="email">eplewis[at]gmail[dot]com</a></li>
+ <li><a href="http://www.emilylewisdesign.com/" class="url" rel="me">Design Portfolio</a></li>
+ <li><a href="http://www.linkedin.com/in/emilyplewis/" rel="me">LinkedIn profile</a></li>
+ </ul>
+ </div>
+ <h3>Highlights of Qualifications</h3>
+ <ul class="summary">
+ <li>Web designer specializing in hand-coded semantic XHTML, cross-browser CSS, progressive enhancement
+ accessibility and usability
+ </li>
+ <li>Expert in the design of corporate web sites, intranets, email campaigns and e-commerce applications</li>
+ </ul>
+ <h3>Technical Expertise</h3>
+ <h4>Web Design & Development</h4>
+ <ul>
+ <li><a href="http://technorati.com/tag/xhtml" class="skill" rel="tag">XHTML</a> â 9 yrs</li>
+ <li><a href="http://technorati.com/tag/css" class="skill" rel="tag">CSS</a> â 9 yrs</li>
+ </ul>
+ <h3>Experience & Accomplishments</h3>
+ <div class="vcalendar">
+ <div class="experience vevent vcard">
+ <a class="include nonVisual" href="#emily-hcard-name"></a>
+ <h4 class="title summary">Web Designer</h4>
+
+ <p class="org fn">Pitney Bowes Business Insight</p>
+
+ <p><abbr class="dtstart" title="2004-12-01">December 2004</abbr> â present</p>
+ <ul class="description">
+ <li>Designed interfaces and developed XHTML, CSS and graphics for main corporate site, international
+ sites, marketing newsletters, corporate blog, corporate intranet and user conference site
+ </li>
+ </ul>
+ </div>
+ </div>
+ <h3>Education</h3>
+ <div class="vcalendar">
+ <div class="education vevent vcard">
+ <h4 class="summary">Web Design & Development Certification</h4>
+ <p class="org fn"><a href="http://www.gwu.edu/index.cfm" class="url" title="Link opens off this site">George
+ Washington University</a>, Center for Professional Development</p>
+ <p><abbr class="dtstart" title="2001-09-01">September 2001</abbr>â<abbr class="dtend" title="2003-06-01">June
+ 2003</abbr></p>
+ <p>GPA 3.8</p>
+ </div>
+ </div>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hreview.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hreview.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hreview.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-hreview.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,17 @@
+<div class="hreview">
+ <span><span class="rating">5</span> out of 5 stars</span>
+ <h4 class="summary">Crepes on Cole is awesome</h4>
+ <span class="reviewer vcard">Reviewer: <span class="fn">Tantek</span> -
+ <abbr class="dtreviewed" title="20050418T2300-0700">April 18, 2005</abbr></span>
+ <div class="description item vcard"><p>
+ <span class="fn org">Crepes on Cole</span> is one of the best little
+ creperies in <span class="adr"><span class="locality">San Francisco</span></span>.
+ Excellent food and service. Plenty of tables in a variety of sizes
+ for parties large and small. Window seating makes for excellent
+ people watching to/from the N-Judah which stops right outside.
+ I've had many fun social gatherings here, as well as gotten
+ plenty of work done thanks to neighborhood WiFi.
+ </p></div>
+ <p>Visit date: <span>April 2005</span></p>
+ <p>Food eaten: <span>Florentine crepe</span></p>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-license.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-license.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-license.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-license.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,2 @@
+<a href="http://creativecommons.org/licenses/by/2.0/" rel="license">cc by 2.0</a>
+<a href="http://www.apache.org/licenses/LICENSE-2.0" rel="license">Apache 2.0</a>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-species.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-species.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-species.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-species.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,64 @@
+<table class="infobox biota" style="text-align: left; width: 200px">
+ <tr>
+ <th colspan="2" style="text-align: center; background-color: #90EE90">Oaks</th>
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: center"><a href="/wiki/File:Quercus_robur.jpg" class="image"><img
+ alt="Cluster of oak leaves and acorns."
+ src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Quercus_robur.jpg/220px-Quercus_robur.jpg"
+ width="220" height="298"/></a></td>
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: center; font-size: 88%">Foliage and acorns of the <a
+ href="/wiki/Pedunculate_Oak" title="Pedunculate Oak" class="mw-redirect">Pedunculate Oak</a>, <i>Quercus
+ robur</i></td>
+ </tr>
+ <tr>
+ <th colspan="2" style="text-align: center; background-color: #90EE90"><a href="/wiki/Biological_classification"
+ title="Biological classification">Scientific
+ classification</a></th>
+ </tr>
+ <tr>
+ <td>Kingdom:</td>
+ <td><span class="kingdom"><a href="/wiki/Plant" title="Plant">Plantae</a></span><br/></td>
+ </tr>
+ <tr>
+ <td>Division:</td>
+ <td><a href="/wiki/Angiospermae" title="Angiospermae" class="mw-redirect">Angiospermae</a><br/></td>
+ </tr>
+ <tr>
+
+ <td>(unranked):</td>
+ <td><a href="/wiki/Eudicots" title="Eudicots">Eudicots</a><br/></td>
+ </tr>
+ <tr>
+ <td>(unranked):</td>
+ <td><a href="/wiki/Rosids" title="Rosids">Rosids</a><br/></td>
+ </tr>
+ <tr>
+ <td>Order:</td>
+ <td><span class="order"><a href="/wiki/Fagales" title="Fagales">Fagales</a></span><br/></td>
+ </tr>
+
+ <tr>
+ <td>Family:</td>
+ <td><span class="family"><a href="/wiki/Fagaceae" title="Fagaceae">Fagaceae</a></span><br/></td>
+ </tr>
+ <tr>
+ <td>Genus:</td>
+ <td><span class="genus"><i><b>Quercus</b></i></span><br/>
+ <small><a href="/wiki/Carl_Linnaeus" title="Carl Linnaeus">L.</a></small>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="2" style="text-align: center; background-color: #90EE90"><a href="/wiki/Species" title="Species">Species</a>
+ </th>
+
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: left">
+ <p>See <a href="/wiki/List_of_Quercus_species" title="List of Quercus species">List of <i>Quercus</i>
+ species</a>.</p>
+ </td>
+ </tr>
+</table>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-xfn.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-xfn.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-xfn.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-mf-xfn.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,4 @@
+<a href="http://josh.example.com/" rel="friend met">Josh</a>
+<a href="http://kat.example.com/" rel="met acquaintance">Kat</a>
+<a href="http://mary.example.com/" rel="co-worker friend met">Mary</a>
+<a href="http://nick.example.com/">Nick</a>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-script-turtle.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-script-turtle.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-script-turtle.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/html/example-script-turtle.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,21 @@
+<html>
+<head>
+ <title>Turtle Embedded in HTML Example</title>
+ <script type="text/turtle"><![CDATA[
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix ex: <http://example.org/stuff/1.0/> .
+
+<http://www.w3.org/TR/rdf-syntax-grammar>
+ dc:title "RDF/XML Syntax Specification (Revised)" ;
+ ex:editor [
+ ex:fullname "Dave Beckett";
+ ex:homePage <http://purl.org/net/dajobe/>
+ ] .
+]]>
+ </script>
+</head>
+<body>
+Document body
+</body>
+</html>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/microdata/example-microdata.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/microdata/example-microdata.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/microdata/example-microdata.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/microdata/example-microdata.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,22 @@
+<div itemscope itemtype="http://schema.org/LocalBusiness">
+ <h1 itemprop="name">
+ Golden Key Mini Storage
+ </h1>
+ <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
+ <p itemprop="streetAddress">
+ 6725 Southwest Bradbury Court
+ </p>
+ <p>
+ <span itemprop="addressLocality">Lake Oswego</span>,
+ <span itemprop="addressRegion">OR</span>
+ <span itemprop="postalCode">97035</span>
+ </p>
+ </div>
+ <p itemprop="telephone">
+ (503) 639-1733
+ </p>
+ <p itemprop="url">
+ http://www.goldenkeyministorage.com/
+ </p>
+</div>
+</div>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdf/example-trix.trx
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdf/example-trix.trx?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdf/example-trix.trx (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdf/example-trix.trx Tue Jan 10 16:32:28 2012
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TriX xmlns="http://www.w3.org/2004/03/trix/trix-1/">
+ <graph>
+ <uri>http://example.org/graph1</uri>
+ <triple>
+ <uri>http://example.org/Bob</uri>
+ <uri>http://example.org/wife</uri>
+ <uri>http://example.org/Mary</uri>
+ </triple>
+ <triple>
+ <uri>http://example.org/Bob</uri>
+ <uri>http://example.org/name</uri>
+ <plainLiteral>Bob</plainLiteral>
+ </triple>
+ <triple>
+ <uri>http://example.org/Mary</uri>
+ <uri>http://example.org/age</uri>
+ <typedLiteral datatype="http://www.w3.org/2001/XMLSchema#integer">32</typedLiteral>
+ </triple>
+ </graph>
+</TriX>
\ No newline at end of file
Added: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdfa/example-rdfa11.html
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdfa/example-rdfa11.html?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdfa/example-rdfa11.html (added)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/extractor/rdfa/example-rdfa11.html Tue Jan 10 16:32:28 2012
@@ -0,0 +1,12 @@
+<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review">
+ <span property="v:itemreviewed">LâAmourita Pizza</span>
+ Reviewed by
+ <span property="v:reviewer">Ulysses Grant</span> on
+ <span property="v:dtreviewed" content="2009-01-06">Jan 6</span>.
+ <span property="v:summary">Delicious, tasty pizza on Eastlake!</span>
+ <span property="v:description">L'Amourita serves up traditional wood-fired
+ Neapolitan-style pizza, brought to your table promptly and without fuss.
+ An ideal neighborhood pizza joint.</span>
+ Rating:
+ <span property="v:rating">4.5</span>
+</div>
\ No newline at end of file
Modified: incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/mime/mimetypes.xml
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/mime/mimetypes.xml?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/mime/mimetypes.xml (original)
+++ incubator/any23/trunk/any23-core/src/main/resources/org/deri/any23/mime/mimetypes.xml Tue Jan 10 16:32:28 2012
@@ -69,14 +69,7 @@
<!-- BEGIN: Semantic Web document mime types. -->
- <!-- RSS -->
- <mime-type type="application/rss+xml">
- <alias type="text/rss"/>
- <root-XML localName="rss"/>
- <root-XML namespaceURI="http://purl.org/rss/1.0/"/>
- <glob pattern="*.rss"/>
- </mime-type>
-
+ <!-- N3 -->
<mime-type type="text/rdf+n3">
<alias type="text/n3"/>
<alias type="application/n3"/>
@@ -86,6 +79,7 @@
</magic>
</mime-type>
+ <!-- NQuads -->
<mime-type type="text/rdf+nq">
<alias type="text/nq"/>
<alias type="application/nq"/>
@@ -99,7 +93,7 @@
<glob pattern="*.ttl"/>
</mime-type>
- <!-- RDF -->
+ <!-- RDFXML -->
<mime-type type="application/rdf+xml">
<sub-class-of type="application/xml"/>
<root-XML localName="RDF"/>
@@ -120,6 +114,25 @@
<glob pattern="*.rdfx"/>
</mime-type>
+ <!-- TriX -->
+ <mime-type type="application/trix">
+ <sub-class-of type="application/xml"/>
+ <root-XML namespaceURI="http://www.w3.org/2004/03/trix/trix-1/" localName="TriX"/>
+ <root-XML localName="TriX"/>
+ <glob pattern="*.trx"/>
+ <glob pattern="*.trix"/>
+ </mime-type>
+
+ <!-- END Semantic Web document mime types. -->
+
+ <!-- RSS -->
+ <mime-type type="application/rss+xml">
+ <alias type="text/rss"/>
+ <root-XML localName="rss"/>
+ <root-XML namespaceURI="http://purl.org/rss/1.0/"/>
+ <glob pattern="*.rss"/>
+ </mime-type>
+
<!-- ATOM -->
<mime-type type="application/atom+xml">
<sub-class-of type="application/xml"/>
@@ -135,8 +148,8 @@
<root-XML namespaceURI="http://schemas.xmlsoap.org/wsdl/" localName="definitions"/>
<glob pattern="*.wsdl"/>
</mime-type>
- <!-- END Semantic Web document mime types. -->
+ <!-- HTML -->
<mime-type type="text/html">
<magic priority="50">
<match value="<!DOCTYPE HTML" type="string" offset="0:64"/>
@@ -161,6 +174,7 @@
<glob pattern="*.htm"/>
</mime-type>
+ <!-- XHTML -->
<mime-type type="application/xhtml+xml">
<sub-class-of type="application/xml"/>
<root-XML namespaceURI='http://www.w3.org/1999/xhtml'
@@ -658,43 +672,6 @@
-->
</mime-type>
- <!--
- <description>
- <mimeType>application/x-compress">
- <extensions>z" />
- <magicNumber encoding="hex">1f 9d 90</magicNumber>
- </mime-type>
-
- <description>
- <mimeType>application/bzip2">
- <extensions>bz2,tbz2" />
- <magicNumber encoding="hex">42 5a 68 39 31</magicNumber>
- </mime-type>
-
- <description>
- <mimeType>application/x-tar">
- <magicNumber encoding="string" offset="257">ustar</magicNumber>
- <extensions>tar" />
- </mime-type>
-
- <description>
- <mimeType>application/x-rar-compressed">
- <extensions>rar" />
- <magicNumber encoding="hex">52 61 72 21 1a</magicNumber>
- </mime-type>
-
- <description>
- <mimeType>application/stuffit">
- <extensions>sit" />
- <magicNumber encoding="string">SIT!</magicNumber>
- </mime-type>
-
- <description>
- <mimeType>application/binhex">
- <extensions>hqx" />
- </mime-type>
- -->
-
<mime-type type="audio/basic">
<glob pattern="*.au"/>
<glob pattern="*.snd"/>
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/Any23Test.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/Any23Test.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/Any23Test.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/Any23Test.java Tue Jan 10 16:32:28 2012
@@ -194,18 +194,18 @@ public class Any23Test extends Any23Onli
/*4*/ ByteArrayOutputStream out = new ByteArrayOutputStream();
/*5*/ TripleHandler handler = new NTriplesWriter(out);
try {
- /*6*/ runner.extract(source, handler);
+ /*6*/ runner.extract(source, handler);
} finally {
- /*7*/ handler.close();
+ /*7*/ handler.close();
}
- /*8*/ String n3 = out.toString("UTF-8");
+ /*8*/ String nt = out.toString("UTF-8");
/*
<http://example.org/ns#bar> <http://example.org/ns#> <http://other.example.org/ns#> .
<http://other.example.org/ns#bar> <http://other.example.org/ns#> <http://example.org/ns#bar> .
*/
- logger.debug("n3: " + n3);
- Assert.assertTrue(n3.length() > 0);
+ logger.debug("nt: " + nt);
+ Assert.assertTrue(nt.length() > 0);
}
/**
@@ -227,8 +227,11 @@ public class Any23Test extends Any23Onli
);
/*5*/ ByteArrayOutputStream out = new ByteArrayOutputStream();
/*6*/ TripleHandler handler = new NTriplesWriter(out);
- /*7*/ runner.extract(source, handler);
- /*8*/ handler.close();
+ try {
+ /*7*/ runner.extract(source, handler);
+ } finally {
+ /*8*/ handler.close();
+ }
/*9*/ String n3 = out.toString("UTF-8");
/*
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ExtractorDocumentationTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ExtractorDocumentationTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ExtractorDocumentationTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ExtractorDocumentationTest.java Tue Jan 10 16:32:28 2012
@@ -16,7 +16,6 @@
package org.deri.any23.cli;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -42,13 +41,13 @@ public class ExtractorDocumentationTest
runToolCheckExit0("-all");
}
- @Ignore("no available example")
+ //@Ignore("no available example")
@Test
public void testExampleInput() throws Exception {
runToolCheckExit0("-i", TARGET_EXTRACTOR);
}
- @Ignore("no available example")
+ //@Ignore("no available example")
@Test
public void testExampleOutput() throws Exception {
runToolCheckExit0("-o", TARGET_EXTRACTOR);
Added: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/MimeDetectorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/MimeDetectorTest.java?rev=1229627&view=auto
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/MimeDetectorTest.java (added)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/MimeDetectorTest.java Tue Jan 10 16:32:28 2012
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008-2010 Digital Enterprise Research Institute (DERI)
+ *
+ * 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.deri.any23.cli;
+
+import org.junit.Test;
+
+/**
+ * Test case for {@link MimeDetector} CLI.
+ *
+ * @author Michele Mostarda (mostarda@fbk.eu)
+ */
+public class MimeDetectorTest extends ToolTestBase {
+
+ public MimeDetectorTest() {
+ super(MimeDetector.class);
+ }
+
+ @Test
+ public void testDetectURL() throws Exception {
+ assumeOnlineAllowed();
+ runToolCheckExit0("http://twitter.com#micmos");
+ }
+
+ @Test
+ public void testDetectFile() throws Exception {
+ assumeOnlineAllowed();
+ runToolCheckExit0("file://./src/test/resources/application/trix/test1.trx");
+ }
+
+ @Test
+ public void testDetectInline() throws Exception {
+ assumeOnlineAllowed();
+ runToolCheckExit0( new String[] {"inline://<http://s> <http://p> <http://o> ."} );
+ }
+
+}
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ToolRunnerTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ToolRunnerTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ToolRunnerTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/cli/ToolRunnerTest.java Tue Jan 10 16:32:28 2012
@@ -20,6 +20,9 @@ import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
/**
* Test case for {@link ToolRunner}.
@@ -28,10 +31,20 @@ import java.io.IOException;
*/
public class ToolRunnerTest {
+ private final Set<Class<? extends Tool>> coreTools = new HashSet<Class<? extends Tool>>(){{
+ add(ExtractorDocumentation.class);
+ add(MicrodataParser.class);
+ add(MimeDetector.class);
+ add(PluginVerifier.class);
+ add(Rover.class);
+ add(Version.class);
+ add(VocabPrinter.class);
+ }};
+
@Test
public void testGetToolsInClasspath() throws IOException {
Class<Tool>[] tools = ToolRunner.getToolsInClasspath();
- Assert.assertEquals(7, tools.length);
+ Assert.assertTrue("Some core tools have not been detected.", coreTools.containsAll(Arrays.asList(tools)));
}
}
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/csv/CSVExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/csv/CSVExtractorTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/csv/CSVExtractorTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/csv/CSVExtractorTest.java Tue Jan 10 16:32:28 2012
@@ -45,36 +45,55 @@ public class CSVExtractorTest extends Ab
public void testExtractionCommaSeparated() throws RepositoryException {
CSV csv = CSV.getInstance();
assertExtracts("org/deri/any23/extractor/csv/test-comma.csv");
+ logger.debug(dumpModelToRDFXML());
+
assertModelNotEmpty();
assertStatementsSize(null, null, null, 28);
assertStatementsSize(null, RDF.TYPE, csv.rowType, 3);
assertContains(null, csv.numberOfColumns, new LiteralImpl("4", XMLSchema.INTEGER));
assertContains(null, csv.numberOfRows, new LiteralImpl("3", XMLSchema.INTEGER));
- logger.debug(dumpModelToRDFXML());
}
@Test
public void testExtractionSemicolonSeparated() throws RepositoryException {
CSV csv = CSV.getInstance();
assertExtracts("org/deri/any23/extractor/csv/test-semicolon.csv");
+ logger.debug(dumpModelToRDFXML());
+
assertModelNotEmpty();
assertStatementsSize(null, null, null, 28);
assertStatementsSize(null, RDF.TYPE, csv.rowType, 3);
assertContains(null, csv.numberOfColumns, new LiteralImpl("4", XMLSchema.INTEGER));
assertContains(null, csv.numberOfRows, new LiteralImpl("3", XMLSchema.INTEGER));
- logger.debug(dumpModelToRDFXML());
}
@Test
public void testExtractionTabSeparated() throws RepositoryException {
CSV csv = CSV.getInstance();
assertExtracts("org/deri/any23/extractor/csv/test-tab.csv");
+ logger.debug(dumpModelToRDFXML());
+
assertModelNotEmpty();
assertStatementsSize(null, null, null, 28);
assertStatementsSize(null, RDF.TYPE, csv.rowType, 3);
assertContains(null, csv.numberOfColumns, new LiteralImpl("4", XMLSchema.INTEGER));
assertContains(null, csv.numberOfRows, new LiteralImpl("3", XMLSchema.INTEGER));
+ }
+
+ @Test
+ public void testTypeManagement() throws RepositoryException {
+ CSV csv = CSV.getInstance();
+ assertExtracts("org/deri/any23/extractor/csv/test-type.csv");
logger.debug(dumpModelToRDFXML());
+
+ assertModelNotEmpty();
+ assertStatementsSize(null, null, null, 21);
+ assertStatementsSize(null, RDF.TYPE, csv.rowType, 3);
+ assertContains(null, csv.numberOfColumns, new LiteralImpl("2", XMLSchema.INTEGER));
+ assertContains(null, csv.numberOfRows, new LiteralImpl("3", XMLSchema.INTEGER));
+ assertContains(null, null, new LiteralImpl("5.2", XMLSchema.FLOAT));
+ assertContains(null, null, new LiteralImpl("7.9", XMLSchema.FLOAT));
+ assertContains(null, null, new LiteralImpl("10" , XMLSchema.INTEGER));
}
}
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/AbstractExtractorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/AbstractExtractorTestCase.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/AbstractExtractorTestCase.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/AbstractExtractorTestCase.java Tue Jan 10 16:32:28 2012
@@ -21,7 +21,7 @@ import org.deri.any23.extractor.Extracti
import org.deri.any23.extractor.ExtractorFactory;
import org.deri.any23.extractor.SingleDocumentExtraction;
import org.deri.any23.extractor.SingleDocumentExtractionReport;
-import org.deri.any23.parser.NQuadsWriter;
+import org.deri.any23.io.nquads.NQuadsWriter;
import org.deri.any23.rdf.RDFUtils;
import org.deri.any23.vocab.SINDICE;
import org.deri.any23.writer.RepositoryWriter;
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/HTMLMetaExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/HTMLMetaExtractorTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/HTMLMetaExtractorTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/html/HTMLMetaExtractorTest.java Tue Jan 10 16:32:28 2012
@@ -19,7 +19,6 @@ package org.deri.any23.extractor.html;
import org.deri.any23.extractor.ExtractorFactory;
import org.deri.any23.vocab.SINDICE;
import org.junit.Test;
-import org.openrdf.model.Value;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.repository.RepositoryException;
@@ -73,13 +72,13 @@ public class HTMLMetaExtractorTest exten
);
assertContains(
new URIImpl("http://bob.example.com/"),
- new URIImpl("http://vocab.sindice.net/robots"),
+ new URIImpl(vSINDICE.NAMESPACE.toString() + "robots"),
"index, follow",
"en"
);
assertContains(
new URIImpl("http://bob.example.com/"),
- new URIImpl("http://vocab.sindice.net/content-language"),
+ new URIImpl(vSINDICE.NAMESPACE.toString() + "content-language"),
"en",
"en"
);
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/microdata/MicrodataExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/microdata/MicrodataExtractorTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/microdata/MicrodataExtractorTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/microdata/MicrodataExtractorTest.java Tue Jan 10 16:32:28 2012
@@ -4,7 +4,7 @@ import org.apache.log4j.Logger;
import org.deri.any23.extractor.ExtractionException;
import org.deri.any23.extractor.ExtractorFactory;
import org.deri.any23.extractor.html.AbstractExtractorTestCase;
-import org.deri.any23.parser.NQuadsParser;
+import org.deri.any23.io.nquads.NQuadsParser;
import org.deri.any23.vocab.SINDICE;
import org.junit.Assert;
import org.junit.Test;
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ExtractorTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ExtractorTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ExtractorTest.java Tue Jan 10 16:32:28 2012
@@ -17,9 +17,11 @@
package org.deri.any23.extractor.rdfa;
import org.deri.any23.extractor.ErrorReporter;
+import org.deri.any23.extractor.ExtractionException;
import org.deri.any23.extractor.ExtractorFactory;
import org.deri.any23.rdf.RDFUtils;
import org.deri.any23.vocab.FOAF;
+import org.deri.any23.vocab.OGP;
import org.junit.Assert;
import org.junit.Test;
import org.openrdf.model.Literal;
@@ -195,6 +197,37 @@ public class RDFa11ExtractorTest extends
assertContainsModel("/html/rdfa/goodrelations-rdfa10-expected.nq");
}
+ /**
+ * Tests the correct support of the new <em>Open Graph Protocol</em>
+ * <a href="http://ogp.me/#structured">Structured Properties</a>.
+ *
+ * @throws IOException
+ * @throws org.deri.any23.extractor.ExtractionException
+ * @throws RepositoryException
+ */
+ @Test
+ public void testOpenGraphStructuredProperties() throws IOException, ExtractionException, RepositoryException {
+ assertExtracts("html/rdfa/opengraph-structured-properties.html");
+ logger.info( dumpHumanReadableTriples() );
+
+ Assert.assertEquals(8, getStatementsSize(null, null, null) );
+ final OGP vOGP = OGP.getInstance();
+ assertContains(baseURI, vOGP.audio, RDFUtils.literal("http://example.com/bond/theme.mp3") );
+ assertContains(
+ baseURI,
+ vOGP.description,
+ RDFUtils.literal(
+ "Sean Connery found fame and fortune as the suave, sophisticated British agent, James Bond."
+ )
+ );
+ assertContains(baseURI, vOGP.determiner, RDFUtils.literal("the") );
+ assertContains(baseURI, vOGP.locale, RDFUtils.literal("en_UK") );
+ assertContains(baseURI, vOGP.localeAlternate, RDFUtils.literal("fr_FR") );
+ assertContains(baseURI, vOGP.localeAlternate, RDFUtils.literal("es_ES") );
+ assertContains(baseURI, vOGP.siteName, RDFUtils.literal("IMDb") );
+ assertContains(baseURI, vOGP.video, RDFUtils.literal("http://example.com/bond/trailer.swf") );
+ }
+
@Override
protected ExtractorFactory<?> getExtractorFactory() {
return RDFa11Extractor.factory;
Modified: incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ParserTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ParserTest.java?rev=1229627&r1=1229626&r2=1229627&view=diff
==============================================================================
--- incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ParserTest.java (original)
+++ incubator/any23/trunk/any23-core/src/test/java/org/deri/any23/extractor/rdfa/RDFa11ParserTest.java Tue Jan 10 16:32:28 2012
@@ -31,6 +31,18 @@ public class RDFa11ParserTest {
}
@Test
+ public void testExtractPrefixSections() {
+ final String[] sections = RDFa11Parser.extractPrefixSections("p1:v1 p2: v2 p3: v3\np4:v4 p5: v5");
+ Assert.assertEquals(5, sections.length);
+ int i = 0;
+ Assert.assertEquals("p1:v1", sections[i++]);
+ Assert.assertEquals("p2:v2", sections[i++]);
+ Assert.assertEquals("p3:v3", sections[i++]);
+ Assert.assertEquals("p4:v4", sections[i++]);
+ Assert.assertEquals("p5:v5", sections[i]);
+ }
+
+ @Test
public void testIsCURIEPositive() {
Assert.assertTrue( RDFa11Parser.isCURIE("[dbr:Albert_Einstein]") );
}