Top Fields Constructors Methods
org.jabref.model.pdf

public Class FileAnnotation

extends Object
Class Inheritance
Imports
java.time.LocalDateTime, java.time.format.DateTimeFormatter, .DateTimeParseException, java.util.Objects, .Optional, org.apache.pdfbox.cos.COSName, org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final int
private static final String
private final FileAnnotationType
private final String
private final String
private static final String
private static final String
private final Optional<FileAnnotation>
private static final Logger
private final int
private final LocalDateTime

Constructor Summary

AccessConstructor and Description
public
FileAnnotation(final String
The authors of the annotation
author
,
final LocalDateTime
The last time this annotation was modified
timeModified
,
final int
The page of the pdf where the annotation occurs
pageNumber
,
final String
the actual content of the annotation
content
,
final FileAnnotationType
the type of the annotation
annotationType
,
final Optional<FileAnnotation> linkedFileAnnotation)

A flexible constructor, mainly used as dummy if there is actually no annotation.

public
FileAnnotation(final org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
The actual annotation that holds the information
annotation
,
final int
The page of the pdf where the annotation occurs
pageNumber
)

Creating a normal FileAnnotation from a PDAnnotation.

public
FileAnnotation(final org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
The actual annotation that holds the information
annotation
,
final int
The page of the pdf where the annotation occurs
pageNumber
,
FileAnnotation
The corresponding note of a marked text area.
linkedFileAnnotation
)

For creating a FileAnnotation that has a connection to another FileAnnotation.

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

the abbreviated name
abbreviateAnnotationName
(final String
annotation to be shortened
annotationName
)

Abbreviate annotation names when they are longer than ABBREVIATED_ANNOTATION_NAME_LENGTH chars

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static LocalDateTime

Returns:

a LocalDateTime parsed from the dateTimeString
extractModifiedTime
(String
In this case of format yyyyMMddHHmmss.
dateTimeString
)

Parses a String into a LocalDateTime.

public FileAnnotationType
public String
public String
public FileAnnotation

Returns:

the note attached to the annotation
getLinkedFileAnnotation
()

Before this getter is called the presence of the linked annotation must be checked via hasLinkedAnnotation()!

public int
public LocalDateTime
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
private String
parseContent(final String content)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ABBREVIATED_ANNOTATION_NAME_LENGTHback to summary
private static final int ABBREVIATED_ANNOTATION_NAME_LENGTH
ANNOTATION_DATE_FORMATback to summary
private static final String ANNOTATION_DATE_FORMAT
annotationTypeback to summary
private final FileAnnotationType annotationType
authorback to summary
private final String author
contentback to summary
private final String content
DATE_TIME_STRINGback to summary
private static final String DATE_TIME_STRING
DATE_TIME_STRING_WITH_TIME_ZONEback to summary
private static final String DATE_TIME_STRING_WITH_TIME_ZONE
linkedFileAnnotationback to summary
private final Optional<FileAnnotation> linkedFileAnnotation
LOGGERback to summary
private static final Logger LOGGER
pageback to summary
private final int page
timeModifiedback to summary
private final LocalDateTime timeModified

Constructor Detail

FileAnnotationback to summary
public FileAnnotation(final String author, final LocalDateTime timeModified, final int pageNumber, final String content, final FileAnnotationType annotationType, final Optional<FileAnnotation> linkedFileAnnotation)

A flexible constructor, mainly used as dummy if there is actually no annotation.

Parameters
author:String

The authors of the annotation

timeModified:LocalDateTime

The last time this annotation was modified

pageNumber:int

The page of the pdf where the annotation occurs

content:String

the actual content of the annotation

annotationType:FileAnnotationType

the type of the annotation

FileAnnotationback to summary
public FileAnnotation(final org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation annotation, final int pageNumber)

Creating a normal FileAnnotation from a PDAnnotation.

Parameters
annotation:org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation

The actual annotation that holds the information

pageNumber:int

The page of the pdf where the annotation occurs

FileAnnotationback to summary
public FileAnnotation(final org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation annotation, final int pageNumber, FileAnnotation linkedFileAnnotation)

For creating a FileAnnotation that has a connection to another FileAnnotation. Needed when creating a text highlighted or underlined annotation with a sticky note.

Parameters
annotation:org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation

The actual annotation that holds the information

pageNumber:int

The page of the pdf where the annotation occurs

linkedFileAnnotation:FileAnnotation

The corresponding note of a marked text area.

Method Detail

abbreviateAnnotationNameback to summary
private String abbreviateAnnotationName(final String annotationName)

Abbreviate annotation names when they are longer than ABBREVIATED_ANNOTATION_NAME_LENGTH chars

Parameters
annotationName:String

annotation to be shortened

Returns:String

the abbreviated name

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
extractModifiedTimeback to summary
public static LocalDateTime extractModifiedTime(String dateTimeString)

Parses a String into a LocalDateTime.

Parameters
dateTimeString:String

In this case of format yyyyMMddHHmmss.

Returns:LocalDateTime

a LocalDateTime parsed from the dateTimeString

getAnnotationTypeback to summary
public FileAnnotationType getAnnotationType()
getAuthorback to summary
public String getAuthor()
getContentback to summary
public String getContent()
getLinkedFileAnnotationback to summary
public FileAnnotation getLinkedFileAnnotation()

Before this getter is called the presence of the linked annotation must be checked via hasLinkedAnnotation()!

Returns:FileAnnotation

the note attached to the annotation

getPageback to summary
public int getPage()
getTimeModifiedback to summary
public LocalDateTime getTimeModified()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hasLinkedAnnotationback to summary
public boolean hasLinkedAnnotation()
parseContentback to summary
private String parseContent(final String content)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override