org.opengis.util.NameSpace.isGlobal()方法的使用及代码示例

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

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

NameSpace.isGlobal介绍

[英]Indicates whether this namespace is a "top level" namespace. Global, or top-level namespaces are not contained within another namespace. There is no namespace called "global" or "root" which contains all of the top-level namespaces. Hence, this flag indicates whether the namespace has a parent.
[中]指示此命名空间是否为“顶级”命名空间。全局或顶级命名空间不包含在另一个命名空间中。没有名为“全局”或“根”的名称空间包含所有顶级名称空间。因此,此标志指示命名空间是否有父级。

代码示例

代码示例来源: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: 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: 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: 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: 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: 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: apache/sis

/**
   * Formats the given name in <cite>expanded form</cite> close to the Java Content Repository (JCR) definition.
   * The expanded form is defined as below:
   *
   * <blockquote><pre> ExpandedName ::= '{' NameSpace '}' LocalPart
   * NameSpace    ::= name.{@linkplain AbstractName#scope() scope()}.{@linkplain DefaultNameSpace#name() name()}.toString()
   * LocalPart    ::= name.{@linkplain AbstractName#toString() toString()}</pre></blockquote>
   *
   * @param  name  the generic name to format in expanded form, or {@code null}.
   * @return expanded form of the given generic name, or {@code null} if the given name was null.
   *
   * @see DefaultNameSpace#toString()
   */
  public static String toExpandedString(final GenericName name) {
    if (name == null) {
      return null;
    }
    final String localPart = name.toString();
    final NameSpace scope = name.scope();
    if (scope == null || scope.isGlobal()) {
      return localPart;
    }
    final String ns = scope.name().toString();
    return new StringBuilder(ns.length() + localPart.length() + 2)
        .append('{').append(ns).append('}').append(localPart).toString();
  }
}

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

/**
   * Formats the given name in <cite>expanded form</cite> close to the Java Content Repository (JCR) definition.
   * The expanded form is defined as below:
   *
   * <blockquote><pre> ExpandedName ::= '{' NameSpace '}' LocalPart
   * NameSpace    ::= name.{@linkplain AbstractName#scope() scope()}.{@linkplain DefaultNameSpace#name() name()}.toString()
   * LocalPart    ::= name.{@linkplain AbstractName#toString() toString()}</pre></blockquote>
   *
   * @param  name  the generic name to format in expanded form, or {@code null}.
   * @return expanded form of the given generic name, or {@code null} if the given name was null.
   *
   * @see DefaultNameSpace#toString()
   */
  public static String toExpandedString(final GenericName name) {
    if (name == null) {
      return null;
    }
    final String localPart = name.toString();
    final NameSpace scope = name.scope();
    if (scope == null || scope.isGlobal()) {
      return localPart;
    }
    final String ns = scope.name().toString();
    return new StringBuilder(ns.length() + localPart.length() + 2)
        .append('{').append(ns).append('}').append(localPart).toString();
  }
}

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

/**
 * 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}.
 *
 * @return the fully-qualified name (never {@code null}).
 */
@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: apache/sis

/**
 * 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}.
 *
 * @return the fully-qualified name (never {@code null}).
 */
@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: org.apache.sis.core/sis-utility

/**
 * 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: 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: org.opengis/geoapi-conformance

/**
 * Ensures that ISO 19103 or GeoAPI restrictions apply.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final NameSpace object) {
  if (object == null) {
    return;
  }
  final GenericName name = object.name();
  mandatory("NameSpace: must have a name.", name);
  if (name != null) {
    final NameSpace scope = name.scope();
    mandatory("NameSpace: must have a scope.", scope);
    if (scope != null) {
      assertTrue("NameSpace: scope must be global.", scope.isGlobal());
    }
    // Following test is a consequence of the previous one, so we check the scope first in
    // order to report the error as a bad scope before to reference this GeoAPI extension.
    assertSame("NameSpace: the name must be fully qualified.", name, name.toFullyQualifiedName());
  }
  if (object.isGlobal()) {
    assertInstanceOf("NameSpace: global namespace must have a local name.", LocalName.class, name);
  }
  validate(name, name.getParsedNames());
}

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

/**
 * Tests {@link Builder#addName(Citation, CharSequence)} and {@link Builder#addName(CharSequence)} with codespace.
 */
@Test
@DependsOnMethod({"testAddName", "testSetCodeSpace"})
public void testAddNameWithScope() {
  final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
  // Expected values to be used later in the test.
  final String      name   = "Mercator (variant A)";
  final GenericName alias1 = factory.createLocalName(scope(factory, "EPSG"), "Mercator (1SP)");
  final GenericName alias2 = new NamedIdentifier(Citations.OGC,     "Mercator_1SP");
  final GenericName alias3 = new NamedIdentifier(Citations.GEOTIFF, "CT_Mercator");
  assertTrue ("That name should not have a scope.", alias3.scope().isGlobal());
  assertTrue ("That name should not have a scope.", alias2.scope().isGlobal());
  assertFalse("That name should be in EPSG scope.", alias1.scope().isGlobal());
  assertEquals("EPSG",                 alias1.scope().name().toString());
  assertEquals("Mercator (1SP)",       alias1.toString());
  assertEquals("OGC:Mercator_1SP",     alias2.toString());
  assertEquals("GeoTIFF:CT_Mercator",  alias3.toString());
  // The test.
  final BuilderMock builder = createMercator(true, false);
  assertEquals(name, builder.getName());
  assertArrayEquals(new GenericName[] {alias1, alias2, alias3}, builder.getAliases());
}

