Here you can find the source of readComplexProperty(String name, List objects, String methodName)HOMEJavaXXML JAXB UnserializereadComplexProperty(String name, List objects, String methodName)Description read Complex Property License Open Source License Declaration public static String readComplexProperty(String name, List<Object> objects, String methodName) Method Source Code //package com.java2s; /*//w w w .j av a2s . c om Copyright ? 2013 Mael Le Gu?vel This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details. */ import java.lang.reflect.Method; import java.util.List; import javax.xml.bind.JAXBElement; public class Main { public static String readComplexProperty(String name, List<Object> objects, String methodName) { for (Object o : objects) { if (o instanceof JAXBElement) { JAXBElement element = (JAXBElement) o; if (name.equals(element.getName().getLocalPart())) { return callMethod(element.getValue(), methodName); } } } return null; } private static String callMethod(Object o, String methodName) { try { Method method = o.getClass().getMethod(methodName); String value = (String) method.invoke(o); return value; } catch (Exception e) { e.printStackTrace(); } return null; } } RelatedparseXml(final Class klass, final Reader xmlReader)parseXML(String content, Class clazz)parseXmlFile(Class type, String filePath)read(Class cl, InputStream is)read(File file, Class typeParameterClass)readExternal(InputStream inputStream, Class clazz)readJAXB(Class clazz, InputStream is)readJaxbObject(InputStream inputStream, Class jaxbModelClass)readObject(Class clazz, File file)
public static String readComplexProperty(String name, List<Object> objects, String methodName)
//package com.java2s; /*//w w w .j av a2s . c om Copyright ? 2013 Mael Le Gu?vel This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details. */ import java.lang.reflect.Method; import java.util.List; import javax.xml.bind.JAXBElement; public class Main { public static String readComplexProperty(String name, List<Object> objects, String methodName) { for (Object o : objects) { if (o instanceof JAXBElement) { JAXBElement element = (JAXBElement) o; if (name.equals(element.getName().getLocalPart())) { return callMethod(element.getValue(), methodName); } } } return null; } private static String callMethod(Object o, String methodName) { try { Method method = o.getClass().getMethod(methodName); String value = (String) method.invoke(o); return value; } catch (Exception e) { e.printStackTrace(); } return null; } }