Skip to content

Commit

Permalink
incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusDietz committed Jun 1, 2017
1 parent 92c97f7 commit b9ddbc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private FileAnnotation createMarkedAnnotations(int pageIndex, PDPage page, PDAnn
annotation.getDictionary().getString(COSName.T), FileAnnotation.extractModifiedTime(annotation.getModifiedDate()),
pageIndex + 1, annotation.getContents(), FileAnnotationType.valueOf(annotation.getSubtype().toUpperCase(Locale.ROOT)), Optional.empty());

if (annotationBelongingToMarking.getAnnotationType().isLinkedAnnotationType()) {
if (annotationBelongingToMarking.getAnnotationType().isLinkedFileAnnotationType()) {
try {
COSArray boundingBoxes = (COSArray) annotation.getDictionary().getDictionaryObject(COSName.getPDFName("QuadPoints"));
annotation.setContents(new TextExtractor(page, boundingBoxes).extractMarkedText());
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/org/jabref/model/pdf/FileAnnotationType.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package org.jabref.model.pdf;

import java.util.Arrays;
import java.util.Collections;
import java.util.Locale;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;

import static java.util.stream.Collectors.toList;

/**
* Our representation of the type of the FileAnnotation. This is needed as some FileAnnotationTypes require special
* handling (e.g., Highlight or Underline), because of the linked FileAnnotations.
Expand All @@ -33,11 +29,11 @@ public enum FileAnnotationType {
private static final Log LOGGER = LogFactory.getLog(FileAnnotationType.class);

private final String name;
private final boolean isLinkedAnnotationType;
private final boolean linkedFileAnnotationType;

FileAnnotationType(String name, boolean isLinkedAnnotationType) {
FileAnnotationType(String name, boolean linkedFileAnnotationType) {
this.name = name;
this.isLinkedAnnotationType = isLinkedAnnotationType;
this.linkedFileAnnotationType = linkedFileAnnotationType;
}

/**
Expand All @@ -63,17 +59,15 @@ public static FileAnnotationType parse(PDAnnotation annotation) {
* @return true if annotationType is a supported marked FileAnnotation type
*/
public static boolean isMarkedFileAnnotationType(String annotationType) {
for (FileAnnotationType type : Collections.unmodifiableList(Arrays.stream(FileAnnotationType.values())
.filter(FileAnnotationType::isLinkedAnnotationType).collect(toList()))) {
if (type.toString().equals(annotationType)) {
return true;
}
try {
return FileAnnotationType.valueOf(annotationType.toUpperCase(Locale.ROOT)).linkedFileAnnotationType;
} catch (IllegalArgumentException e) {
return false;
}
return false;
}

public boolean isLinkedAnnotationType() {
return isLinkedAnnotationType;
public boolean isLinkedFileAnnotationType() {
return linkedFileAnnotationType;
}

public String toString() {
Expand Down

0 comments on commit b9ddbc4

Please sign in to comment.