代码示例来源: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: org.opengis/geoapi-conformance

/**
 * Tests the creation of {@code "EPSG:4326"} as local names. First the {@code "EPSG"}
 * namespace is created. Then a {@code "4326"} local name is created in that namespace.
 * This test uses the following factory methods:
 * <p>
 * <ul>
 *   <li>{@link NameFactory#createLocalName}</li>
 *   <li>{@link NameFactory#createNameSpace}</li>
 * </ul>
 */
@Test
public void testLocalName() {
  assumeNotNull(factory);
  final String EPSG = "EPSG";
  final LocalName authority = factory.createLocalName(null, EPSG);
  validate(authority);
  assertTrue(authority.scope().isGlobal());
  assertEquals(EPSG, authority.toString());
  assertEquals(EPSG, authority.toInternationalString().toString());
  final NameSpace ns = createNameSpace(authority, ":", ":");
  validate(ns);
  assertEquals(authority, ns.name());
  final String WGS84 = "4326";
  final LocalName code = factory.createLocalName(ns, WGS84);
  validate(code);
  assertEquals(ns, code.scope());
  assertEquals(WGS84, code.toString());
  assertEquals(EPSG + ':' + WGS84, code.toFullyQualifiedName().toString());
}

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

/**
 * Tests the creation of {@code "EPSG:4326"} as local names. First the {@code "EPSG"}
 * namespace is created. Then a {@code "4326"} local name is created in that namespace.
 * This test uses the following factory methods:
 *
 * <ul>
 *   <li>{@link NameFactory#createLocalName(NameSpace, CharSequence)}</li>
 *   <li>{@link NameFactory#createNameSpace(GenericName, Map)}</li>
 * </ul>
 */
@Test
public void testLocalName() {
  assumeNotNull(factory);
  final String EPSG = "EPSG";
  final LocalName authority = factory.createLocalName(null, EPSG);
  validators.validate(authority);
  assertTrue(authority.scope().isGlobal());
  assertEquals(EPSG, authority.toString());
  assertEquals(EPSG, authority.toInternationalString().toString());
  final NameSpace ns = createNameSpace(authority, ":", ":");
  validators.validate(ns);
  assertEquals(authority, ns.name());
  final String WGS84 = "4326";
  final LocalName code = factory.createLocalName(ns, WGS84);
  validators.validate(code);
  assertEquals(ns, code.scope());
  assertEquals(WGS84, code.toString());
  assertEquals(EPSG + ':' + WGS84, code.toFullyQualifiedName().toString());
}

代码示例来源: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());
}

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

/**
 * Tests the {@link NamedIdentifier#NamedIdentifier(GenericName)} constructor.
 */
@Test
public void testCreateFromName() {
  final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
  final NameSpace scope = factory.createNameSpace(factory.createLocalName(null, "IOGP"), null);
  final NamedIdentifier identifier = new NamedIdentifier(factory.createGenericName(scope, "EPSG", "4326"));
  Validators.validate((ReferenceIdentifier) identifier);
  Validators.validate((GenericName) identifier);
  // ImmutableIdentifier properties
  assertEquals("code",      "4326", identifier.getCode());
  assertEquals("codeSpace", "EPSG", identifier.getCodeSpace());
  assertEquals("authority", "IOGP", Citations.toCodeSpace(identifier.getAuthority()));
  assertNull  ("version",           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());
  assertSame  ("scope", scope,       identifier.scope());
  assertFalse ("scope.isGlobal",     scope.isGlobal());
  assertEquals("scope", "IOGP",      scope.name().toString());
}

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

/**
 * Tests the {@link NamedIdentifier#NamedIdentifier(Citation, CharSequence)} constructor.
 */
@Test
@DependsOnMethod("testCreateFromCode")
public void testCreateFromInternationalString() {
  final NamedIdentifier identifier = createI18N();
  Validators.validate((ReferenceIdentifier) identifier);
  Validators.validate((GenericName) identifier);
  // ImmutableIdentifier properties
  assertEquals("code",      "name",         identifier.getCode());
  assertEquals("codeSpace", "EPSG",         identifier.getCodeSpace());
  assertSame  ("authority", Citations.EPSG, identifier.getAuthority());
  assertNull  ("version",                   identifier.getVersion());
  assertNull  ("description",               identifier.getDescription());
  // NamedIdentifier properties
  assertEquals("depth",  2,          identifier.depth());
  assertEquals("tip",   "name",      identifier.tip().toInternationalString().toString(Locale.ENGLISH));
  assertEquals("tip",   "nom",       identifier.tip().toInternationalString().toString(Locale.FRENCH));
  assertEquals("tip",   "名前",       identifier.tip().toInternationalString().toString(Locale.JAPANESE));
  assertEquals("head",  "EPSG",      identifier.head().toString());
  assertEquals("name",  "EPSG:name", identifier.toInternationalString().toString(Locale.ENGLISH));
  assertEquals("name",  "EPSG:nom",  identifier.toInternationalString().toString(Locale.FRENCH));
  assertEquals("name",  "EPSG:名前",  identifier.toInternationalString().toString(Locale.JAPANESE));
  assertTrue  ("scope.isGlobal",     identifier.scope().isGlobal());
}

相关文章