Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NQuadsWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NQuadsWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NQuadsWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NQuadsWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class NQuadsWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "text/plain"; + public static final String IDENTIFIER = "nquads"; + + /** + * + */ + public NQuadsWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + return RDFFormat.NQUADS; + } + + @Override + public String getIdentifier() { + return NQuadsWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return NQuadsWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new NQuadsWriter(os); + } + +}
Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriter.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriter.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriter.java (original) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriter.java Mon Aug 13 06:15:29 2012 @@ -22,7 +22,6 @@ 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) { Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/NTriplesWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class NTriplesWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "text/plain"; + public static final String IDENTIFIER = "ntriples"; + + /** + * + */ + public NTriplesWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + return RDFFormat.NTRIPLES; + } + + @Override + public String getIdentifier() { + return NTriplesWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return NTriplesWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new NTriplesWriter(os); + } + +} Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriter.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriter.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriter.java (original) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriter.java Mon Aug 13 06:15:29 2012 @@ -22,7 +22,6 @@ 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) { Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/RDFXMLWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class RDFXMLWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "application/rdf+xml"; + public static final String IDENTIFIER = "rdfxml"; + + /** + * + */ + public RDFXMLWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + return RDFFormat.RDFXML; + } + + @Override + public String getIdentifier() { + return RDFXMLWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return RDFXMLWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new RDFXMLWriter(os); + } + +} Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriter.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriter.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriter.java (original) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriter.java Mon Aug 13 06:15:29 2012 @@ -24,7 +24,6 @@ import java.io.OutputStream; * * @author Michele Mostarda ([email protected]) */ -@Writer(identifier = "trix", mimeType = "application/trix") public class TriXWriter extends RDFWriterTripleHandler implements FormatWriter { public TriXWriter(OutputStream out) { Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TriXWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class TriXWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "application/trix"; + public static final String IDENTIFIER = "trix"; + + /** + * + */ + public TriXWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + return RDFFormat.TRIX; + } + + @Override + public String getIdentifier() { + return TriXWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return TriXWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new TriXWriter(os); + } + +} Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriter.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriter.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriter.java (original) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriter.java Mon Aug 13 06:15:29 2012 @@ -22,7 +22,6 @@ import java.io.OutputStream; /** * <i>N3</i> notation writer. */ -@Writer(identifier = "turtle", mimeType = "text/turtle") public class TurtleWriter extends RDFWriterTripleHandler implements FormatWriter { /** Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/TurtleWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class TurtleWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "text/turtle"; + public static final String IDENTIFIER = "turtle"; + + /** + * + */ + public TurtleWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + return RDFFormat.TURTLE; + } + + @Override + public String getIdentifier() { + return TurtleWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return TurtleWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new TurtleWriter(os); + } + +} Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriter.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriter.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriter.java (original) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriter.java Mon Aug 13 06:15:29 2012 @@ -33,7 +33,6 @@ import java.util.List; * * @author Davide Palmisano ([email protected]) */ -@Writer(identifier = "uri", mimeType = "text/plain") public class URIListWriter implements FormatWriter { private List<Resource> resources; Added: incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriterFactory.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriterFactory.java?rev=1372269&view=auto ============================================================================== --- incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriterFactory.java (added) +++ incubator/any23/trunk/core/src/main/java/org/apache/any23/writer/URIListWriterFactory.java Mon Aug 13 06:15:29 2012 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.any23.writer; + +import java.io.OutputStream; + +import org.kohsuke.MetaInfServices; +import org.openrdf.rio.RDFFormat; + +/** + * @author Peter Ansell [email protected] + * + */ +@MetaInfServices +public class URIListWriterFactory implements WriterFactory { + + public static final String MIME_TYPE = "text/plain"; + public static final String IDENTIFIER = "uri"; + + /** + * + */ + public URIListWriterFactory() { + } + + @Override + public RDFFormat getRdfFormat() { + throw new RuntimeException("This writer does not print RDF triples"); + } + + @Override + public String getIdentifier() { + return URIListWriterFactory.IDENTIFIER; + } + + @Override + public String getMimeType() { + return URIListWriterFactory.MIME_TYPE; + } + + @Override + public FormatWriter getRdfWriter(OutputStream os) { + return new URIListWriter(os); + } + +} Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/AbstractAny23TestBase.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/AbstractAny23TestBase.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/test/java/org/apache/any23/AbstractAny23TestBase.java (original) +++ incubator/any23/trunk/core/src/test/java/org/apache/any23/AbstractAny23TestBase.java Mon Aug 13 06:15:29 2012 @@ -30,67 +30,70 @@ import org.junit.Rule; import org.junit.rules.TemporaryFolder; /** - * This file encapsulates access to test resource files using temporary files that are automatically - * cleaned up by JUnit after each test. + * This file encapsulates access to test resource files using temporary files + * that are automatically cleaned up by JUnit after each test. * * @author Peter Ansell [email protected] */ -public class AbstractAny23TestBase -{ - +public class AbstractAny23TestBase { + @Rule public TemporaryFolder testFolder = new TemporaryFolder(); protected File tempDirectory; - - public AbstractAny23TestBase() - { + + public AbstractAny23TestBase() { super(); } - + @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { tempDirectory = testFolder.newFolder(); } - - protected DocumentSource getDocumentSourceFromResource(String resourceLocation) throws IOException - { + + protected DocumentSource getDocumentSourceFromResource( + String resourceLocation) throws IOException { return new FileDocumentSource(copyResourceToTempFile(resourceLocation)); } - - protected DocumentSource getDocumentSourceFromResource(String resourceLocation, String baseUri) throws IOException - { - return new FileDocumentSource(copyResourceToTempFile(resourceLocation), baseUri); + + protected DocumentSource getDocumentSourceFromResource( + String resourceLocation, String baseUri) throws IOException { + return new FileDocumentSource(copyResourceToTempFile(resourceLocation), + baseUri); } - + /** - * Copies a resource to a temporary directory and returns a file handle that can be used to - * access the resource as a file from the temp directory. + * Copies a resource to a temporary directory and returns a file handle that + * can be used to access the resource as a file from the temp directory. * * @param resourceLocation - * The absolute location of the resource in the classpath, which can be used with - * this.getClass().getResourceAsStream. + * The absolute location of the resource in the classpath, which + * can be used with this.getClass().getResourceAsStream. * @return * @throws FileNotFoundException * @throws IOException */ - protected File copyResourceToTempFile(String resourceLocation) throws FileNotFoundException, IOException - { - Assert.assertNotNull("Temporary directory was null. Did you forget to call super.setUp() to initialise it?", + protected File copyResourceToTempFile(String resourceLocation) + throws FileNotFoundException, IOException { + Assert.assertNotNull( + "Temporary directory was null. Did you forget to call super.setUp() to initialise it?", + tempDirectory); + String fileEnding = resourceLocation.substring(resourceLocation + .lastIndexOf("/") + 1); + + File tempFile = File.createTempFile("any23test-", "-" + fileEnding, tempDirectory); - String fileEnding = resourceLocation.substring(resourceLocation.lastIndexOf("/") + 1); - - File tempFile = File.createTempFile("any23test-", "-" + fileEnding, tempDirectory); - + FileOutputStream output = new FileOutputStream(tempFile); - - InputStream input = this.getClass().getResourceAsStream(resourceLocation); - - Assert.assertNotNull("Test resource was not found: " + resourceLocation, input); - + + InputStream input = this.getClass().getResourceAsStream( + resourceLocation); + + Assert.assertNotNull( + "Test resource was not found: " + resourceLocation, input); + IOUtils.copy(input, output); - + return tempFile; } - + } \ No newline at end of file Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/SingleDocumentExtractionTest.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/SingleDocumentExtractionTest.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/SingleDocumentExtractionTest.java (original) +++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/SingleDocumentExtractionTest.java Mon Aug 13 06:15:29 2012 @@ -87,7 +87,7 @@ public class SingleDocumentExtractionTes @Before public void setUp() throws Exception { super.setUp(); - extractorGroup = ExtractorRegistry.getInstance().getExtractorGroup(); + extractorGroup = ExtractorRegistryImpl.getInstance().getExtractorGroup(); store = new MemoryStore(); store.initialize(); conn = new SailRepository(store).getConnection(); Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/writer/WriterRegistryTest.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/writer/WriterRegistryTest.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/core/src/test/java/org/apache/any23/writer/WriterRegistryTest.java (original) +++ incubator/any23/trunk/core/src/test/java/org/apache/any23/writer/WriterRegistryTest.java Mon Aug 13 06:15:29 2012 @@ -22,7 +22,9 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; /** @@ -34,34 +36,34 @@ public class WriterRegistryTest { private static final int NUM_OF_WRITERS = 7; - private final WriterRegistry target = WriterRegistry.getInstance(); + private final WriterFactoryRegistry target = WriterFactoryRegistry.getInstance(); @Test public void testGetIdentifiers() { - final String[] ids = target.getIdentifiers(); - Assert.assertTrue(ids.length >= NUM_OF_WRITERS); + final List<String> ids = target.getIdentifiers(); + Assert.assertTrue(ids.size() >= NUM_OF_WRITERS); assertUnique(ids); } @Test public void testHasIdentifier() { - Assert.assertTrue( target.hasIdentifier( target.getIdentifiers()[0] ) ); + Assert.assertTrue( target.hasIdentifier( target.getIdentifiers().get(0) ) ); } @Test public void testGetMimeTypes() { - final String[] mimeTypes = target.getMimeTypes(); - Assert.assertTrue(mimeTypes.length > 0); + final Collection<String> mimeTypes = target.getMimeTypes(); + Assert.assertTrue(mimeTypes.size() > 0); } @Test public void testGetWriters() { - Assert.assertTrue( target.getWriters().length >= NUM_OF_WRITERS); + Assert.assertTrue( target.getWriters().size() >= NUM_OF_WRITERS); } @Test public void testGetWriterByIdentifier() { - final String[] ids = target.getIdentifiers(); + final List<String> ids = target.getIdentifiers(); for(String id : ids) { Assert.assertNotNull( target.getWriterByIdentifier(id) ); } @@ -69,7 +71,7 @@ public class WriterRegistryTest { @Test public void testGetWriterInstanceByIdentifier() { - final String[] ids = target.getIdentifiers(); + final List<String> ids = target.getIdentifiers(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); for(String id : ids) { Assert.assertNotNull( target.getWriterInstanceByIdentifier(id, baos) ); @@ -78,15 +80,15 @@ public class WriterRegistryTest { @Test public void testGetWritersByMimeType() { - final Set<Class<? extends FormatWriter>> set = new HashSet<Class<? extends FormatWriter>>(); - final String[] mimeTypes = target.getMimeTypes(); + final Set<WriterFactory> set = new HashSet<WriterFactory>(); + final Collection<String> mimeTypes = target.getMimeTypes(); for(String mimeType : mimeTypes) { - set.addAll( Arrays.asList(target.getWritersByMimeType(mimeType)) ); + set.addAll( target.getWritersByMimeType(mimeType) ); } Assert.assertEquals( NUM_OF_WRITERS, set.size() ); } - private void assertUnique(String[] list) { + private void assertUnique(List<String> list) { final Set<String> set = new HashSet<String>(); for(String elem : list) { if(set.contains(elem)) Modified: incubator/any23/trunk/plugins/integration-test/src/test/java/org/apache/any23/plugin/PluginIT.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/plugins/integration-test/src/test/java/org/apache/any23/plugin/PluginIT.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/plugins/integration-test/src/test/java/org/apache/any23/plugin/PluginIT.java (original) +++ incubator/any23/trunk/plugins/integration-test/src/test/java/org/apache/any23/plugin/PluginIT.java Mon Aug 13 06:15:29 2012 @@ -20,6 +20,7 @@ package org.apache.any23.plugin; import org.apache.any23.cli.Crawler; import org.apache.any23.cli.Tool; import org.apache.any23.extractor.ExtractorGroup; +import org.apache.any23.extractor.ExtractorRegistryImpl; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -75,10 +76,11 @@ public class PluginIT { @Test public void testDetectExtractorPlugins() throws IOException, InstantiationException, IllegalAccessException { final ExtractorGroup extractorGroup = manager.getApplicableExtractors( - HTML_SCRAPER_TARGET_DIR, - HTML_SCRAPER_DEPENDENCY_DIR, // Required to satisfy class dependencies. - OFFICE_SCRAPER_TARGET_DIR, - OFFICE_SCRAPER_DEPENDENCY_DIR // Required to satisfy class dependencies. + ExtractorRegistryImpl.getInstance(), + HTML_SCRAPER_TARGET_DIR, // Required to satisfy class dependencies. + HTML_SCRAPER_DEPENDENCY_DIR, + OFFICE_SCRAPER_TARGET_DIR +, OFFICE_SCRAPER_DEPENDENCY_DIR // Required to satisfy class dependencies. ); assertEquals(NUM_OF_EXTRACTORS + 2, // HTMLScraper Plugin, OfficeScraper Plugin. extractorGroup.getNumOfExtractors() Modified: incubator/any23/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/any23/trunk/pom.xml?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/pom.xml (original) +++ incubator/any23/trunk/pom.xml Mon Aug 13 06:15:29 2012 @@ -188,6 +188,7 @@ </mailingLists> <modules> + <module>api</module> <module>test-resources</module> <module>core</module> <module>plugins/basic-crawler</module> Modified: incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/WebResponder.java URL: http://svn.apache.org/viewvc/incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/WebResponder.java?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/WebResponder.java (original) +++ incubator/any23/trunk/service/src/main/java/org/apache/any23/servlet/WebResponder.java Mon Aug 13 06:15:29 2012 @@ -33,7 +33,8 @@ import org.apache.any23.writer.CountingT import org.apache.any23.writer.FormatWriter; import org.apache.any23.writer.ReportingTripleHandler; import org.apache.any23.writer.TripleHandler; -import org.apache.any23.writer.WriterRegistry; +import org.apache.any23.writer.WriterFactory; +import org.apache.any23.writer.WriterFactoryRegistry; import sun.security.validator.ValidatorException; import javax.servlet.ServletOutputStream; @@ -52,7 +53,7 @@ import java.util.List; */ class WebResponder { - private static final WriterRegistry writerRegistry = WriterRegistry.getInstance(); + private static final WriterFactoryRegistry writerRegistry = WriterFactoryRegistry.getInstance(); /** * Library facade. @@ -305,8 +306,8 @@ class WebResponder { } private boolean initRdfWriter(String format, boolean report, boolean annotate) throws IOException { - final FormatWriter fw = getFormatWriter(format, annotate); - if (fw == null) { + final WriterFactory factory = getFormatWriter(format); + if (factory == null) { sendError( 400, "Invalid format '" + format + "', try one of: [rdfxml, turtle, ntriples, nquads, trix, json]", @@ -316,7 +317,9 @@ class WebResponder { ); return false; } - outputMediaType = WriterRegistry.getMimeType( fw.getClass() ); + FormatWriter fw = factory.getRdfWriter(byteOutStream); + fw.setAnnotated(annotate); + outputMediaType = factory.getMimeType(); List<TripleHandler> tripleHandlers = new ArrayList<TripleHandler>(); tripleHandlers.add(new IgnoreAccidentalRDFa(fw)); tripleHandlers.add(new CountingTripleHandler()); @@ -329,8 +332,9 @@ class WebResponder { return true; } - private FormatWriter getFormatWriter(String format, boolean annotate) throws IOException { + private WriterFactory getFormatWriter(String format) throws IOException { final String finalFormat; + // FIXME: Remove this hardcoded set if ("rdf".equals(format) || "xml".equals(format) || "rdfxml".equals(format)) { finalFormat = "rdfxml"; } else if ("turtle".equals(format) || "ttl".equals(format)) { @@ -348,8 +352,7 @@ class WebResponder { } else { return null; } - final FormatWriter writer = writerRegistry.getWriterInstanceByIdentifier(finalFormat, byteOutStream); - writer.setAnnotated(annotate); + final WriterFactory writer = writerRegistry.getWriterByIdentifier(finalFormat); return writer; } Modified: incubator/any23/trunk/test-resources/pom.xml URL: http://svn.apache.org/viewvc/incubator/any23/trunk/test-resources/pom.xml?rev=1372269&r1=1372268&r2=1372269&view=diff ============================================================================== --- incubator/any23/trunk/test-resources/pom.xml (original) +++ incubator/any23/trunk/test-resources/pom.xml Mon Aug 13 06:15:29 2012 @@ -16,29 +16,29 @@ limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>apache-any23</artifactId> - <groupId>org.apache.any23</groupId> - <version>0.7.1-incubating-SNAPSHOT</version> - <relativePath>../</relativePath> - </parent> - <artifactId>apache-any23-test-resources</artifactId> - <name>Apache Any23 :: Test Resources</name> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>apache-any23</artifactId> + <groupId>org.apache.any23</groupId> + <version>0.7.1-incubating-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <artifactId>apache-any23-test-resources</artifactId> + <name>Apache Any23 :: Test Resources</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> </project>
