Package com.github.alex1304.jdash.util
Class ParseUtils
- java.lang.Object
-
- com.github.alex1304.jdash.util.ParseUtils
-
public final class ParseUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static reactor.util.function.Tuple3<Integer,Integer,Integer>
extractPageInfo(String raw)
Extracts a triplet (a set of exactly 3 integer values) from the given raw data string.static Map<Integer,String>
splitToMap(String str, String regex)
Transforms a string into a map.static Map<Long,String>
structureCreatorsInfo(String creatorsInfoRD)
Parses the String representing level creators into a Map that associates the creator ID with their namestatic Map<Long,GDSong>
structureSongsInfo(String songsInfoRD)
Parses the String representing level songs into a Map that associates the song ID with their title
-
-
-
Method Detail
-
splitToMap
public static Map<Integer,String> splitToMap(String str, String regex)
Transforms a string into a map. The string must be in a specific format for this method to work. For example, a string formatted as"1:abc:2:def:3:xyz"
will return the following map:1 => abc 2 => def 3 => xyz
- Parameters:
str
- the string to convert to mapregex
- the regex representing the separator between values in the string. In the example above, it would be ":"- Returns:
- a Map of Integer, String
- Throws:
NumberFormatException
- if a key of the map couldn't be converted to int. Example, the string1:abc:A:xyz
would throw this exception.
-
structureCreatorsInfo
public static Map<Long,String> structureCreatorsInfo(String creatorsInfoRD)
Parses the String representing level creators into a Map that associates the creator ID with their name- Parameters:
creatorsInfoRD
- the String representing the creators- Returns:
- a Map of Long, String
-
structureSongsInfo
public static Map<Long,GDSong> structureSongsInfo(String songsInfoRD)
Parses the String representing level songs into a Map that associates the song ID with their title- Parameters:
songsInfoRD
- the String representing the songs- Returns:
- a Map of Long, String
-
extractPageInfo
public static reactor.util.function.Tuple3<Integer,Integer,Integer> extractPageInfo(String raw)
Extracts a triplet (a set of exactly 3 integer values) from the given raw data string. The string is expected to match the regex:[0-9]+:[0-9]+:[0-9]+
- Parameters:
raw
- the String to parse- Returns:
- an int array of length 3 containing the three values of the triplet.
-
-