예제 #1
0
  @Override
  public synchronized String serializeUserData(UserData data) throws TransformationException {
    if (data == null) {
      throw new TransformationException("Supplied UserData is not valid.");
    }
    StringWriter writer = new StringWriter();
    type = data.getUserDataType();
    MetaField[] fields = type.getFields();
    MetaField field;

    writer.write("<object>");

    for (int i = 0; i < fields.length; i++) {
      field = fields[i];
      this.serializeType(writer, field.getName(), field, data, true);
    }

    writer.write("</object>");
    writer.flush();
    /*
     * logger.logp(java.util.logging.Level.FINEST, "UserDataSerializerXML",
     * "serializeUserData", "Serialized data:\n" + writer.toString());
     */
    return writer.toString();
  }
  protected HashMap<String, ArrayList<String>> CollectSingleTableData(
      UserData data, String struct) {
    LinkedHashSet<String> s;
    List<String> tmp;

    MetaType mt = data.getUserDataType();
    s = new LinkedHashSet<String>(data.getUserData().keySet());
    HashMap<String, ArrayList<String>> tableVales = new HashMap<String, ArrayList<String>>();
    tmp = new ArrayList<String>();
    /* strip [] from userdata */
    for (String key : s) {

      String newKey = mt.removeIndicesFromStruct(key, struct);
      tmp.add(newKey);
      if (tableVales.containsKey(newKey)) {
        ArrayList<String> tmpVal = tableVales.get(newKey);
        tmpVal.add(data.getUserData().get(key));
        tableVales.put(newKey, tmpVal);
      } else {
        ArrayList<String> tmpVal = new ArrayList<String>();
        tmpVal.add(data.getUserData().get(key));
        tableVales.put(newKey, tmpVal);
      }
    }
    return tableVales;
  }