Package lupos.datastructures.items.literal

Examples of lupos.datastructures.items.literal.TypedLiteral


    }
    return new Constant(literal, argu);
  }

  public Object visit(final RIFLiteralWithLangTag n, final IRuleNode argu) {
    final TypedLiteral content = (TypedLiteral) ((Constant) n.f0.accept(
        this, argu)).getLiteral();
    final String langTag = (String) n.f1.accept(this, argu);
    final Literal literal = LiteralFactory.createLanguageTaggedLiteralWithoutLazyLiteral(
        content.getContent(), langTag);
    return new Constant(literal, argu);
  }
View Full Code Here


    }
   
    // third typed literals:
    // Numeric comparison?
    if (l0 instanceof TypedLiteral && l1 instanceof TypedLiteral) {
      final TypedLiteral tl0 = (TypedLiteral) l0;
      final TypedLiteral tl1 = (TypedLiteral) l1;
      if (Helper.isNumeric(tl0.getType())
          && Helper.isNumeric(tl1.getType())) {
        if (Helper.isInteger(tl0.getType())
            && Helper.isInteger(tl1.getType())) {
            BigInteger a;
            try {
              a = Helper.getInteger(tl0);
            } catch (final NumberFormatException e) {
              a = null;
View Full Code Here

    public static Geometry getGeoSPARQLGeometry(Object a) throws TypeErrorException
    {
      a = Helper.unlazy(a);
        if (a instanceof TypedLiteral) {
            final TypedLiteral tl = (TypedLiteral) a;
            String content = tl.getContent();
            if(content.startsWith("\"")){
                content = tl.getContent().substring(1, tl.getContent().length() - 1);
            }

            if (tl.getType().compareTo("<" + geoSPARQLwktDataTypeURI + ">") == 0){
                return new GeoSPARQLWktDeserializer().toGeometry(content);
            }
            else if(tl.getType().compareTo("<" + geoSPARQLgmlDataTypeURI + ">") == 0){
                return new GmlDeserializer().toGeometry(content);
            }
            throw new TypeErrorException();
        }
        throw new TypeErrorException();
View Full Code Here

    }

    public static Geometry getStSPARQLGeometry(Object a) throws TypeErrorException {
      a = Helper.unlazy(a);
        if (a instanceof TypedLiteral) {
            final TypedLiteral tl = (TypedLiteral) a;
            String content = tl.getContent();
            if(content.startsWith("\"")){
                content = tl.getContent().substring(1, tl.getContent().length() - 1);
            }
            if (tl.getType().compareTo("<" + stWktDataTypeURI + ">") == 0 || tl.getType().compareTo("<" + stGeometryDataTypeURI + ">") == 0){
                return new StSPARQLWktDeserializer().toGeometry(content);
            }
            else if(tl.getType().compareTo("<" + stGmlDataTypeURI + ">") == 0){
                return new GmlDeserializer().toGeometry(content);
            }
            throw new TypeErrorException();
        }
        throw new TypeErrorException();
View Full Code Here

      return new BigDecimal((BigInteger) a);
    if(a instanceof LazyLiteral){
      a = ((LazyLiteral)a).getLiteral();
    }
    if (a instanceof TypedLiteral) {
      final TypedLiteral tl = (TypedLiteral) a;
      String content = tl.getContent().substring(1,
          tl.getContent().length() - 1);
      while(content.startsWith("+")){
        content = content.substring(1,content.length());
      }       
      if (isInteger(tl.getType()))
        return new BigDecimal(new BigInteger(content));
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#float>") == 0)
        return new BigDecimal(Float.parseFloat(content));
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#double>") == 0)
        return new BigDecimal(Double.parseDouble(content));
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#decimal>") == 0)
        return new BigDecimal(content);
    }
    throw new TypeErrorException();
  }
View Full Code Here

      return BigDecimal.class;
    if(a instanceof LazyLiteral){
      a = ((LazyLiteral)a).getLiteral();
    }
    if (a instanceof TypedLiteral) {
      final TypedLiteral tl = (TypedLiteral) a;
      if (isInteger(tl.getType()))
        return BigInteger.class;
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#double>") == 0)
        return Double.class;
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#float>") == 0)
        return Float.class;
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#decimal>") == 0)
        return BigDecimal.class;
    }
    throw new TypeErrorException();
  }
View Full Code Here

    return false;
  }

  public static String getString(final Object o) {
    if (o instanceof TypedLiteral) {
      final TypedLiteral tl = (TypedLiteral) o;
      return tl.getContent().substring(1, tl.getContent().length() - 1);
//      if (isNumeric(tl.getType()))
//        return tl.toString();
//      else if (tl.getType().compareTo(
//          "<http://www.w3.org/2001/XMLSchema#string>") == 0)
//        return tl.getContent().substring(1,
View Full Code Here

   * @return Number of same value
   * @throws NumberFormatException if literal is not typed or type is not a number (see content2Number)
   */
  protected Number literal2Number(Literal literal) throws NumberFormatException{
    if (literal.isTypedLiteral()) {
      TypedLiteral tl = (TypedLiteral) literal;
      String typ = tl.getType();
      String content = tl.getContent();
      return content2Number(typ, content);
    }
   
    throw new NumberFormatException();
    //return null;
View Full Code Here

   * Returns the untyped content of a Literal
   * @param literal
   * @return
   */
  protected String stripType(Literal literal){
    TypedLiteral tl = null;
    String content;
    if (literal.isTypedLiteral()) {
      // strip of the type
      tl = (TypedLiteral) literal;
      content = tl.getContent();
      return content.substring(1, content.length() - 1);
    } else // has no type
      return literal.toString();
    }
  }
View Full Code Here

      return (BigInteger) a;
    if(a instanceof LazyLiteral){
      a = ((LazyLiteral)a).getLiteral();
    }
    if (a instanceof TypedLiteral) {
      final TypedLiteral tl = (TypedLiteral) a;
      String content = tl.getContent().substring(1,
          tl.getContent().length() - 1);
      while(content.startsWith("+")){
        content = content.substring(1,content.length());
      }       
      if (isInteger(tl.getType()))
        return new BigInteger(content);
    }
    throw new TypeErrorException();
  }
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.literal.TypedLiteral

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.