use of org.opengis.util.GenericName in project sis by apache.
the class GO_GenericName method getValue.
/**
* Returns the {@code LocalName} or {@code ScopedName} to marshal. Returns {@code null} if the name
* is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getName()} instead.
* Example:
*
* {@preformat xml
* <gml:alias>
* <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName>
* </gml:alias>
* }
*
* @return the code for the current name, or {@code null} if none.
*/
@XmlElementRef
public final NameValue getValue() {
final GenericName name = this.name;
final NameValue code;
if (name instanceof LocalName) {
if (name instanceof TypeName || name instanceof MemberName) {
return null;
} else if (FilterByVersion.LEGACY_METADATA.accept()) {
code = new NameValue.Local();
} else {
// ISO 19115-3:2016 does not seem to define gco:LocalName anymore.
code = new NameValue.Scoped();
}
} else if (name instanceof ScopedName) {
code = new NameValue.Scoped();
} else {
return null;
}
code.setName(name);
return code;
}
use of org.opengis.util.GenericName in project sis by apache.
the class DefaultScopedNameTest method testSimpleInternationalString.
/**
* Tests the creation of scoped names where different parts of the name are {@link SimpleInternationalString}
* instances. The implementation should be able to detect that the names and their hash codes are equal.
*
* @see DefaultNameFactoryTest#testSimpleInternationalString()
*/
@Test
public void testSimpleInternationalString() {
GenericName n1 = new DefaultScopedName(null, Arrays.asList("ns1", "Route"));
GenericName n2 = new DefaultScopedName(null, Arrays.asList(new SimpleInternationalString("ns1"), "Route"));
GenericName n3 = new DefaultScopedName(null, Arrays.asList("ns1", new SimpleInternationalString("Route")));
assertNameEqual(n1, n2);
assertNameEqual(n1, n3);
assertNameEqual(n2, n3);
}
use of org.opengis.util.GenericName in project sis by apache.
the class DefaultNameFactoryTest method testNavigation.
/**
* Tests navigation in a name parsed from a string.
*/
@Test
public void testNavigation() {
final GenericName name = factory.parseGenericName(null, "codespace:subspace:name");
assertEquals("codespace:subspace:name", name.toString());
assertEquals("codespace:subspace", name.tip().scope().name().toString());
assertEquals("codespace", name.tip().scope().name().tip().scope().name().toString());
assertSame(name, name.toFullyQualifiedName());
assertSame(name, name.tip().toFullyQualifiedName());
}
use of org.opengis.util.GenericName in project sis by apache.
the class DefaultNameFactoryTest method testSimpleInternationalString.
/**
* Tests the creation of scoped names where different parts of the name are {@link SimpleInternationalString}
* instances. The implementation should be able to detect that the names and their hash codes are equal.
*
* @see DefaultScopedNameTest#testSimpleInternationalString()
*/
@Test
public void testSimpleInternationalString() {
GenericName n1 = factory.createGenericName(null, "ns1", "Route");
GenericName n2 = factory.createGenericName(null, new SimpleInternationalString("ns1"), "Route");
GenericName n3 = factory.createGenericName(null, "ns1", new SimpleInternationalString("Route"));
assertSame(n1, n2);
assertSame(n1, n3);
assertSame(n2, n3);
}
use of org.opengis.util.GenericName in project sis by apache.
the class CoordinateOperationMethods method writeName.
/**
* Writes the primary name and aliases.
*/
private void writeName(final ParameterDescriptor<?> param) throws IOException {
final int td = openTag("td class=\"sep\"");
openTag("details");
final ReferenceIdentifier name = param.getName();
final String codeSpace = name.getCodeSpace();
if (Constants.EPSG.equalsIgnoreCase(codeSpace)) {
println("summary", escape(name.getCode()));
} else {
println("summary", "<span class=\"non-epsg\">" + codeSpace + ":</span>" + "<code>" + name.getCode() + "</code>");
}
openTag("table class=\"aliases\"");
for (final GenericName alias : param.getAlias()) {
reopenTag("tr");
println("th", escape(alias.head().toString() + ':'));
println("td", escape(alias.tip().toString()));
}
closeTags(td);
}
Aggregations