use of jena.cmd.CmdException in project jena by apache.
the class ModLangParse method processArgs.
@Override
public void processArgs(CmdArgModule cmdLine) {
if (cmdLine.contains(argValidate)) {
validate = true;
strict = true;
explicitCheck = true;
bitbucket = true;
}
if (cmdLine.contains(argSyntax)) {
String syntax = cmdLine.getValue(argSyntax);
Lang lang$ = RDFLanguages.nameToLang(syntax);
if (lang$ == null)
throw new CmdException("Can not detemine the syntax from '" + syntax + "'");
this.lang = lang$;
}
if (cmdLine.contains(argCheck))
explicitCheck = true;
if (cmdLine.contains(argNoCheck))
explicitNoCheck = true;
if (cmdLine.contains(argStrict))
strict = true;
if (cmdLine.contains(argSkip))
skipOnBadTerm = true;
if (cmdLine.contains(argNoSkip))
skipOnBadTerm = false;
if (cmdLine.contains(argBase)) {
baseIRI = cmdLine.getValue(argBase);
IRI iri = IRIResolver.resolveIRI(baseIRI);
if (iri.hasViolation(false))
throw new CmdException("Bad base IRI: " + baseIRI);
if (!iri.isAbsolute())
throw new CmdException("Base IRI must be an absolute IRI: " + baseIRI);
}
if (cmdLine.contains(argStop))
stopOnBadTerm = true;
if (cmdLine.contains(argSink))
bitbucket = true;
if (cmdLine.contains(argRDFS)) {
try {
rdfsVocabFilename = cmdLine.getArg(argRDFS).getValue();
rdfsVocab = FileManager.get().loadModel(rdfsVocabFilename);
} catch (RiotException ex) {
throw new CmdException("Error in RDFS vocabulary: " + rdfsVocabFilename);
} catch (Exception ex) {
throw new CmdException("Error: " + ex.getMessage());
}
}
}
use of jena.cmd.CmdException in project jena by apache.
the class textindexer method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
super.processModulesAndArgs();
// Two forms : with and without arg.
// Maximises similarity with other tools.
String file;
if (!super.contains(assemblerDescDecl) && getNumPositional() == 0)
throw new CmdException("No assembler description given");
if (super.contains(assemblerDescDecl)) {
if (getValues(assemblerDescDecl).size() != 1)
throw new CmdException("Multiple assembler descriptions given via --desc");
if (getPositional().size() != 0)
throw new CmdException("Additional assembler descriptions given");
file = getValue(assemblerDescDecl);
} else {
if (getNumPositional() != 1)
throw new CmdException("Multiple assembler descriptions given as positional arguments");
file = getPositionalArg(0);
}
if (file == null)
throw new CmdException("No dataset specified");
// Assumes a single test dataset description in the assembler file.
Dataset ds = TextDatasetFactory.create(file);
if (ds == null)
throw new CmdException("No dataset description found");
// get index.
dataset = (DatasetGraphText) (ds.asDatasetGraph());
textIndex = dataset.getTextIndex();
if (textIndex == null)
throw new CmdException("Dataset has no text index");
entityDefinition = textIndex.getDocDef();
}
Aggregations