1 57 58 package org.enhydra.apache.xerces.readers; 59 60 import org.enhydra.apache.xerces.framework.XMLErrorReporter; 61 62 68 abstract class XMLEntityReader implements XMLEntityHandler.EntityReader { 69 72 protected XMLEntityHandler fEntityHandler = null; 73 protected XMLErrorReporter fErrorReporter = null; 74 protected boolean fSendCharDataAsCharArray; 75 protected XMLEntityHandler.CharDataHandler fCharDataHandler = null; 76 protected boolean fInCDSect = false; 77 private boolean fStillActive = true; 78 81 protected int fCarriageReturnCounter = 1; 82 protected int fLinefeedCounter = 1; 83 protected int fCharacterCounter = 1; 84 protected int fCurrentOffset = 0; 85 88 protected XMLEntityReader(XMLEntityHandler entityHandler, XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray) { 89 fEntityHandler = entityHandler; 90 fErrorReporter = errorReporter; 91 fSendCharDataAsCharArray = sendCharDataAsCharArray; 92 fCharDataHandler = fEntityHandler.getCharDataHandler(); 93 } 94 97 protected XMLEntityReader(XMLEntityHandler entityHandler, XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, int lineNumber, int columnNumber) { 98 fEntityHandler = entityHandler; 99 fErrorReporter = errorReporter; 100 fSendCharDataAsCharArray = sendCharDataAsCharArray; 101 fCharDataHandler = fEntityHandler.getCharDataHandler(); 102 fLinefeedCounter = lineNumber; 103 fCharacterCounter = columnNumber; 104 } 105 protected void init(XMLEntityHandler entityHandler, XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, int lineNumber, int columnNumber) { 106 fEntityHandler = entityHandler; 107 fErrorReporter = errorReporter; 108 fSendCharDataAsCharArray = sendCharDataAsCharArray; 109 fCharDataHandler = fEntityHandler.getCharDataHandler(); 110 fLinefeedCounter = lineNumber; 111 fCharacterCounter = columnNumber; 112 fStillActive = true; 113 fInCDSect = false; 114 fCarriageReturnCounter = 1; 115 fCurrentOffset = 0; 116 } 117 118 123 public int currentOffset() { 124 return fCurrentOffset; 125 } 126 127 132 public int getLineNumber() { 133 if (fLinefeedCounter > 1) 134 return fLinefeedCounter; 135 else 136 return fCarriageReturnCounter; 137 } 138 139 144 public int getColumnNumber() { 145 return fCharacterCounter; 146 } 147 148 151 public void setInCDSect(boolean inCDSect) { 152 fInCDSect = inCDSect; 153 } 154 155 158 public boolean getInCDSect() { 159 return fInCDSect; 160 } 161 162 165 protected XMLEntityHandler.EntityReader changeReaders() throws Exception { 166 XMLEntityHandler.EntityReader nextReader = null; 167 if (fStillActive) { 168 nextReader = fEntityHandler.changeReaders(); 169 fStillActive = false; 170 fEntityHandler = null; 172 fErrorReporter = null; 173 fCharDataHandler = null; 174 } 175 return nextReader; 176 } 177 } 178 | Popular Tags |