コード例 #1
0
 /** Returns the names of all currently registered authorities. */
 public static synchronized Set<String> getAuthorityNames() {
   /*
    * IMPORTANT: Return the same Set instance (unmodifiable) as long as there is no change
    * in the list of registered factories, and create a new instance in case of changes.
    * 'add/removeAuthorityFactory(...)' and 'scanForPlugins()' methods reset 'authorityNames'
    * to null, which will cause the creation of a new Set instance. Some implementations like
    * AllAuthoritiesFactory rely on this behavior as a way to be notified of registration
    * changes for clearing their cache.
    */
   if (authorityNames == null) {
     authorityNames = new LinkedHashSet<String>();
     final Hints hints = EMPTY_HINTS;
     loop:
     for (int i = 0; ; i++) {
       final Set<? extends AuthorityFactory> factories;
       switch (i) {
         case 0:
           factories = getCRSAuthorityFactories(hints);
           break;
         case 1:
           factories = getCSAuthorityFactories(hints);
           break;
         case 2:
           factories = getDatumAuthorityFactories(hints);
           break;
         case 3:
           factories = getCoordinateOperationAuthorityFactories(hints);
           break;
         default:
           break loop;
       }
       for (final AuthorityFactory factory : factories) {
         final Citation authority = factory.getAuthority();
         if (authority != null) {
           authorityNames.add(Citations.getIdentifier(authority));
           for (final Identifier id : authority.getIdentifiers()) {
             authorityNames.add(id.getCode());
           }
         }
       }
     }
     authorityNames = Collections.unmodifiableSet(authorityNames);
   }
   return authorityNames;
 }
コード例 #2
0
 /**
  * Returns the selected object, usually as a {@link CoordinateReferenceSystem}.
  *
  * @return
  * @throws FactoryException if the factory can't create the selected object.
  */
 public IdentifiedObject getSelectedItem() throws FactoryException {
   final String code = getSelectedCode();
   return (code != null) ? factory.createObject(code) : null;
 }