
net.morimekta.terminal.args.parser.LongParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of terminal Show documentation
Show all versions of terminal Show documentation
Utilities handling specialized terminal input and output.
The newest version!
package net.morimekta.terminal.args.parser;
import net.morimekta.terminal.args.ArgException;
import net.morimekta.terminal.args.ValueParser;
/**
* A converter to long values.
*/
public class LongParser implements ValueParser {
@Override
public Long parse(String s) {
try {
if (s.startsWith("0x")) {
return Long.parseLong(s.substring(2), 16);
} else if (s.startsWith("0")) {
return Long.parseLong(s, 8);
}
return Long.parseLong(s);
} catch (NumberFormatException nfe) {
throw new ArgException("Invalid long value %s", s, nfe);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy