Ignore:
Timestamp:
06/25/14 22:02:05 (10 years ago)
Author:
rkrimmel
Message:

Code cleanup, removed alot of unneccessary code from pal sources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/SimpleTree.java

    r1573 r1579  
    1010 
    1111import java.io.PrintWriter; 
    12 import java.io.Serializable; 
    1312import java.io.StringWriter; 
    14 import java.util.Hashtable; 
     13 
    1514 
    1615import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 
    17 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.LabelMapping; 
     16 
    1817 
    1918 
     
    5655        private int numExternalNodes; 
    5756 
    58         /** attributes attached to this tree. */ 
    59         private Hashtable[] attributes = null; 
    60  
    61  
    62  
    6357        /** constructor tree consisting solely of root node */ 
    6458        public SimpleTree() { 
     
    7771                createNodeList(); 
    7872        } 
    79  
    80         /** clone constructor */ 
    81         public SimpleTree(Tree tree) 
    82         { 
    83                 root = new FengDoolittleNode(tree.getRoot()); 
    84                 createNodeList(); 
    85         } 
    86  
    87         /** clone constructor */ 
    88         public SimpleTree(Tree tree, boolean keepIdentifiers) 
    89         { 
    90                 root = new FengDoolittleNode(tree.getRoot(), keepIdentifiers); 
    91                 createNodeList(); 
    92         } 
    93         /** 
    94          * clone constructor 
    95          * @param lm - a label mapping use for translating the original label names into something else 
    96          */ 
    97         public SimpleTree(Tree tree, LabelMapping lm) 
    98         { 
    99                 root = new FengDoolittleNode(tree.getRoot(), lm); 
    100                 createNodeList(); 
    101         } 
    102  
    10373 
    10474 
     
    225195        } 
    226196 
    227         private int getIndex(Node node) { 
    228                 if (node.isLeaf()) return node.getNumber(); 
    229                 return getExternalNodeCount() + node.getNumber(); 
    230         } 
    231  
    232         /** 
    233          * Sets an named attribute for a given node. 
    234          * @param node the node whose attribute is being set. 
    235          * @param name the name of the attribute. 
    236          * @param value the new value of the attribute. 
    237          */ 
    238         public void setAttribute(Node node, String name, Object value) { 
    239                 if (node instanceof AttributeNode) { 
    240                         ((AttributeNode)node).setAttribute(name, value); 
    241                 } else { 
    242                         int index = getIndex(node); 
    243                         if (attributes == null) { 
    244                                 attributes = new Hashtable[getExternalNodeCount() + getInternalNodeCount()]; 
    245                         } 
    246                         if (attributes[index] == null) { 
    247                                 attributes[index] = new Hashtable(); 
    248                         } 
    249                         attributes[index].put(name, value); 
    250                 } 
    251         } 
     197 
     198 
    252199 
    253200        public String toString() { 
     
    258205        } 
    259206 
    260         /** 
    261          * @return an object representing the named attributed for the numbered node. 
    262          * @param node the node being interrogated. 
    263          * @param name the name of the attribute of interest. 
    264          */ 
    265         public Object getAttribute(Node node, String name) { 
    266                 if (node instanceof AttributeNode) { 
    267                         return ((AttributeNode)node).getAttribute(name); 
    268                 } else { 
    269                         int index = getIndex(node); 
    270                         if (attributes == null || attributes[index] == null) { 
    271                                 return null; 
    272                         } 
    273                         return attributes[index].get(name); 
    274                 } 
    275         } 
    276207 
    277208 
Note: See TracChangeset for help on using the changeset viewer.