static ArrayList<Profile> getProfiles_( String xml) throws IOException {
ArrayList<Profile> list = new ArrayList<Profile>();
Profile profile = null;
Allocation alloc = null;
BufferedReader reader = new BufferedReader( new StringReader( xml) );
String line;
int state = 0; // 0=none; 1=list of groups; 2=reading group 3=listOfAllocations 4=allocation
for( int lc = 0; ((line=reader.readLine()) != null); lc++) {
line = line.trim();
switch( state) {
// top of file
case 0:
if (line.equals( "<ListOfAllocationProfiles>")) {
state = 1;
}
break;
// reading profiles
case 1:
if (line.equals( "<AllocationProfile>")) {
profile = new Profile();
state = 2;
}
else if (line.equals( "</ListOfAllocationProfiles>")) {
state = 0;
}
else {
err( line);
}
break;
// reading Profile
case 2:
if (line.startsWith( "<name>") ) {
profile.name( getVal( line) );
}
else if (line.startsWith( "<type>")) {
int i = Integer.parseInt( getVal( line) );
profile.type( Type.get( i) );
}
else if (line.startsWith( "<ListOfAllocations")) {
state = 3;
}
else if (line.equals( "</AllocationProfile>")) {
list.add( profile);
state = 1;
}
else {
err( line);
}
break;
// reading list of allocations
case 3:
if (line.equals( "<Allocation>")) {
alloc = new Allocation();
state = 4;
}
else if (line.equals( "</ListOfAllocations>")) {
state = 2;
}
else {
err( line);
}
break;
// reading Allocation
case 4:
if (line.startsWith( "<acct>") ) {
alloc.account( getVal( line) );
}
else if (line.startsWith( "<amount>") ) {
alloc.amount( getVal( line) );
}
else if (line.startsWith( "<posEff>") ) {
// skip this
}
else if (line.equals( "</Allocation>") ) {