Package org.apache.jena.riot.tokens

Examples of org.apache.jena.riot.tokens.Token


      }
      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

    return lookingAt(TokenType.STRING1) || lookingAt(TokenType.STRING2);
  }

    private Token checkValidForObjectProperty()
    {
      Token t = null;
      if (lookingAt(TokenType.STRING1) || lookingAt(TokenType.STRING2))
        t = nextToken();
      else
        exception(peekToken(), "JSON Values given for properties for an Object must be Strings") ;
      return t;
View Full Code Here

            case DOUBLE :
                return createTypedLiteral(str, XSDDatatype.XSDdouble, line, col) ;
            case INTEGER :
                return createTypedLiteral(str, XSDDatatype.XSDinteger, line, col) ;
            case LITERAL_DT : {
                Token tokenDT = token.getSubToken2() ;
                String uriStr ;

                switch (tokenDT.getType()) {
                    case IRI :
                        uriStr = tokenDT.getImage() ;
                        break ;
                    case PREFIXED_NAME : {
                        String prefix = tokenDT.getImage() ;
                        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) ;
            }

            case LITERAL_LANG :
View Full Code Here

        if ( tokenEOF != null )
            return true ;
       
        if ( ! moreTokens() )
        {
            tokenEOF = new Token(tokens.getLine(), tokens.getColumn()) ;
            tokenEOF.setType(EOF) ;
            return true ;
        }
        return false ;
    }
View Full Code Here

        if ( eof() )
            return tokenEOF ;
       
        // Tokenizer errors appear here!
        try {
            Token t = peekIter.next() ;
            currLine = t.getLine() ;
            currCol = t.getColumn() ;
            return t ;
        } catch (RiotParseException ex)
        {
            // Intercept to log it.
            raiseException(ex) ;
View Full Code Here

   
    protected final void expect(String msg, TokenType ttype)
    {
        if ( ! lookingAt(ttype) )
        {
            Token location = peekToken() ;
            exception(location, msg) ;
        }
        nextToken() ;
    }
View Full Code Here

    //Loop here because we might see some things we can discard first
    do
    {
      if (!isPropertyName())
      {
        Token t = nextToken();
        String name = t.getImage();
        checkColon();
       
        if (name.equals("head"))
        {
          if (headerSeen) exception(t, "Invalid duplicate header property");
View Full Code Here

  {
    do
    {
      if (isPropertyName())
      {
        Token t = nextToken();
        String name = t.getImage();
        checkColon();
       
        if (name.equals("vars"))
        {
          parseVars();
View Full Code Here

TOP

Related Classes of org.apache.jena.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.