Class BookmarkHelper
java.lang.Object
com.vdoc.sdk.commons.backend.bookmarks.BookmarkHelper
Allow string building with String template and DataSource
- Author:
- famaridon
-
Constructor Summary
ConstructorsConstructorDescriptioncreate object with default REGEX ${bookmark}BookmarkHelper(String startQuote, String endQuote) Constructor Create object with specified quote -
Method Summary
Modifier and TypeMethodDescriptionbuildString(String source, Map<String, String> varsValue) build a string which have $var$ parameters and replace it with value Map Example : expr = folder/$year$/name Map varsValue = {{"$year$","1970"}} return = folder/1970/namecleanBookmark(String bookmark) Remove bookmark's start and endevaluatBookmark(String bookmark, IBookmarkEvaluator evaluator) Try to evaluate a bookmark with specified evaluator The first bookmark value find is return If not found the evaluator add not found value (null)evaluatBookmark(String bookmark, List<IBookmarkEvaluator> evaluators) Try to evaluate a bookmark with all evaluators The first bookmark value find is return If not found the evaluator add not found value (null)evaluatBookmarks(List<String> bookmarks, IBookmarkEvaluator evaluator) Try to evaluate bookmarks with a specified evaluator The first bookmark value find is return If not found the evaluator add not found value (null)evaluatBookmarks(List<String> lBookmarks, List<IBookmarkEvaluator> lEvaluator) Try to evaluate all bookmarks with all evaluator The first bookmark value find is return If not found the evaluator add not found value (null)findBookmarks(String source) Read string and build list with all bookmarks foundputDefaultValue(String key, String defaultValues) Add a default valueRemove a value by its key
-
Constructor Details
-
BookmarkHelper
public BookmarkHelper()create object with default REGEX ${bookmark} -
BookmarkHelper
Constructor Create object with specified quote- Parameters:
startQuote- the start quote patternendQuote- the end quote pattern
-
-
Method Details
-
buildString
public String buildString(String source, Map<String, String> varsValue) throws IllegalArgumentExceptionbuild a string which have $var$ parameters and replace it with value Map Example : expr = folder/$year$/name Map varsValue = {{"$year$","1970"}} return = folder/1970/name- Parameters:
source- the string to buildvarsValue- the Map containing variables value- Returns:
- the build result
- Throws:
IllegalArgumentException- if can't resolve a variable
-
findBookmarks
Read string and build list with all bookmarks found- Parameters:
source- the source- Returns:
- the list
-
evaluatBookmark
Try to evaluate a bookmark with specified evaluator The first bookmark value find is return If not found the evaluator add not found value (null)- Parameters:
bookmark- the bookmarkevaluator- the evaluator- Returns:
- the evaluation
-
evaluatBookmark
Try to evaluate a bookmark with all evaluators The first bookmark value find is return If not found the evaluator add not found value (null)- Parameters:
bookmark- the bookmarkevaluators- the evaluators- Returns:
- the evaluation
-
evaluatBookmarks
Try to evaluate bookmarks with a specified evaluator The first bookmark value find is return If not found the evaluator add not found value (null)- Parameters:
bookmarks- the bookmarksevaluator- the evaluator- Returns:
- the evaluations
-
evaluatBookmarks
public Map<String,String> evaluatBookmarks(List<String> lBookmarks, List<IBookmarkEvaluator> lEvaluator) Try to evaluate all bookmarks with all evaluator The first bookmark value find is return If not found the evaluator add not found value (null)- Parameters:
lBookmarks- the bookmarkslEvaluator- the evaluators- Returns:
- the evaluations
-
cleanBookmark
Remove bookmark's start and end- Parameters:
bookmark- the bookmark- Returns:
- the cleaned bookmark
-
putDefaultValue
Add a default value- Parameters:
key- the keydefaultValues- the default value- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
remove
Remove a value by its key- Parameters:
key- the key- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-