-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TIKA-1599 -- migrate to jsoup parser
- Loading branch information
Showing
74 changed files
with
7,727 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tika-parsers/tika-parsers-extended/tika-parser-tagsoup-module/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
<groupId>org.apache.tika</groupId> | ||
<artifactId>tika-parsers-extended</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>tika-parser-tagsoup-module</artifactId> | ||
<name>Apache Tika Tagsoup-based HTML parser module</name> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.ccil.cowan.tagsoup</groupId> | ||
<artifactId>tagsoup</artifactId> | ||
<version>${tagsoup.version}</version> | ||
</dependency> | ||
<!-- needed for charset/encoding detection --> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>tika-parser-text-module</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
81 changes: 81 additions & 0 deletions
81
...arser-tagsoup-module/src/main/java/org/apache/tika/parser/html/tagsoup/DataURIScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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.parser.html.tagsoup; | ||
|
||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream; | ||
|
||
import org.apache.tika.mime.MediaType; | ||
|
||
public class DataURIScheme { | ||
|
||
|
||
private final String rawMediaTypeString; | ||
private final boolean isBase64; | ||
private final byte[] data; | ||
|
||
DataURIScheme(String mediaTypeString, boolean isBase64, byte[] data) { | ||
this.rawMediaTypeString = mediaTypeString; | ||
this.isBase64 = isBase64; | ||
this.data = data; | ||
} | ||
|
||
public InputStream getInputStream() { | ||
return new UnsynchronizedByteArrayInputStream(data); | ||
} | ||
|
||
/** | ||
* @return parsed media type or <code>null</code> if parse fails or if media type string was | ||
* not specified | ||
*/ | ||
public MediaType getMediaType() { | ||
if (rawMediaTypeString != null) { | ||
return MediaType.parse(rawMediaTypeString); | ||
} | ||
return null; | ||
} | ||
|
||
public boolean isBase64() { | ||
return isBase64; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof DataURIScheme)) { | ||
return false; | ||
} | ||
DataURIScheme that = (DataURIScheme) o; | ||
return isBase64() == that.isBase64() && | ||
Objects.equals(rawMediaTypeString, that.rawMediaTypeString) && | ||
Arrays.equals(data, that.data); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
|
||
int result = Objects.hash(rawMediaTypeString, isBase64()); | ||
result = 31 * result + Arrays.hashCode(data); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.