Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlProperty#setScale()
The following examples show how to use
org.apache.olingo.commons.api.edm.provider.CsdlProperty#setScale() .
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: EdmPropertyImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void facets() { EdmProviderImpl edm = new EdmProviderImpl(mock(CsdlEdmProvider.class)); CsdlProperty propertyProvider = new CsdlProperty(); propertyProvider.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()); propertyProvider.setPrecision(42); propertyProvider.setScale(12); propertyProvider.setMaxLength(128); propertyProvider.setUnicode(true); propertyProvider.setNullable(false); propertyProvider.setDefaultValue("x"); final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); assertTrue(property.isPrimitive()); assertNull(property.getMapping()); assertNull(property.getMimeType()); assertEquals(Integer.valueOf(42), property.getPrecision()); assertEquals(Integer.valueOf(12), property.getScale()); assertEquals(Integer.valueOf(128), property.getMaxLength()); assertTrue(property.isUnicode()); assertFalse(property.isNullable()); assertEquals("x", property.getDefaultValue()); assertNull(property.getSrid()); }
Example 2
Source File: MetadataParser.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private CsdlProperty readProperty(XMLEventReader reader, StartElement element) throws XMLStreamException { CsdlProperty property = new CsdlProperty(); property.setName(attr(element, "Name")); property.setType(readType(element)); property.setCollection(isCollectionType(element)); property.setNullable(Boolean.parseBoolean(attr(element, "Nullable") == null ? "true" : attr( element, "Nullable"))); if (attr(element, "Unicode") != null) { property.setUnicode(Boolean.parseBoolean(attr(element, "Unicode"))); } String maxLength = attr(element, "MaxLength"); if (maxLength != null) { property.setMaxLength(Integer.parseInt(maxLength)); } String precision = attr(element, "Precision"); if (precision != null) { property.setPrecision(Integer.parseInt(precision)); } String scale = attr(element, "Scale"); if (scale != null) { property.setScale(Integer.parseInt(scale)); } String srid = attr(element, "SRID"); if (srid != null) { property.setSrid(SRID.valueOf(srid)); } String defaultValue = attr(element, "DefaultValue"); if (defaultValue != null) { property.setDefaultValue(defaultValue); } peekAnnotations(reader, element.getName().getLocalPart(), property); return property; }