Class Utils

java.lang.Object
de.gwdg.metadataqa.marc.Utils

public class Utils extends Object
Utility methods used elsewhere in the tool
  • Method Details

    • generateCodes

      public static List<EncodedValue> generateCodes(String... input)
    • generateControlPositionList

      public static List<ControlfieldPositionDefinition> generateControlPositionList(ControlfieldPositionDefinition... input)
    • extractPackageName

      public static String extractPackageName(DataField field)
    • extractPackageName

      public static String extractPackageName(DataFieldDefinition field)
    • extractPackageName

      public static String extractPackageName(Class<? extends DataFieldDefinition> field)
    • getVersion

      public static MarcVersion getVersion(DataFieldDefinition field)
    • getVersion

      public static MarcVersion getVersion(Class<? extends DataFieldDefinition> field)
    • package2version

      public static MarcVersion package2version(String packageName)
    • quote

      public static List<Object> quote(List<? extends Serializable> values)
    • quote

      public static Object quote(Object value)
    • count

      public static <T> void count(T key, Map<T,Integer> counter)
      If the key is not in the map, it will be added with the value of 1. In any case, the value will be incremented by i.
      Type Parameters:
      T - Any kind of object. Type of the key in the counter map.
      Parameters:
      key - A key in the counter map or a value that can be used as a key of that map
      counter - A map which uses any kind of object as key and integer as value. Essentially counts the occurrences of the keys.
    • addToCounter

      public static <T> void addToCounter(T key, Map<T,Integer> counter, int i)
      If the key is not in the map, it will be added with the value of 0. In any case, the value will be incremented by i.
      Type Parameters:
      T - Any kind of object. Type of the key in the counter map.
      Parameters:
      key - A key in the counter map or a value that can be used as a key of that map
      counter - A map which uses any kind of object as key and integer as value. Essentially counts the occurrences of its keys.
      i - The value to increment the counter with
    • counterToList

      public static List<String> counterToList(Map<Integer,Integer> counter)
    • counterToList

      public static List<String> counterToList(char separator, Map<Integer,Integer> counter)
    • solarize

      public static String solarize(String abbreviation)
    • createRow

      public static String createRow(Object... fields)
    • createRowWithSep

      public static String createRowWithSep(char separator, Object... fields)
    • base36Encode

      public static String base36Encode(String id)
      Transforms a positive integer to a base36 encoded string
      Parameters:
      id - a positive integer either in normal or in scientific notation (e.g. 12 or 10E+3)
      Returns:
    • parseId

      public static int parseId(String id)
    • base36Encode

      public static String base36Encode(int i)
    • mergeMap

      public static void mergeMap(Map<String,List<String>> base, Map<String,List<String>> extra)
    • scientificNotationToInt

      public static int scientificNotationToInt(String scientificNotation)
    • substring

      public static String substring(String value, int start, int end)
    • listToMap

      public static Map<String,Boolean> listToMap(List<String> list)
      Convert a list of strings to a map where the keys are the strings and the values are true.
      Parameters:
      list - A list of strings.
      Returns:
      A map where the keys are the strings and the values are true.
    • base64decode

      public static String base64decode(String raw)
    • formatDuration

      public static String formatDuration(long duration)
      Create a human readable duration string, such as '03:24:12' or '1d 12:34:56'
      Parameters:
      duration - Duration in milliseconds
      Returns:
      a human readable duration string
    • romanToInt

      public static String romanToInt(String roman)
      The solution is taken from Shreedhar A https://medium.com/@ac.shreedhar/roman-to-integer-in-java-97566dd2656d
      Parameters:
      roman -
      Returns: