de.weltraumschaf.commons.shell.Parsers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common Utility Classes for Java.
The newest version!
/*
* LICENSE
*
* "THE BEER-WARE LICENSE" (Revision 43):
* "Sven Strittmatter" wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a non alcohol-free beer in return.
*
* Copyright (C) 2012 "Sven Strittmatter"
*/
package de.weltraumschaf.commons.shell;
/**
* Factory to create parsers.
*
* @author Sven Strittmatter
*/
public final class Parsers {
/**
* Hide constructor for factories sake.
*/
private Parsers() {
super();
}
/**
* Creates a new parser with default scanner implementation and {@link NullCommandVerifier}.
*
* @param m map key word literals to command types
* @return new instance
*/
public static Parser newParser(final LiteralCommandMap m) {
return newParser(Scanners.newScanner(m), m);
}
/**
* Create new parser with custom scanner and {@link NullCommandVerifier}.
*
* @param s used to tokenize input
* @param m map key word literals to command types
* @return new instance
*/
public static Parser newParser(final Scanner s, final LiteralCommandMap m) {
return newParser(Scanners.newScanner(m), new NullCommandVerifier(), m);
}
/**
* Creates parser with {@link DefaultScanner}.
*
* @param v verifies parsed commands
* @param m map key word literals to command types
* @return new instance
*/
public static Parser newParser(final CommandVerifier v, final LiteralCommandMap m) {
return newParser(Scanners.newScanner(m), v, m);
}
/**
* Creates parser.
*
* @param s used to tokenize input
* @param v verifies parsed commands
* @param m map key word literals to command types
* @return new instance
*/
public static Parser newParser(final Scanner s, final CommandVerifier v, final LiteralCommandMap m) {
return new DefaultParser(s, v, m);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy