Package de.timroes.axmlrpc.xmlcreator

Examples of de.timroes.axmlrpc.xmlcreator.XmlElement


  }

  public XmlElement serialize(Object object) {

    XmlElement struct = new XmlElement(SerializerHandler.TYPE_STRUCT);

    try {

      XmlElement entry, name, value;

      // We can safely cast here, this Serializer should only be called when
      // the parameter is a map.
      @SuppressWarnings("unchecked")
      Map<String,Object> map = (Map<String,Object>)object;

      for(Map.Entry<String,Object> member : map.entrySet()) {
        entry = new XmlElement(STRUCT_MEMBER);
        name = new XmlElement(STRUCT_NAME);
        value = new XmlElement(STRUCT_VALUE);
        name.setContent(member.getKey());
        value.addChildren(SerializerHandler.getDefault().serialize(member.getValue()));
        entry.addChildren(name);
        entry.addChildren(value);
        struct.addChildren(entry);
      }

    } catch(XMLRPCException ex) {
      throw new XMLRPCRuntimeException(ex);
View Full Code Here


   * @param type The type of the xml tag. What will be filled in the <..>.
   * @param content The content of the tag.
   * @return The xml tag with its content as a string.
   */
  public static XmlElement makeXmlTag(String type, String content) {
    XmlElement xml = new XmlElement(type);
    xml.setContent(content);
    return xml;
  }
View Full Code Here

    if ( object instanceof Iterable<?>){
      iter = (Iterable<?>)object;
    } else {
      iter = Arrays.asList((Object[]) object);
    }
    XmlElement array = new XmlElement(SerializerHandler.TYPE_ARRAY);
    XmlElement data = new XmlElement(ARRAY_DATA);
    array.addChildren(data);

    try {

      XmlElement e;
      for(Object obj : iter) {
        e = new XmlElement(ARRAY_VALUE);
        e.addChildren(SerializerHandler.getDefault().serialize(obj));
        data.addChildren(e);
      }

    } catch(XMLRPCException ex) {
      throw new XMLRPCRuntimeException(ex);
View Full Code Here

   */
  public String getXML() throws XMLRPCException {

    SimpleXMLCreator creator = new SimpleXMLCreator();

    XmlElement methodCall = new XmlElement(XMLRPCClient.METHOD_CALL);
    creator.setRootElement(methodCall);

    XmlElement methodName = new XmlElement(XMLRPCClient.METHOD_NAME);
    methodName.setContent(method);
    methodCall.addChildren(methodName);

    if(params != null && params.length > 0) {
      XmlElement params = new XmlElement(XMLRPCClient.PARAMS);
      methodCall.addChildren(params);

      for(Object o : this.params) {
        params.addChildren(getXMLParam(o));
      }
    }

    return creator.toString();
  }
View Full Code Here

   * @param o The parameter object.
   * @return The object serialized into an xml tag.
   * @throws XMLRPCException Will be thrown if the serialization failed.
   */
  private XmlElement getXMLParam(Object o) throws XMLRPCException {
    XmlElement param = new XmlElement(XMLRPCClient.PARAM);
    XmlElement value = new XmlElement(XMLRPCClient.VALUE);
    param.addChildren(value);
    value.addChildren(SerializerHandler.getDefault().serialize(o));
    return param;
  }
View Full Code Here

  public Object deserialize(Element content) throws XMLRPCException {
    return null;
  }

  public XmlElement serialize(Object object) {
    return new XmlElement(SerializerHandler.TYPE_NULL);
  }
View Full Code Here

TOP

Related Classes of de.timroes.axmlrpc.xmlcreator.XmlElement

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.