Top Fields Constructors Methods
org.jabref.gui.fieldeditors

public Class URLUtil

extends Object
Class Inheritance
Imports
java.net.MalformedURLException, .URL, .URLDecoder, java.nio.charset.StandardCharsets, java.util.Objects, .Optional, org.jabref.gui.externalfiletype.ExternalFileTypes, org.jabref.preferences.FilePreferences

Field Summary

Modifier and TypeField and Description
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the cleaned Google URL or url if no search URL was detected
cleanGoogleSearchURL
(String
the Google search URL string
url
)

Cleans URLs returned by Google search.

public static Optional<String>

Returns:

The suffix, excluding the dot (e.g. "pdf")
getSuffix
(final String
The link
link
,
FilePreferences filePreferences)

Look for the last '.' in the link, and return the following characters.

public static boolean

Returns:

true if url contains a valid URL
isURL
(String
the String to check for a URL
url
)

Checks whether the given String is a URL.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GOOGLE_SEARCH_EXPback to summary
private static final String GOOGLE_SEARCH_EXP
URL_EXPback to summary
private static final String URL_EXP

Constructor Detail

URLUtilback to summary
private URLUtil()

Method Detail

cleanGoogleSearchURLback to summary
public static String cleanGoogleSearchURL(String url)

Cleans URLs returned by Google search.

Example

If you copy links from search results from Google, all links will be enriched with search meta data, e.g. https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&&url=http%3A%2F%2Fwww.inrg.csie.ntu.edu.tw%2Falgorithm2014%2Fhomework%2FWagner-74.pdf&ei=DifeVYHkDYWqU5W0j6gD&usg=AFQjCNFl638rl5KVta1jIMWLyb4CPSZidg&sig2=0hSSMw9XZXL3HJWwEcJtOg
Parameters
url:String

the Google search URL string

Returns:String

the cleaned Google URL or url if no search URL was detected

getSuffixback to summary
public static Optional<String> getSuffix(final String link, FilePreferences filePreferences)

Look for the last '.' in the link, and return the following characters.

This gives the extension for most reasonably named links.

Parameters
link:String

The link

Returns:Optional<String>

The suffix, excluding the dot (e.g. "pdf")

isURLback to summary
public static boolean isURL(String url)

Checks whether the given String is a URL.

Currently only checks for a protocol String.

Parameters
url:String

the String to check for a URL

Returns:boolean

true if url contains a valid URL