public Object newChild(Object parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs) { // Get the newChild method Class objClass = parent.getClass(); Class[] classes = new Class[] { objClass, UnmarshallingContext.class, String.class, String.class, Attributes.class }; Method method = ObjectModelBuilder.getMethodForElement(typedFactory, "newChild", classes); // If null, try to get the newChild method from the super class while (method == null && objClass.getSuperclass() != Object.class) { objClass = objClass.getSuperclass(); classes = new Class[] { objClass, UnmarshallingContext.class, String.class, String.class, Attributes.class }; method = ObjectModelBuilder.getMethodForElement(typedFactory, "newChild", classes); } // invoke the setValue method Object child = null; if (method != null) { Object[] objects = new Object[] { parent, navigator, namespaceURI, localName, attrs }; child = ObjectModelBuilder.invokeFactory(typedFactory, method, objects); } return child; }
public void setValue(Object o, UnmarshallingContext navigator, String namespaceURI, String localName, String value) { // Get the setValue method Class objClass = o.getClass(); Class[] classes = new Class[] { objClass, UnmarshallingContext.class, String.class, String.class, String.class }; Method method = ObjectModelBuilder.getMethodForElement(typedFactory, "setValue", classes); // If null, try to get the setValue method from the super class while (method == null && objClass.getSuperclass() != Object.class) { objClass = objClass.getSuperclass(); classes = new Class[] { objClass, UnmarshallingContext.class, String.class, String.class, String.class }; method = ObjectModelBuilder.getMethodForElement(typedFactory, "setValue", classes); } // invoke the setValue method if (method != null) { // property replacement if( replaceProps ) value = StringPropertyReplacer.replaceProperties(value); Object[] objects = new Object[] { o, navigator, namespaceURI, localName, value }; ObjectModelBuilder.invokeFactory(typedFactory, method, objects); } }