Package org.openjena.riot.tokens

Examples of org.openjena.riot.tokens.Token


    protected abstract void emit(Node subject, Node predicate, Node object) ;

    protected final void directive()
    {
        // It's a directive ...
        Token t = peekToken() ;
        String x = t.getImage() ;
        nextToken() ;
       
        if ( x.equals("base") )
        {
            directiveBase() ;
View Full Code Here


    static protected final Node nodeLogImplies = Node.createURI("http://www.w3.org/2000/10/swap/log#implies") ;
   
    /** Get predicate - maybe null for "illegal" */
    protected final Node predicate()
    {
        Token t = peekToken() ;
       
        if ( t.hasType(TokenType.KEYWORD) )
        {
            Token tErr = peekToken() ;
            String image = peekToken().getImage() ;
            if ( image.equals(KW_A) )
                return NodeConst.nodeRDFType ;
            if ( !strict && image.equals(KW_SAME_AS) )
                return nodeSameAs ;
View Full Code Here

        }

        // Special words.
        if ( lookingAt(TokenType.KEYWORD) )
        {
            Token tErr = peekToken() ;
            // Location independent node words
            String image = peekToken().getImage() ;
            nextToken() ;
            if ( image.equals(KW_TRUE) )
                return NodeConst.nodeTrue ;
View Full Code Here

       
        startList() ;
       
        for ( ;; )
        {
            Token errorToken = peekToken() ;
            if ( eof() )
                exception (peekToken(), "Unterminated list") ;
           
            if ( lookingAt(RPAREN) )
            {
View Full Code Here

//    static final Triple T = new Triple(X, X, X) ;
   
    @Override
    protected final Triple parseOne()
    {
        Token sToken = nextToken() ;
        if ( sToken.isEOF() )
            exception(sToken, "Premature end of file: %s", sToken) ;
       
        Token pToken = nextToken() ;
        if ( pToken.isEOF() )
            exception(pToken, "Premature end of file: %s", pToken) ;
       
        Token oToken = nextToken() ;
        if ( oToken.isEOF() )
            exception(oToken, "Premature end of file: %s", oToken) ;

        // Check in createTriple - but this is cheap so do it anyway.
        checkIRIOrBNode(sToken) ;
        checkIRI(pToken) ;
        checkRDFTerm(oToken) ;
        Token x = nextToken() ;
       
        if ( x.getType() != TokenType.DOT )
            exception(x, "Triple not terminated by DOT: %s", x) ;
//        Node s = X ;
//        Node p = X ;
//        Node o = X ;
//        return T ;
View Full Code Here

    public Lang getLang()   { return Lang.NQUADS ; }
   
    @Override
    protected final Quad parseOne()
    {
        Token sToken = nextToken() ;
        if ( sToken.getType() == TokenType.EOF )
            exception(sToken, "Premature end of file: %s", sToken) ;
       
        Token pToken = nextToken() ;
        if ( pToken.getType() == TokenType.EOF )
            exception(pToken, "Premature end of file: %s", pToken) ;
       
        Token oToken = nextToken() ;
        if ( oToken.getType() == TokenType.EOF )
            exception(oToken, "Premature end of file: %s", oToken) ;
       
        Token xToken = nextToken() ;    // Maybe DOT
        if ( xToken.getType() == TokenType.EOF )
            exception(xToken, "Premature end of file: Quad not terminated by DOT: %s", xToken) ;
       
        // Process graph node first, before S,P,O
        // to set bnode label scope (if not global)
        Node c = null ;

        if ( xToken.getType() != TokenType.DOT )
        {
            checkIRI(xToken) ;
            c = tokenAsNode(xToken) ;
            xToken = nextToken() ;
            currentGraph = c ;
        }
        else
        {
            c = Quad.defaultGraphNodeGenerated ;
            currentGraph = null ;
        }
       
        // createQuad may also check but these checks are cheap and do form syntax errors.
        checkIRIOrBNode(sToken) ;
        checkIRI(pToken) ;
        checkRDFTerm(oToken) ;
        // Already done. checkIRI(xToken) ;

        Node s = tokenAsNode(sToken) ;
        Node p = tokenAsNode(pToken) ;
        Node o = tokenAsNode(oToken) ;
       
        // Check end of tuple.
       
        if ( xToken.getType() != TokenType.DOT )
            exception(xToken, "Quad not terminated by DOT: %s", xToken) ;
       
        return profile.createQuad(c, s, p, o, sToken.getLine(), sToken.getColumn()) ;
    }
View Full Code Here

      }
      else if (isPropertyName())
      {
        subjectExpected = false;
        //Is a Property Name so represents a Subject
        Token t = nextToken() ;
        Node subj;
        if (t.getImage().startsWith("_:"))
        {
          subj = profile.createBlankNode(null, t.getImage().substring(2), t.getLine(), t.getColumn()) ;
        }
        else
        {
          subj = profile.createURI(t.getImage(), t.getLine(), t.getColumn()) ;
        }

        //Should always be a : after a Property Name
        checkColon() ;
View Full Code Here

    {
      if (isPropertyName())
      {
        first = false;
        propertyNameExpected = false;
        Token t = nextToken();
        Node pred = profile.createURI(t.getImage(), t.getLine(), t.getColumn()) ;

        //Must be a : after Property Name
        checkColon() ;

        //Then we can try and parse the Object List
View Full Code Here

    //JSON Object
    //It has mandatory properties 'value' and 'type' plus optional
    //properties 'lang', 'xml:lang' and 'datatype'

    Node obj = null;
    Token value = null, type = null, lang = null, datatype = null;

    //First we expect to see the { character to start the JSON Object
    if (lookingAt(TokenType.LBRACE))
    {
      //Discard the {
      nextToken();

      //Then see a stream of tokens which are property value pairs
      //representing the properties of the object
      boolean first = true;
      boolean propertyNameExpected = true;
      while (true)
      {
        if (isPropertyName())
        {
          first = false;
          propertyNameExpected = false;

          Token t = nextToken();
          String name = t.getImage();

          //Must always be a : after a property name
          checkColon();

          //Is this one of our valid properties
          if (name.equals("value"))
          {
            if (value == null)
            {
              value = checkValidForObjectProperty();
            }
            else
            {
              exception(t, "Encountered the value property on an Object when the value property has already been specified") ;
            }
          }
          else if (name.equals("type"))
          {
            if (type == null)
            {
              type = checkValidForObjectProperty();
            }
            else
            {
              exception(t, "Encountered the type property on an Object when the type property has already been specified") ;
            }
          }
          else if (name.equals("lang") || name.equals("xml:lang"))
          {
            if (lang == null && datatype == null)
            {
              lang = checkValidForObjectProperty();
            }
            else
            {
              exception(t, "Encountered the %s property on an Object when lang/datatype has already been specified", name) ;
            }
          }
          else if (name.equals("datatype"))
          {
            if (lang == null && datatype == null)
            {
              datatype = checkValidForObjectProperty();
            }
            else
            {
              exception(t, "Encountered the %s property on an Object when lang/datatype has already been specified", name) ;
            }
          }
          else
          {
            exception(t, "Unexpected Property Name %s encountered, expected one of value, type, lang or datatype", t.getImage()) ;
          }

          //After each Property Value pair we may optionally
          //see a comma to indicate further pairs are present
          if (lookingAt(TokenType.COMMA))
View Full Code Here

   
    protected final void oneNamedGraphBlock()
    {
        // Directives are only between graphs.
        Node graphNode = Quad.tripleInQuad ;
        Token token = peekToken() ;

        // <foo> = { ... } .
        if ( token.isNode() )
        {
            Token t = token ;   // Keep for error message.
            graphNode = node() ;
            nextToken() ;
            token = peekToken() ;

            if ( graphNode.isURI() )
View Full Code Here

TOP

Related Classes of org.openjena.riot.tokens.Token

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.