本文整理了Java中org.jvnet.hk2.config.Dom.leafElements()
方法的一些代码示例,展示了Dom.leafElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dom.leafElements()
方法的具体详情如下:
包路径:org.jvnet.hk2.config.Dom
类名称:Dom
方法名:leafElements
[英]Picks up all leaf-element values of the given name.
[中]拾取给定名称的所有叶元素值。
代码示例来源:origin: javaee/glassfish
public Object get(final Dom dom, Type returnType) {
// TODO: perhaps support more collection types?
final List<String> v = dom.leafElements(xmlName);
if(!(returnType instanceof ParameterizedType))
throw new IllegalArgumentException("List needs to be parameterized");
final Class itemType = Types.erasure(Types.getTypeArgument(returnType,0));
// return a live list
return new AbstractList<Object>() {
public Object get(int index) {
return convertLeafValue(dom, itemType, v.get(index));
}
public void add(int index, Object element) {
// update the master children list, as well as this view 'v'
dom.addLeafElement(xmlName, elementValue(element));
v.add(index, element.toString());
}
public Object remove(int index) {
dom.removeLeafElement(xmlName, v.get(index));
return v.remove(index);
}
public Object set(int index, Object element) {
dom.changeLeafElement(xmlName, v.get(index), elementValue(element));
return v.set(index, element.toString());
}
public int size() {
return v.size();
}
};
}
代码示例来源:origin: org.glassfish.main.core/kernel
public Map<String, String> getNodeAttributes(Dom node, String prefix) {
Map<String, String> result = new HashMap<String, String>();
for (String attrName : node.model.getAttributeNames()) {
String value = (String) node.model.findIgnoreCase(attrName).get(node, String.class);
if (value!=null) {
result.put(attrName, value);
}
}
for (String leafName : node.model.getLeafElementNames()) {
List values = node.leafElements(leafName);
Iterator i = values.iterator();
StringBuffer value = new StringBuffer();
while (i.hasNext()) {
String nextValue = (String) i.next();
if (nextValue!=null) {
value.append(nextValue);
if(i.hasNext()) {
value.append(",");
}
}
}
result.put(leafName, value.toString());
}
return result;
}
代码示例来源:origin: com.sun.enterprise/config
public Object get(final Dom dom, Type returnType) {
// TODO: perhaps support more collection types?
final List<String> v = dom.leafElements(xmlName);
if(!(returnType instanceof ParameterizedType))
throw new IllegalArgumentException("List needs to be parameterized");
final Class itemType = Types.erasure(Types.getTypeArgument(returnType,0));
// return a live list
return new AbstractList<Object>() {
public Object get(int index) {
return convertLeafValue(itemType, v.get(index));
}
public void add(int index, Object element) {
// update the master children list, as well as this view 'v'
dom.addLeafElement(xmlName, element.toString());
v.add(index, element.toString());
}
public Object remove(int index) {
dom.removeLeafElement(xmlName, v.get(index));
return v.remove(index);
}
public Object set(int index, Object element) {
dom.changeLeafElement(xmlName, v.get(index), element.toString());
return v.set(index, element.toString());
}
public int size() {
return v.size();
}
};
}
代码示例来源:origin: org.glassfish.hk2/config
public Object get(final Dom dom, Type returnType) {
// TODO: perhaps support more collection types?
final List<String> v = dom.leafElements(xmlName);
if(!(returnType instanceof ParameterizedType))
throw new IllegalArgumentException("List needs to be parameterized");
final Class itemType = Types.erasure(Types.getTypeArgument(returnType,0));
// return a live list
return new AbstractList<Object>() {
public Object get(int index) {
return convertLeafValue(dom, itemType, v.get(index));
}
public void add(int index, Object element) {
// update the master children list, as well as this view 'v'
dom.addLeafElement(xmlName, elementValue(element));
v.add(index, element.toString());
}
public Object remove(int index) {
dom.removeLeafElement(xmlName, v.get(index));
return v.remove(index);
}
public Object set(int index, Object element) {
dom.changeLeafElement(xmlName, v.get(index), elementValue(element));
return v.set(index, element.toString());
}
public int size() {
return v.size();
}
};
}
代码示例来源:origin: org.glassfish.hk2/hk2-config
public Object get(final Dom dom, Type returnType) {
// TODO: perhaps support more collection types?
final List<String> v = dom.leafElements(xmlName);
if(!(returnType instanceof ParameterizedType))
throw new IllegalArgumentException("List needs to be parameterized");
final Class itemType = Types.erasure(Types.getTypeArgument(returnType,0));
// return a live list
return new AbstractList<Object>() {
public Object get(int index) {
return convertLeafValue(dom, itemType, v.get(index));
}
public void add(int index, Object element) {
// update the master children list, as well as this view 'v'
dom.addLeafElement(xmlName, elementValue(element));
v.add(index, element.toString());
}
public Object remove(int index) {
dom.removeLeafElement(xmlName, v.get(index));
return v.remove(index);
}
public Object set(int index, Object element) {
dom.changeLeafElement(xmlName, v.get(index), elementValue(element));
return v.set(index, element.toString());
}
public int size() {
return v.size();
}
};
}
代码示例来源:origin: eclipse-ee4j/glassfish
public Object get(final Dom dom, Type returnType) {
// TODO: perhaps support more collection types?
final List<String> v = dom.leafElements(xmlName);
if(!(returnType instanceof ParameterizedType))
throw new IllegalArgumentException("List needs to be parameterized");
final Class itemType = Types.erasure(Types.getTypeArgument(returnType,0));
// return a live list
return new AbstractList<Object>() {
public Object get(int index) {
return convertLeafValue(dom, itemType, v.get(index));
}
public void add(int index, Object element) {
// update the master children list, as well as this view 'v'
dom.addLeafElement(xmlName, elementValue(element));
v.add(index, element.toString());
}
public Object remove(int index) {
dom.removeLeafElement(xmlName, v.get(index));
return v.remove(index);
}
public Object set(int index, Object element) {
dom.changeLeafElement(xmlName, v.get(index), elementValue(element));
return v.set(index, element.toString());
}
public int size() {
return v.size();
}
};
}
内容来源于网络,如有侵权,请联系作者删除!