Package com.adaptiweb.utils.xmlbind.annotation

Examples of com.adaptiweb.utils.xmlbind.annotation.BindAttribute


  }

  private void appendAttributes(Object obj, List<Method> attributes, MarshallerOutput output) throws ParserException, IOException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    for(Method method : attributes) {
      Class<?> type = method.getReturnType();
      BindAttribute annotation = method.getAnnotation(BindAttribute.class);

      String name = annotation.name().length() != 0 ? annotation.name() :
        BindUtils.toXmlName(method.getName().substring(method.getName().startsWith("is") ? 2 : 3));
       
      String value = null;
     
      if(Iterable.class.isAssignableFrom(type) || type.isArray()) {
        String separator = annotation.separator();
        StringBuffer result = new StringBuffer();
       
        if(type.isArray())
          for(Object o : (Object[]) method.invoke(obj))
            result.append(separator).append(extractValue(o, annotation.evalProvider(), name));
        else
          for(Object o : (Iterable<?>) method.invoke(obj))
            result.append(separator).append(extractValue(o, annotation.evalProvider(), name));
       
        value = result.substring(separator.length());
      }
      else value = extractValue(method.invoke(obj), annotation.evalProvider(), name);
     
      output.addAttribute(name, value);
    }
  }
View Full Code Here

TOP

Related Classes of com.adaptiweb.utils.xmlbind.annotation.BindAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.