• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Literal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.olingo.server.api.uri.queryoption.expression.Literal的典型用法代码示例。如果您正苦于以下问题:Java Literal类的具体用法?Java Literal怎么用?Java Literal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Literal类属于org.apache.olingo.server.api.uri.queryoption.expression包,在下文中一共展示了Literal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: accept

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public void accept(Expression expr) {
    if (expr instanceof Alias) {
        visit((Alias) expr);
    } else if (expr instanceof Binary) {
        visit((Binary) expr);
    } else if (expr instanceof Enumeration) {
        visit((Enumeration) expr);
    } else if (expr instanceof LambdaRef) {
        visit((LambdaRef) expr);
    } else if (expr instanceof Literal) {
        visit((Literal) expr);
    } else if (expr instanceof Member) {
        visit((Member) expr);
    } else if (expr instanceof Method) {
        visit((Method) expr);
    } else if (expr instanceof TypeLiteral) {
        visit((TypeLiteral) expr);
    } else if (expr instanceof Unary) {
        visit((Unary) expr);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:22,代码来源:ODataExpressionVisitor.java


示例2: getFunctionParameters

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
private Map<String, Parameter> getFunctionParameters(final EdmFunction function,
    final List<UriParameter> parameters, final UriInfoResource uriInfo) throws DataProviderException {
  Map<String, Parameter> values = new HashMap<String, Parameter>();
  for (final UriParameter parameter : parameters) {
    if (parameter.getExpression() != null && !(parameter.getExpression() instanceof Literal)) {
      throw new DataProviderException("Expression in function-parameter value is not supported yet!",
          HttpStatusCode.NOT_IMPLEMENTED);
    }
    final EdmParameter edmParameter = function.getParameter(parameter.getName());
    final String text = parameter.getAlias() == null ?
        parameter.getText() :
        uriInfo.getValueForAlias(parameter.getAlias());
    if (text != null) {
      try {
        values.put(parameter.getName(),
            odata.createFixedFormatDeserializer().parameter(text, edmParameter));
      } catch (final DeserializerException e) {
        throw new DataProviderException("Invalid function parameter.", HttpStatusCode.BAD_REQUEST, e);
      }
    }
  }
  return values;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:DataProvider.java


示例3: isType

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public FilterValidator isType(final FullQualifiedName fullName) {
  EdmType actualType = null;

  if (curExpression instanceof Member) {
    actualType = ((Member) curExpression).getType();
  } else if (curExpression instanceof TypeLiteral) {
    actualType = ((TypeLiteral) curExpression).getType();
  } else if (curExpression instanceof Literal) {
    actualType = ((Literal) curExpression).getType();
  } else if (curExpression instanceof Enumeration) {
    actualType = ((Enumeration) curExpression).getType();
  } else if (curExpression instanceof Unary) {
    actualType = ((UnaryImpl) curExpression).getType();
  } else if (curExpression instanceof Binary) {
    actualType = ((BinaryImpl) curExpression).getType();
  } else if (curExpression instanceof Method) {
    actualType = ((MethodImpl) curExpression).getType();
  }

  assertNotNull("Current expression not typed", actualType);
  assertEquals(fullName, actualType.getFullQualifiedName());
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:FilterValidator.java


示例4: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
  // To keep this tutorial simple, our filter expression visitor supports only Edm.Int32 and Edm.String
  // In real world scenarios it can be difficult to guess the type of an literal.
  // We can be sure, that the literal is a valid OData literal because the URI Parser checks 
  // the lexicographical structure
  
  // String literals start and end with an single quotation mark
  String literalAsString = literal.getText();
  if(literal.getType() instanceof EdmString) {
    String stringLiteral = "";
    if(literal.getText().length() > 2) {
      stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
    }
    
    return stringLiteral;
  } else {
    // Try to convert the literal into an Java Integer
    try {
      return Integer.parseInt(literalAsString);
    } catch(NumberFormatException e) {
      throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented", 
          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:FilterExpressionVisitor.java


示例5: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
  // To keep this tutorial simple, our filter expression visitor supports only Edm.Int32 and Edm.String
  // In real world scenarios it can be difficult to guess the type of an literal.
  // We can be sure, that the literal is a valid OData literal because the URI Parser checks 
  // the lexicographical structure
  
  // String literals start and end with an single quotation mark
  String literalAsString = literal.getText();
  if(literal.getType() instanceof EdmString) {
    String stringLiteral = "";
    if(literal.getText().length() > 2) {
      stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
    }
    
    return stringLiteral;
  } else {
    // Try to convert the literal into an Java Integer
    try {
      return Integer.parseInt(literalAsString);
    } catch(NumberFormatException e) {
      throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented", 
          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:FilterExpressionVisitor.java


示例6: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal)
    throws ExpressionVisitException, ODataApplicationException {

  String value = literal.getText();
  if (literal.getType() instanceof EdmString) {
    value = LiteralUtils.unquote(value);
  }

  return value;
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:12,代码来源:ElasticsearchExpressionVisitor.java


示例7: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
	String decodedEntityKey = SparqlEntity.URLDecodeEntityKey(literal.toString());
	try{
		return "<"+ this.rdfModel.getRdfPrefixes().expandPredicateKey(decodedEntityKey)+">";
	
	} catch(Exception e) {
		switch (literal.getType().toString()) {
		case "Null":
			return "null";
		case "Edm.Time":
			return "\"" + literal.getText() + "\"^^xsd:time";
		case "Edm.Date":
			return "\"" + literal.getText() + "\"^^xsd:date";
		case "Edm.DateTime":
			return "\"" + literal.getText() + "\"^^xsd:dateTime";
		case "Edm.DateTimeOffset":
		case "Edm.String":
			return "\"" + literal.getText().substring(1, literal.getText().length() - 1) + "\"";
		case "Edm.Guid":
			return "guid\"" + literal.getText() + "\"";
		case "Edm.Binary":
			return "X\"" + literal.getText() + "\"";
		default:
			return literal.getText();
		}
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:29,代码来源:SparqlExpressionVisitor.java


示例8: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public ExpressionMember visitLiteral(Literal literal)
        throws ExpressionVisitException, ODataApplicationException {
    String literalAsString = literal.getText();
    EdmType type = literal.getType();
    return new LiteralMember(literalAsString, type);
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:8,代码来源:ElasticSearchExpressionVisitor.java


示例9: visit

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public void visit(Literal expr) {
    Object value = LiteralParser.parseLiteral(expr.getText());
    if (this.prepared) {
        stack.add(new Reference(this.params.size()));
        this.params.add(new SQLParam(value, JDBCSQLTypeInfo.getSQLTypeFromClass(value.getClass().getName())));
    } else {
        this.stack.add(new Constant(value));
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:11,代码来源:ODataExpressionToSQLVisitor.java


示例10: read

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
    final List<UriParameter> keys) throws DataProviderException {
  try {
    for (final Entity entity : entitySet.getEntities()) {
      boolean found = true;
      for (final UriParameter key : keys) {
        EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
        Object value =  findPropertyRefValue(entity, refType);
        
        final EdmProperty property = refType.getProperty();
        final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
        
        if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
          throw new DataProviderException("Expression in key value is not supported yet!",
              HttpStatusCode.NOT_IMPLEMENTED);
        }
        final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
        final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
            property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
            property.isUnicode(),
            Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
        if (!value.equals(keyValue)) {
          found = false;
          break;
        }
      }
      if (found) {
        return entity;
      }
    }
    return null;
  } catch (final EdmPrimitiveTypeException e) {
    throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:36,代码来源:DataProvider.java


示例11: readDataFromEntity

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public Entity readDataFromEntity(final EdmEntityType edmEntityType,
    final List<UriParameter> keys) throws DataProviderException {
  EntityCollection coll = data.get(edmEntityType.getName());
  List<Entity> entities = coll.getEntities();
  try {
    for (final Entity entity : entities) {
      boolean found = true;
      for (final UriParameter key : keys) {
        EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
        Object value =  findPropertyRefValue(entity, refType);
        
        final EdmProperty property = refType.getProperty();
        final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
        
        if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
          throw new DataProviderException("Expression in key value is not supported yet!",
              HttpStatusCode.NOT_IMPLEMENTED);
        }
        final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
        final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
            property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
            property.isUnicode(),
            Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
        if (!value.equals(keyValue)) {
          found = false;
          break;
        }
      }
      if (found) {
        return entity;
      }
    }
    return null;
  } catch (final EdmPrimitiveTypeException e) {
    throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:38,代码来源:DataProvider.java


示例12: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public JsonNode visitLiteral(final Literal literal) throws ExpressionVisitException, ODataApplicationException {
  return nodeFactory.objectNode()
      .put(NODE_TYPE_NAME, LITERAL_NAME)
      .put(TYPE_NAME, getTypeString(literal.getType()))
      .put(VALUE_NAME, literal.getText());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:8,代码来源:ExpressionJsonVisitor.java


示例13: getType

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
protected static EdmType getType(final Expression expression) throws UriParserException {
  EdmType type;
  if (expression instanceof Literal) {
    type = ((Literal) expression).getType();
  } else if (expression instanceof TypeLiteral) {
    type = ((TypeLiteral) expression).getType();
  } else if (expression instanceof Enumeration) {
    type = ((Enumeration) expression).getType();
  } else if (expression instanceof Member) {
    type = ((Member) expression).getType();
  } else if (expression instanceof Unary) {
    type = ((UnaryImpl) expression).getType();
  } else if (expression instanceof Binary) {
    type = ((BinaryImpl) expression).getType();
  } else if (expression instanceof Method) {
    type = ((MethodImpl) expression).getType();
  } else if (expression instanceof Alias) {
    final AliasQueryOption alias = ((AliasImpl) expression).getAlias();
    type = alias == null || alias.getValue() == null ? null : getType(alias.getValue());
  } else if (expression instanceof LambdaRef) {
    throw new UriParserSemanticException("Type determination not implemented.",
        UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED, expression.toString());
  } else {
    throw new UriParserSemanticException("Unknown expression type.",
        UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED, expression.toString());
  }
  if (type != null && type.getKind() == EdmTypeKind.DEFINITION) {
    type = ((EdmTypeDefinition) type).getUnderlyingType();
  }
  return type;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:ExpressionParser.java


示例14: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public SQLExpression visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
	String literalAsString = literal.getText();
	if(literal.getType() instanceof EdmString) {			
		return new StringValue(literal.getText());
	} else {	        
		try {
			return new LongValue(literalAsString);
		} catch(NumberFormatException e) {
			throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented",
					HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
		}
	}
}
 
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:15,代码来源:FilterExpressionVisitor.java


示例15: visit

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
void visit(@SuppressWarnings("unused") Literal expr) {
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:3,代码来源:ODataExpressionVisitor.java


示例16: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public VisitorOperand visitLiteral(final Literal literal) throws ExpressionVisitException, ODataApplicationException {
  return new UntypedOperand(literal.getText());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:ExpressionVisitorImpl.java


示例17: visitLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
@Override
public String visitLiteral(final Literal literal) throws ExpressionVisitException {
  return "<" + literal.getText() + ">";
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:FilterTreeToText.java


示例18: isLiteral

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public FilterValidator isLiteral(final String literalText) {
  assertTrue("Current expression is not a literal", curExpression instanceof Literal);
  String actualLiteralText = ((Literal) curExpression).getText();
  assertEquals(literalText, actualLiteralText);
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:FilterValidator.java


示例19: isLiteralType

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
public FilterValidator isLiteralType(final EdmType edmType) {
  assertTrue("Current expression is not a literal", curExpression instanceof Literal);
  final EdmType type = ((Literal) curExpression).getType();
  assertEquals(edmType, type);
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:FilterValidator.java


示例20: parseFunctionParameters

import org.apache.olingo.server.api.uri.queryoption.expression.Literal; //导入依赖的package包/类
protected static List<UriParameter> parseFunctionParameters(UriTokenizer tokenizer,
    final Edm edm, final EdmType referringType, final boolean withComplex,
    final Map<String, AliasQueryOption> aliases)
    throws UriParserException, UriValidationException {
  List<UriParameter> parameters = new ArrayList<UriParameter>();
  Set<String> parameterNames = new HashSet<String>();
  ParserHelper.requireNext(tokenizer, TokenKind.OPEN);
  if (tokenizer.next(TokenKind.CLOSE)) {
    return parameters;
  }
  do {
    ParserHelper.requireNext(tokenizer, TokenKind.ODataIdentifier);
    final String name = tokenizer.getText();
    if (parameterNames.contains(name)) {
      throw new UriParserSemanticException("Duplicated function parameter " + name,
          UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, name);
    }
    parameterNames.add(name);
    ParserHelper.requireNext(tokenizer, TokenKind.EQ);
    if (tokenizer.next(TokenKind.COMMA) || tokenizer.next(TokenKind.CLOSE) || tokenizer.next(TokenKind.EOF)) {
      throw new UriParserSyntaxException("Parameter value expected.", UriParserSyntaxException.MessageKeys.SYNTAX);
    }
    UriParameterImpl parameter = new UriParameterImpl().setName(name);
    if (tokenizer.next(TokenKind.ParameterAliasName)) {
      final String aliasName = tokenizer.getText();
      parameter.setAlias(aliasName)
          .setExpression(aliases.containsKey(aliasName) ? aliases.get(aliasName).getValue() : null);
    } else if (tokenizer.next(TokenKind.jsonArrayOrObject)) {
      if (withComplex) {
        parameter.setText(tokenizer.getText());
      } else {
        throw new UriParserSemanticException("A JSON array or object is not allowed as parameter value.",
            UriParserSemanticException.MessageKeys.COMPLEX_PARAMETER_IN_RESOURCE_PATH, tokenizer.getText());
      }
    } else if (withComplex) {
      final Expression expression = new ExpressionParser(edm, odata).parse(tokenizer, referringType, null, aliases);
      parameter.setText(expression instanceof Literal ?
          "null".equals(((Literal) expression).getText()) ? null : ((Literal) expression).getText() :
          null)
          .setExpression(expression instanceof Literal ? null : expression);
    } else if (nextPrimitiveValue(tokenizer) == null) {
      throw new UriParserSemanticException("Wrong parameter value.",
          UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, "");
    } else {
      final String literalValue = tokenizer.getText();
      parameter.setText("null".equals(literalValue) ? null : literalValue);
    }
    parameters.add(parameter);
  } while (tokenizer.next(TokenKind.COMMA));
  ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
  return parameters;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:ParserHelper.java



注:本文中的org.apache.olingo.server.api.uri.queryoption.expression.Literal类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RobotKeywordOverload类代码示例发布时间:2022-05-23
下一篇:
Java AttributeMap类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap