1 51 52 package com.sun.org.apache.xerces.internal.impl.xs.models; 53 54 import com.sun.org.apache.xerces.internal.impl.Constants; 55 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; 56 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode; 57 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; 58 59 65 public class CMNodeFactory { 66 67 70 private static final String ERROR_REPORTER = 71 Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY; 72 73 76 private static final boolean DEBUG = false; 77 78 81 private int nodeCount = 0; 82 83 87 private XMLErrorReporter fErrorReporter = null; 88 89 92 public CMNodeFactory() { 93 94 if (DEBUG) { 95 System.err.println("CMNodeFactory()"); 96 } 97 } 98 99 104 public void reset(XMLComponentManager componentManager) { 105 106 if (DEBUG) { 107 System.err.println("CMNodeFactory#reset(" 108 + "componentManager[" + componentManager.toString() + "])"); 109 } 110 111 fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER); 113 } 115 125 public CMNode getCMLeafNode(int type, Object leaf, int id, int position) { 126 127 nodeCount++; 129 130 if (DEBUG) { 131 System.err.println("CMNodeFactory#getCMLeafNode(" 132 + "type[" + type + "], " 133 + "leaf[" + leaf.toString() + "], " 134 + "id[" + id + "], " 135 + "position[" + position + "])\n" 136 + "\tnodeCount=" + nodeCount); 137 } 138 139 return new XSCMLeaf(type, leaf, id, position); 141 } 142 143 151 public CMNode getCMUniOpNode(int type, CMNode childNode) { 152 153 nodeCount++; 155 156 if (DEBUG) { 157 System.err.println("CMNodeFactory#getCMUniOpNode(" 158 + "type[" + type + "], " 159 + "childNode[" + childNode.toString() + "])\n" 160 + "\tnodeCount=" + nodeCount); 161 } 162 163 return new XSCMUniOp(type, childNode); 165 } 166 167 176 public CMNode getCMBinOpNode(int type, CMNode leftNode, CMNode rightNode) { 177 178 nodeCount++; 180 181 if (DEBUG) { 182 System.err.println("CMNodeFactory#getCMBinOpNode(" 183 + "type[" + type + "], " 184 + "leftNode[" + leftNode.toString() + "], " 185 + "rightNode[" + rightNode.toString() + "])\n" 186 + "\tnodeCount=" + nodeCount); 187 } 188 189 return new XSCMBinOp(type, leftNode, rightNode); 191 } 192 193 196 public void resetNodeCount() { 197 nodeCount = 0; 198 199 if (DEBUG) { 200 System.err.println("CMNodeFactory#resetNodeCount: " 201 + "nodeCount=" + nodeCount + " (after reset)"); 202 } 203 } 204 205 215 public void setProperty(String propertyId, Object value) { 216 217 if (DEBUG) { 218 System.err.println("CMNodeFactory#setProperty(" 219 + "propertyId[" + propertyId + "], " 220 + "value[" + value.toString() + "])"); 221 } 222 223 if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { 225 String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length()); 226 227 if (property.equals(Constants.ERROR_REPORTER_PROPERTY)) { 229 fErrorReporter = (XMLErrorReporter) value; 230 return; 231 } 232 233 return; 235 } else { 236 return; 238 } 239 240 } } | Popular Tags |