test_class.declarator: topicSort
test_class.modifier: private
test_class.original_string: private TopicIF topicSort;
test_class.type: TopicIF
test_class.var_name: topicSort
test_class.declarator: topicPlay
test_class.modifier: private
test_class.original_string: private TopicIF topicPlay;
test_class.type: TopicIF
test_class.var_name: topicPlay
test_class.declarator: topic5
test_class.modifier: private
test_class.original_string: private TopicIF topic5;
test_class.type: TopicIF
test_class.var_name: topic5
test_class.declarator: basename5A
test_class.modifier: private
test_class.original_string: private TopicNameIF basename5A;
test_class.type: TopicNameIF
test_class.var_name: basename5A
test_class.declarator: basename5B
test_class.modifier: private
test_class.original_string: private TopicNameIF basename5B;
test_class.type: TopicNameIF
test_class.var_name: basename5B
test_class.file: ontopia-engine/src/test/java/net/ontopia/topicmaps/utils/NameGrabberTest.java
test_class.identifier: NameGrabberTest
test_case.body: @Test
    public void testNameGrabber5B() {
      GrabberIF grabber = new NameGrabber(Collections.EMPTY_LIST);
  
      Assert.assertTrue("wrong base name grabbed",
             ((TopicNameIF) grabber.grab(topic5)).equals(basename5B));
    }
test_case.class_method_signature: NameGrabberTest.testNameGrabber5B()
test_case.full_signature: @Test public void testNameGrabber5B()
test_case.identifier: testNameGrabber5B
test_case.invocations: assertTrue equals grab
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testNameGrabber5B()
focal_class.declarator: themeIndicator
focal_class.modifier: protected
focal_class.original_string: protected LocatorIF themeIndicator;
focal_class.type: LocatorIF
focal_class.var_name: themeIndicator
focal_class.declarator: indicatorVariant
focal_class.modifier: protected
focal_class.original_string: protected boolean indicatorVariant;
focal_class.type: boolean
focal_class.var_name: indicatorVariant
focal_class.declarator: scope
focal_class.modifier: protected
focal_class.original_string: protected Collection<TopicIF> scope;
focal_class.type: Collection<TopicIF>
focal_class.var_name: scope
focal_class.declarator: variantScope
focal_class.modifier: protected
focal_class.original_string: protected Collection<TopicIF> variantScope;
focal_class.type: Collection<TopicIF>
focal_class.var_name: variantScope
focal_class.declarator: grabOnlyTopicName = true
focal_class.modifier: protected
focal_class.original_string: protected boolean grabOnlyTopicName = true;
focal_class.type: boolean
focal_class.var_name: grabOnlyTopicName
focal_class.file: ontopia-engine/src/main/java/net/ontopia/topicmaps/utils/NameGrabber.java
focal_class.identifier: NameGrabber
focal_class.interfaces: implements GrabberIF<TopicIF, NameIF>
focal_class.class_method_signature: NameGrabber.NameGrabber(LocatorIF themeIndicator)
focal_class.full_signature: public  NameGrabber(LocatorIF themeIndicator)
focal_class.identifier: NameGrabber
focal_class.modifiers: public
focal_class.parameters: (LocatorIF themeIndicator)
focal_class.signature:  NameGrabber(LocatorIF themeIndicator)
focal_class.class_method_signature: NameGrabber.NameGrabber(LocatorIF themeIndicator, boolean variant)
focal_class.full_signature: public  NameGrabber(LocatorIF themeIndicator, boolean variant)
focal_class.identifier: NameGrabber
focal_class.modifiers: public
focal_class.parameters: (LocatorIF themeIndicator, boolean variant)
focal_class.signature:  NameGrabber(LocatorIF themeIndicator, boolean variant)
focal_class.class_method_signature: NameGrabber.NameGrabber(Collection<TopicIF> scope)
focal_class.full_signature: public  NameGrabber(Collection<TopicIF> scope)
focal_class.identifier: NameGrabber
focal_class.modifiers: public
focal_class.parameters: (Collection<TopicIF> scope)
focal_class.signature:  NameGrabber(Collection<TopicIF> scope)
focal_class.class_method_signature: NameGrabber.NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope)
focal_class.full_signature: public  NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope)
focal_class.identifier: NameGrabber
focal_class.modifiers: public
focal_class.parameters: (Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope)
focal_class.signature:  NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope)
focal_class.class_method_signature: NameGrabber.NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope,
                       boolean grabOnlyTopicName)
