Пример #1
0
  public static String putVal(String name, String val, Document doc, Map<String, Object> locals) {
    String ns = null;
    int inx = name.indexOf('.');
    if (inx != -1) {
      ns = name.substring(0, inx);
      name = name.substring(inx + 1);
    }

    if (val == null || val.length() == 0) {
      // removeAttr
      if ("pref".equals(ns)) Multivalent.getInstance().removePreference(name);
      else if ("doc".equals(ns)) doc.removeAttr(name);
      else locals.remove(name);
    } else {
      val = getVal(val, doc, locals);
      if ("pref".equals(ns)) Multivalent.getInstance().putPreference(name, val);
      else if ("doc".equals(ns)) doc.putAttr(name, val);
      else locals.put(name, val);
    }

    return val;
  }
Пример #2
0
  public static String getVar(String name, Document doc, Map<String, Object> locals) {
    String ns = null;
    String val;
    int inx = name.indexOf('.');
    if (inx != -1) {
      ns = name.substring(0, inx);
      name = name.substring(inx + 1);
    }
    if ("pref".equals(ns)) val = Multivalent.getInstance().getPreference(name, null);
    else if ("doc".equals(ns)) val = doc.getAttr(name);
    else val = (String) locals.get(name);

    return val != null ? val : "";
  }