Esempio n. 1
0
 /**
  * @param p_path path using # as delimiter.
  * @param p_optionDescription
  */
 public void addOptionDescription(String p_path, OptionDescription p_optionDescription) {
   OptionGroup group = getOptionGroup(null, p_path);
   group.getOptions().add(p_optionDescription);
   if (p_optionDescription.getOption() instanceof ApplicationOption) {
     m_applicationOptions.add((ApplicationOption) p_optionDescription.getOption());
   } else if (p_optionDescription.getOption() instanceof CompanyOption) {
     m_companyOptions.add((CompanyOption) p_optionDescription.getOption());
   } else if (p_optionDescription.getOption() instanceof UserOption) {
     m_userOptions.add((UserOption) p_optionDescription.getOption());
   }
 }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 private <T> List<T> getOptionsOfClass(OptionGroup p_group, Class<T> p_class) {
   List<T> result = new ArrayList<T>();
   for (OptionDescription option : p_group.getOptions()) {
     if (option.getOption().getClass().equals(p_class)) {
       result.add((T) option.getOption());
     }
   }
   for (OptionGroup group : p_group.getSubgroups()) {
     result.addAll(getOptionsOfClass(group, p_class));
   }
   return result;
 }
Esempio n. 3
0
  private OptionGroup getOptionGroup(OptionGroup p_parent, String p_path) {
    OptionGroup result = null;
    List<OptionGroup> possibleSubGroups = m_optionGroups;
    if (p_parent != null) {
      possibleSubGroups = p_parent.getSubgroups();
    }
    String groupName = "";
    String theRestOfThePath = "";
    if (p_path.contains("#")) {
      theRestOfThePath = p_path.substring(p_path.indexOf("#") + 1);
      groupName = p_path.substring(0, p_path.indexOf("#"));
    } else {
      groupName = p_path;
      theRestOfThePath = null;
    }

    for (OptionGroup optionsGroup : possibleSubGroups) {
      if (optionsGroup.getGroupName().equals(groupName)) {
        result = optionsGroup;
        break;
      }
    }
    if (result == null) {
      result = new OptionGroup(groupName);
      if (p_parent == null) {
        m_optionGroups.add(result);
      } else {
        p_parent.getSubgroups().add(result);
      }
    }
    if (theRestOfThePath != null) {
      return getOptionGroup(result, theRestOfThePath);
    } else {
      return result;
    }
  }