1 21 22 package net.percederberg.grammatica.parser; 23 24 import java.util.ArrayList ; 25 26 35 public class Production extends Node { 36 37 40 private ProductionPattern pattern; 41 42 45 private ArrayList children; 46 47 52 public Production(ProductionPattern pattern) { 53 this.pattern = pattern; 54 this.children = new ArrayList (); 55 } 56 57 64 boolean isHidden() { 65 return pattern.isSynthetic(); 66 } 67 68 73 public ProductionPattern getPattern() { 74 return pattern; 75 } 76 77 84 public int getId() { 85 return pattern.getId(); 86 } 87 88 93 public String getName() { 94 return pattern.getName(); 95 } 96 97 102 public int getChildCount() { 103 return children.size(); 104 } 105 106 114 public Node getChildAt(int index) { 115 if (index < 0 || index >= children.size()) { 116 return null; 117 } else { 118 return (Node) children.get(index); 119 } 120 } 121 122 128 public void addChild(Node child) { 129 if (child != null) { 130 child.setParent(this); 131 children.add(child); 132 } 133 } 134 135 140 public String toString() { 141 StringBuffer buffer = new StringBuffer (); 142 143 buffer.append(pattern.getName()); 144 buffer.append('('); 145 buffer.append(pattern.getId()); 146 buffer.append(')'); 147 148 return buffer.toString(); 149 } 150 } 151 | Popular Tags |