Package de.gwdg.metadataqa.marc
Class Utils
java.lang.Object
de.gwdg.metadataqa.marc.Utils
Utility methods used elsewhere in the tool
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidaddToCounter(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.static Stringbase36Encode(int i) static Stringbase36Encode(String id) Transforms a positive integer to a base36 encoded stringstatic Stringbase64decode(String raw) static <T> voidIf the key is not in the map, it will be added with the value of 1.counterToList(char separator, Map<Integer, Integer> counter) counterToList(Map<Integer, Integer> counter) static Stringstatic StringcreateRowWithSep(char separator, Object... fields) static StringextractPackageName(DataField field) static Stringstatic StringextractPackageName(Class<? extends DataFieldDefinition> field) static StringformatDuration(long duration) Create a human readable duration string, such as '03:24:12' or '1d 12:34:56'static List<EncodedValue>generateCodes(String... input) static List<ControlfieldPositionDefinition>static MarcVersiongetVersion(DataFieldDefinition field) static MarcVersiongetVersion(Class<? extends DataFieldDefinition> field) Convert a list of strings to a map where the keys are the strings and the values are true.static voidstatic MarcVersionpackage2version(String packageName) static intstatic Objectquote(List<? extends Serializable> values) static StringromanToInt(String roman) The solution is taken from Shreedhar A https://medium.com/@ac.shreedhar/roman-to-integer-in-java-97566dd2656dstatic intscientificNotationToInt(String scientificNotation) static Stringstatic String
-
Method Details
-
generateCodes
-
generateControlPositionList
public static List<ControlfieldPositionDefinition> generateControlPositionList(ControlfieldPositionDefinition... input) -
extractPackageName
-
extractPackageName
-
extractPackageName
-
getVersion
-
getVersion
-
package2version
-
quote
-
quote
-
count
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 mapcounter- A map which uses any kind of object as key and integer as value. Essentially counts the occurrences of the keys.
-
addToCounter
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 mapcounter- 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
-
counterToList
-
solarize
-
createRow
-
createRowWithSep
-
base36Encode
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
-
base36Encode
-
mergeMap
-
scientificNotationToInt
-
substring
-
listToMap
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
-
formatDuration
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
The solution is taken from Shreedhar A https://medium.com/@ac.shreedhar/roman-to-integer-in-java-97566dd2656d- Parameters:
roman-- Returns:
-