Verified Owner
Top Inners Fields Constructors Methods
org.jabref.logic.importer.util

public Class FileFieldParser

extends Object
Class Inheritance
Imports
java.net.MalformedURLException, java.nio.file.InvalidPathException, .Path, java.util.ArrayList, .HashMap, .List, .Map, java.util.stream.Collectors, org.jabref.logic.util.URLUtil, org.jabref.model.entry.LinkedFile, org.jabref.model.util.Range, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private StringBuilder
private static final Logger
private final String
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static LinkedFile

Returns:

a LinkedFile object
convert
(List<String>
the list of elements in the linked file textual representation
entry
)

Converts the given textual representation of a LinkedFile object

SIDE EFFECT: The given entry list is cleared upon completion

Expected format is: description:link:fileType:sourceURL fileType is an org.jabref.gui.externalfiletype.ExternalFileType, which contains a name and a mime type

public static List<LinkedFile>
parse(String value)

Converts the string representation of LinkedFileData to a List of LinkedFile

The syntax of one element is description:path:type Multiple elements are concatenated with ;

The main challenges of the implementation are:

  • that XML characters might be included (thus one cannot simply split on ";")
  • some characters might be escaped
  • Windows absolute paths might be included without escaping
private List<FileFieldParser.LinkedFilePosition>
public static Map<LinkedFile, Range>
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charactersOfCurrentElementback to summary
private StringBuilder charactersOfCurrentElement
LOGGERback to summary
private static final Logger LOGGER
valueback to summary
private final String value
windowsPathback to summary
private boolean windowsPath

Constructor Detail

FileFieldParserback to summary
private FileFieldParser(String value)

Method Detail

convertback to summary
pack-priv static LinkedFile convert(List<String> entry)

Converts the given textual representation of a LinkedFile object

SIDE EFFECT: The given entry list is cleared upon completion

Expected format is: description:link:fileType:sourceURL fileType is an org.jabref.gui.externalfiletype.ExternalFileType, which contains a name and a mime type

Parameters
entry:List<String>

the list of elements in the linked file textual representation

Returns:LinkedFile

a LinkedFile object

parseback to summary
public static List<LinkedFile> parse(String value)

Converts the string representation of LinkedFileData to a List of LinkedFile

The syntax of one element is description:path:type Multiple elements are concatenated with ;

The main challenges of the implementation are:

  • that XML characters might be included (thus one cannot simply split on ";")
  • some characters might be escaped
  • Windows absolute paths might be included without escaping
parseback to summary
private List<FileFieldParser.LinkedFilePosition> parse()
parseToPositionback to summary
public static Map<LinkedFile, Range> parseToPosition(String value)
resetDataStructuresForNextElementback to summary
private void resetDataStructuresForNextElement()
org.jabref.logic.importer.util back to summary

private final Record FileFieldParser.LinkedFilePosition

extends Record
Class Inheritance
Record Components
linkedFile:LinkedFile 
range:Range 

Field Summary

Modifier and TypeField and Description
private final LinkedFile
linkedFile

Record Component accessed by linkedFile().

private final Range
range

Record Component accessed by range().

Constructor Summary

AccessConstructor and Description
private
LinkedFilePosition(LinkedFile linkedFile, Range range)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public LinkedFile
linkedFile()

Record Component getter of linkedFile.

public Range
range()

Record Component getter of range.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

linkedFileback to summary
private final LinkedFile linkedFile

Record Component accessed by linkedFile().

rangeback to summary
private final Range range

Record Component accessed by range().

Constructor Detail

LinkedFilePositionback to summary
private LinkedFilePosition(LinkedFile linkedFile, Range range)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

linkedFileback to summary
public LinkedFile linkedFile()

Record Component getter of linkedFile.

rangeback to summary
public Range range()

Record Component getter of range.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.