struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yunaki <yun...@126.com>
Subject type convertion about complex object question
Date Sat, 08 May 2010 17:20:45 GMT

I want to convert a group of html input tag into hashmap? each value of html
input tag is for a set of Sequence Objects. e.g.

code in input.jsp

<input name="SequenceMap" value="1,2|A;U;T">
<input name="SequenceMap" value="1,2|S;T;R">
<input name="SequenceMap" value="1,3|S;T;R">


a converter split the value by vertical bar, 
the left part of the value contains two id property for Property1 and
Property2 objects in each new Sequence and is the corresponding key in map.
the converter also split the right part of the value to set Character
property of a set of Sequence objects

e.g.    value="property1Id,Property2Id|Character1;character2;

Map key is "property1Id,Property2Id"

convertFromString(Map arg0, String[] arg1, Class arg2){
  
  Map<int, Set<Sequence>> SequenceMap=new HashMap<int, Set<Sequence>>();
  
  for(int a=0; a<arg1.length;a++){
      String[] valueSet=arg1[a].split("|");
      String[] propertySet=valueSet[0].split[";"]
      Set<Sequence> SequenceSet=new HashSet<Sequence>();
      Property1 proeprty1=new Property1(propertySet[0]);
      Property2 proeprty2=new Property2(propertySet[1]);
      String[] sequenceSet=valueSet[1].split(";");
      for(int b=0;b<sequenceSet.length;b++){
           Sequence sequence=new Sequence();
           sequence.setproeprty1(proeprty1);
           sequence.setproeprty2(proeprty2);
           sequence.setCharacter(sequenceSet[b]);
           SequenceSet.add(sequence);
      }
      SequenceMap.put(valueSet[0],SequenceSet);
  }
  return SequenceMap;
}


map property in action is:

Map<int, Set<Sequence>> SequenceMap

Sequence class:

public class Sequence{
   int id:
   String Character;
   Property1 property1;
   Property2 property2
}

public Property1 class{
   int property1Id
}

public Property2 class{
  int property2Id
}

Any know how to write "Element" and "KeyProperty" type convertion properties
file?

many thanks
-- 
View this message in context: http://old.nabble.com/type-convertion-about-complex-object-question-tp28497158p28497158.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message