Class BookmarkHelper

java.lang.Object
com.vdoc.sdk.commons.backend.bookmarks.BookmarkHelper

public class BookmarkHelper extends Object
Allow string building with String template and DataSource
Author:
famaridon
  • Constructor Details

    • BookmarkHelper

      public BookmarkHelper()
      create object with default REGEX ${bookmark}
    • BookmarkHelper

      public BookmarkHelper(String startQuote, String endQuote)
      Constructor Create object with specified quote
      Parameters:
      startQuote - the start quote pattern
      endQuote - the end quote pattern
  • Method Details

    • buildString

      public String buildString(String source, Map<String,String> varsValue) throws IllegalArgumentException
      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/name
      Parameters:
      source - the string to build
      varsValue - the Map containing variables value
      Returns:
      the build result
      Throws:
      IllegalArgumentException - if can't resolve a variable
    • findBookmarks

      public List<String> findBookmarks(String source)
      Read string and build list with all bookmarks found
      Parameters:
      source - the source
      Returns:
      the list
    • evaluatBookmark

      public String evaluatBookmark(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)
      Parameters:
      bookmark - the bookmark
      evaluator - the evaluator
      Returns:
      the evaluation
    • evaluatBookmark

      public String 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)
      Parameters:
      bookmark - the bookmark
      evaluators - the evaluators
      Returns:
      the evaluation
    • evaluatBookmarks

      public Map<String,String> 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)
      Parameters:
      bookmarks - the bookmarks
      evaluator - 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 bookmarks
      lEvaluator - the evaluators
      Returns:
      the evaluations
    • cleanBookmark

      public String cleanBookmark(String bookmark)
      Remove bookmark's start and end
      Parameters:
      bookmark - the bookmark
      Returns:
      the cleaned bookmark
    • putDefaultValue

      public String putDefaultValue(String key, String defaultValues)
      Add a default value
      Parameters:
      key - the key
      defaultValues - the default value
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
    • remove

      public String remove(String key)
      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.