当前位置: 首页>>代码示例>>Java>>正文


Java CsdlConstantExpression类代码示例

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


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

示例1: getTerm

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
public CsdlTerm getTerm(FullQualifiedName termName) {
  if (TERM_DESCRIPTION.equals(termName)) {
    return new CsdlTerm().setName("Description").setType("Edm.String")
        .setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
            new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
                "A brief description of a model element")),
            new CsdlAnnotation().setTerm("Core.IsLanguageDependent")));
  } else if (TERM_LONG_DESCRIPTION.equals(termName)) {
    return new CsdlTerm().setName("LongDescription").setType("Edm.String")
        .setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
            new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
                "A lengthy description of a model element")),
            new CsdlAnnotation().setTerm("Core.IsLanguageDependent")));
  } else if (TERM_DATA.equals(termName)) {
    return new CsdlTerm().setName("Data").setType("Edm.Boolean")
        .setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
            new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
                "Indicates if data in the TechSvc is available for the given object"))));
  }

  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:TermProvider.java

示例2: labeledElementWithNameAndValue

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void labeledElementWithNameAndValue() {
  CsdlLabeledElement csdlLabeledElement = new CsdlLabeledElement();
  csdlLabeledElement.setName("name");
  csdlLabeledElement.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlLabeledElement.setAnnotations(csdlAnnotations);
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlLabeledElement);
  EdmLabeledElement asLabeled = exp.asDynamic().asLabeledElement();

  assertEquals("name", asLabeled.getName());
  assertNotNull(asLabeled.getValue());
  assertTrue(asLabeled.getValue().isConstant());

  assertNotNull(asLabeled.getAnnotations());
  assertEquals(1, asLabeled.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmLabeledElementImplTest.java

示例3: collectionWithThreeItems

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void collectionWithThreeItems() {
  CsdlCollection csdlCollection = new CsdlCollection();
  List<CsdlExpression> items = new ArrayList<CsdlExpression>();
  items.add(new CsdlConstantExpression(ConstantExpressionType.String));
  items.add(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And));
  items.add(new CsdlConstantExpression(ConstantExpressionType.Bool));
  csdlCollection.setItems(items);
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlCollection);
  EdmCollection asCollection = exp.asDynamic().asCollection();

  assertNotNull(asCollection.getItems());
  assertEquals(3, asCollection.getItems().size());

  assertTrue(asCollection.getItems().get(0).isConstant());
  assertTrue(asCollection.getItems().get(1).isDynamic());
  assertTrue(asCollection.getItems().get(2).isConstant());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmCollectionImplTest.java

