本文整理汇总了Java中org.apache.commons.cli2.OptionException类的典型用法代码示例。如果您正苦于以下问题:Java OptionException类的具体用法?Java OptionException怎么用?Java OptionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OptionException类属于org.apache.commons.cli2包,在下文中一共展示了OptionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseCommandLine
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Parses the command line.
*
* @param vsArgs
* The command line
* @return The parsed command line
*/
private static CommandLine parseCommandLine(final String[] vsArgs) {
try {
Group opts = configureCommandLine();
// configure a HelpFormatter
HelpFormatter hf = new HelpFormatter();
// configure a parser
Parser p = new Parser();
p.setGroup(opts);
p.setHelpFormatter(hf);
// p.setHelpTrigger("--help");
return p.parse(vsArgs);
} catch (OptionException oe) {
printUsage(oe);
} catch (Exception e) {
e.printStackTrace();
// Should never happen...
}
return null;
}
开发者ID:ziccardi,项目名称:jnrpe,代码行数:28,代码来源:JNRPEServer.java
示例2: main
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
GroupBuilder gbuilder = new GroupBuilder();
Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create();
Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create();
Option vectorOpt = obuilder.withLongName("vector").withRequired(false).withArgument(
abuilder.withName("v").withMinimum(1).withMaximum(1).create()).withDescription(
"The vector implementation to use.").withShortName("v").create();
Option helpOpt = DefaultOptionCreator.helpOption();
Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(
vectorOpt).withOption(helpOpt).create();
try {
Parser parser = new Parser();
parser.setGroup(group);
CommandLine cmdLine = parser.parse(args);
if (cmdLine.hasOption(helpOpt)) {
CommandLineUtil.printHelp(group);
return;
}
Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString());
Path output = new Path(cmdLine.getValue(outputOpt, "output").toString());
String vectorClassName = cmdLine.getValue(vectorOpt,
"org.apache.mahout.math.RandomAccessSparseVector").toString();
//runJob(input, output, vectorClassName);
} catch (OptionException e) {
InputDriver.log.error("Exception parsing command line: ", e);
CommandLineUtil.printHelp(group);
}
}
开发者ID:PacktPublishing,项目名称:HBase-High-Performance-Cookbook,代码行数:36,代码来源:InputDriver.java
示例3: printHelpWithGenericOptions
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
HelpFormatter formatter = new HelpFormatter();
formatter.setGroup(group);
formatter.setPrintWriter(pw);
formatter.setException(oe);
formatter.print();
}
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:10,代码来源:CommandLineUtil.java
示例4: main
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
public static void main( String[] args ) throws IOException, TasteException, OptionException
{
CreateCsvRatingsFile();
// create data source (model) - from the csv file
File ratingsFile = new File(outputFile);
DataModel model = new FileDataModel(ratingsFile);
// create a simple recommender on our data
CachingRecommender cachingRecommender = new CachingRecommender(new SlopeOneRecommender(model));
// for all users
for (LongPrimitiveIterator it = model.getUserIDs(); it.hasNext();){
long userId = it.nextLong();
// get the recommendations for the user
List<RecommendedItem> recommendations = cachingRecommender.recommend(userId, 10);
// if empty write something
if (recommendations.size() == 0){
System.out.print("User ");
System.out.print(userId);
System.out.println(": no recommendations");
}
// print the list of recommendations for each
for (RecommendedItem recommendedItem : recommendations) {
System.out.print("User ");
System.out.print(userId);
System.out.print(": ");
System.out.println(recommendedItem);
}
}
}
开发者ID:pgiacome,项目名称:Apache-Mahout-cookbook,代码行数:36,代码来源:App.java
示例5: testMyCommandLine_1
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Normalfall(alle verpflichtenden Optionen vorhanden mit gueltigen Werten der Argumente)
*/
@Test
public void testMyCommandLine_1() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例6: testMyCommandLine_2
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Normalfall(alle moeglichen Optionen vorhanden mit gueltigen Werten der Argumente)
*/
@Test
public void testMyCommandLine_2() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例7: testMyCommandLine_3
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lieferant))
*/
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_3() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "0", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例8: testMyCommandLine_4
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --monteur))
*/
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_4() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "0", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例9: testMyCommandLine_5
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --laufzeit))
*/
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_5() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "10", "--laufzeit", "100", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例10: testMyCommandLine_6
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lagermitarbeiter))
*/
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_6() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "10", "--laufzeit", "1000", "--lagermitarbeiter", "0"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例11: testMyCommandLine_7
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen fehlen)
*/
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_7() {
String[] args = {};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:15,代码来源:TestMyCommandLine.java
示例12: testMyCommandLine_8
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lieferant))
*/
@Test
public void testMyCommandLine_8() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "blala", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例13: testMyCommandLine_9
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --monteur))
*/
@Test
public void testMyCommandLine_9() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "blala", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例14: testMyCommandLine_10
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --laufzeit))
*/
@Test
public void testMyCommandLine_10() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "10", "--laufzeit", "blala", "--lagermitarbeiter", "100"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例15: testMyCommandLine_11
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet den Konstruktor.
* Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lagermitarbeiter))
*/
@Test
public void testMyCommandLine_11() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "10", "--monteure", "10", "--laufzeit", "1000", "--lagermitarbeiter", "blalaa"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
throw new IllegalArgumentException();
}
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例16: testGetLagerVerzeichnis
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet die getLagerVerzeichnis-Methode
*/
@Test
public void testGetLagerVerzeichnis() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
assertEquals("roboterfabrik/lager/", cli.getLagerVerzeichnis());
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例17: testGetLogVerzeichnis
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet die getLogVerzeichnis-Methode
*/
@Test
public void testGetLogVerzeichnis() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
assertEquals("roboterfabrik/logs/", cli.getLogVerzeichnis());
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例18: testGetLieferantenAnzahl
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet die getLieferantenAnzahl-Methode
*/
@Test
public void testGetLieferantenAnzahl() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
assertEquals(101, cli.getLieferantenAnzahl());
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例19: testGetMonteurAnzahl
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet die getMonteurAnzahl-Methode
*/
@Test
public void testGetMonteurAnzahl() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
assertEquals(102, cli.getMonteurAnzahl());
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
示例20: testGetLagerMitarbeiterAnzahl
import org.apache.commons.cli2.OptionException; //导入依赖的package包/类
/**
* Testet die getLagerMitarbeiterAnzahl-Methode
*/
@Test
public void testGetLagerMitarbeiterAnzahl() {
String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/",
"--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003", "--lagermitarbeiter", "104"};
MyCommandLine cli;
try {
assertNotNull(cli = new MyCommandLine(args));
} catch (OptionException e) {
cli = null;
}
assertEquals(104, cli.getLagerMitarbeiterAnzahl());
}
开发者ID:aayvazyan-tgm,项目名称:tgm.sew.4ahit.roboterfabrik.Simulation,代码行数:16,代码来源:TestMyCommandLine.java
注:本文中的org.apache.commons.cli2.OptionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论