Java Code Examples for org.apache.olingo.server.api.uri.queryoption.expression.Literal#getText()
The following examples show how to use
org.apache.olingo.server.api.uri.queryoption.expression.Literal#getText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterExpressionVisitor.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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); } } }
Example 2
Source File: FilterExpressionVisitor.java From olingo-odata4 with Apache License 2.0 | 6 votes |
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); } } }
Example 3
Source File: FilterExpressionVisitor.java From syndesis with Apache License 2.0 | 5 votes |
@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; } // 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, e); } }
Example 4
Source File: ExpressionVisitorImpl.java From micro-integrator with Apache License 2.0 | 4 votes |
@Override public VisitorOperand visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException { return new UntypedOperand(literal.getText()); }
Example 5
Source File: ExpressionVisitorImpl.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Override public VisitorOperand visitLiteral(final Literal literal) throws ExpressionVisitException, ODataApplicationException { return new UntypedOperand(literal.getText()); }
Example 6
Source File: FilterTreeToText.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Override public String visitLiteral(final Literal literal) throws ExpressionVisitException { return "<" + literal.getText() + ">"; }