Convert new lines from windows to unix
Project: http://git-wip-us.apache.org/repos/asf/tika/repo Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/c7a6bcac Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/c7a6bcac Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/c7a6bcac Branch: refs/heads/2.x Commit: c7a6bcac422f10d130399f6ff5446e24c3f50ac5 Parents: dd3c2a4 Author: tballison <talli...@mitre.org> Authored: Wed Jun 29 07:10:47 2016 -0400 Committer: tballison <talli...@mitre.org> Committed: Wed Jun 29 07:10:53 2016 -0400 ---------------------------------------------------------------------- .../ConfigurableThreadPoolExecutor.java | 64 +- .../concurrent/SimpleThreadPoolExecutor.java | 80 +- .../apache/tika/detect/AbstractDetector.java | 86 +- .../org/apache/tika/detect/DetectorProxy.java | 134 +- .../tika/detect/EncodingDetectorProxy.java | 82 +- .../java/org/apache/tika/io/StringUtil.java | 242 +- .../tika/osgi/TikaAbstractBundleActivator.java | 142 +- .../java/org/apache/tika/osgi/TikaService.java | 50 +- .../tika/osgi/internal/TikaServiceImpl.java | 162 +- .../org/apache/tika/parser/ParserProxy.java | 148 +- .../org/apache/tika/utils/ConcurrentUtils.java | 114 +- .../org/apache/tika/config/DummyExecutor.java | 60 +- .../apache/tika/detect/DetectorProxyTest.java | 112 +- .../apache/tika/detect/DummyProxyDetector.java | 62 +- .../apache/tika/parser/DummyProxyParser.java | 88 +- .../org/apache/tika/parser/ParserProxyTest.java | 130 +- .../apache/tika/utils/ConcurrentUtilsTest.java | 126 +- .../services/org.apache.tika.parser.Parser | 34 +- .../apache/tika/config/TIKA-1762-executors.xml | 56 +- tika-parser-bundles/pom.xml | 350 +-- .../tika-parser-advanced-bundle/pom.xml | 162 +- .../tika-parser-cad-bundle/pom.xml | 144 +- .../tika-parser-code-bundle/pom.xml | 148 +- .../tika-parser-crypto-bundle/pom.xml | 156 +- .../tika-parser-database-bundle/pom.xml | 134 +- .../tika-parser-ebook-bundle/pom.xml | 142 +- .../tika-parser-journal-bundle/pom.xml | 158 +- .../tika-parser-multimedia-bundle/pom.xml | 168 +- .../tika-parser-office-bundle/pom.xml | 280 +- .../tika-parser-package-bundle/pom.xml | 158 +- .../tika-parser-pdf-bundle/pom.xml | 216 +- .../tika-parser-scientific-bundle/pom.xml | 402 +-- .../tika-parser-text-bundle/pom.xml | 156 +- .../tika-parser-web-bundle/pom.xml | 184 +- tika-parser-modules/pom.xml | 410 +-- .../tika-parser-advanced-module/pom.xml | 136 +- .../module/advanced/internal/Activator.java | 72 +- .../tika-parser-cad-module/pom.xml | 110 +- .../tika/module/cad/internal/Activator.java | 72 +- .../org/apache/tika/parser/dwg/DWGParser.java | 712 ++--- .../tika-parser-code-module/pom.xml | 136 +- .../tika/module/code/internal/Activator.java | 72 +- .../org/apache/tika/parser/asm/ClassParser.java | 108 +- .../tika/parser/asm/XHTMLClassVisitor.java | 646 ++-- .../tika/parser/code/SourceCodeParser.java | 284 +- .../apache/tika/parser/asm/ClassParserTest.java | 118 +- .../tika/parser/code/SourceCodeParserTest.java | 202 +- .../tika-parser-crypto-module/pom.xml | 104 +- .../tika/module/crypto/internal/Activator.java | 72 +- .../tika/parser/crypto/Pkcs7ParserTest.java | 94 +- .../tika-parser-database-module/pom.xml | 132 +- .../module/database/internal/Activator.java | 72 +- .../tika-parser-ebook-module/pom.xml | 94 +- .../tika/module/ebook/internal/Activator.java | 72 +- .../tika/parser/epub/EpubContentParser.java | 118 +- .../org/apache/tika/parser/epub/EpubParser.java | 238 +- .../apache/tika/parser/epub/EpubParserTest.java | 116 +- .../tika-parser-journal-module/pom.xml | 134 +- .../tika/module/journal/internal/Activator.java | 72 +- .../tika-parser-multimedia-module/pom.xml | 200 +- .../module/multimedia/internal/Activator.java | 72 +- .../apache/tika/parser/audio/AudioParser.java | 278 +- .../apache/tika/parser/audio/MidiParser.java | 242 +- .../apache/tika/parser/font/TrueTypeParser.java | 222 +- .../parser/image/ImageMetadataExtractor.java | 1124 +++---- .../apache/tika/parser/image/ImageParser.java | 406 +-- .../tika/parser/image/MetadataFields.java | 168 +- .../apache/tika/parser/image/TiffParser.java | 136 +- .../org/apache/tika/parser/jpeg/JpegParser.java | 138 +- .../org/apache/tika/parser/mp3/AudioFrame.java | 504 ++-- .../tika/parser/mp3/CompositeTagHandler.java | 284 +- .../org/apache/tika/parser/mp3/ID3Tags.java | 508 ++-- .../apache/tika/parser/mp3/ID3v1Handler.java | 366 +-- .../apache/tika/parser/mp3/ID3v22Handler.java | 318 +- .../apache/tika/parser/mp3/ID3v23Handler.java | 276 +- .../apache/tika/parser/mp3/ID3v24Handler.java | 286 +- .../org/apache/tika/parser/mp3/ID3v2Frame.java | 848 +++--- .../apache/tika/parser/mp3/LyricsHandler.java | 312 +- .../org/apache/tika/parser/mp3/MP3Frame.java | 50 +- .../org/apache/tika/parser/mp3/Mp3Parser.java | 492 +-- .../org/apache/tika/parser/video/FLVParser.java | 536 ++-- .../parser/ocr/TesseractOCRConfig.properties | 40 +- .../tika/parser/audio/AudioParserTest.java | 150 +- .../tika/parser/audio/MidiParserTest.java | 84 +- .../image/ImageMetadataExtractorTest.java | 278 +- .../tika/parser/image/ImageParserTest.java | 324 +- .../tika/parser/image/MetadataFieldsTest.java | 72 +- .../tika/parser/image/TiffParserTest.java | 132 +- .../apache/tika/parser/jpeg/JpegParserTest.java | 568 ++-- .../apache/tika/parser/mp3/Mp3ParserTest.java | 828 ++--- .../tika/parser/ocr/TesseractOCRConfigTest.java | 184 +- .../apache/tika/parser/video/FLVParserTest.java | 88 +- .../tika-parser-office-module/pom.xml | 250 +- .../tika/module/office/internal/Activator.java | 72 +- .../org/apache/tika/parser/chm/ChmParser.java | 224 +- .../tika/parser/chm/accessor/ChmAccessor.java | 78 +- .../chm/accessor/ChmDirectoryListingSet.java | 796 ++--- .../tika/parser/chm/accessor/ChmItsfHeader.java | 984 +++--- .../tika/parser/chm/accessor/ChmItspHeader.java | 1096 +++---- .../parser/chm/accessor/ChmLzxcControlData.java | 638 ++-- .../parser/chm/accessor/ChmLzxcResetTable.java | 682 ++--- .../tika/parser/chm/accessor/ChmPmgiHeader.java | 352 +-- .../tika/parser/chm/accessor/ChmPmglHeader.java | 412 +-- .../chm/accessor/DirectoryListingEntry.java | 302 +- .../tika/parser/chm/assertion/ChmAssert.java | 338 +-- .../apache/tika/parser/chm/core/ChmCommons.java | 722 ++--- .../tika/parser/chm/core/ChmConstants.java | 204 +- .../tika/parser/chm/core/ChmExtractor.java | 784 ++--- .../apache/tika/parser/chm/core/ChmWrapper.java | 294 +- .../chm/exception/ChmParsingException.java | 54 +- .../tika/parser/chm/lzx/ChmBlockInfo.java | 470 +-- .../apache/tika/parser/chm/lzx/ChmLzxBlock.java | 1826 +++++------ .../apache/tika/parser/chm/lzx/ChmLzxState.java | 654 ++-- .../apache/tika/parser/chm/lzx/ChmSection.java | 444 +-- .../org/apache/tika/parser/mbox/MboxParser.java | 418 +-- .../tika/parser/mbox/OutlookPSTParser.java | 406 +-- .../parser/odf/NSNormalizerContentHandler.java | 198 +- .../parser/odf/OpenDocumentContentParser.java | 992 +++--- .../tika/parser/odf/OpenDocumentMetaParser.java | 398 +-- .../tika/parser/odf/OpenDocumentParser.java | 450 +-- .../org/apache/tika/parser/opc/OPCDetector.java | 310 +- .../parser/opendocument/OpenOfficeParser.java | 56 +- .../org/apache/tika/parser/rtf/GroupState.java | 134 +- .../apache/tika/parser/rtf/ListDescriptor.java | 70 +- .../org/apache/tika/parser/rtf/RTFParser.java | 186 +- .../apache/tika/parser/rtf/TextExtractor.java | 2846 +++++++++--------- .../tika/parser/chm/TestChmBlockInfo.java | 250 +- .../tika/parser/chm/TestChmExtraction.java | 424 +-- .../tika/parser/chm/TestChmExtractor.java | 126 +- .../tika/parser/chm/TestChmItsfHeader.java | 244 +- .../tika/parser/chm/TestChmItspHeader.java | 320 +- .../apache/tika/parser/chm/TestChmLzxState.java | 202 +- .../tika/parser/chm/TestChmLzxcControlData.java | 288 +- .../tika/parser/chm/TestChmLzxcResetTable.java | 312 +- .../parser/chm/TestDirectoryListingEntry.java | 170 +- .../apache/tika/parser/chm/TestParameters.java | 208 +- .../apache/tika/parser/chm/TestPmgiHeader.java | 90 +- .../apache/tika/parser/chm/TestPmglHeader.java | 152 +- .../apache/tika/parser/mbox/MboxParserTest.java | 312 +- .../tika/parser/mbox/OutlookPSTParserTest.java | 220 +- .../AbstractPOIContainerExtractionTest.java | 150 +- .../tika/parser/microsoft/ExcelParserTest.java | 824 ++--- .../tika/parser/microsoft/OfficeParserTest.java | 92 +- .../parser/microsoft/OutlookParserTest.java | 478 +-- .../microsoft/POIContainerExtractionTest.java | 764 ++--- .../parser/microsoft/PowerPointParserTest.java | 502 +-- .../parser/microsoft/PublisherParserTest.java | 106 +- .../tika/parser/microsoft/TNEFParserTest.java | 196 +- .../tika/parser/microsoft/VisioParserTest.java | 102 +- .../tika/parser/microsoft/WordParserTest.java | 1012 +++---- .../apache/tika/parser/odf/ODFParserTest.java | 680 ++--- .../apache/tika/parser/rtf/RTFParserTest.java | 1020 +++---- .../tika-parser-package-module/pom.xml | 150 +- .../tika/module/pkg/internal/Activator.java | 72 +- .../tika/parser/iwork/AutoPageNumberUtils.java | 224 +- .../tika/parser/iwork/IWorkPackageParser.java | 438 +-- .../parser/iwork/KeynoteContentHandler.java | 348 +-- .../parser/iwork/NumbersContentHandler.java | 462 +-- .../tika/parser/iwork/PagesContentHandler.java | 896 +++--- .../apache/tika/parser/pkg/PackageParser.java | 574 ++-- .../tika/parser/pkg/ZipContainerDetector.java | 648 ++-- .../parser/iwork/AutoPageNumberUtilsTest.java | 156 +- .../tika/parser/iwork/IWorkParserTest.java | 932 +++--- .../apache/tika/parser/pkg/AbstractPkgTest.java | 186 +- .../apache/tika/parser/pkg/Bzip2ParserTest.java | 178 +- .../apache/tika/parser/pkg/GzipParserTest.java | 204 +- .../apache/tika/parser/pkg/TarParserTest.java | 210 +- .../apache/tika/parser/pkg/ZipParserTest.java | 384 +-- .../tika-parser-pdf-module/pom.xml | 250 +- .../tika/module/pdf/internal/Activator.java | 72 +- .../tika-parser-scientific-module/pom.xml | 270 +- .../module/scientific/internal/Activator.java | 72 +- .../org/apache/tika/parser/hdf/HDFParser.java | 244 +- .../apache/tika/parser/hdf/HDFParserTest.java | 144 +- .../tika/parser/netcdf/NetCDFParserTest.java | 122 +- .../tika-parser-text-module/pom.xml | 132 +- .../tika/module/text/internal/Activator.java | 40 +- .../apache/tika/parser/txt/CharsetDetector.java | 1088 +++---- .../apache/tika/parser/txt/CharsetMatch.java | 572 ++-- .../tika/parser/txt/CharsetRecog_2022.java | 326 +- .../tika/parser/txt/CharsetRecog_UTF8.java | 198 +- .../tika/parser/txt/CharsetRecog_Unicode.java | 278 +- .../tika/parser/txt/CharsetRecog_mbcs.java | 1064 +++---- .../tika/parser/txt/CharsetRecog_sbcs.java | 2706 ++++++++--------- .../tika/parser/txt/CharsetRecognizer.java | 108 +- .../org/apache/tika/parser/txt/TXTParser.java | 196 +- .../parser/xml/AbstractMetadataHandler.java | 186 +- .../xml/AttributeDependantMetadataHandler.java | 164 +- .../parser/xml/AttributeMetadataHandler.java | 122 +- .../org/apache/tika/parser/xml/DcXMLParser.java | 120 +- .../tika/parser/xml/ElementMetadataHandler.java | 510 ++-- .../tika/parser/xml/FictionBookParser.java | 234 +- .../apache/tika/parser/xml/MetadataHandler.java | 170 +- .../org/apache/tika/parser/xml/XMLParser.java | 178 +- .../apache/tika/parser/txt/TXTParserTest.java | 548 ++-- .../apache/tika/parser/xml/DcXMLParserTest.java | 174 +- .../EmptyAndDuplicateElementsXMLParserTest.java | 232 +- .../tika/parser/xml/FictionBookParserTest.java | 108 +- .../tika-parser-web-module/pom.xml | 178 +- .../tika/module/web/internal/Activator.java | 72 +- .../org/apache/tika/parser/feed/FeedParser.java | 254 +- .../parser/html/BoilerpipeContentHandler.java | 694 ++--- .../tika/parser/html/DefaultHtmlMapper.java | 274 +- .../apache/tika/parser/html/HtmlHandler.java | 618 ++-- .../org/apache/tika/parser/html/HtmlMapper.java | 138 +- .../org/apache/tika/parser/html/HtmlParser.java | 388 +-- .../tika/parser/html/IdentityHtmlMapper.java | 86 +- .../tika/parser/html/XHTMLDowngradeHandler.java | 156 +- .../tika/parser/mail/MailContentHandler.java | 752 ++--- .../apache/tika/parser/mail/RFC822Parser.java | 190 +- .../apache/tika/parser/feed/FeedParserTest.java | 150 +- .../apache/tika/parser/html/HtmlParserTest.java | 2262 +++++++------- .../tika/parser/mail/RFC822ParserTest.java | 970 +++--- 213 files changed, 35548 insertions(+), 35548 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/concurrent/ConfigurableThreadPoolExecutor.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/concurrent/ConfigurableThreadPoolExecutor.java b/tika-core/src/main/java/org/apache/tika/concurrent/ConfigurableThreadPoolExecutor.java index 86f74a7..1f7c4a0 100644 --- a/tika-core/src/main/java/org/apache/tika/concurrent/ConfigurableThreadPoolExecutor.java +++ b/tika-core/src/main/java/org/apache/tika/concurrent/ConfigurableThreadPoolExecutor.java @@ -1,32 +1,32 @@ -/* - * 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.tika.concurrent; - -import java.util.concurrent.ExecutorService; - -/** - * Allows Thread Pool to be Configurable. - * - * @since Apache Tika 1.11 - */ -public interface ConfigurableThreadPoolExecutor extends ExecutorService { - - public void setMaximumPoolSize(int threads); - - public void setCorePoolSize(int threads); - -} +/* + * 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.tika.concurrent; + +import java.util.concurrent.ExecutorService; + +/** + * Allows Thread Pool to be Configurable. + * + * @since Apache Tika 1.11 + */ +public interface ConfigurableThreadPoolExecutor extends ExecutorService { + + public void setMaximumPoolSize(int threads); + + public void setCorePoolSize(int threads); + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/concurrent/SimpleThreadPoolExecutor.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/concurrent/SimpleThreadPoolExecutor.java b/tika-core/src/main/java/org/apache/tika/concurrent/SimpleThreadPoolExecutor.java index a7e443f..0a18e94 100644 --- a/tika-core/src/main/java/org/apache/tika/concurrent/SimpleThreadPoolExecutor.java +++ b/tika-core/src/main/java/org/apache/tika/concurrent/SimpleThreadPoolExecutor.java @@ -1,40 +1,40 @@ -/* - * 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.tika.concurrent; - -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * Simple Thread Pool Executor - * - * @since Apache Tika 1.11 - */ -public class SimpleThreadPoolExecutor extends ThreadPoolExecutor implements ConfigurableThreadPoolExecutor { - - public SimpleThreadPoolExecutor() { - super(1, 2, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { - - @Override - public Thread newThread(Runnable r) { - return new Thread(r, "Tika Executor Thread"); - } - }); - } -} +/* + * 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.tika.concurrent; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Simple Thread Pool Executor + * + * @since Apache Tika 1.11 + */ +public class SimpleThreadPoolExecutor extends ThreadPoolExecutor implements ConfigurableThreadPoolExecutor { + + public SimpleThreadPoolExecutor() { + super(1, 2, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "Tika Executor Thread"); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/detect/AbstractDetector.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/detect/AbstractDetector.java b/tika-core/src/main/java/org/apache/tika/detect/AbstractDetector.java index f0d6129..952a089 100644 --- a/tika-core/src/main/java/org/apache/tika/detect/AbstractDetector.java +++ b/tika-core/src/main/java/org/apache/tika/detect/AbstractDetector.java @@ -1,43 +1,43 @@ -/* - * 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.tika.detect; - -/** - * Abstract base class for new detectors. This class has a convenience method for - * creating a DetectorProxy - * - * @since Apache Tika 2.0 - */ -public abstract class AbstractDetector implements Detector { - - /** - * Serial version UID. - */ - private static final long serialVersionUID = -5869078281784941763L; - - /** - * Convenience method for creating DetectorProxy instances - * with the current class' ClassLoader - * - * @param detectorClassName - * @return - */ - public Detector createDetectorProxy(String detectorClassName){ - return new DetectorProxy(detectorClassName, getClass().getClassLoader()); - } - -} +/* + * 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.tika.detect; + +/** + * Abstract base class for new detectors. This class has a convenience method for + * creating a DetectorProxy + * + * @since Apache Tika 2.0 + */ +public abstract class AbstractDetector implements Detector { + + /** + * Serial version UID. + */ + private static final long serialVersionUID = -5869078281784941763L; + + /** + * Convenience method for creating DetectorProxy instances + * with the current class' ClassLoader + * + * @param detectorClassName + * @return + */ + public Detector createDetectorProxy(String detectorClassName){ + return new DetectorProxy(detectorClassName, getClass().getClassLoader()); + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/detect/DetectorProxy.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/detect/DetectorProxy.java b/tika-core/src/main/java/org/apache/tika/detect/DetectorProxy.java index ed5e638..404ec0a 100644 --- a/tika-core/src/main/java/org/apache/tika/detect/DetectorProxy.java +++ b/tika-core/src/main/java/org/apache/tika/detect/DetectorProxy.java @@ -1,68 +1,68 @@ -/* - * 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.tika.detect; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.tika.config.LoadErrorHandler; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; - -/** - * This detector is a proxy for another detector - * this allows modules to use detectors from other modules - * as optional dependencies since not including the classes - * simply does nothing rather than throwing a ClassNotFoundException. - * - * @since Apache Tika 2.0 - */ -public class DetectorProxy implements Detector -{ - private static final long serialVersionUID = 4534101565629801667L; - - private Detector detector; - - public DetectorProxy(String detectorClassName, ClassLoader loader) - { - this(detectorClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") - ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); - } - - public DetectorProxy(String detectorClassName, ClassLoader loader, LoadErrorHandler handler) - { - try - { - this.detector = (Detector)Class.forName(detectorClassName, true, loader).newInstance(); - } - catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) - { - handler.handleLoadError(detectorClassName, e); - } - } - - @Override - public MediaType detect(InputStream input, Metadata metadata) throws IOException - { - if(detector != null) - { - return detector.detect(input, metadata); - } - return null; - } - +/* + * 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.tika.detect; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.tika.config.LoadErrorHandler; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; + +/** + * This detector is a proxy for another detector + * this allows modules to use detectors from other modules + * as optional dependencies since not including the classes + * simply does nothing rather than throwing a ClassNotFoundException. + * + * @since Apache Tika 2.0 + */ +public class DetectorProxy implements Detector +{ + private static final long serialVersionUID = 4534101565629801667L; + + private Detector detector; + + public DetectorProxy(String detectorClassName, ClassLoader loader) + { + this(detectorClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") + ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); + } + + public DetectorProxy(String detectorClassName, ClassLoader loader, LoadErrorHandler handler) + { + try + { + this.detector = (Detector)Class.forName(detectorClassName, true, loader).newInstance(); + } + catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) + { + handler.handleLoadError(detectorClassName, e); + } + } + + @Override + public MediaType detect(InputStream input, Metadata metadata) throws IOException + { + if(detector != null) + { + return detector.detect(input, metadata); + } + return null; + } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/detect/EncodingDetectorProxy.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/detect/EncodingDetectorProxy.java b/tika-core/src/main/java/org/apache/tika/detect/EncodingDetectorProxy.java index b927597..5e569bd 100644 --- a/tika-core/src/main/java/org/apache/tika/detect/EncodingDetectorProxy.java +++ b/tika-core/src/main/java/org/apache/tika/detect/EncodingDetectorProxy.java @@ -1,41 +1,41 @@ -package org.apache.tika.detect; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; - -import org.apache.tika.config.LoadErrorHandler; -import org.apache.tika.metadata.Metadata; - -public class EncodingDetectorProxy implements EncodingDetector { - -private EncodingDetector detector; - - public EncodingDetectorProxy(String encodingDetectorClassName, ClassLoader loader) - { - this(encodingDetectorClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") - ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); - } - - public EncodingDetectorProxy(String encodingDetectorClassName, ClassLoader loader, LoadErrorHandler handler) - { - try - { - this.detector = (EncodingDetector)Class.forName(encodingDetectorClassName, true, loader).newInstance(); - } - catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) - { - handler.handleLoadError(encodingDetectorClassName, e); - } - } - - @Override - public Charset detect(InputStream input, Metadata metadata) throws IOException { - if(detector != null) - { - return detector.detect(input, metadata); - } - return null; - } - -} +package org.apache.tika.detect; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +import org.apache.tika.config.LoadErrorHandler; +import org.apache.tika.metadata.Metadata; + +public class EncodingDetectorProxy implements EncodingDetector { + +private EncodingDetector detector; + + public EncodingDetectorProxy(String encodingDetectorClassName, ClassLoader loader) + { + this(encodingDetectorClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") + ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); + } + + public EncodingDetectorProxy(String encodingDetectorClassName, ClassLoader loader, LoadErrorHandler handler) + { + try + { + this.detector = (EncodingDetector)Class.forName(encodingDetectorClassName, true, loader).newInstance(); + } + catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) + { + handler.handleLoadError(encodingDetectorClassName, e); + } + } + + @Override + public Charset detect(InputStream input, Metadata metadata) throws IOException { + if(detector != null) + { + return detector.detect(input, metadata); + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/io/StringUtil.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/io/StringUtil.java b/tika-core/src/main/java/org/apache/tika/io/StringUtil.java index 164765a..8876a0d 100644 --- a/tika-core/src/main/java/org/apache/tika/io/StringUtil.java +++ b/tika-core/src/main/java/org/apache/tika/io/StringUtil.java @@ -1,121 +1,121 @@ -/* - * 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.tika.io; - -import java.nio.charset.Charset; - -/** - * General String Related Utilities. - * <p> - * This class provides static utility methods for string operations - * <p> - * Origin of code: Based on the version in POI - */ -public class StringUtil { - - protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); - protected static final Charset UTF16LE = Charset.forName("UTF-16LE"); - public static final Charset UTF8 = Charset.forName("UTF-8"); - - private StringUtil() { - // no instances of this class - } - - /** - * Given a byte array of 16-bit unicode characters in Little Endian - * format (most important byte last), return a Java String representation - * of it. - * - * { 0x16, 0x00 } -0x16 - * - * @param string the byte array to be converted - * @param offset the initial offset into the - * byte array. it is assumed that string[ offset ] and string[ offset + - * 1 ] contain the first 16-bit unicode character - * @param len the length of the final string - * @return the converted string, never <code>null</code>. - * @exception ArrayIndexOutOfBoundsException if offset is out of bounds for - * the byte array (i.e., is negative or is greater than or equal to - * string.length) - * @exception IllegalArgumentException if len is too large (i.e., - * there is not enough data in string to create a String of that - * length) - */ - public static String getFromUnicodeLE( - final byte[] string, - final int offset, - final int len) - throws ArrayIndexOutOfBoundsException, IllegalArgumentException { - if ((offset < 0) || (offset >= string.length)) { - throw new ArrayIndexOutOfBoundsException("Illegal offset " + offset + " (String data is of length " + string.length + ")"); - } - if ((len < 0) || (((string.length - offset) / 2) < len)) { - throw new IllegalArgumentException("Illegal length " + len); - } - - return new String(string, offset, len * 2, UTF16LE); - } - - /** - * Given a byte array of 16-bit unicode characters in little endian - * format (most important byte last), return a Java String representation - * of it. - * - * { 0x16, 0x00 } -0x16 - * - * @param string the byte array to be converted - * @return the converted string, never <code>null</code> - */ - public static String getFromUnicodeLE(byte[] string) { - if(string.length == 0) { return ""; } - return getFromUnicodeLE(string, 0, string.length / 2); - } - - /** - * Read 8 bit data (in ISO-8859-1 codepage) into a (unicode) Java - * String and return. - * (In Excel terms, read compressed 8 bit unicode as a string) - * - * @param string byte array to read - * @param offset offset to read byte array - * @param len length to read byte array - * @return String generated String instance by reading byte array - */ - public static String getFromCompressedUnicode( - final byte[] string, - final int offset, - final int len) { - int len_to_use = Math.min(len, string.length - offset); - return new String(string, offset, len_to_use, ISO_8859_1); - } - - /** - * Takes a unicode (java) string, and returns it as 8 bit data (in ISO-8859-1 - * codepage). - * (In Excel terms, write compressed 8 bit unicode) - * - * @param input the String containing the data to be written - * @param output the byte array to which the data is to be written - * @param offset an offset into the byte arrat at which the data is start - * when written - */ - public static void putCompressedUnicode(String input, byte[] output, int offset) { - byte[] bytes = input.getBytes(ISO_8859_1); - System.arraycopy(bytes, 0, output, offset, bytes.length); - } - -} +/* + * 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.tika.io; + +import java.nio.charset.Charset; + +/** + * General String Related Utilities. + * <p> + * This class provides static utility methods for string operations + * <p> + * Origin of code: Based on the version in POI + */ +public class StringUtil { + + protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); + protected static final Charset UTF16LE = Charset.forName("UTF-16LE"); + public static final Charset UTF8 = Charset.forName("UTF-8"); + + private StringUtil() { + // no instances of this class + } + + /** + * Given a byte array of 16-bit unicode characters in Little Endian + * format (most important byte last), return a Java String representation + * of it. + * + * { 0x16, 0x00 } -0x16 + * + * @param string the byte array to be converted + * @param offset the initial offset into the + * byte array. it is assumed that string[ offset ] and string[ offset + + * 1 ] contain the first 16-bit unicode character + * @param len the length of the final string + * @return the converted string, never <code>null</code>. + * @exception ArrayIndexOutOfBoundsException if offset is out of bounds for + * the byte array (i.e., is negative or is greater than or equal to + * string.length) + * @exception IllegalArgumentException if len is too large (i.e., + * there is not enough data in string to create a String of that + * length) + */ + public static String getFromUnicodeLE( + final byte[] string, + final int offset, + final int len) + throws ArrayIndexOutOfBoundsException, IllegalArgumentException { + if ((offset < 0) || (offset >= string.length)) { + throw new ArrayIndexOutOfBoundsException("Illegal offset " + offset + " (String data is of length " + string.length + ")"); + } + if ((len < 0) || (((string.length - offset) / 2) < len)) { + throw new IllegalArgumentException("Illegal length " + len); + } + + return new String(string, offset, len * 2, UTF16LE); + } + + /** + * Given a byte array of 16-bit unicode characters in little endian + * format (most important byte last), return a Java String representation + * of it. + * + * { 0x16, 0x00 } -0x16 + * + * @param string the byte array to be converted + * @return the converted string, never <code>null</code> + */ + public static String getFromUnicodeLE(byte[] string) { + if(string.length == 0) { return ""; } + return getFromUnicodeLE(string, 0, string.length / 2); + } + + /** + * Read 8 bit data (in ISO-8859-1 codepage) into a (unicode) Java + * String and return. + * (In Excel terms, read compressed 8 bit unicode as a string) + * + * @param string byte array to read + * @param offset offset to read byte array + * @param len length to read byte array + * @return String generated String instance by reading byte array + */ + public static String getFromCompressedUnicode( + final byte[] string, + final int offset, + final int len) { + int len_to_use = Math.min(len, string.length - offset); + return new String(string, offset, len_to_use, ISO_8859_1); + } + + /** + * Takes a unicode (java) string, and returns it as 8 bit data (in ISO-8859-1 + * codepage). + * (In Excel terms, write compressed 8 bit unicode) + * + * @param input the String containing the data to be written + * @param output the byte array to which the data is to be written + * @param offset an offset into the byte arrat at which the data is start + * when written + */ + public static void putCompressedUnicode(String input, byte[] output, int offset) { + byte[] bytes = input.getBytes(ISO_8859_1); + System.arraycopy(bytes, 0, output, offset, bytes.length); + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/osgi/TikaAbstractBundleActivator.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/osgi/TikaAbstractBundleActivator.java b/tika-core/src/main/java/org/apache/tika/osgi/TikaAbstractBundleActivator.java index b959147..52a43dc 100644 --- a/tika-core/src/main/java/org/apache/tika/osgi/TikaAbstractBundleActivator.java +++ b/tika-core/src/main/java/org/apache/tika/osgi/TikaAbstractBundleActivator.java @@ -1,71 +1,71 @@ -/* - * 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.tika.osgi; - -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.Locale; -import java.util.Properties; -import java.util.ServiceLoader; - -import org.apache.tika.parser.Parser; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; - -public abstract class TikaAbstractBundleActivator implements BundleActivator { - - Dictionary createServiceRankProperties(String configName, BundleContext context) { - Dictionary serviceProps = new Properties(); - String serviceRank = context.getProperty(configName); - if (serviceRank != null) { - serviceProps.put(Constants.SERVICE_RANKING, Integer.parseInt(serviceRank)); - } - return serviceProps; - - } - - public void registerTikaParserServiceLoader(BundleContext context, ClassLoader loader) - { - ServiceLoader<Parser> serviceLoader = ServiceLoader.load(Parser.class, loader); - for(Parser currentParser: serviceLoader) - { - registerTikaService(context, currentParser, null); - } - } - - void registerTikaService(BundleContext context, Parser parserService, - Dictionary additionalServiceProperties) { - String parserFullyClassifiedName = parserService.getClass().getCanonicalName().toLowerCase(Locale.US); - - String serviceRankingPropName = parserFullyClassifiedName + ".serviceRanking"; - - Dictionary serviceProperties = createServiceRankProperties(serviceRankingPropName, context); - - if (additionalServiceProperties != null) { - Enumeration keys = additionalServiceProperties.keys(); - while (keys.hasMoreElements()) { - String currentKey = (String) keys.nextElement(); - serviceProperties.put(currentKey, additionalServiceProperties.get(currentKey)); - } - - } - - context.registerService(Parser.class, parserService, serviceProperties); - } - -} +/* + * 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.tika.osgi; + +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Properties; +import java.util.ServiceLoader; + +import org.apache.tika.parser.Parser; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; + +public abstract class TikaAbstractBundleActivator implements BundleActivator { + + Dictionary createServiceRankProperties(String configName, BundleContext context) { + Dictionary serviceProps = new Properties(); + String serviceRank = context.getProperty(configName); + if (serviceRank != null) { + serviceProps.put(Constants.SERVICE_RANKING, Integer.parseInt(serviceRank)); + } + return serviceProps; + + } + + public void registerTikaParserServiceLoader(BundleContext context, ClassLoader loader) + { + ServiceLoader<Parser> serviceLoader = ServiceLoader.load(Parser.class, loader); + for(Parser currentParser: serviceLoader) + { + registerTikaService(context, currentParser, null); + } + } + + void registerTikaService(BundleContext context, Parser parserService, + Dictionary additionalServiceProperties) { + String parserFullyClassifiedName = parserService.getClass().getCanonicalName().toLowerCase(Locale.US); + + String serviceRankingPropName = parserFullyClassifiedName + ".serviceRanking"; + + Dictionary serviceProperties = createServiceRankProperties(serviceRankingPropName, context); + + if (additionalServiceProperties != null) { + Enumeration keys = additionalServiceProperties.keys(); + while (keys.hasMoreElements()) { + String currentKey = (String) keys.nextElement(); + serviceProperties.put(currentKey, additionalServiceProperties.get(currentKey)); + } + + } + + context.registerService(Parser.class, parserService, serviceProperties); + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/osgi/TikaService.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/osgi/TikaService.java b/tika-core/src/main/java/org/apache/tika/osgi/TikaService.java index 4ada094..283ae1c 100644 --- a/tika-core/src/main/java/org/apache/tika/osgi/TikaService.java +++ b/tika-core/src/main/java/org/apache/tika/osgi/TikaService.java @@ -1,25 +1,25 @@ -/* - * 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.tika.osgi; - -import org.apache.tika.detect.Detector; -import org.apache.tika.language.translate.Translator; -import org.apache.tika.parser.Parser; - -public interface TikaService extends Parser, Detector, Translator { - -} +/* + * 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.tika.osgi; + +import org.apache.tika.detect.Detector; +import org.apache.tika.language.translate.Translator; +import org.apache.tika.parser.Parser; + +public interface TikaService extends Parser, Detector, Translator { + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/osgi/internal/TikaServiceImpl.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/osgi/internal/TikaServiceImpl.java b/tika-core/src/main/java/org/apache/tika/osgi/internal/TikaServiceImpl.java index f3b6171..fefa1af 100644 --- a/tika-core/src/main/java/org/apache/tika/osgi/internal/TikaServiceImpl.java +++ b/tika-core/src/main/java/org/apache/tika/osgi/internal/TikaServiceImpl.java @@ -1,81 +1,81 @@ -/* - * 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.tika.osgi.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Set; - -import org.apache.tika.Tika; -import org.apache.tika.config.TikaConfig; -import org.apache.tika.exception.TikaException; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; -import org.apache.tika.osgi.TikaService; -import org.apache.tika.parser.ParseContext; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -public class TikaServiceImpl implements TikaService { - - private static final long serialVersionUID = 1L; - - private final Tika tika; - - public TikaServiceImpl() { - this.tika = new Tika(); - } - - public TikaServiceImpl(TikaConfig config) - { - this.tika = new Tika(config); - } - - @Override - public Set<MediaType> getSupportedTypes(ParseContext context) { - return this.tika.getParser().getSupportedTypes(context); - } - - @Override - public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) - throws IOException, SAXException, TikaException { - tika.getParser().parse(stream, handler, metadata, context); - - } - - @Override - public MediaType detect(InputStream input, Metadata metadata) throws IOException { - return tika.getDetector().detect(input, metadata); - } - - @Override - public String translate(String text, String sourceLanguage, String targetLanguage) - throws TikaException, IOException { - return tika.getTranslator().translate(text, sourceLanguage, targetLanguage); - } - - @Override - public String translate(String text, String targetLanguage) throws TikaException, IOException { - return tika.getTranslator().translate(text, targetLanguage); - } - - @Override - public boolean isAvailable() { - return tika.getTranslator().isAvailable(); - } - -} +/* + * 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.tika.osgi.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; + +import org.apache.tika.Tika; +import org.apache.tika.config.TikaConfig; +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; +import org.apache.tika.osgi.TikaService; +import org.apache.tika.parser.ParseContext; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +public class TikaServiceImpl implements TikaService { + + private static final long serialVersionUID = 1L; + + private final Tika tika; + + public TikaServiceImpl() { + this.tika = new Tika(); + } + + public TikaServiceImpl(TikaConfig config) + { + this.tika = new Tika(config); + } + + @Override + public Set<MediaType> getSupportedTypes(ParseContext context) { + return this.tika.getParser().getSupportedTypes(context); + } + + @Override + public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) + throws IOException, SAXException, TikaException { + tika.getParser().parse(stream, handler, metadata, context); + + } + + @Override + public MediaType detect(InputStream input, Metadata metadata) throws IOException { + return tika.getDetector().detect(input, metadata); + } + + @Override + public String translate(String text, String sourceLanguage, String targetLanguage) + throws TikaException, IOException { + return tika.getTranslator().translate(text, sourceLanguage, targetLanguage); + } + + @Override + public String translate(String text, String targetLanguage) throws TikaException, IOException { + return tika.getTranslator().translate(text, targetLanguage); + } + + @Override + public boolean isAvailable() { + return tika.getTranslator().isAvailable(); + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/parser/ParserProxy.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/parser/ParserProxy.java b/tika-core/src/main/java/org/apache/tika/parser/ParserProxy.java index 9f363f6..8c99d17 100644 --- a/tika-core/src/main/java/org/apache/tika/parser/ParserProxy.java +++ b/tika-core/src/main/java/org/apache/tika/parser/ParserProxy.java @@ -1,74 +1,74 @@ -/* - * 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.tika.parser; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.Set; - -import org.apache.tika.config.LoadErrorHandler; -import org.apache.tika.exception.TikaException; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -/** - * This parser is a proxy for another detector this allows modules to use - * parsers from other modules as optional dependencies since not including the - * classes simply does nothing rather than throwing a ClassNotFoundException. - * - * @since Apache Tika 2.0 - */ -public class ParserProxy extends AbstractParser { - - private static final long serialVersionUID = -4838436708916910179L; - private Parser parser; - - public ParserProxy(String parserClassName, ClassLoader loader) { - - this(parserClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") - ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); - } - - public ParserProxy(String parserClassName, ClassLoader loader, LoadErrorHandler handler) { - try { - this.parser = (Parser) Class.forName(parserClassName, true, loader).newInstance(); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { - handler.handleLoadError(parserClassName, e); - } - - } - - @Override - public Set<MediaType> getSupportedTypes(ParseContext context) { - if (parser == null) { - return Collections.emptySet(); - } - return parser.getSupportedTypes(context); - } - - @Override - public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) - throws IOException, SAXException, TikaException { - if (parser != null) { - parser.parse(stream, handler, metadata, context); - } - // Otherwise do nothing - } -} +/* + * 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.tika.parser; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.Set; + +import org.apache.tika.config.LoadErrorHandler; +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +/** + * This parser is a proxy for another detector this allows modules to use + * parsers from other modules as optional dependencies since not including the + * classes simply does nothing rather than throwing a ClassNotFoundException. + * + * @since Apache Tika 2.0 + */ +public class ParserProxy extends AbstractParser { + + private static final long serialVersionUID = -4838436708916910179L; + private Parser parser; + + public ParserProxy(String parserClassName, ClassLoader loader) { + + this(parserClassName, loader, Boolean.getBoolean("org.apache.tika.service.proxy.error.warn") + ? LoadErrorHandler.WARN:LoadErrorHandler.IGNORE); + } + + public ParserProxy(String parserClassName, ClassLoader loader, LoadErrorHandler handler) { + try { + this.parser = (Parser) Class.forName(parserClassName, true, loader).newInstance(); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + handler.handleLoadError(parserClassName, e); + } + + } + + @Override + public Set<MediaType> getSupportedTypes(ParseContext context) { + if (parser == null) { + return Collections.emptySet(); + } + return parser.getSupportedTypes(context); + } + + @Override + public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) + throws IOException, SAXException, TikaException { + if (parser != null) { + parser.parse(stream, handler, metadata, context); + } + // Otherwise do nothing + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/main/java/org/apache/tika/utils/ConcurrentUtils.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/utils/ConcurrentUtils.java b/tika-core/src/main/java/org/apache/tika/utils/ConcurrentUtils.java index 5f4cd13..a47f747 100644 --- a/tika-core/src/main/java/org/apache/tika/utils/ConcurrentUtils.java +++ b/tika-core/src/main/java/org/apache/tika/utils/ConcurrentUtils.java @@ -1,57 +1,57 @@ -/** - * 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.tika.utils; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; - -import org.apache.tika.parser.ParseContext; - -/** - * Utility Class for Concurrency in Tika - * - * @since Apache Tika 1.11 - */ -public class ConcurrentUtils { - - /** - * - * Execute a runnable using an ExecutorService from the ParseContext if possible. - * Otherwise fallback to individual threads. - * - * @param context - * @param runnable - * @return - */ - public static Future execute(ParseContext context, Runnable runnable) { - - Future future = null; - ExecutorService executorService = context.get(ExecutorService.class); - if(executorService == null) { - FutureTask task = new FutureTask<>(runnable, null); - Thread thread = new Thread(task, "Tika Thread"); - thread.start(); - future = task; - } - else { - future = executorService.submit(runnable); - } - - return future; - } -} +/** + * 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.tika.utils; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.FutureTask; + +import org.apache.tika.parser.ParseContext; + +/** + * Utility Class for Concurrency in Tika + * + * @since Apache Tika 1.11 + */ +public class ConcurrentUtils { + + /** + * + * Execute a runnable using an ExecutorService from the ParseContext if possible. + * Otherwise fallback to individual threads. + * + * @param context + * @param runnable + * @return + */ + public static Future execute(ParseContext context, Runnable runnable) { + + Future future = null; + ExecutorService executorService = context.get(ExecutorService.class); + if(executorService == null) { + FutureTask task = new FutureTask<>(runnable, null); + Thread thread = new Thread(task, "Tika Thread"); + thread.start(); + future = task; + } + else { + future = executorService.submit(runnable); + } + + return future; + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/test/java/org/apache/tika/config/DummyExecutor.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/config/DummyExecutor.java b/tika-core/src/test/java/org/apache/tika/config/DummyExecutor.java index 849eda3..5da9d0d 100644 --- a/tika-core/src/test/java/org/apache/tika/config/DummyExecutor.java +++ b/tika-core/src/test/java/org/apache/tika/config/DummyExecutor.java @@ -1,30 +1,30 @@ -/* - * 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.tika.config; - -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.apache.tika.concurrent.ConfigurableThreadPoolExecutor; - -class DummyExecutor extends ThreadPoolExecutor implements ConfigurableThreadPoolExecutor { - public DummyExecutor() - { - super(1,1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); - } -} +/* + * 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.tika.config; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.tika.concurrent.ConfigurableThreadPoolExecutor; + +class DummyExecutor extends ThreadPoolExecutor implements ConfigurableThreadPoolExecutor { + public DummyExecutor() + { + super(1,1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/test/java/org/apache/tika/detect/DetectorProxyTest.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/detect/DetectorProxyTest.java b/tika-core/src/test/java/org/apache/tika/detect/DetectorProxyTest.java index 060f3d9..33683a9 100644 --- a/tika-core/src/test/java/org/apache/tika/detect/DetectorProxyTest.java +++ b/tika-core/src/test/java/org/apache/tika/detect/DetectorProxyTest.java @@ -1,56 +1,56 @@ -/* - * 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.tika.detect; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import org.apache.tika.config.LoadErrorHandler; -import org.apache.tika.mime.MediaType; -import org.junit.Test; - -public class DetectorProxyTest -{ - @Test - public void testDetectorProxyExists() throws IOException - { - Detector dummyDetector = new DetectorProxy("org.apache.tika.detect.DummyProxyDetector", - getClass().getClassLoader(), - LoadErrorHandler.IGNORE); - - MediaType result = dummyDetector.detect(null, null); - - assertEquals("Detector being proxied exists so result should not be null", - MediaType.TEXT_PLAIN, result ); - - } - - @Test - public void testParserProxyNotExists() throws IOException - { - Detector dummyDetector = new DetectorProxy("org.apache.tika.detect.DoesNotExist", - getClass().getClassLoader(), - LoadErrorHandler.IGNORE); - - MediaType result = dummyDetector.detect(null, null); - - assertNull("Detector being proxied does not exists so result should be null", result ); - - } - -} +/* + * 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.tika.detect; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import org.apache.tika.config.LoadErrorHandler; +import org.apache.tika.mime.MediaType; +import org.junit.Test; + +public class DetectorProxyTest +{ + @Test + public void testDetectorProxyExists() throws IOException + { + Detector dummyDetector = new DetectorProxy("org.apache.tika.detect.DummyProxyDetector", + getClass().getClassLoader(), + LoadErrorHandler.IGNORE); + + MediaType result = dummyDetector.detect(null, null); + + assertEquals("Detector being proxied exists so result should not be null", + MediaType.TEXT_PLAIN, result ); + + } + + @Test + public void testParserProxyNotExists() throws IOException + { + Detector dummyDetector = new DetectorProxy("org.apache.tika.detect.DoesNotExist", + getClass().getClassLoader(), + LoadErrorHandler.IGNORE); + + MediaType result = dummyDetector.detect(null, null); + + assertNull("Detector being proxied does not exists so result should be null", result ); + + } + +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/test/java/org/apache/tika/detect/DummyProxyDetector.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/detect/DummyProxyDetector.java b/tika-core/src/test/java/org/apache/tika/detect/DummyProxyDetector.java index a11b584..ce1207a 100644 --- a/tika-core/src/test/java/org/apache/tika/detect/DummyProxyDetector.java +++ b/tika-core/src/test/java/org/apache/tika/detect/DummyProxyDetector.java @@ -1,31 +1,31 @@ -/* - * 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.tika.detect; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; - -public class DummyProxyDetector implements Detector -{ - @Override - public MediaType detect(InputStream input, Metadata metadata) throws IOException { - return MediaType.TEXT_PLAIN; - } -} +/* + * 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.tika.detect; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; + +public class DummyProxyDetector implements Detector +{ + @Override + public MediaType detect(InputStream input, Metadata metadata) throws IOException { + return MediaType.TEXT_PLAIN; + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/test/java/org/apache/tika/parser/DummyProxyParser.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/parser/DummyProxyParser.java b/tika-core/src/test/java/org/apache/tika/parser/DummyProxyParser.java index ca766c9..4ae7898 100644 --- a/tika-core/src/test/java/org/apache/tika/parser/DummyProxyParser.java +++ b/tika-core/src/test/java/org/apache/tika/parser/DummyProxyParser.java @@ -1,44 +1,44 @@ -/* - * 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.tika.parser; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Set; - -import org.apache.tika.exception.TikaException; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -public class DummyProxyParser extends AbstractParser -{ - @Override - public Set<MediaType> getSupportedTypes(ParseContext context) - { - return null; - } - - @Override - public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) - throws IOException, SAXException, TikaException - { - metadata.add("Test", "value"); - - } -} +/* + * 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.tika.parser; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; + +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.mime.MediaType; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +public class DummyProxyParser extends AbstractParser +{ + @Override + public Set<MediaType> getSupportedTypes(ParseContext context) + { + return null; + } + + @Override + public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) + throws IOException, SAXException, TikaException + { + metadata.add("Test", "value"); + + } +} http://git-wip-us.apache.org/repos/asf/tika/blob/c7a6bcac/tika-core/src/test/java/org/apache/tika/parser/ParserProxyTest.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/parser/ParserProxyTest.java b/tika-core/src/test/java/org/apache/tika/parser/ParserProxyTest.java index 20c6247..9f57965 100644 --- a/tika-core/src/test/java/org/apache/tika/parser/ParserProxyTest.java +++ b/tika-core/src/test/java/org/apache/tika/parser/ParserProxyTest.java @@ -1,65 +1,65 @@ -/* - * 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.tika.parser; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import org.apache.tika.config.LoadErrorHandler; -import org.apache.tika.exception.TikaException; -import org.apache.tika.metadata.Metadata; -import org.junit.Test; -import org.xml.sax.SAXException; - -public class ParserProxyTest -{ - - @Test - public void testParserProxyExists() throws IOException, SAXException, TikaException - { - Parser dummyParser = new ParserProxy("org.apache.tika.parser.DummyProxyParser", - getClass().getClassLoader(), - LoadErrorHandler.IGNORE); - - Metadata metadata = new Metadata(); - - dummyParser.parse(null, null, metadata, null); - - assertEquals("Parser being proxied exists so metadata should be added", - 1, metadata.size()); - - } - - @Test - public void testParserProxyNotExists() throws IOException, SAXException, TikaException - { - Parser dummyParser = new ParserProxy("org.apache.tika.parser.NotExists", - getClass().getClassLoader(), - LoadErrorHandler.IGNORE); - - Metadata metadata = new Metadata(); - - dummyParser.parse(null, null, metadata, null); - - assertEquals("Parser being proxied doesn't exist so metadata not change", - 0, metadata.size()); - - } - - -} +/* + * 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.tika.parser; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import org.apache.tika.config.LoadErrorHandler; +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.junit.Test; +import org.xml.sax.SAXException; + +public class ParserProxyTest +{ + + @Test + public void testParserProxyExists() throws IOException, SAXException, TikaException + { + Parser dummyParser = new ParserProxy("org.apache.tika.parser.DummyProxyParser", + getClass().getClassLoader(), + LoadErrorHandler.IGNORE); + + Metadata metadata = new Metadata(); + + dummyParser.parse(null, null, metadata, null); + + assertEquals("Parser being proxied exists so metadata should be added", + 1, metadata.size()); + + } + + @Test + public void testParserProxyNotExists() throws IOException, SAXException, TikaException + { + Parser dummyParser = new ParserProxy("org.apache.tika.parser.NotExists", + getClass().getClassLoader(), + LoadErrorHandler.IGNORE); + + Metadata metadata = new Metadata(); + + dummyParser.parse(null, null, metadata, null); + + assertEquals("Parser being proxied doesn't exist so metadata not change", + 0, metadata.size()); + + } + + +}