/** * Returns the shortest identifier for the specified citation, or the title if there is no * identifier. This method is useful for extracting the namespace from an authority, for example * {@code "EPSG"}. * * @param citation The citation for which to get the identifier. * @return The shortest identifier of the given citation. * @since 2.4 */ public static String getIdentifier(final Citation citation) { String identifier = null; for (final Identifier id : citation.getIdentifiers()) { final String candidate = id.getCode().trim(); final int length = candidate.length(); if (length != 0) { if (identifier == null || length < identifier.length()) { identifier = candidate; } } } if (identifier == null) { identifier = String.valueOf(citation.getTitle()); } return identifier; } }
/** * Returns {@code true} if any {@linkplain Citation#getIdentifiers identifiers} in the given * citation matches the given string. The comparaison is case-insensitive and ignores leading * and trailing spaces. If (and <em>only</em> if) the citation do not contains any identifier, * then this method fallback on titles comparaison using the {@link #titleMatches(Citation, * String) titleMatches} method. This fallback exists for compatibility with client codes using * citation {@linkplain Citation#getTitle titles} without identifiers. * * @param citation The citation to check for. * @param identifier The identifier to compare. * @return {@code true} if the title or alternate title matches the given string. */ public static boolean identifierMatches(final Citation citation, String identifier) { identifier = identifier.trim(); final Collection<? extends Identifier> identifiers = citation.getIdentifiers(); for (final Identifier id : identifiers) { final String code = id.getCode().trim(); if (identifier.equalsIgnoreCase(code)) { return true; } } if (identifiers.isEmpty()) { return titleMatches(citation, identifier); } else { return false; } }
/** * Implementation of {@link CRS#getSupportedAuthorities}. Provided here in order to reduce the * amount of class loading when using {@link CRS} for other purpose than CRS decoding. */ static Set<String> getSupportedAuthorities(final boolean returnAliases) { final Set<String> result = new LinkedHashSet<String>(); for (final CRSAuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) { for (final Identifier id : factory.getAuthority().getIdentifiers()) { result.add(id.getCode()); if (!returnAliases) { break; } } } return result; }
Iterator<? extends Identifier> iterator = c2.getIdentifiers().iterator(); if (!iterator.hasNext()) { iterator = c1.getIdentifiers().iterator(); if (!iterator.hasNext()) { return titleMatches(c1, c2);
final Citation authority = ((AuthorityFactory) factory).getAuthority(); if (authority != null) { final Collection<? extends Identifier> identifiers = authority.getIdentifiers(); if (identifiers != null && !identifiers.isEmpty()) { boolean next = false;
Errors.format(ErrorKeys.FILE_DOES_NOT_EXIST_$1, FILENAME)); final Iterator<? extends Identifier> ids = getAuthority().getIdentifiers().iterator(); final String authority = ids.hasNext() ? ids.next().getCode() : "EPSG"; final LogRecord record =
/** * Creates the backing store authority factory. * * @return The backing store to uses in {@code createXXX(...)} methods. * @throws FactoryNotFoundException if the no {@code epsg.properties} file has been found. * @throws FactoryException if the constructor failed to find or read the file. This exception * usually has an {@link IOException} as its cause. */ protected AbstractAuthorityFactory createBackingStore() throws FactoryException { try { URL url = getDefinitionsURL(); if (url == null) { throw new FactoryNotFoundException( Errors.format(ErrorKeys.FILE_DOES_NOT_EXIST_$1, FILENAME)); } final Iterator<? extends Identifier> ids = getAuthority().getIdentifiers().iterator(); final String authority = ids.hasNext() ? ids.next().getCode() : "EPSG"; final LogRecord record = Loggings.format( Level.CONFIG, LoggingKeys.USING_FILE_AS_FACTORY_$2, url.getPath(), authority); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); return new PropertyAuthorityFactory(factories, getAuthorities(), url); } catch (IOException exception) { throw new FactoryException(Errors.format(ErrorKeys.CANT_READ_$1, FILENAME), exception); } }
final Collection<Identifier> identifiers = c.getIdentifiers(); for (int i = 1; i < authorities.length; i++) { identifiers.addAll(authorities[i].getIdentifiers());
if (authority != null) { authorityNames.add(Citations.getIdentifier(authority)); for (final Identifier id : authority.getIdentifiers()) { authorityNames.add(id.getCode());
/** * Tries to get a codespace from the specified authority. This method scan first through the * identifier, then through the titles if no suitable identifier were found. */ private static String getCodeSpace(final Citation authority) { final Collection<? extends Identifier> identifiers = authority.getIdentifiers(); if (identifiers != null) { for (final Identifier id : identifiers) { final String identifier = id.getCode(); if (isValidCodeSpace(identifier)) { return identifier; } } } // The "null" locale argument is required for getting the unlocalized version. final String title = getShortestTitle(authority).toString(null); if (isValidCodeSpace(title)) { return title; } return null; }
String s = this.authority.getIdentifiers().iterator().next().getCode(); CoordinateReferenceSystem source = CRS.decode(s + ":" + sourceCRS); CoordinateReferenceSystem target = CRS.decode(s + ":" + targetCRS);
final Citation authority = ((AuthorityFactory) provider).getAuthority(); final Iterator<? extends Identifier> identifiers = authority.getIdentifiers().iterator(); final String identifier = identifiers.hasNext()
final Citation authority = factory.getAuthority(); final Iterator<? extends Identifier> identifiers = authority.getIdentifiers().iterator(); if (!identifiers.hasNext()) {
/** * Returns the first identifier of the given citation. */ static Identifier getAggregateDataSetIdentifier(final Citation name) { if (name != null) { final Collection<? extends Identifier> names = name.getIdentifiers(); if (names != null) { // May be null on XML marshalling. final Iterator<? extends Identifier> it = names.iterator(); if (it.hasNext()) { return it.next(); } } } return null; }
/** * Returns the first identifier of the given citation. */ private static Identifier getAggregateDataSetIdentifier(final Citation name) { if (name != null) { final Collection<? extends Identifier> names = name.getIdentifiers(); if (names != null) { // May be null on XML marshalling. final Iterator<? extends Identifier> it = names.iterator(); if (it.hasNext()) { return it.next(); } } } return null; }
@Override public Collection<? extends Identifier> getIdentifiers() {return delegate().getIdentifiers();} @Override public Collection<? extends ResponsibleParty> getCitedResponsibleParties() {return delegate().getCitedResponsibleParties();}
@Override public Collection<? extends Identifier> getIdentifiers() {return delegate().getIdentifiers();} @Override public Collection<? extends ResponsibleParty> getCitedResponsibleParties() {return delegate().getCitedResponsibleParties();}
/** * Return the factory for the given authority code. * * @param authorityCode registry name * @return ProcessingRegistry or null if not found */ public static ProcessingRegistry getProcessFactory(final Iterator<? extends ProcessingRegistry> factories, final String authorityCode) { while (factories.hasNext()) { final ProcessingRegistry candidate = factories.next(); for (final Identifier id : candidate.getIdentification().getCitation().getIdentifiers()) { if (id.getCode().equalsIgnoreCase(authorityCode)) { return candidate; } } } return null; }
public static String getIdentifier(Metadata metadata) { final Collection<? extends Identification> identifications = metadata.getIdentificationInfo(); for (Identification identification : identifications) { final Citation citation = identification.getCitation(); if (citation != null) { for (Identifier identifier : citation.getIdentifiers()) { return identifier.getCode(); } } } return null; }
/** * Validates the given citation. * * @param object The object to validate, or {@code null}. */ public void validate(final Citation object) { if (object == null) { return; } validateMandatory(object.getTitle()); validateOptional (object.getEdition()); validateOptional (object.getOtherCitationDetails()); validateOptional (object.getCollectiveTitle()); validateCollection(InternationalString.class, object.getAlternateTitles()); validateCollection(Identifier.class, object.getIdentifiers()); } }