Skip to content

Refine check at LinkedFileHandler#getSuggestedFileName(java.lang.String) #13735

@koppor

Description

@koppor

The if condition at org.jabref.logic.externalfiles.LinkedFileHandler#getSuggestedFileName(java.lang.String) checks for -. The reason is that [bibtexkey] - [title] is the default pattern (see org.jabref.logic.FilePreferences#DEFAULT_FILENAME_PATTERNS).

The return of

Task:

  1. The return type of org.jabref.logic.util.io.FileUtil#createFileNameFromPattern should be Optional. If the empty string (or "-" or "default") would be returned, return an empty optinal. Note that test cases need to be adapted. Especially instead of "default", there will be Optional.empty().
  2. Adapt org.jabref.logic.util.io.FileUtil#createFileNameFromPattern to return an empty Optional if no brackets could be replaced.

Hint:

  • ´org.jabref.logic.citationkeypattern.BracketedPattern#expandBrackets(java.lang.String, java.util.function.Function<java.lang.String,java.lang.String>)can be used with a function returning "" for each input string. Then, one retrieves all non-bracktet characters from the input stirng. Example:[AUTHOR] - [YEAR]will result in - `.
  • Add with a JUnit test for expandBrackets to ensure the claim is current.
  • If the claim is correct, task 2 should be "easy" to do by "just" calling expandBrackets with the empty string function and checking if targetName equals that name.

Background: Risen by #13295.

Metadata

Metadata

Labels

good first issueAn issue intended for project-newcomers. Varies in difficulty.📌 Pinned📍 AssignedAssigned by assign-issue-action (or manually assigned)🔔 reminder-sent

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions