Top Description Fields Constructors Methods
org.jabref.model.entry.identifier

public Class DOI

extends Object
implements Identifier
Class Inheritance
All Implemented Interfaces
org.jabref.model.entry.identifier.Identifier
Annotations
@AllowedToUseLogic:because we want to have this class \'smart\' an be able to parse obscure DOIs, too. For this, we need the LatexToUnicodeformatter.
Imports
java.net.URI, .URISyntaxException, .URLDecoder, java.nio.charset.StandardCharsets, java.util.Locale, .Objects, .Optional, java.util.regex.Matcher, .Pattern, org.jabref.architecture.AllowedToUseLogic, org.jabref.logic.layout.format.LatexToUnicodeFormatter, org.jabref.model.entry.field.Field, .StandardField, org.slf4j.Logger, .LoggerFactory

Class for working with Digital object identifiers (DOIs) and Short DOIs

Field Summary

Modifier and TypeField and Description
public static final URI
private static final String
private final String
private static final String
private static final Pattern
private static final Pattern
private static final Pattern
private static final String
private static final Pattern
private static final String
private static final Pattern
private static final Pattern
private static final String
private static final String
private boolean
private static final Logger
public static final URI
private static final String
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
DOI(String
the DOI/Short DOI string
doi
)

Creates a DOI from various schemes including URL, URN, and plain DOIs/Short DOIs.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

DOIs are case-insensitive.

public static Optional<DOI>

Returns:

an Optional containing the DOI or an empty Optional
findInText
(String
the Text which might contain a DOI/Short DOI
text
)

Tries to find a DOI/Short DOI inside the given text.

public Field
public String

Returns:

the plain DOI/Short DOI value.
getDOI
()

Return the plain DOI/Short DOI

public Optional<URI>

Returns:

an encoded URI representation of the DOI/Short DOI
getExternalURI
()

Implements org.jabref.model.entry.identifier.Identifier.getExternalURI.

Return a URI presentation for the DOI/Short DOI

public Optional<URI>
public Optional<URI>
public String
public String

Returns:

an encoded URL representation of the DOI/Short DOI
getURIAsASCIIString
()

Return an ASCII URL presentation for the DOI/Short DOI

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if DOI is short DOI, false otherwise
isShortDoi
()

Determines whether DOI is short DOI or not

public static boolean

Returns:

true if DOI is valid, false otherwise
isValid
(String
the DOI/Short DOI string
doi
)

Determines whether a DOI/Short DOI is valid or not

public static Optional<DOI>

Returns:

an Optional containing the DOI or an empty Optional
parse
(String
the DOI/Short DOI string
doi
)

Creates an Optional<DOI> from various schemes including URL, URN, and plain DOIs.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

AGENCY_RESOLVERback to summary
public static final URI AGENCY_RESOLVER
CHARS_TO_REMOVEback to summary
private static final String CHARS_TO_REMOVE
doiback to summary
private final String doi
DOI_EXPback to summary
private static final String DOI_EXP
EXACT_DOI_PATTback to summary
private static final Pattern EXACT_DOI_PATT
EXACT_SHORT_DOI_PATTback to summary
private static final Pattern EXACT_SHORT_DOI_PATT
EXACT_SHORT_DOI_SHORTCUTback to summary
private static final Pattern EXACT_SHORT_DOI_SHORTCUT
FIND_DOI_EXPback to summary
private static final String FIND_DOI_EXP
FIND_DOI_PATTback to summary
private static final Pattern FIND_DOI_PATT
FIND_SHORT_DOI_EXPback to summary
private static final String FIND_SHORT_DOI_EXP
FIND_SHORT_DOI_PATTback to summary
private static final Pattern FIND_SHORT_DOI_PATT
FIND_SHORT_DOI_SHORTCUTback to summary
private static final Pattern FIND_SHORT_DOI_SHORTCUT
HTTP_EXPback to summary
private static final String HTTP_EXP
IN_TEXT_SHORT_DOI_SHORTCUTback to summary
private static final String IN_TEXT_SHORT_DOI_SHORTCUT
isShortDoiback to summary
private boolean isShortDoi
LOGGERback to summary
private static final Logger LOGGER
RESOLVERback to summary
public static final URI RESOLVER
SHORT_DOI_EXPback to summary
private static final String SHORT_DOI_EXP
SHORT_DOI_EXP_PREFIXback to summary
private static final String SHORT_DOI_EXP_PREFIX
SHORT_DOI_HTTP_EXPback to summary
private static final String SHORT_DOI_HTTP_EXP
SHORT_DOI_SHORTCUTback to summary
private static final String SHORT_DOI_SHORTCUT

Constructor Detail

DOIback to summary
public DOI(String doi)

Creates a DOI from various schemes including URL, URN, and plain DOIs/Short DOIs.

Parameters
doi:String

the DOI/Short DOI string

Exceptions
NullPointerException:
if DOI/Short DOI is null
IllegalArgumentException:
if doi does not include a valid DOI/Short DOI

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

DOIs are case-insensitive. Thus, 10.1109/cloud.2017.89 equals 10.1109/CLOUD.2017.89

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

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

Annotations
@Override
findInTextback to summary
public static Optional<DOI> findInText(String text)

Tries to find a DOI/Short DOI inside the given text.

Parameters
text:String

the Text which might contain a DOI/Short DOI

Returns:Optional<DOI>

an Optional containing the DOI or an empty Optional

getDefaultFieldback to summary
public Field getDefaultField()

Implements org.jabref.model.entry.identifier.Identifier.getDefaultField.

Annotations
@Override
getDOIback to summary
public String getDOI()

Return the plain DOI/Short DOI

Returns:String

the plain DOI/Short DOI value.

getExternalURIback to summary
public Optional<URI> getExternalURI()

Implements org.jabref.model.entry.identifier.Identifier.getExternalURI.

Return a URI presentation for the DOI/Short DOI

Returns:Optional<URI>

an encoded URI representation of the DOI/Short DOI

Annotations
@Override
getExternalURIFromBaseback to summary
public Optional<URI> getExternalURIFromBase(URI base)
getExternalURIWithCustomBaseback to summary
public Optional<URI> getExternalURIWithCustomBase(String customBase)
getNormalizedback to summary
public String getNormalized()

Implements org.jabref.model.entry.identifier.Identifier.getNormalized.

Doc from org.jabref.model.entry.identifier.Identifier.getNormalized.

Returns the identifier.

Annotations
@Override
getURIAsASCIIStringback to summary
public String getURIAsASCIIString()

Return an ASCII URL presentation for the DOI/Short DOI

Returns:String

an encoded URL representation of the DOI/Short DOI

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
isShortDoiback to summary
public boolean isShortDoi()

Determines whether DOI is short DOI or not

Returns:boolean

true if DOI is short DOI, false otherwise

isValidback to summary
public static boolean isValid(String doi)

Determines whether a DOI/Short DOI is valid or not

Parameters
doi:String

the DOI/Short DOI string

Returns:boolean

true if DOI is valid, false otherwise

parseback to summary
public static Optional<DOI> parse(String doi)

Creates an Optional<DOI> from various schemes including URL, URN, and plain DOIs.

Useful for suppressing the IllegalArgumentException of the Constructor and checking for Optional.isPresent() instead.

Parameters
doi:String

the DOI/Short DOI string

Returns:Optional<DOI>

an Optional containing the DOI or an empty Optional

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