public Object get(int index) { return v.get(index).get(); }
/** * 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()); } }
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; }
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); } }
/** * 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()); } }
@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()); }
public T get(int index) { return baseType.cast(elements.get(index).get()); } public int size() {
/** * 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()); } }
/** * 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()); }
@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()); }
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); }
/** * 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()); } }
/** * 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()); }
@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()); }
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); }
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); }
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); }
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); }
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); }
public void element_setGadgetModulePrefs(Dom dom, GadgetModule target) { Dom v1 = dom.nodeElement("ModulePrefs"); if (v1 == null) { return ; } target.setGadgetModulePrefs(((GadgetModulePrefs) v1 .get())); }