コード例 #1
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
 /*package*/ void fillAttributes(XMLStreamReader in) {
   for (int i = in.getAttributeCount() - 1; i >= 0; i--) {
     String n = in.getAttributeLocalName(i);
     if (model.attributes.containsKey(n)) {
       if (attributes == null) attributes = new HashMap<String, String>();
       attributes.put(n, in.getAttributeValue(i));
     }
   }
   if (attributes == null) attributes = Collections.emptyMap();
 }
コード例 #2
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
 /**
  * Updates the attribute value.
  *
  * <p>This would trigger the re-injection of the value.
  */
 public void attribute(String name, String value) {
   if (value == null) {
     attributes.remove(name);
   } else {
     attributes.put(name, value);
     // TODO:
     // this re-injection has two problems. First, it forces an instantiation
     // even if that hasn't happened yet. Second, if the component is scoped,
     // this won't work correctly (but then, there's no way to make that work,
     // since we can't enumerate all scope instances.)
     getInjector().injectAttribute(this, name, get());
   }
 }
コード例 #3
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
  /**
   * Returns the map of attributes names and values for attributes which value is neither null or
   * the default value. These attributes are considered having a non default value and must be
   * written out.
   *
   * @return map of attributes indexed by name that must be persisted
   */
  private Map<String, String> attributesToWrite() {

    Map<String, String> attributesToWrite = new HashMap<String, String>();
    Map<String, String> localAttr = new HashMap<String, String>(attributes);
    for (Map.Entry<String, String> a : localAttr.entrySet()) {
      ConfigModel.AttributeLeaf am = model.attributes.get(a.getKey());
      String dv = am.getDefaultValue();
      if (dv == null || !dv.equals(a.getValue())) {
        attributesToWrite.put(a.getKey(), a.getValue());
      }
    }
    return attributesToWrite;
  }