use of org.opengis.util.MemberName in project sis by apache.
the class ServiceParameterTest method create.
/**
* Creates the parameter to use for testing purpose.
*
* @return the test parameter.
*/
public static ServiceParameter create() {
final MemberName paramName = Names.createMemberName(null, null, "Version", String.class);
final ServiceParameter param = new ServiceParameter();
param.memberName = paramName;
param.optionality = true;
param.repeatability = false;
return param;
}
use of org.opengis.util.MemberName in project sis by apache.
the class DefaultRecordSchemaTest method testCreateRecordType.
/**
* Tests {@link DefaultRecordSchema#createRecordType(CharSequence, Map)}.
*/
@Test
public void testCreateRecordType() {
final DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "MySchema");
final Map<CharSequence, Class<?>> members = new LinkedHashMap<>(8);
assertNull(members.put("city", String.class));
assertNull(members.put("latitude", Double.class));
assertNull(members.put("longitude", Double.class));
assertNull(members.put("population", Integer.class));
final RecordType recordType = schema.createRecordType("MyRecordType", members);
/*
* Inspect properties.
*/
assertSame("container", schema, recordType.getContainer());
assertEquals("typeName", Names.createTypeName("MySchema", ":", "MyRecordType"), recordType.getTypeName());
int count = 0;
for (final Map.Entry<MemberName, Type> entry : recordType.getMemberTypes().entrySet()) {
final String expectedName;
final String expectedType;
final Class<?> expectedClass;
switch(count) {
case 0:
{
expectedName = "city";
expectedType = "OGC:CharacterString";
expectedClass = String.class;
break;
}
case 1:
{
expectedName = "latitude";
expectedType = "OGC:Real";
expectedClass = Double.class;
break;
}
case 2:
{
expectedName = "longitude";
expectedType = "OGC:Real";
expectedClass = Double.class;
break;
}
case 3:
{
expectedName = "population";
expectedType = "OGC:Integer";
expectedClass = Integer.class;
break;
}
default:
{
throw new AssertionError(count);
}
}
final Type type = entry.getValue();
assertEquals(expectedName, entry.getKey().toString());
assertEquals(expectedType, type.getTypeName().toFullyQualifiedName().toString());
assertEquals(expectedClass, ((SimpleAttributeType) type).getValueClass());
count++;
}
/*
* The DefaultRecordType(TypeName, RecordSchema, Map) constructor performs many argument checks, so
* we use that constructor as a way to perform a final validation, especially regarding namespaces.
*/
final DefaultRecordType copy = new DefaultRecordType(recordType.getTypeName(), recordType.getContainer(), recordType.getMemberTypes());
assertEquals(recordType, copy);
}
use of org.opengis.util.MemberName in project sis by apache.
the class MetadataBuilder method setBandIdentifier.
/**
* Sets the number that uniquely identifies instances of bands of wavelengths on which a sensor operates.
* This is a convenience method for {@link #setBandIdentifier(MemberName)} when the band is specified only
* by a number.
*
* @param sequenceIdentifier the band number, or 0 or negative if none.
*/
public final void setBandIdentifier(final int sequenceIdentifier) {
if (sequenceIdentifier > 0) {
final boolean cached = (sequenceIdentifier <= BAND_NUMBERS.length);
MemberName name = null;
if (cached)
synchronized (BAND_NUMBERS) {
name = BAND_NUMBERS[sequenceIdentifier - 1];
}
if (name == null) {
name = Names.createMemberName(null, null, String.valueOf(sequenceIdentifier), Integer.class);
if (cached)
synchronized (BAND_NUMBERS) {
/*
* No need to check if a value has been set concurrently because Names.createMemberName(…)
* already checked if an equal instance exists in the current JVM.
*/
BAND_NUMBERS[sequenceIdentifier - 1] = name;
}
}
setBandIdentifier(name);
}
}
Aggregations