Beispiel #1
0
    /**
     * Search if the given element has classes attributes and fill the given array with the set of
     * rules that match these classes.
     *
     * @param element The element for which classes must be found.
     * @param rules The rule array to fill.
     */
    protected void getClassRules(Element element, ArrayList<Rule> rules) {
      Object o = element.getAttribute("ui.class");

      if (o != null) {
        if (o instanceof Object[]) {
          for (Object s : (Object[]) o) {
            if (s instanceof CharSequence) {
              Rule rule = byClass.get((CharSequence) s);

              if (rule != null) rules.add(rule);
            }
          }
        } else if (o instanceof CharSequence) {
          String classList = ((CharSequence) o).toString().trim();
          String[] classes = classList.split("\\s*,\\s*");

          for (String c : classes) {
            Rule rule = byClass.get(c);

            if (rule != null) rules.add(rule);
          }
        } else {
          throw new RuntimeException("Oups ! class attribute is of type " + o.getClass().getName());
        }
      }
    }
Beispiel #2
0
  /**
   * @param source
   * @param target
   */
  public static void copyAttributes(Element source, Element target) {
    for (String key : source.getAttributeKeySet()) {
      Object value = source.getAttribute(key);
      value = checkedArrayOrCollectionCopy(value);

      target.setAttribute(key, value);
    }
  }