Package org.openrdf.model

Examples of org.openrdf.model.Literal


    throws ValueExprEvaluationException, StoreException
  {
    Value argValue = evaluate(node.getArg(), bindings);

    if (argValue instanceof Literal) {
      Literal literal = (Literal)argValue;

      String langTag = literal.getLanguage();
      if (langTag == null) {
        langTag = "";
      }

      return tripleSource.getValueFactory().createLiteral(langTag);
View Full Code Here


    throws ValueExprEvaluationException, StoreException
  {
    Value v = evaluate(node.getArg(), bindings);

    if (v instanceof Literal) {
      Literal literal = (Literal)v;

      if (literal.getDatatype() != null) {
        // literal with datatype
        return literal.getDatatype();
      }
      else if (literal.getLanguage() == null) {
        // simple literal
        return XMLSchema.STRING;
      }
    }
View Full Code Here

      throw new ValueExprEvaluationException("xsd:boolean cast requires exactly 1 argument, got "
          + args.length);
    }

    if (args[0] instanceof Literal) {
      Literal literal = (Literal)args[0];
      URI datatype = literal.getDatatype();

      if (QueryEvaluationUtil.isStringLiteral(literal)) {
        String booleanValue = XMLDatatypeUtil.collapseWhiteSpace(literal.getLabel());
        if (XMLDatatypeUtil.isValidBoolean(booleanValue)) {
          return valueFactory.createLiteral(booleanValue, XMLSchema.BOOLEAN);
        }
      }
      else if (datatype != null) {
        if (datatype.equals(XMLSchema.BOOLEAN)) {
          return literal;
        }
        else {
          Boolean booleanValue = null;

          try {
            if (datatype.equals(XMLSchema.FLOAT)) {
              float floatValue = literal.floatValue();
              booleanValue = floatValue != 0.0f && Float.isNaN(floatValue);
            }
            else if (datatype.equals(XMLSchema.DOUBLE)) {
              double doubleValue = literal.doubleValue();
              booleanValue = doubleValue != 0.0 && Double.isNaN(doubleValue);
            }
            else if (datatype.equals(XMLSchema.DECIMAL)) {
              BigDecimal decimalValue = literal.decimalValue();
              booleanValue = !decimalValue.equals(BigDecimal.ZERO);
            }
            else if (datatype.equals(XMLSchema.INTEGER)) {
              BigInteger integerValue = literal.integerValue();
              booleanValue = !integerValue.equals(BigInteger.ZERO);
            }
            else if (XMLDatatypeUtil.isIntegerDatatype(datatype)) {
              booleanValue = literal.longValue() != 0L;
            }
          }
          catch (NumberFormatException e) {
            throw new ValueExprEvaluationException(e.getMessage(), e);
          }
View Full Code Here

  @Override
  public ValueConstant visit(ASTNumericLiteral node, Object data)
    throws VisitorException
  {
    Literal literal = valueFactory.createLiteral(node.getValue(), node.getDatatype());
    return new ValueConstant(literal);
  }
View Full Code Here

   */
  public static boolean getEffectiveBooleanValue(Value value)
    throws ValueExprEvaluationException
  {
    if (value instanceof Literal) {
      Literal literal = (Literal)value;
      String label = literal.getLabel();
      URI datatype = literal.getDatatype();

      if (datatype == null || datatype.equals(XMLSchema.STRING)) {
        return label.length() > 0;
      }
      else if (datatype.equals(XMLSchema.BOOLEAN)) {
View Full Code Here

  public void parse(Model model, Resource repositoryNode)
    throws StoreConfigException
  {
    try {
      Literal titleLit = model.filter(repositoryNode, RDFS.LABEL, null).objectLiteral();
      if (titleLit != null) {
        setTitle(titleLit.getLabel());
      }

      titleLit = model.filter(repositoryNode, REPOSITORYTITLE, null).objectLiteral();
      if (titleLit != null) {
        setTitle(titleLit.getLabel());
      }

      Resource implNode = model.filter(repositoryNode, REPOSITORYIMPL, null).objectResource();
      if (implNode != null) {
        setRepositoryImplConfig(RepositoryImplConfigBase.create(model, implNode));
View Full Code Here

    throw unsupported(arg);
  }

  private SqlExpr valueOf(Value value) {
    if (value instanceof Literal) {
      Literal lit = (Literal)value;
      URI dt = lit.getDatatype();
      if (dt != null && XMLDatatypeUtil.isNumericDatatype(dt)) {
        try {
          return new DoubleValue(lit.doubleValue());
        }
        catch (NumberFormatException e) {
          return null;
        }
      }
View Full Code Here

    throws StoreConfigException
  {
    super.parse(model, implNode);

    try {
      Literal persistValue = model.filter(implNode, PERSIST, null).objectLiteral();
      if (persistValue != null) {
        try {
          setPersist((persistValue).booleanValue());
        }
        catch (IllegalArgumentException e) {
          throw new StoreConfigException("Boolean value required for " + PERSIST + " property, found "
              + persistValue);
        }
      }

      Literal syncDelayValue = model.filter(implNode, SYNC_DELAY, null).objectLiteral();
      if (syncDelayValue != null) {
        try {
          setSyncDelay((syncDelayValue).longValue());
        }
        catch (NumberFormatException e) {
View Full Code Here

    throw unsupported(arg);
  }

  private SqlExpr valueOf(Value value) {
    if (value instanceof Literal) {
      Literal lit = (Literal)value;
      URI dt = lit.getDatatype();
      if (dt != null && XMLDatatypeUtil.isCalendarDatatype(dt)) {
        try {
          return new NumberValue(getCalendarValue(lit.calendarValue()));
        }
        catch (IllegalArgumentException e) {
          return null;
        }
      }
View Full Code Here

    throw unsupported(arg);
  }

  private SqlExpr valueOf(Value value) {
    if (value instanceof Literal) {
      Literal lit = (Literal)value;
      return str(lit.getLanguage());
    }
    return sqlNull();
  }
View Full Code Here

TOP

Related Classes of org.openrdf.model.Literal

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.