Package org.apache.jena.riot

Examples of org.apache.jena.riot.RiotException


  private static boolean checkValidPrefixName(String prefixedName)
  {
      // Split it to get the parts.
      int i = prefixedName.indexOf(':') ;
      if ( i < 0 )
          throw new RiotException("Broken short form -- "+prefixedName) ;
      String p = prefixedName.substring(0,i) ;
      String x = prefixedName.substring(i+1) ;
      // Check legality
      if ( checkValidPrefixedName(p, x) )
          return true ;
View Full Code Here


    private void checkTriple(Node subject, Node predicate, Node object, long line, long col)
    {
        if ( subject == null || ( ! subject.isURI() && ! subject.isBlank() ) )
        {
            errorHandler.error("Subject is not a URI or blank node", line, col) ;
            throw new RiotException("Bad subject: "+subject) ;
        }
        if ( predicate == null || ( ! predicate.isURI() ) )
        {
            errorHandler.error("Predicate not a URI", line, col) ;
            throw new RiotException("Bad predicate: "+predicate) ;
        }
        if ( object == null || ( ! object.isURI() && ! object.isBlank() && ! object.isLiteral() ) )
        {
            errorHandler.error("Object is not a URI, blank node or literal", line, col) ;
            throw new RiotException("Bad object: "+object) ;
        }
    }
View Full Code Here

    private void checkQuad(Node graph, Node subject, Node predicate, Node object, long line, long col)
    {
        if ( graph != null && ! graph.isURI() && ! graph.isBlank() )    // Allow blank nodes - syntax may restrict more.
        {
            errorHandler.error("Graph name is not a URI or blank node: "+FmtUtils.stringForNode(graph), line, col) ;
            throw new RiotException("Bad graph name: "+graph) ;
        }       
        checkTriple(subject,predicate,object,line,col) ;
    }
View Full Code Here

                        String suffix = tokenDT.getImage2() ;
                        uriStr = expandPrefixedName(prefix, suffix, tokenDT) ;
                        break ;
                    }
                    default :
                        throw new RiotException("Expected IRI for datatype: " + token) ;
                }

                uriStr = resolveIRI(uriStr, tokenDT.getLine(), tokenDT.getColumn()) ;
                RDFDatatype dt = NodeFactory.getType(uriStr) ;
                return createTypedLiteral(str, dt, line, col) ;
View Full Code Here

    if ( s.isBlank() ) {
      out.key("_:" + s.getBlankNodeLabel()) ;
    } else if ( s.isURI() ) {
      out.key(s.getURI()) ;
    } else {
      throw new RiotException ("Only URIs or blank nodes are legal subjects.") ;
    }
    out.startObject() ;
    // out.pair(key, value) ;
    Map<Node, Set<Node>> predicates = item.getRight() ;
    for (Node p : predicates.keySet() ) {
View Full Code Here

                        String suffix = tokenDT.getImage2() ;
                        uriStr = expandPrefixedName(prefix, suffix, tokenDT) ;
                        break ;
                    }
                    default:
                        throw new RiotException("Expected IRI for datatype: "+token) ;
                }
               
                uriStr = resolveIRI(uriStr, tokenDT.getLine(), tokenDT.getColumn()) ;
                RDFDatatype dt = NodeFactory.getType(uriStr) ;
                return createTypedLiteral(str, dt, line, col) ;
View Full Code Here

    static Token create(String s)
    {
        PeekReader pr = PeekReader.readString(s) ;
        TokenizerText tt = new TokenizerText(pr) ;
        if ( ! tt.hasNext() )
            throw new RiotException("No token") ;
        Token t = tt.next() ;
        if ( tt.hasNext() )
            throw new RiotException("Extraneous charcaters") ;
        return t ;
    }
View Full Code Here

            case PREFIXED_NAME :
                if ( pmap == null )
                    return NodeFactory.createURI("urn:prefixed-name:"+tokenImage+":"+tokenImage2) ;
                String x = pmap.expand(tokenImage, tokenImage2) ;
                if ( x == null )
                    throw new RiotException("Can't expand prefixed name: "+this) ;
                return NodeFactory.createURI(x) ;
            case DECIMAL :  return NodeFactory.createLiteral(tokenImage, null, XSDDatatype.XSDdecimal;
            case DOUBLE :   return NodeFactory.createLiteral(tokenImage, null, XSDDatatype.XSDdouble;
            case INTEGER:   return NodeFactory.createLiteral(tokenImage, null, XSDDatatype.XSDinteger) ;
            case LITERAL_DT :
            {
                Token lexToken = getSubToken1() ;
                Token dtToken  = getSubToken2() ;
               
                if ( pmap == null && dtToken.hasType(TokenType.PREFIXED_NAME) )
                    // Must be able to resolve the datattype else we can't find it's datatype.
                    throw new RiotException("Invalid token: "+this) ;
                Node n = dtToken.asNode(pmap);
                if ( ! n.isURI() )
                    throw new RiotException("Invalid token: "+this) ;
                RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(n.getURI()) ;
                return NodeFactory.createLiteral(lexToken.getImage(), null, dt;
            }
            case LITERAL_LANG : return NodeFactory.createLiteral(tokenImage, tokenImage2, null;
            case STRING:
View Full Code Here

    /** Get the graph writer factory asscoiated with the language */
    public static WriterGraphRIOTFactory getWriterGraphFactory(Lang lang)
    {
        RDFFormat serialization = defaultSerialization(lang) ;
        if ( serialization == null )
            throw new RiotException("No default serialization for language "+lang) ;
        return getWriterGraphFactory(serialization) ;
    }
View Full Code Here

    /** Get the dataset writer factory asscoiated with the language */
    public static WriterDatasetRIOTFactory getWriterDatasetFactory(Lang lang)
    {
        RDFFormat serialization = defaultSerialization(lang) ;
        if ( serialization == null )
            throw new RiotException("No default serialization for language "+lang) ;
        return getWriterDatasetFactory(serialization)
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.riot.RiotException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.