org.opengis.util.NameSpace类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.opengis.util.NameSpace类的一些代码示例,展示了NameSpace类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NameSpace类的具体详情如下:
包路径:org.opengis.util.NameSpace
类名称:NameSpace

NameSpace介绍

[英]A domain in which GenericName given by character strings are defined.
[中]一种域,其中定义了由字符串给出的通用名称。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Null-safe getter for the namespace argument to be given to {@link #toClass(String, String)}.
 */
static String namespace(final NameSpace ns) {
  if (ns != null && !ns.isGlobal()) {
    final GenericName name = ns.name();
    if (name != null) {
      return name.toString();
    }
  }
  return null;
}

代码示例来源:origin: geotools/geotools

/**
 * Returns the scope (name space) of this generic name. This method is protected from overriding
 * by the user.
 */
private GenericName getInternalScope() {
  if (asScopedName != null) {
    final NameSpace scope = asScopedName.scope();
    if (scope != null) {
      return scope.name();
    }
  }
  return null;
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Returns a view of this name as a fully-qualified name. The {@linkplain #scope() scope}
 * of a fully qualified name will be {@linkplain NameSpace#isGlobal() global}. If the scope
 * of this name is already global, then this method returns {@code this}.
 *
 * @return the fully-qualified name (never {@code null}).
 */
@Override
public GenericName toFullyQualifiedName() {
  if (scope == null || scope.isGlobal()) {
    return this;
  }
  throw new UnsupportedOperationException();
}

代码示例来源:origin: geotools/geotools

/**
 * Returns the scope (name space) of this generic name. If this name has no scope (e.g. is the
 * root), then this method returns {@code null}.
 *
 * @deprecated Replaced by {@link #scope()}.
 */
public GenericName getScope() {
  return getName().scope().name();
}

代码示例来源:origin: org.opengis/geoapi-conformance

if (fullyQualified != null) {
  assertEquals("GenericName: toFullyQualifiedName() inconsistent with the global scope status.",
      object.scope().isGlobal(), fullyQualified == object);

代码示例来源:origin: apache/sis

/**
 * Null-safe getter for the namespace argument to be given to {@link #toClass(String, String)}.
 */
static String namespace(final NameSpace ns) {
  if (ns != null && !ns.isGlobal()) {
    final GenericName name = ns.name();
    if (name != null) {
      return name.toString();
    }
  }
  return null;
}

代码示例来源:origin: geotools/geotools

/**
 * Produce a good key based on the privided citaiton and code. You can think of the citation as
 * being "here" and the code being the "what".
 *
 * @param code Code
 * @return A good key for use with ObjectCache
 */
public static String toKey(Citation citation, String code) {
  code = code.trim();
  final GenericName name = NameFactory.create(code);
  final GenericName scope = name.scope().name();
  if (scope == null) {
    return code;
  }
  if (citation != null && Citations.identifierMatches(citation, scope.toString())) {
    return name.tip().toString().trim();
  }
  return code;
}

代码示例来源:origin: opengeospatial/geoapi

if (fullyQualified != null) {
  assertEquals("GenericName: toFullyQualifiedName() inconsistent with the global scope status.",
      object.scope().isGlobal(), fullyQualified == object);

代码示例来源:origin: org.apache.sis.core/sis-metadata

/**
 * Returns the scope of the given name if it is not global.
 * This method is null-safe, including paranoiac checks against null scope.
 *
 * @param  name  the name from which to get the scope, or {@code null}.
 * @return the scope of the given name, or {@code null} if the given name was null or has a global scope.
 */
private static GenericName scope(final GenericName name) {
  if (name != null) {
    final NameSpace scope = name.scope();
    if (scope != null && !scope.isGlobal()) {
      return scope.name();
    }
  }
  return null;
}

代码示例来源:origin: geotools/geotools

/**
 * Trims the authority scope, if present. If more than one authority were given at {@linkplain
 * #PropertyAuthorityFactory(ReferencingFactoryContainer, Citation[], URL) construction time},
 * then any of them may appears as the scope in the supplied code.
 *
 * @param code The code to trim.
 * @return The code without the authority scope.
 */
@Override
protected String trimAuthority(String code) {
  code = code.trim();
  final GenericName name = NameFactory.create(code);
  final GenericName scope = name.scope().name();
  if (scope == null) {
    return code;
  }
  final String candidate = scope.toString();
  for (int i = 0; i < authorities.length; i++) {
    if (Citations.identifierMatches(authorities[i], candidate)) {
      return name.tip().toString().trim();
    }
  }
  return code;
}

代码示例来源:origin: org.opengis/geoapi-conformance

boolean global = scope.isGlobal();
for (final LocalName name : parsedNames) {
  assertNotNull("ScopedName: getParsedNames() can not contain null element.", name);
  assertNotSame("ScopedName: the enclosing scoped name can not be in any parsed name.", object, name);
  assertEquals("ScopedName: inconsistent value of isGlobal().", global, name.scope().isGlobal());
  global = false; // Only the first name may be global.
  validate(name);

代码示例来源:origin: apache/sis

/**
 * Returns the scope of the given name if it is not global.
 * This method is null-safe, including paranoiac checks against null scope.
 *
 * @param  name  the name from which to get the scope, or {@code null}.
 * @return the scope of the given name, or {@code null} if the given name was null or has a global scope.
 */
private static GenericName scope(final GenericName name) {
  if (name != null) {
    final NameSpace scope = name.scope();
    if (scope != null && !scope.isGlobal()) {
      return scope.name();
    }
  }
  return null;
}

代码示例来源:origin: geotools/geotools

/**
 * Trims the authority scope, if present. For example if this factory is an EPSG authority
 * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed.
 * Otherwise, the string is returned unchanged (except for leading and trailing spaces).
 *
 * @param code The code to trim.
 * @return The code without the authority scope.
 */
protected String trimAuthority(String code) {
  /*
   * IMPLEMENTATION NOTE: This method is overridden in
   * PropertyAuthorityFactory. If the implementation below is modified, it
   * is probably worth revisiting the overridden method as well.
   */
  code = code.trim();
  final GenericName name = NameFactory.create(code);
  final GenericName scope = name.scope().name();
  if (scope == null) {
    return code;
  }
  if (Citations.identifierMatches(getAuthority(), scope.toString())) {
    return name.tip().toString().trim();
  }
  return code;
}

代码示例来源:origin: opengeospatial/geoapi

boolean global = (scope != null) && scope.isGlobal();
for (final LocalName name : parsedNames) {
  assertNotNull("ScopedName: getParsedNames() can not contain null element.", name);
  assertNotSame("ScopedName: the enclosing scoped name can not be in any parsed name.", object, name);
  assertEquals("ScopedName: inconsistent value of isGlobal().", global, name.scope().isGlobal());
  global = false;         // Only the first name may be global.
  validate(name);

代码示例来源:origin: org.geotoolkit/geotk-metadata

/**
 * Returns a view of this name as a fully-qualified name. The {@linkplain #scope() scope}
 * of a fully qualified name is {@linkplain DefaultNameSpace#isGlobal() global}. If the
 * scope of this name is already global, then this method returns {@code this}.
 */
@Override
public synchronized GenericName toFullyQualifiedName() {
  if (fullyQualified == null) {
    final NameSpace scope = scope();
    if (scope.isGlobal()) {
      fullyQualified = this;
    } else {
      final GenericName prefix = scope.name();
      assert prefix.scope().isGlobal() : prefix;
      fullyQualified = new DefaultScopedName(prefix, this);
    }
  }
  return fullyQualified;
}

代码示例来源:origin: geotools/geotools

/**
 * Trims the authority scope, if present. For example if this factory is an EPSG authority
 * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed.
 * Otherwise, the string is returned unchanged (except for leading and trailing spaces).
 *
 * @param code The code to trim.
 * @return The code without the authority scope.
 */
protected String trimAuthority(String code) {
  /*
   * IMPLEMENTATION NOTE: This method is overrided in PropertyAuthorityFactory. If
   * implementation below is modified, it is probably worth to revisit the overrided
   * method as well.
   */
  code = code.trim();
  final GenericName name = NameFactory.create(code);
  final GenericName scope = name.scope().name();
  if (scope == null) {
    return code;
  }
  if (Citations.identifierMatches(getAuthority(), scope.toString())) {
    return name.tip().toString().trim();
  }
  return code;
}

代码示例来源:origin: apache/sis

/**
 * Tests {@link Builder#addName(CharSequence)} without codespace.
 */
@Test
public void testAddName() {
  final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
  // Expected values to be used later in the test.
  final String    name   = "Mercator (variant A)";
  final LocalName alias1 = factory.createLocalName(null, "Mercator (1SP)");
  final LocalName alias2 = factory.createLocalName(null, "Mercator_1SP");
  final LocalName alias3 = factory.createLocalName(null, "CT_Mercator");
  assertTrue("That name should not have a scope.", alias1.scope().isGlobal());
  assertTrue("That name should not have a scope.", alias2.scope().isGlobal());
  assertTrue("That name should not have a scope.", alias3.scope().isGlobal());
  assertEquals("Mercator (1SP)", alias1.toString());
  assertEquals("Mercator_1SP",   alias2.toString());
  assertEquals("CT_Mercator",    alias3.toString());
  // The test.
  final BuilderMock builder = new BuilderMock();
  assertSame(builder, builder.addName("Mercator (variant A)"));   // EPSG version 7.6 and later.
  assertSame(builder, builder.addName("Mercator (1SP)"));         // EPSG before version 7.6.
  assertSame(builder, builder.addName("Mercator_1SP"));           // OGC
  assertSame(builder, builder.addName("CT_Mercator"));            // GeoTIFF
  builder.onCreate(false);
  assertEquals(name, builder.getName());
  assertArrayEquals(new GenericName[] {alias1, alias2, alias3}, builder.getAliases());
}

代码示例来源:origin: apache/sis

/**
 * Sets the value from the given name.
 *
 * @param name  the name to marshal.
 */
public final void setName(final GenericName name) {
  this.value = name.toString();
  final NameSpace scope = name.scope();
  if (scope != null && !scope.isGlobal()) {
    codeSpace = scope.name().toString();
  }
}

代码示例来源:origin: geotools/geotools

final GenericName scope = alias.scope().name();
final GenericName name = alias.tip();
final Object title;

代码示例来源:origin: apache/sis

/**
 * Tests the {@link NamedIdentifier#NamedIdentifier(Citation, String, CharSequence, String, InternationalString)}
 * constructor.
 */
@Test
public void testCreateFromCode() {
  final NamedIdentifier identifier = new NamedIdentifier(Citations.EPSG, "EPSG", "4326", "8.3", null);
  Validators.validate((ReferenceIdentifier) identifier);
  Validators.validate((GenericName) identifier);
  // ImmutableIdentifier properties
  assertEquals("code",       "4326",         identifier.getCode());
  assertEquals("codeSpace",  "EPSG",         identifier.getCodeSpace());
  assertSame  ("authority",  Citations.EPSG, identifier.getAuthority());
  assertEquals("version",    "8.3",          identifier.getVersion());
  assertNull  ("description",                identifier.getDescription());
  // NamedIdentifier properties
  assertEquals("depth",  2,          identifier.depth());
  assertEquals("tip",   "4326",      identifier.tip().toString());
  assertEquals("head",  "EPSG",      identifier.head().toString());
  assertEquals("name",  "EPSG:4326", identifier.toString());
  assertTrue  ("scope.isGlobal",     identifier.scope().isGlobal());
}

相关文章