<commit_before>/*
 * Created on Aug 8, 2005
 */
package uk.org.ponder.rsf.components;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import uk.org.ponder.util.AssertionException;

/**
 * @author <NAME> (<EMAIL>)
 * 
 */
public class UIContainer extends UIComponent {
  // This is a map to either the single component with a given ID prefix, or a 
  // list in the case of a repetitive domain (non-null suffix)
  private Map childmap;
 
  public UIComponent getComponent(String id) {
    return (UIComponent) childmap.get(id);
  }
  
  public List getComponents(String id) {
    return (List) childmap.get(id);
  }
  
  // this is a map of component IDs in this container, to their parent
  // form.
  private Map componentToForm;
  
  public UIForm formForComponent(UIComponent component) {
    return (UIForm) componentToForm.get(component);
  }
  
  /** This field is used as a convenience when building up a component
   * tree in code. It is periodically set to null or otherwise, and the
   * next added component will be ascribed to the mentioned form.
   */
  public transient UIForm currentform;
  
  public void startForm(String ID) {
    if (currentform == null) {
      // could even check parents.
      throw new AssertionException("Error starting form - form already in progress");
    }
    currentform = new UIForm();
    currentform.ID = ID;<commit_msg>Should I die of malaria or a big boulder, this resolution logic in ViewRender will allow my intention to be implemented.<commit_after>/*
 * Created on Aug 8, 2005
 */
package uk.org.ponder.rsf.components;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import uk.org.ponder.util.AssertionException;

/**
 * @author <NAME> (<EMAIL>.cam.ac.uk)
 * 
 */
public class UIContainer extends UIComponent {
  // This is a map to either the single component with a given ID prefix, or a 
  // list in the case of a repetitive domain (non-null suffix)
  private Map childmap;
 
  public UIComponent getComponent(String id) {
    return (UIComponent) childmap.get(id);
  }
  /** Return all child components with the given prefix */
  public List getComponents(String id) {
    return (List) childmap.get(id);
  }
  
  public Iterator children() {
    return childmap.values().iterator();
  }
  
  // this is a map of component IDs in this container, to their parent
  // form.
  private Map componentToForm;
  
  public UIForm formForComponent(UIComponent component) {
    return (UIForm) componentToForm.get(component);
  }
  
  /** This field is used as a convenience when building up a component
   * tree in code. It is periodically set to null or otherwise, and the
   * next added component will be ascribed to the mentioned form.
   */
  public transient UIForm currentform;
  
  public void startForm(String ID) {
    if (currentform == null) {
      // could even check parents.
      throw new AssertionException("Error starting form - form already in progress");
    }
    currentform = new UIForm();
    currentform.ID = ID;
{'fraction_non_alphanumeric': 0.08954269267668692, 'fraction_numerical': 0.0031979533098816758, 'mean_word_length': 3.3085399449035813, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3955401', 'n_tokens_mistral': 917, 'n_tokens_neox': 909, 'n_words': 348}