Search in sources :

Example 16 with InternalErrorException

use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.

the class JSONMaker method finishPair.

@Override
public void finishPair(long currLine, long currCol) {
    if (value == null)
        throw new InternalErrorException("null for 'value' (bad finishPair() allignment)");
    String k = keys.pop();
    JsonObject obj = objects.peek();
    if (obj.hasKey(k))
        Log.warn("JSON", "Duplicate key '" + k + "' for object [" + currLine + "," + currCol + "]");
    obj.put(k, value);
    value = null;
}
Also used : InternalErrorException(org.apache.jena.atlas.lib.InternalErrorException)

Example 17 with InternalErrorException

use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.

the class JsonLDReader method createNode.

private Node createNode(Map<String, Object> map) {
    String type = (String) map.get("type");
    String lex = (String) map.get("value");
    if (type.equals(IRI))
        return createURI(lex);
    else if (type.equals(BLANK_NODE))
        return createBlankNode(lex);
    else if (type.equals(LITERAL)) {
        String lang = (String) map.get("language");
        String datatype = (String) map.get("datatype");
        if (Objects.equals(xsdString, datatype))
            // In RDF 1.1, simple literals and xsd:string are the same.
            // During migration, we prefer simple literals to xsd:strings. 
            datatype = null;
        if (lang == null && datatype == null)
            return profile.createStringLiteral(lex, -1, -1);
        if (lang != null)
            return profile.createLangLiteral(lex, lang, -1, -1);
        RDFDatatype dt = NodeFactory.getType(datatype);
        return profile.createTypedLiteral(lex, dt, -1, -1);
    } else
        throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type);
}
Also used : InternalErrorException(org.apache.jena.atlas.lib.InternalErrorException) RDFDatatype(org.apache.jena.datatypes.RDFDatatype)

Example 18 with InternalErrorException

use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.

the class MapWithScope method get.

/** Get a B object for an A object in scope S object */
public B get(S scope, A item) {
    if (item == null)
        throw new InternalErrorException("null in MapWithScope.get(,null)");
    Map<A, B> map = scopePolicy.getScope(scope);
    if (map == null)
        // No map - no item->allocation tracking.
        return allocator.alloc(scope, item);
    B mappedItem = map.get(item);
    if (mappedItem == null) {
        mappedItem = allocator.alloc(scope, item);
        map.put(item, mappedItem);
    }
    return mappedItem;
}
Also used : InternalErrorException(org.apache.jena.atlas.lib.InternalErrorException)

Aggregations

InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)18 Node (org.apache.jena.graph.Node)5 Triple (org.apache.jena.graph.Triple)2 Dataset (org.apache.jena.query.Dataset)2 Model (org.apache.jena.rdf.model.Model)2 RiotException (org.apache.jena.riot.RiotException)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 Var (org.apache.jena.sparql.core.Var)2 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)2 Binding (org.apache.jena.sparql.engine.binding.Binding)2 Expr (org.apache.jena.sparql.expr.Expr)2 ExprVar (org.apache.jena.sparql.expr.ExprVar)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 CmdException (jena.cmd.CmdException)1 ContentType (org.apache.jena.atlas.web.ContentType)1 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)1 DatasetDescriptionRegistry (org.apache.jena.fuseki.build.DatasetDescriptionRegistry)1 Graph (org.apache.jena.graph.Graph)1