Package org.opengis.util

Examples of org.opengis.util.GenericName


        assertEquals("Some remarks.",    parameters[0].getRemarks().toString());
        assertEquals(Double.valueOf(84), parameters[1].getMaximumValue());
        assertEquals(SI.METRE,           parameters[4].getUnit());
        assertTrue  (                    parameters[1].getAlias().isEmpty());

        final GenericName alias = parameters[0].getAlias().iterator().next();
        assertEquals("central_meridian",     alias.tip().toString());
        assertEquals("OGC",                  alias.head().toString());
        assertEquals("OGC:central_meridian", alias.toString());
    }
View Full Code Here


     */
    @Override
    public ReferenceIdentifier next() {
        final ReferenceIdentifier n = next;
        while (alias.hasNext()) {
            final GenericName c = alias.next();
            if (c instanceof ReferenceIdentifier) {
                next = (ReferenceIdentifier) c;
                return n;
            }
        }
View Full Code Here

        } else {
            /*
             * Our Code and RS_Identifier implementations should always create NamedIdentifier instance,
             * so the 'instanceof' check should not be necessary. But we do a paranoiac check anyway.
             */
            final GenericName n = id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id);
            if (alias == null) {
                alias = Collections.singleton(n);
            } else {
                /*
                 * This implementation is inefficient since each addition copies the array, but we rarely
View Full Code Here

        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;
    }
View Full Code Here

                names[i] = new DefaultLocalName(scan.parent, scan.name);
                scan = scan.parent;
            }
            assert depth(scan) == 0 || scan.isGlobal();
            path = DefaultScopedName.create(UnmodifiableArrayList.wrap(names));
            GenericName truncated = path;
            for (int i=depth; --i>=0;) {
                names[i].fullyQualified = truncated;
                truncated = (truncated instanceof ScopedName) ? ((ScopedName) truncated).path() : null;
            }
        }
View Full Code Here

    @Test
    public void testUrnNamespace() {
        final String[] parsed = new String[] {
            "urn","ogc","def","crs","epsg","4326"
        };
        GenericName name = new DefaultScopedName(null, Arrays.asList(parsed));
        assertSame(name, name.toFullyQualifiedName());
        assertEquals("urn:ogc:def:crs:epsg:4326", name.toString());
        assertNotSame(name, assertSerializedEquals(name));
        validate(name); // GeoAPI tests.
        for (int i=parsed.length; --i>=0;) {
            name = name.tip();
            validate(name);
            assertSame(parsed[i], name.toString());
            name = name.scope().name();
        }
    }
View Full Code Here

     * Tests navigation in a name parsed from a string.
     */
    @Test
    public void testNavigating() {
        final DefaultNameFactory factory = new DefaultNameFactory();
        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());
    }
View Full Code Here

        stmt.setString(1, code);
        final ResultSet result = stmt.executeQuery();
        while (result.next()) {
            final String scope = result.getString(1);
            final String local = getString(result, 2, code);
            final GenericName generic;
            if (scope == null) {
                generic = new LocalName(local);
            } else {
                LocalName cached = scopes.get(scope);
                if (cached == null) {
View Full Code Here

     * ignored.
     */
    private static final int putAll(final GenericName[] names, final Map<String,GenericName> map) {
        int ignored = 0;
        for (int i=0; i<names.length; i++) {
            final GenericName   name = names[i];
            final GenericName scoped = name.toFullyQualifiedName();
            final String         key = toCaseless(scoped.toString());
            final GenericName    old = map.put(key, name);
            if (old instanceof ScopedName) {
                map.put(key, old); // Preserves the user value, except if it was unscoped.
                ignored++;
            }
        }
View Full Code Here

                 * determined that some alias may be available in addition. Add local alias
                 * (i.e. names without their scope) to the 'elementNames' row.
                 */
                int count = 0;
                for (final GenericName alias : aliases) {
                    final GenericName scope = alias.scope().name();
                    final GenericName name  = alias.tip();
                    final Object title;
                    if (scope != null) {
                        if (scopes!=null && !scopes.contains(scope.toString())) {
                            /*
                             * The user requested only a subset of alias (the 'scopes' argument),
                             * and the current alias is not a member of this subset. Continue the
                             * search to other alias.
                             */
                            continue;
                        }
                        title = scope.toInternationalString().toString(locale);
                    } else {
                        title = count++;
                    }
                    /*
                     * The alias scope is used as the column's title. If the alias has no scope,
                     * then a sequencial number is used instead. Now check if the column already
                     * exists. If it exists, fetch its position. If it doesn't exist, inserts the
                     * new column at the end of existing columns.
                     */
                    Integer position = titles.get(title);
                    if (position == null) {
                        position = titles.size();
                        titles.put(title, position);
                    }
                    /*
                     * Now stores the alias local name at the position we just determined above.
                     * Note that more than one value may exist for the same column. For example
                     * both "WGS 84" and "4326" may appear as EPSG alias (as EPSG name and EPSG
                     * identifier respectively), depending how the parameters given by the user
                     * were constructed.
                     */
                    final int index = position.intValue();
                    if (index >= elementNames.length) {
                        elementNames = XArray.resize(elementNames, index+1);
                    }
                    final String oldName = elementNames[index];
                    final String newName = name.toInternationalString().toString(locale);
                    if (oldName==null || oldName.length()>newName.length()) {
                        /*
                         * Keep the shortest string, since it is often a code used
                         * for identification (e.g. EPSG code). It also help to fit
                         * the table in the window's width.
                         */
                        elementNames[index] = newName;
                    }
                }
            }
            /*
             * Before to add the name and alias to the list, fetch the remarks (if any).
             * They are stored in a separated list and will appear as the very last column.
             */
            final InternationalString remarks = element.getRemarks();
            if (remarks != null) {
                if (descriptions == null) {
                    descriptions = new String[parameters.size()];
                }
                descriptions[names.size()] = remarks.toString(locale);
            }
            names.add(elementNames);
        }
        /*
         * Trim the columns that duplicates the identifier column (#0). This is
         * usually the case of the OGC column (usually #1), since we already use
         * OGC name as the main identifier in most cases.
         */
        final boolean[] hide = new boolean[titles.size()];
trim:   for (int column=hide.length; --column>=1;) {
            for (final String[] alias : names) {
                if (alias.length > column) {
                    final String name = alias[column];
                    if (name!=null && !name.equals(alias[0])) {
                        // No need to looks at the next lines.
                        // Move to previous column.
                        continue trim;
                    }
                }
View Full Code Here

TOP

Related Classes of org.opengis.util.GenericName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.