public final class LyricUtil
extends java.lang.Object
This class provides methods to deal with Lyrics events, especially according to RP-026.
Modifier and Type | Field and Description |
---|---|
private static java.util.ArrayList<java.util.regex.Pattern> |
escapePatterns |
private static java.util.ArrayList<java.lang.String> |
escapeReplacements |
private static java.util.ArrayList<java.util.regex.Pattern> |
forwardPatterns |
private static java.util.ArrayList<java.lang.String> |
forwardReplacements |
private static LyricUtil |
instance
Singleton object of this class
|
private static java.util.regex.Pattern |
pattCR |
private static java.util.regex.Pattern |
pattLF |
private static java.util.regex.Pattern |
pattSongInfo |
private static java.util.regex.Pattern |
pattTab |
private static java.util.ArrayList<java.util.regex.Pattern> |
reversePatterns |
private static java.util.ArrayList<java.lang.String> |
reverseReplacements |
private static java.util.ArrayList<java.lang.String> |
reverseSpecialChars |
static java.lang.String |
SOFTWARE
used for the software and version meta info
|
private static java.util.regex.Pattern |
tagPattern |
Modifier | Constructor and Description |
---|---|
private |
LyricUtil()
Private constructor, precompiling needed regex patterns.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
decodeHashes(java.lang.String text)
Replaces hash values by their original escaped characters.
|
private java.lang.String |
encodeHashes(java.lang.String text)
Replaces escaped characters with their hash values so that they don’t disturb regexes.
|
java.lang.String |
escape(java.lang.String text)
Escapes special characters of the given string according to RP-026.
|
static LyricUtil |
getInstance()
Creates and returns a singleton object of this class.
|
java.util.HashMap<java.lang.String,java.lang.String> |
getSongInfo(java.lang.String text)
Searches for song info tags in the given text.
|
private java.lang.String |
hashesToSpecial(java.lang.String text)
Replaces hash values of escaped characters by the according special characters.
|
java.lang.String |
removeTags(java.lang.String text)
Removes RP-026 tags from the given lyrics text.
|
java.lang.String |
unescapeSpecialWhitespaces(java.lang.String text)
Unescapes escaped special whitespace characters in lyrics events.
|
public static final java.lang.String SOFTWARE
used for the software and version meta info
private static LyricUtil instance
Singleton object of this class
private static final java.util.ArrayList<java.util.regex.Pattern> forwardPatterns
private static final java.util.ArrayList<java.lang.String> forwardReplacements
private static final java.util.ArrayList<java.util.regex.Pattern> reversePatterns
private static final java.util.ArrayList<java.lang.String> reverseReplacements
private static final java.util.ArrayList<java.lang.String> reverseSpecialChars
private static final java.util.regex.Pattern tagPattern
private static final java.util.regex.Pattern pattSongInfo
private static final java.util.ArrayList<java.util.regex.Pattern> escapePatterns
private static final java.util.ArrayList<java.lang.String> escapeReplacements
private static final java.util.regex.Pattern pattCR
private static final java.util.regex.Pattern pattLF
private static final java.util.regex.Pattern pattTab
private LyricUtil()
Private constructor, precompiling needed regex patterns.
public static final LyricUtil getInstance()
Creates and returns a singleton object of this class.
public final java.util.HashMap<java.lang.String,java.lang.String> getSongInfo(java.lang.String text)
Searches for song info tags in the given text. The text is assumed to be the text part of a lyrics meta event. Such tags look like {#…=…}.
text
- The text to search.public final java.lang.String escape(java.lang.String text)
Escapes special characters of the given string according to RP-026.
text
- The text to be escaped.public final java.lang.String unescapeSpecialWhitespaces(java.lang.String text)
Unescapes escaped special whitespace characters in lyrics events. Replaces \r, \n and \t.
text
- The text to unescape.public final java.lang.String removeTags(java.lang.String text)
Removes RP-026 tags from the given lyrics text.
text
- The lyrics text.private final java.lang.String encodeHashes(java.lang.String text)
Replaces escaped characters with their hash values so that they don’t disturb regexes.
text
- The text to be encoded.private final java.lang.String decodeHashes(java.lang.String text)
Replaces hash values by their original escaped characters.
text
- The text to be decoded.private final java.lang.String hashesToSpecial(java.lang.String text)
Replaces hash values of escaped characters by the according special characters.
text
- The text to be decoded.