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


Java CsdlTerm.setAppliesTo方法代码示例

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


在下文中一共展示了CsdlTerm.setAppliesTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invalidAppliesToContent

import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void invalidAppliesToContent() {
  CsdlTerm csdlTerm = new CsdlTerm();
  FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
  csdlTerm.setName(csdlTerm1Name.getName());
  csdlTerm.setType("Edm.String");
  csdlTerm.setAppliesTo(Arrays.asList("Invalid"));
  EdmTerm localTerm = new EdmTermImpl(mock(Edm.class), "namespace", csdlTerm);

  try {
    localTerm.getAppliesTo();
    fail("Expected an EdmException");
  } catch (EdmException e) {
    assertEquals("Invalid AppliesTo value: Invalid", e.getMessage());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:EdmTermImplTest.java

示例2: setupTypes

import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Before
public void setupTypes() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);

  CsdlTerm csdlTerm = new CsdlTerm();
  FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
  csdlTerm.setName(csdlTerm1Name.getName());
  csdlTerm.setType("Edm.String");
  when(provider.getTerm(csdlTerm1Name)).thenReturn(csdlTerm);
  initialTerm = new EdmTermImpl(edm, "namespace", csdlTerm);

  CsdlTerm derivedCsdlTerm = new CsdlTerm();
  FullQualifiedName derivedTermName = new FullQualifiedName("namespace", "name2");
  derivedCsdlTerm.setName(derivedTermName.getName());
  derivedCsdlTerm.setType("Edm.String");
  derivedCsdlTerm.setBaseTerm("namespace.name1");
  List<String> appliesTo = new ArrayList<String>();
  appliesTo.add("Property");
  derivedCsdlTerm.setAppliesTo(appliesTo);
  List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
  csdlAnnotations.add(new CsdlAnnotation().setTerm("name1"));
  derivedCsdlTerm.setAnnotations(csdlAnnotations);

  derivedCsdlTerm.setNullable(false);
  derivedCsdlTerm.setMaxLength(new Integer(15));
  derivedCsdlTerm.setDefaultValue("abc");
  derivedCsdlTerm.setPrecision(new Integer(14));
  derivedCsdlTerm.setScale(new Integer(13));

  when(provider.getTerm(derivedTermName)).thenReturn(derivedCsdlTerm);
  derivedTerm = new EdmTermImpl(edm, "namespace", derivedCsdlTerm);

}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:35,代码来源:EdmTermImplTest.java

示例3: readTerm

import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
private CsdlTerm readTerm(XMLEventReader reader, StartElement element) throws XMLStreamException {
  CsdlTerm term = new CsdlTerm();
  term.setName(attr(element, "Name"));
  term.setType(attr(element, "Type"));
  
  if (attr(element, "BaseTerm") != null) {
    term.setBaseTerm(attr(element, "BaseTerm"));
  }
  if (attr(element, "DefaultValue") != null) {
    term.setDefaultValue(attr(element, "DefaultValue"));
  }
  if (attr(element, "AppliesTo") != null) {
    String[] appliesTo = attr(element, "AppliesTo").split("\\s+");
    term.setAppliesTo(Arrays.asList(appliesTo));
  }
  term.setNullable(Boolean.parseBoolean(attr(element, "Nullable")));
  String maxLength = attr(element, "MaxLength");
  if (maxLength != null) {
    term.setMaxLength(Integer.parseInt(maxLength));
  }
  String precision = attr(element, "Precision");
  if (precision != null) {
    term.setPrecision(Integer.parseInt(precision));
  }
  String scale = attr(element, "Scale");
  if (scale != null) {
    term.setScale(Integer.parseInt(scale));
  }
  String srid = attr(element, "SRID");
  if (srid != null) {
    term.setSrid(SRID.valueOf(srid));
  }
  peekAnnotations(reader, "Term", term);
  return term;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:36,代码来源:MetadataParser.java


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