Exemplo n.º 1
0
  public void setAttribute(String attribute, Object obj1) {
    Set<Entry<String, StringTemplate>> set = m_templates.entrySet();
    Iterator<Entry<String, StringTemplate>> it = set.iterator();

    while (it.hasNext()) {
      Map.Entry<String, StringTemplate> m = (Map.Entry<String, StringTemplate>) it.next();

      // Call setAttribute
      Log.printDebug(
          "setting attribute (obj1) to template group "
              + m.getKey()
              + " to "
              + m.getValue().getName());
      StringTemplate template = m.getValue();
      template.setAttribute(attribute, obj1);
      // Update extensions
      List<StringTemplate> extensions =
          m_extensionstemplates.get(m.getKey() + "_" + template.getName());
      if (extensions != null) {
        for (StringTemplate extension : extensions) {
          extension.setAttribute(attribute, obj1);
        }
      }
    }
  }
Exemplo n.º 2
0
  public StringTemplate getTemplate(String groupname) {
    StringTemplate template = m_templates.get(groupname);

    // If there is extensiones, add them before return the template.
    if (m_extensionstemplates.containsKey(groupname + "_" + template.getName())) {
      List<StringTemplate> extemplates = new ArrayList<StringTemplate>();
      List<StringTemplate> extensions =
          m_extensionstemplates.get(groupname + "_" + template.getName());

      for (StringTemplate extension : extensions) {
        extemplates.add(extension);
      }

      template.setAttribute("extensions", extemplates);
    }

    return template;
  }
Exemplo n.º 3
0
  public void setAttribute(String attribute, TemplateGroup tg) {
    if (tg != null) {
      Set<Entry<String, StringTemplate>> set = m_templates.entrySet();
      Iterator<Entry<String, StringTemplate>> it = set.iterator();

      while (it.hasNext()) {
        Map.Entry<String, StringTemplate> m = (Map.Entry<String, StringTemplate>) it.next();

        // Call setAttribute
        StringTemplate template = tg.getTemplate(m.getKey());

        if (template != null) {
          Log.printDebug(
              "setting attribute (TemplateGroup) to template group "
                  + m.getKey()
                  + " from "
                  + template.getName()
                  + " to "
                  + m.getValue().getName());
          m.getValue().setAttribute(attribute, template.toString());
        }
      }
    }
  }
Exemplo n.º 4
0
 public void addTemplate(
     String groupname, StringTemplate template, List<StringTemplate> extensionstemplates) {
   addTemplate(groupname, template);
   m_extensionstemplates.put(groupname + "_" + template.getName(), extensionstemplates);
 }