コード例 #1
0
ファイル: AnnotationMapper.java プロジェクト: johnmay/mdk
 /**
  * Given an accession, try and infer which resource the identifier is from. If the accession is
  * very general and can not be inferred it is added to the {@link #ambiguous()} set. If a single
  * resource was inferred it will try to be mapped to any entities matching the given key.
  *
  * <blockquote>
  *
  * <pre>
  *     IdentifierMap mapper = ...;
  *     mapper.map("atp", "C00002");
  *     mapper.map("atp", "CHEBI:57299");
  * </pre>
  *
  * </blockquote>
  *
  * @param key the key to locate the entity
  * @param accession the accession to infer a resource from
  * @return an entity <i>handled</i> the identifier
  * @see #ambiguous()
  */
 public boolean map(K key, String accession) {
   Collection<Class<? extends Identifier>> ids = idFactory.ofPattern(accession);
   if (ids.size() == 1) {
     Identifier identifier = idFactory.ofClass(ids.iterator().next());
     identifier.setAccession(accession);
     return map(key, identifier);
   } else if (ids.size() > 1) {
     ambiguous.add(accession);
   }
   return false;
 }