org.jvnet.hk2.config.Dom.get()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.jvnet.hk2.config.Dom.get()方法的一些代码示例,展示了Dom.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dom.get()方法的具体详情如下:
包路径:org.jvnet.hk2.config.Dom
类名称:Dom
方法名:get

Dom.get介绍

[英]Returns the list of attributes with a value on this config instance. This is by definition a subset of the attributes names as known to the model ConfigModel.getAttributeNames.
[中]返回在此配置实例上具有值的属性列表。根据定义,这是模型ConfigModel已知的属性名称的子集。GetAttributeName。

代码示例

代码示例来源:origin: javaee/glassfish

public Object get(int index) {
  return v.get(index).get();
}

代码示例来源:origin: javaee/glassfish

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

代码示例来源:origin: javaee/glassfish

public <T> T nodeByTypeElement(Class<T> baseType) {
  int len = children.size();
  for( int i=0; i<len; i++ ) {
    Child child = children.get(i);
    if (child instanceof NodeChild) {
      NodeChild nc = (NodeChild) child;
      if(model.elements.containsKey(nc.name))
        continue;   // match with named
      if(baseType.isAssignableFrom(nc.dom.getImplementationClass()))
        return baseType.cast(nc.dom.get());
    }
  }
  return null;
}

代码示例来源:origin: javaee/glassfish

protected Object convertLeafValue(Dom parent, Class<?> returnType, String v) {
  // let's look first the fast way.
  Object candidate = parent.getHabitat().getService(returnType, v);
  if (candidate!=null) {
    return returnType.cast(candidate);
  }
  parent = parent.getSymbolSpaceRoot(v);
  Dom dom = parent.resolveReference(v,returnType.getName());
  if (dom!=null) {
    return returnType.cast(dom.get());
  } else {
    throw new IllegalArgumentException("Cannot find an instance of " + returnType + " named " + v);
  }
}

代码示例来源:origin: javaee/glassfish

/**
 * Updates the attribute value.
 *
 * 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());
  }
}

代码示例来源:origin: javaee/glassfish

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.leafElement(xmlName);
  Class<?> type = Types.erasure(returnType);
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getService(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

代码示例来源:origin: javaee/glassfish

public T get(int index) {
  return baseType.cast(elements.get(index).get());
}
public int size() {

代码示例来源:origin: org.glassfish.hk2/hk2-config

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

代码示例来源:origin: javaee/glassfish

/**
 * Updates leaf-element values.
 * <p>
 * Synchronized so that concurrenct modifications will work correctly.
 */
public synchronized void setLeafElements(final String name, String... values) {
  List<Child> newChildren = new ArrayList<Child>(children);
  LeafChild[] leaves = new LeafChild[values.length];
  for (int i = 0; i < values.length; i++)
    leaves[i] = new LeafChild(name,values[i]);
  stitchList(newChildren,name,Arrays.asList(leaves));
  children = newChildren;
  // see attribute(String,String) for the issue with this
  getInjector().injectElement(this,name,get());
}

代码示例来源:origin: javaee/glassfish

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  Class<?> type = Types.erasure(returnType);
  
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getService(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

代码示例来源:origin: javaee/glassfish

public void element_setIndexItems(Dom dom, org.glassfish.admingui.connector.IndexItem target) {
  List<Dom> v1 = dom.nodeElements("indexitem");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.IndexItem>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.IndexItem) v3 .get()));
  }
  target.setIndexItems(v2);
}

代码示例来源:origin: org.glassfish.hk2/config

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

代码示例来源:origin: javaee/glassfish

/**
 * Updates node-element values.
 * <p>
 * Synchronized so that concurrenct modifications will work correctly.
 */
public synchronized void setNodeElements(final String name, Dom... values) {
  List<Child> newChildren = new ArrayList<Child>(children);
  NodeChild[] leaves = new NodeChild[values.length];
  for (int i = 0; i < values.length; i++)
    leaves[i] = new NodeChild(name,values[i]);
  List<Child> removed = stitchList(newChildren,name,Arrays.asList(leaves));
  children = newChildren;
  for (Child c : removed) {
    ((NodeChild) c).dom.release();
  }
  // see attribute(String,String) for the issue with this
  getInjector().injectElement(this,name,get());
}

代码示例来源:origin: org.glassfish.hk2/hk2-config

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.leafElement(xmlName);
  Class<?> type = Types.erasure(returnType);
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getService(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

代码示例来源:origin: javaee/glassfish

public void element_setTOCItems(Dom dom, org.glassfish.admingui.connector.TOCItem target) {
  List<Dom> v1 = dom.nodeElements("tocitem");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.TOCItem>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.TOCItem) v3 .get()));
  }
  target.setTOCItems(v2);
}

代码示例来源:origin: javaee/glassfish

public void element_setTOCItems(Dom dom, TOC target) {
  List<Dom> v1 = dom.nodeElements("tocitem");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.TOCItem>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.TOCItem) v3 .get()));
  }
  target.setTOCItems(v2);
}

代码示例来源:origin: javaee/glassfish

public void element_setIndexItems(Dom dom, Index target) {
  List<Dom> v1 = dom.nodeElements("indexitem");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.IndexItem>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.IndexItem) v3 .get()));
  }
  target.setIndexItems(v2);
}

代码示例来源:origin: javaee/glassfish

public void element_setIntegrationPoints(Dom dom, ConsoleConfig target) {
  List<Dom> v1 = dom.nodeElements("integration-point");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.IntegrationPoint>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.IntegrationPoint) v3 .get()));
  }
  target.setIntegrationPoints(v2);
}

代码示例来源:origin: javaee/glassfish

public void element_setGadgetUserPref(Dom dom, GadgetModule target) {
  List<Dom> v1 = dom.nodeElements("UserPref");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.GadgetUserPref>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.GadgetUserPref) v3 .get()));
  }
  target.setGadgetUserPref(v2);
}

代码示例来源:origin: javaee/glassfish

public void element_setGadgetModulePrefs(Dom dom, GadgetModule target) {
  Dom v1 = dom.nodeElement("ModulePrefs");
  if (v1 == null) {
    return ;
  }
  target.setGadgetModulePrefs(((GadgetModulePrefs) v1 .get()));
}

相关文章