Map<Character,DiscreteCharState> stateForSymbol = new HashMap<Character,DiscreteCharState>();
CharacterStateSet xmlStateSet = xmlMatrix.createCharacterStateSet();
for ( int i = 0; i < tbStateLabels.size(); i++ ) {
for ( int j = 0; j < tbStateLabels.get(i).size(); j++ ) {
Character symbol = tbStateLabels.get(i).get(j).getSymbol();
DiscreteCharState state = tbStateLabels.get(i).get(j);
stateForSymbol.put(symbol, state);
}
}
// then create the single state set out of the map, assigning all non-missing characters to missing
Set<CharacterState> xmlMissingStates = new HashSet<CharacterState>();
for ( Character symbol : stateForSymbol.keySet() ) {
char sym = symbol.charValue();
if ( sym != '-' && sym != '?' ) {
String symString = symbol.toString();
CharacterState xmlState = xmlStateSet.createCharacterState(symString);
xmlMissingStates.add(xmlState);
DiscreteCharState tbState = stateForSymbol.get(symbol);
xmlState.setLabel(symString);
attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class);
}
}