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

Java EdmString类代码示例

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

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



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

示例1: getValue

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
/**
 * Checks the edm type of the string value, and creates concrete type from
 * this value.
 *
 * @return converted value
 */
public Object getValue() {
    UriTokenizer tokenizer = new UriTokenizer(value);
    if (tokenizer.next(UriTokenizer.TokenKind.StringValue) && edmType instanceof EdmString) {
        return value.substring(1, value.length() - 1).replaceAll("''", SINGLE_QUOTE);
    } else if (tokenizer.next(TokenKind.jsonArrayOrObject) && edmType == null) {
        String arrayAsString = value.substring(1, value.length() - 1);
        List<String> values = new ArrayList<>();
        for (String string : arrayAsString.split(",")) {
            values.add(string.replace("\"", ""));
        }
        return values;
    } else if (tokenizer.next(TokenKind.NULL)) {
        return null;
    } else {
        return value;
    }
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:24,代码来源:LiteralMember.java


示例2: visitLiteral

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
    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 {
            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:sbcd90,项目名称:olingo-jersey,代码行数:19,代码来源:FilterExpressionVisitor.java


示例3: replaceInvalidCharacters

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
static String replaceInvalidCharacters(EdmPrimitiveType expectedType,
    String value, Boolean isUniCode, String invalidCharacterReplacement) {
  if (!(expectedType instanceof EdmString)
      || invalidCharacterReplacement == null || isUniCode == null || !isUniCode) {
    return value;
  }
  String s = value;
  StringBuilder result = null;
  for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (c <= 0x0020 && c != ' ' && c != '\n' && c != '\t' && c != '\r') {
      if (result == null) {
        result = new StringBuilder();
        result.append(s.substring(0, i));
      }
      result.append(invalidCharacterReplacement);
    } else if (result != null) {
      result.append(c);
    }
  }
  if (result == null) {
    return value;
  }
  return result.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataXmlSerializer.java


示例4: visitLiteral

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的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.commons.core.edm.primitivetype.EdmString; //导入依赖的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.commons.core.edm.primitivetype.EdmString; //导入依赖的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: LiteralMember

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
/**
 * Initialize fields.
 * 
 * @param value
 *            literal value
 * @param edmType
 *            the EDM type
 */
public LiteralMember(String value, EdmType edmType) {
    if (edmType instanceof EdmString
            && (!value.startsWith(SINGLE_QUOTE) || !value.endsWith(SINGLE_QUOTE))) {
        throw new IllegalArgumentException(
                "String values should be enclosed in single quotation marks");
    }
    this.edmType = edmType;
    this.value = value;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:18,代码来源:LiteralMember.java


示例8: teiidType

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
public static String teiidType(SingletonPrimitiveType type) {
    if (type instanceof EdmBinary) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Binary);
    } else if (type instanceof EdmBoolean) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Boolean);
    } else if (type instanceof EdmByte) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Byte);
    } else if (type instanceof EdmDate) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Date);
    } else if (type instanceof EdmDateTime) {
        return odatakeyed.get(EdmPrimitiveTypeKind.DateTime);
    } else if (type instanceof EdmDateTimeOffset) {
        return odatakeyed.get(EdmPrimitiveTypeKind.DateTime);
    } else if (type instanceof EdmDecimal) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Decimal);
    } else if (type instanceof EdmDouble) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Double);
    } else if (type instanceof EdmDuration) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Int32);
    } else if (type instanceof EdmGuid) {
        return odatakeyed.get(EdmPrimitiveTypeKind.String);
    } else if (type instanceof EdmInt16) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Int16);
    } else if (type instanceof EdmInt32) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Int32);
    } else if (type instanceof EdmInt64) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Int64);
    } else if (type instanceof EdmSByte) {
        return odatakeyed.get(EdmPrimitiveTypeKind.SByte);
    } else if (type instanceof EdmSingle) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Single);
    } else if (type instanceof EdmStream) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Stream);
    } else if (type instanceof EdmString) {
        return odatakeyed.get(EdmPrimitiveTypeKind.String);
    } else if (type instanceof EdmTimeOfDay) {
        return odatakeyed.get(EdmPrimitiveTypeKind.Time);
    }
    return null;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:41,代码来源:ODataTypeManager.java


示例9: buildLocation

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
public static String buildLocation(String baseURL, Entity entity, String enitySetName, EdmEntityType type) 
    throws EdmPrimitiveTypeException {
  StringBuilder location = new StringBuilder();

  location.append(baseURL).append("/").append(enitySetName);
  
  int i = 0;
  boolean usename = type.getKeyPredicateNames().size() > 1;
  location.append("(");
  for (String key : type.getKeyPredicateNames()) {
    if (i > 0) {
      location.append(",");
    }
    i++;
    if (usename) {
      location.append(key).append("=");
    }
    
    EdmProperty property = (EdmProperty)type.getProperty(key);
    String propertyType = entity.getProperty(key).getType();
    Object propertyValue = entity.getProperty(key).getValue();
    
    if (propertyValue == null) {
      throw new EdmPrimitiveTypeException("The key value for property "+key+" is invalid; Key value cannot be null");
    }
    
    if(propertyType.startsWith("Edm.")) {
      propertyType = propertyType.substring(4);
    }
    EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(propertyType);
    String value =  EdmPrimitiveTypeFactory.getInstance(kind).valueToString(
        propertyValue, true, property.getMaxLength(), property.getPrecision(), property.getScale(), true);
    if (kind == EdmPrimitiveTypeKind.String) {
        value = EdmString.getInstance().toUriLiteral(Encoder.encode(value));
    }
    location.append(value);
  }
  location.append(")");
  return location.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:EntityResponse.java


示例10: visitLiteral

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的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


示例11: buildLocation

import org.apache.olingo.commons.core.edm.primitivetype.EdmString; //导入依赖的package包/类
/**
 * This method creates access uri for the entity.
 *
 * @param baseURL      base URL
 * @param entity       entity
 * @param enitySetName entity Set Name
 * @param type         entity Type
 * @return Entity URI
 * @throws EdmPrimitiveTypeException
 */
public static String buildLocation(String baseURL, Entity entity, String enitySetName, EdmEntityType type)
        throws EdmPrimitiveTypeException {
    StringBuilder location = new StringBuilder();
    location.append(baseURL).append("/").append(enitySetName);
    int i = 0;
    boolean usename = type.getKeyPredicateNames().size() > 1;
    location.append("(");

    String value;
    for (Iterator var7 = type.getKeyPredicateNames().iterator(); var7.hasNext(); location.append(value)) {
        String key = (String) var7.next();
        if (i > 0) {
            location.append(",");
        }

        ++i;
        if (usename) {
            location.append(key).append("=");
        }

        String propertyType = entity.getProperty(key).getType();
        Object propertyValue = entity.getProperty(key).getValue();
        if (propertyType.startsWith("Edm.")) {
            propertyType = propertyType.substring(4);
        }

        EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(propertyType);
        EdmProperty property = type.getStructuralProperty(key);
        value = EdmPrimitiveTypeFactory.getInstance(kind)
                                       .valueToString(propertyValue, property.isNullable(), property.getMaxLength(),
                                                      property.getPrecision(), property.getScale(),
                                                      property.isUnicode());
        if (kind == EdmPrimitiveTypeKind.String) {
            value = EdmString.getInstance().toUriLiteral(Encoder.encode(value));
        }
    }

    location.append(")");
    return location.toString();
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:51,代码来源:ODataUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MonitorRegistryMetricPoller类代码示例发布时间:2022-05-23
下一篇:
Java IRecipeTransferError类代码示例发布时间: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