Ignore:
Timestamp:
04/14/11 16:09:27 (13 years ago)
Author:
sherbold
Message:

+ added Dot output to de.ugoe.cs.eventbench.models.Trie and accessor for the Dot representation of the trie to de.ugoe.cs.eventbench.models.TrieBasedModel?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java

    r13 r30  
    2626        public TrieNode(T symbol) { 
    2727                if( symbol==null ) { 
    28                         throw new InvalidParameterException("symbol must not be null."); 
     28                        throw new InvalidParameterException("symbol must not be null. null is reserved for root node!"); 
    2929                } 
    3030                this.symbol = symbol; 
     
    120120                }                
    121121        } 
    122  
     122         
     123        void appendDotRepresentation(StringBuilder stringBuilder) { 
     124                String thisSaneId; 
     125                if( symbol==null ) { 
     126                        thisSaneId = "root"; 
     127                } else { 
     128                        thisSaneId = symbol.toString().replace("\"", "\\\"").replaceAll("[\r\n]","")+"#"+count; 
     129                } 
     130                stringBuilder.append(" " + hashCode() + " [label=\""+thisSaneId+"\"];" + StringTools.ENDLINE); 
     131                for( TrieNode<T> childNode : children ) { 
     132                        stringBuilder.append(" "+hashCode()+" -> " + childNode.hashCode() + ";" + StringTools.ENDLINE); 
     133                } 
     134                for( TrieNode<T> childNode : children ) { 
     135                        childNode.appendDotRepresentation(stringBuilder); 
     136                } 
     137        } 
    123138} 
Note: See TracChangeset for help on using the changeset viewer.