focal_class.full_signature: public  NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope,
                       boolean grabOnlyTopicName)
focal_class.identifier: NameGrabber
focal_class.modifiers: public
focal_class.parameters: (Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope,
                       boolean grabOnlyTopicName)
focal_class.signature:  NameGrabber(Collection<TopicIF> basenameScope, Collection<TopicIF> variantScope,
                       boolean grabOnlyTopicName)
focal_class.class_method_signature: NameGrabber.setGrabOnlyTopicName(boolean grabOnlyTopicName)
focal_class.full_signature: public void setGrabOnlyTopicName(boolean grabOnlyTopicName)
focal_class.identifier: setGrabOnlyTopicName
focal_class.modifiers: public
focal_class.parameters: (boolean grabOnlyTopicName)
focal_class.return: void
focal_class.signature: void setGrabOnlyTopicName(boolean grabOnlyTopicName)
focal_class.class_method_signature: NameGrabber.getGrabOnlyTopicName()
focal_class.full_signature: public boolean getGrabOnlyTopicName()
focal_class.identifier: getGrabOnlyTopicName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean getGrabOnlyTopicName()
focal_class.class_method_signature: NameGrabber.grab(TopicIF topic)
focal_class.full_signature: @Override public NameIF grab(TopicIF topic)
focal_class.identifier: grab
focal_class.modifiers: @Override public
focal_class.parameters: (TopicIF topic)
focal_class.return: NameIF
focal_class.signature: NameIF grab(TopicIF topic)
focal_method.body: @Override
    public NameIF grab(TopicIF topic) {
      if (topic == null)
        return null;
      
      List<TopicNameIF> basenames = new ArrayList<TopicNameIF>(topic.getTopicNames());
      if (basenames.isEmpty())
        return null;
  
      // If subject indicator of theme is set use this to setup scope
      if (themeIndicator != null) {
        // Get theme
        TopicMapIF tm = topic.getTopicMap();
        
        // Test if tm is null before getting theme. tm may be null if topic was
        // created (for internal purposes) in situations where no topic map was
        // available.
        if (tm != null) {
          TopicIF theme = tm.getTopicBySubjectIdentifier(themeIndicator);
          if (theme != null) {
            if (indicatorVariant)
              variantScope = Collections.singleton(theme);
            else
              scope = Collections.singleton(theme);
          }
        }
      }
      
      // sort the base names
      Collections.sort(basenames, new TopicNameComparator(scope));
  
      // TODO: Do we really have to create this grabber over and over again?
      VariantNameGrabber vngrabber = new VariantNameGrabber(variantScope);
      NameIF name = null;
      VariantNameIF vn = null;
  
      for (TopicNameIF current : basenames) {
        if (name == null)
          name = current;
  
        if (!variantScope.isEmpty()) {
          vn = vngrabber.grab(current);
          if (vn != null) {
            // TODO: Should not use intersection to find appropriate
            // variant, but rather exact matching, or perhaps ranking.
            
            // if there exists some overlap between variant name themes
            // and specified scope then we are delivering this variant
            Collection<TopicIF> interSection = new HashSet<TopicIF>(vn.getScope());
            interSection.retainAll(variantScope);
            if (!interSection.isEmpty())
              break;
            else
              vn = null;
          }
        }
      } // while
  
      // if valid variant name get base name which belongs to this
      if (vn != null) {
        if (grabOnlyTopicName)
          name = vn.getTopicName();
        else
          name = vn;
      }
  
      return name;
    }
focal_method.class_method_signature: NameGrabber.grab(TopicIF topic)
focal_method.full_signature: @Override public NameIF grab(TopicIF topic)
focal_method.identifier: grab
focal_method.invocations: getTopicNames isEmpty getTopicMap getTopicBySubjectIdentifier singleton singleton sort isEmpty grab getScope retainAll isEmpty getTopicName
focal_method.modifiers: @Override public
focal_method.parameters: (TopicIF topic)
focal_method.return: NameIF
focal_method.signature: NameIF grab(TopicIF topic)