1 19 20 21 package org.netbeans.modules.i18n.regexp; 22 23 29 class TreeNode { 30 31 static final int REGEXP = 0; 32 static final int MULTI_REGEXP = 1; 33 static final int SIMPLE_REGEXP = 2; 34 static final int Q_REGEXP = 3; 35 static final int QUANTIFIER = 4; 36 static final int NUMBER = 5; 37 static final int METACHAR = 6; 38 static final int UNICODE_CHAR = 7; 39 static final int CHAR = 8; 40 static final int SUBEXPR = 9; 41 static final int POSIX_SET = 10; 42 static final int SET = 11; 43 static final int RANGE = 12; 44 static final int TOKEN = 13; 45 46 49 int start; 50 53 int end; 54 55 private int tokenType; 56 57 private Object attribs; 58 59 private TreeNode parent; 60 61 private java.util.List children; 62 63 72 TreeNode(int tokenType, int start, int end) { 73 this.tokenType = tokenType; 74 this.start = start; 75 this.end = end; 76 } 77 78 88 TreeNode(int tokenType, int start, int end, Object attribs) { 89 this(tokenType, start, end); 90 this.attribs = attribs; 91 } 92 93 98 void add(TreeNode child) { 99 if (child == null) { 100 throw new IllegalArgumentException ("null"); } 102 103 child.parent = this; 104 105 if (children == null) { 106 children = new java.util.ArrayList (4); 107 } 108 children.add(child); 109 } 110 111 118 String getRegexp() { 119 120 TreeNode candidate = this; 121 TreeNode candidParent; 122 123 124 while ((candidParent = candidate.parent) != null) { 125 candidate = candidParent; 126 } 127 assert candidate instanceof TreeNodeRoot; 128 129 return candidate.getRegexp(); 130 } 131 132 137 int getTokenType() { 138 return tokenType; 139 } 140 141 147 Object getAttribs() { 148 return attribs; 149 } 150 151 157 java.util.List getChildren() { 158 return children != null ? new java.util.ArrayList (children) 159 : null; 160 } 161 162 } 163 | Popular Tags |