Skip to content

Commit

Permalink
Move isOnlineLink back to linked file
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Nov 4, 2017
1 parent 2f31be2 commit 4ffdabf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
16 changes: 13 additions & 3 deletions src/main/java/org/jabref/model/entry/LinkedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LinkedFile(String description, String link, String fileType) {
this.description.setValue(Objects.requireNonNull(description));

String fileLink = Objects.requireNonNull(link);
if (!FileHelper.isOnlineLink(fileLink)) {
if (!isOnlineLink(fileLink)) {
this.link.setValue(fileLink.replace("\\", "/"));
} else {
this.link.setValue(fileLink);
Expand Down Expand Up @@ -69,7 +69,7 @@ public String getLink() {
}

public void setLink(String link) {
if (!FileHelper.isOnlineLink(link)) {
if (!isOnlineLink(link)) {
this.link.setValue(link.replace("\\", "/"));
} else {
this.link.setValue(link);
Expand Down Expand Up @@ -117,6 +117,15 @@ private void readObject(ObjectInputStream in) throws IOException {
description = new SimpleStringProperty(in.readUTF());
}

/**
* Checks if the given String is an online link
* @param toCheck The String to check
* @return True if it starts with http://, https:// or contains www; false otherwise
*/
private boolean isOnlineLink(String toCheck) {
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
}

@Override
public int hashCode() {
return Objects.hash(description.get(), link.get(), fileType.get());
Expand All @@ -136,7 +145,7 @@ public boolean isEmpty() {
}

public boolean isOnlineLink() {
return FileHelper.isOnlineLink(link.get());
return isOnlineLink(link.get());
}

public Optional<Path> findIn(BibDatabaseContext databaseContext, FileDirectoryPreferences fileDirectoryPreferences) {
Expand All @@ -152,4 +161,5 @@ public Optional<Path> findIn(List<Path> directories) {
return FileHelper.expandFilenameAsPath(link.get(), directories);
}
}

}
9 changes: 0 additions & 9 deletions src/main/java/org/jabref/model/util/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@

public class FileHelper {

/**
* Checks if the given String is an online link
* @param toCheck The String to check
* @return True if it starts with http://, https:// or contains www; false otherwise
*/
public static boolean isOnlineLink(String toCheck) {
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
}

/**
* Returns the extension of a file or Optional.empty() if the file does not have one (no . in name).
*
Expand Down

0 comments on commit 4ffdabf

Please sign in to comment.