示例4: logicalOrOperationsClassesWithExpressions

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void logicalOrOperationsClassesWithExpressions() {
  for (LogicalOrComparisonExpressionType type : LogicalOrComparisonExpressionType.values()) {
    EdmExpression path = AbstractEdmExpression.getExpression(
        mock(Edm.class),
        new CsdlLogicalOrComparisonExpression(type)
            .setLeft(new CsdlConstantExpression(ConstantExpressionType.String))
            .setRight(new CsdlLogicalOrComparisonExpression(type)));

    EdmDynamicExpression dynExp = assertDynamic(path);
    assertEquals(type.toString(), dynExp.getExpressionName());
    assertSingleKindDynamicExpression(dynExp);

    EdmLogicalOrComparisonExpression logicOrComparisonExp = (EdmLogicalOrComparisonExpression) dynExp;
    assertNotNull(logicOrComparisonExp.getLeftExpression());
    assertNotNull(logicOrComparisonExp.getRightExpression());
    if (type == LogicalOrComparisonExpressionType.Not) {
      assertTrue(logicOrComparisonExp.getLeftExpression() == logicOrComparisonExp.getRightExpression());
    } else {
      assertTrue(logicOrComparisonExp.getLeftExpression() instanceof EdmConstantExpression);
      assertTrue(logicOrComparisonExp.getRightExpression() instanceof EdmDynamicExpression);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:EdmLogicalOrComparisonImplTest.java

示例5: urlRefWithInvalidValue

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void urlRefWithInvalidValue() {
  CsdlUrlRef csdlUrlRef = new CsdlUrlRef();
  csdlUrlRef.setValue(new CsdlConstantExpression(ConstantExpressionType.Bool));
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlUrlRef);
  EdmUrlRef asUrlRef = exp.asDynamic().asUrlRef();
  assertNotNull(asUrlRef.getValue());
  assertTrue(asUrlRef.getValue().isConstant());

  csdlUrlRef = new CsdlUrlRef();
  csdlUrlRef.setValue(new CsdlNull());
  exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlUrlRef);
  asUrlRef = exp.asDynamic().asUrlRef();
  assertNotNull(asUrlRef.getValue());
  assertTrue(asUrlRef.getValue().isDynamic());
  assertTrue(asUrlRef.getValue().asDynamic().isNull());
  assertNotNull(asUrlRef.getValue().asDynamic().asNull());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmUrlRefImplTest.java

示例6: withAllExpressions

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void withAllExpressions() {
  CsdlIf csdlIf = new CsdlIf();
  csdlIf.setGuard(new CsdlConstantExpression(ConstantExpressionType.Bool));
  csdlIf.setThen(new CsdlConstantExpression(ConstantExpressionType.String));
  csdlIf.setElse(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And));
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlIf.setAnnotations(csdlAnnotations);
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlIf);
  EdmIf asIf = exp.asDynamic().asIf();

  assertNotNull(asIf.getGuard());
  assertTrue(asIf.getGuard().isConstant());
  assertNotNull(asIf.getThen());
  assertTrue(asIf.getThen().isConstant());
  assertNotNull(asIf.getElse());
  assertTrue(asIf.getElse().isDynamic());

  assertNotNull(asIf.getAnnotations());
  assertEquals(1, asIf.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:EdmIfImplTest.java

示例7: propertyValue

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void propertyValue() {
  CsdlPropertyValue csdlPropertyValue = new CsdlPropertyValue();
  csdlPropertyValue.setProperty("property");
  csdlPropertyValue.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlPropertyValue.setAnnotations(csdlAnnotations);
  EdmPropertyValue asPropValue = new EdmPropertyValueImpl(mock(Edm.class), csdlPropertyValue);

  assertNotNull(asPropValue.getProperty());
  assertEquals("property", asPropValue.getProperty());
  assertNotNull(asPropValue.getValue());
  assertTrue(asPropValue.getValue().isConstant());

  assertNotNull(asPropValue.getAnnotations());
  assertEquals(1, asPropValue.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmPropertyValueImplTest.java

示例8: getEnumType

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Override
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
  
  if (nameENString.equals(enumTypeName)) {
    
    CsdlAnnotation memberAnnotation = new CsdlAnnotation()
        .setTerm("Core.Description")
        .setQualifier("Target")
        .setExpression(new CsdlConstantExpression(ConstantExpressionType.String, "Description of Enum Member"));
    
    return new CsdlEnumType()
    .setName(nameENString.getName())
    .setFlags(true)
    .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
    .setMembers(Collections.singletonList(
        new CsdlEnumMember().setName("String1").setValue("1").setAnnotations(Arrays.asList(memberAnnotation))));
  }
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:MetadataDocumentJsonSerializerTest.java

示例9: readAnnotations

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
private void readAnnotations(XMLEventReader reader, StartElement element,
    CsdlAnnotatable edmObject) throws XMLStreamException {
  if (!parseAnnotations) {
    return;
  }
  final CsdlAnnotation annotation = new CsdlAnnotation();
  annotation.setTerm(attr(element, "Term"));
  for (ConstantExpressionType type:ConstantExpressionType.values()) {
    if (attr(element, type.name()) != null) {
      annotation.setExpression(new CsdlConstantExpression(
          type, attr(element, type.name())));
    }        
  }
  readExpressions(reader, element, annotation);
  edmObject.getAnnotations().add(annotation);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:MetadataParser.java

示例10: castWithExpression

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void castWithExpression() {
  CsdlCast csdlExp = new CsdlCast();
  csdlExp.setMaxLength(new Integer(1));
  csdlExp.setPrecision(new Integer(2));
  csdlExp.setScale(new Integer(3));
  csdlExp.setType("Edm.String");
  csdlExp.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlExp.setAnnotations(csdlAnnotations);
  EdmExpression isOf = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);

  EdmCast asIsOf = isOf.asDynamic().asCast();

  assertEquals(new Integer(1), asIsOf.getMaxLength());
  assertEquals(new Integer(2), asIsOf.getPrecision());
  assertEquals(new Integer(3), asIsOf.getScale());

  assertNotNull(asIsOf.getType());
  assertTrue(asIsOf.getType() instanceof EdmPrimitiveType);

  assertNotNull(asIsOf.getValue());
  assertTrue(asIsOf.getValue().isConstant());

  assertNotNull(asIsOf.getAnnotations());
  assertEquals(1, asIsOf.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:EdmCastImplTest.java

示例11: functionWithParameters

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void functionWithParameters() {
  CsdlApply csdlApply = new CsdlApply();
  csdlApply.setFunction("Function");

  List<CsdlExpression> parameters = new ArrayList<CsdlExpression>();
  parameters.add(new CsdlConstantExpression(ConstantExpressionType.String));
  parameters.add(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And));
  csdlApply.setParameters(parameters);

  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlApply.setAnnotations(csdlAnnotations);

  EdmExpression apply = AbstractEdmExpression.getExpression(mock(Edm.class), csdlApply);

  EdmDynamicExpression dynExp = assertDynamic(apply);
  EdmApply asApply = dynExp.asApply();

  assertEquals("Function", asApply.getFunction());
  assertNotNull(asApply.getParameters());
  assertEquals(2, asApply.getParameters().size());
  assertTrue(asApply.getParameters().get(0).isConstant());
  assertTrue(asApply.getParameters().get(1).isDynamic());

  assertNotNull(asApply.getAnnotations());
  assertEquals(1, asApply.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:EdmApplyImplTest.java

示例12: isOfWithExpression

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void isOfWithExpression() {
  CsdlIsOf csdlExp = new CsdlIsOf();
  csdlExp.setMaxLength(new Integer(1));
  csdlExp.setPrecision(new Integer(2));
  csdlExp.setScale(new Integer(3));
  csdlExp.setType("Edm.String");
  csdlExp.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
  csdlExp.setAnnotations(csdlAnnotations);
  EdmExpression isOf = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);

  EdmIsOf asIsOf = isOf.asDynamic().asIsOf();

  assertEquals(new Integer(1), asIsOf.getMaxLength());
  assertEquals(new Integer(2), asIsOf.getPrecision());
  assertEquals(new Integer(3), asIsOf.getScale());

  assertNotNull(asIsOf.getType());
  assertTrue(asIsOf.getType() instanceof EdmPrimitiveType);

  assertNotNull(asIsOf.getValue());
  assertTrue(asIsOf.getValue().isConstant());

  assertNotNull(asIsOf.getAnnotations());
  assertEquals(1, asIsOf.getAnnotations().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:EdmIsOfImplTest.java

示例13: binaryExpression

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void binaryExpression() {
  CsdlConstantExpression csdlExp = new CsdlConstantExpression(ConstantExpressionType.Binary, "qrvM3e7_");
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);

  assertConstant(exp);

  assertEquals(EdmExpressionType.Binary, exp.getExpressionType());
  assertEquals("Binary", exp.asConstant().getExpressionName());
  assertEquals("qrvM3e7_", exp.asConstant().getValueAsString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:EdmConstantExpressionImplTest.java

示例14: boolExpression

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void boolExpression() {
  CsdlConstantExpression csdlExp = new CsdlConstantExpression(ConstantExpressionType.Bool, "true");
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);

  assertConstant(exp);

  assertEquals(EdmExpressionType.Bool, exp.getExpressionType());
  assertEquals("Bool", exp.asConstant().getExpressionName());
  assertEquals("true", exp.asConstant().getValueAsString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:EdmConstantExpressionImplTest.java

示例15: dateExpression

import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; //导入依赖的package包/类
@Test
public void dateExpression() {
  CsdlConstantExpression csdlExp = new CsdlConstantExpression(ConstantExpressionType.Date, "2012-02-29");
  EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);

  assertConstant(exp);

  assertEquals(EdmExpressionType.Date, exp.getExpressionType());
  assertEquals("Date", exp.asConstant().getExpressionName());
  assertEquals("2012-02-29", exp.asConstant().getValueAsString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:EdmConstantExpressionImplTest.java


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