Search in sources :

Example 31 with CmdException

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());
        }
    }
}
Also used : IRI(org.apache.jena.iri.IRI) RiotException(org.apache.jena.riot.RiotException) CmdException(jena.cmd.CmdException) Lang(org.apache.jena.riot.Lang) RiotException(org.apache.jena.riot.RiotException) CmdException(jena.cmd.CmdException)

Example 32 with CmdException

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();
}
Also used : CmdException(jena.cmd.CmdException) Dataset(org.apache.jena.query.Dataset)

Aggregations

CmdException (jena.cmd.CmdException)32 Lang (org.apache.jena.riot.Lang)8 Dataset (org.apache.jena.query.Dataset)6 Node (org.apache.jena.graph.Node)3 Model (org.apache.jena.rdf.model.Model)3 JenaException (org.apache.jena.shared.JenaException)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 ArgDecl (jena.cmd.ArgDecl)2 TerminationException (jena.cmd.TerminationException)2 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)2 Graph (org.apache.jena.graph.Graph)2 RiotException (org.apache.jena.riot.RiotException)2 PrefixMapping (org.apache.jena.shared.PrefixMapping)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)2 Transactional (org.apache.jena.sparql.core.Transactional)2 TransactionalNull (org.apache.jena.sparql.core.TransactionalNull)2 ResultSetException (org.apache.jena.sparql.resultset.ResultSetException)2 UpdateRequest (org.apache.jena.update.UpdateRequest)2 ModDataset (arq.cmdline.ModDataset)1 IOException (java.io.IOException)1