129 * <strong>Note:</strong> The character is consumed.
130 *
131 * @throws IOException Thrown if i/o error occurs.
132 * @throws EOFException Thrown on end of file.
133 */
134 public int scanChar() throws IOException {
135
136 // load more characters, if needed
137 if (fCurrentEntity.position == fCurrentEntity.count) {
138 load(0, true, true);
139 }
140
141 // scan character
142 int c = fCurrentEntity.ch[fCurrentEntity.position++];
143 boolean external = false;
144 if (c == '\n' ||
145 ((c == '\r' || c == 0x85 || c == 0x2028) && (external = fCurrentEntity.isExternal()))) {
146 fCurrentEntity.lineNumber++;
147 fCurrentEntity.columnNumber = 1;
148 if (fCurrentEntity.position == fCurrentEntity.count) {
149 fCurrentEntity.ch[0] = (char)c;
150 load(1, false, true);
151 }
152 if (c == '\r' && external) {
153 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
154 if (cc != '\n' && cc != 0x85) {
155 fCurrentEntity.position--;
156 }
157 }
158 c = '\n';
159 }
160
161 // return character that was scanned
162 fCurrentEntity.columnNumber++;
163 return c;
164
165 } // scanChar():int
166
167 /**
168 * Returns a string matching the NMTOKEN production appearing immediately
169 * on the input as a symbol, or null if NMTOKEN Name string is present.
170 * <p>
288 *
289 * @throws IOException Thrown if i/o error occurs.
290 * @throws EOFException Thrown on end of file.
291 *
292 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
293 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
294 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
295 */
296 public String scanName() throws IOException {
297 // load more characters, if needed
298 if (fCurrentEntity.position == fCurrentEntity.count) {
299 load(0, true, true);
300 }
301
302 // scan name
303 int offset = fCurrentEntity.position;
304 char ch = fCurrentEntity.ch[offset];
305
306 if (XML11Char.isXML11NameStart(ch)) {
307 if (++fCurrentEntity.position == fCurrentEntity.count) {
308 fCurrentEntity.ch[0] = ch;
309 offset = 0;
310 if (load(1, false, true)) {
311 fCurrentEntity.columnNumber++;
312 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
313 return symbol;
314 }
315 }
316 }
317 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
318 if (++fCurrentEntity.position == fCurrentEntity.count) {
319 fCurrentEntity.ch[0] = ch;
320 offset = 0;
321 if (load(1, false, true)) {
322 --fCurrentEntity.position;
323 --fCurrentEntity.startPosition;
324 return null;
325 }
326 }
327 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
328 if ( !XMLChar.isLowSurrogate(ch2) ||
329 !XML11Char.isXML11NameStart(XMLChar.supplemental(ch, ch2)) ) {
330 --fCurrentEntity.position;
331 return null;
332 }
333 if (++fCurrentEntity.position == fCurrentEntity.count) {
334 fCurrentEntity.ch[0] = ch;
335 fCurrentEntity.ch[1] = ch2;
336 offset = 0;
337 if (load(2, false, true)) {
338 fCurrentEntity.columnNumber += 2;
339 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
340 return symbol;
341 }
342 }
343 }
344 else {
345 return null;
346 }
347
348 do {
349 ch = fCurrentEntity.ch[fCurrentEntity.position];
350 if (XML11Char.isXML11Name(ch)) {
351 if (++fCurrentEntity.position == fCurrentEntity.count) {
352 int length = fCurrentEntity.position - offset;
353 invokeListeners(length);
354 if (length == fCurrentEntity.ch.length) {
355 // bad luck we have to resize our buffer
356 char[] tmp = new char[fCurrentEntity.ch.length << 1];
357 System.arraycopy(fCurrentEntity.ch, offset,
446 * @throws IOException Thrown if i/o error occurs.
447 * @throws EOFException Thrown on end of file.
448 *
449 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
450 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCName
451 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCNameStart
452 */
453 public String scanNCName() throws IOException {
454
455 // load more characters, if needed
456 if (fCurrentEntity.position == fCurrentEntity.count) {
457 load(0, true, true);
458 }
459
460 // scan name
461 int offset = fCurrentEntity.position;
462 char ch = fCurrentEntity.ch[offset];
463
464 if (XML11Char.isXML11NCNameStart(ch)) {
465 if (++fCurrentEntity.position == fCurrentEntity.count) {
466 fCurrentEntity.ch[0] = ch;
467 offset = 0;
468 if (load(1, false, true)) {
469 fCurrentEntity.columnNumber++;
470 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
471 return symbol;
472 }
473 }
474 }
475 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
476 if (++fCurrentEntity.position == fCurrentEntity.count) {
477 fCurrentEntity.ch[0] = ch;
478 offset = 0;
479 if (load(1, false, true)) {
480 --fCurrentEntity.position;
481 --fCurrentEntity.startPosition;
482 return null;
483 }
484 }
485 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
486 if ( !XMLChar.isLowSurrogate(ch2) ||
487 !XML11Char.isXML11NCNameStart(XMLChar.supplemental(ch, ch2)) ) {
488 --fCurrentEntity.position;
489 return null;
490 }
491 if (++fCurrentEntity.position == fCurrentEntity.count) {
492 fCurrentEntity.ch[0] = ch;
493 fCurrentEntity.ch[1] = ch2;
494 offset = 0;
495 if (load(2, false, true)) {
496 fCurrentEntity.columnNumber += 2;
497 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
498 return symbol;
499 }
500 }
501 }
502 else {
503 return null;
504 }
505
506 do {
507 ch = fCurrentEntity.ch[fCurrentEntity.position];
508 if (XML11Char.isXML11NCName(ch)) {
509 if (++fCurrentEntity.position == fCurrentEntity.count) {
510 int length = fCurrentEntity.position - offset;
511 invokeListeners(length);
512 if (length == fCurrentEntity.ch.length) {
513 // bad luck we have to resize our buffer
514 char[] tmp = new char[fCurrentEntity.ch.length << 1];
515 System.arraycopy(fCurrentEntity.ch, offset,
610 * @throws IOException Thrown if i/o error occurs.
611 * @throws EOFException Thrown on end of file.
612 *
613 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
614 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
615 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
616 */
617 public boolean scanQName(QName qname) throws IOException {
618
619 // load more characters, if needed
620 if (fCurrentEntity.position == fCurrentEntity.count) {
621 load(0, true, true);
622 }
623
624 // scan qualified name
625 int offset = fCurrentEntity.position;
626 char ch = fCurrentEntity.ch[offset];
627
628 if (XML11Char.isXML11NCNameStart(ch)) {
629 if (++fCurrentEntity.position == fCurrentEntity.count) {
630 fCurrentEntity.ch[0] = ch;
631 offset = 0;
632 if (load(1, false, true)) {
633 fCurrentEntity.columnNumber++;
634 String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
635 qname.setValues(null, name, name, null);
636 return true;
637 }
638 }
639 }
640 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
641 if (++fCurrentEntity.position == fCurrentEntity.count) {
642 fCurrentEntity.ch[0] = ch;
643 offset = 0;
644 if (load(1, false, true)) {
645 --fCurrentEntity.startPosition;
646 --fCurrentEntity.position;
647 return false;
648 }
649 }
650 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
651 if ( !XMLChar.isLowSurrogate(ch2) ||
652 !XML11Char.isXML11NCNameStart(XMLChar.supplemental(ch, ch2)) ) {
653 --fCurrentEntity.position;
654 return false;
655 }
656 if (++fCurrentEntity.position == fCurrentEntity.count) {
657 fCurrentEntity.ch[0] = ch;
658 fCurrentEntity.ch[1] = ch2;
659 offset = 0;
660 if (load(2, false, true)) {
661 fCurrentEntity.columnNumber += 2;
662 String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
663 qname.setValues(null, name, name, null);
664 return true;
665 }
666 }
667 }
668 else {
669 return false;
670 }
671
672 int index = -1;
673 boolean sawIncompleteSurrogatePair = false;
674 do {
675 ch = fCurrentEntity.ch[fCurrentEntity.position];
676 if (XML11Char.isXML11Name(ch)) {
677 if (ch == ':') {
678 if (index != -1) {
679 break;
680 }
817 * to the entity scanner. Therefore, the caller is responsible for
818 * immediately using the returned character data or making a copy of
819 * the character data.
820 *
821 * @param content The content structure to fill.
822 *
823 * @return Returns the next character on the input, if known. This
824 * value may be -1 but this does <em>note</em> designate
825 * end of file.
826 *
827 * @throws IOException Thrown if i/o error occurs.
828 * @throws EOFException Thrown on end of file.
829 */
830 public int scanContent(XMLString content) throws IOException {
831
832 // load more characters, if needed
833 if (fCurrentEntity.position == fCurrentEntity.count) {
834 load(0, true, true);
835 }
836 else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
837 fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
838 load(1, false, true);
839 fCurrentEntity.position = 0;
840 fCurrentEntity.startPosition = 0;
841 }
842
843 // normalize newlines
844 int offset = fCurrentEntity.position;
845 int c = fCurrentEntity.ch[offset];
846 int newlines = 0;
847 boolean external = fCurrentEntity.isExternal();
848 if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
849 do {
850 c = fCurrentEntity.ch[fCurrentEntity.position++];
851 if ((c == '\r' ) && external) {
852 newlines++;
853 fCurrentEntity.lineNumber++;
854 fCurrentEntity.columnNumber = 1;
855 if (fCurrentEntity.position == fCurrentEntity.count) {
856 offset = 0;
857 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
858 fCurrentEntity.position = newlines;
958 * the character data.
959 *
960 * @param quote The quote character that signifies the end of the
961 * attribute value data.
962 * @param content The content structure to fill.
963 *
964 * @return Returns the next character on the input, if known. This
965 * value may be -1 but this does <em>note</em> designate
966 * end of file.
967 *
968 * @throws IOException Thrown if i/o error occurs.
969 * @throws EOFException Thrown on end of file.
970 */
971 public int scanLiteral(int quote, XMLString content)
972 throws IOException {
973 // load more characters, if needed
974 if (fCurrentEntity.position == fCurrentEntity.count) {
975 load(0, true, true);
976 }
977 else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
978 fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
979 load(1, false, true);
980 fCurrentEntity.startPosition = 0;
981 fCurrentEntity.position = 0;
982 }
983
984 // normalize newlines
985 int offset = fCurrentEntity.position;
986 int c = fCurrentEntity.ch[offset];
987 int newlines = 0;
988 boolean external = fCurrentEntity.isExternal();
989 if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
990 do {
991 c = fCurrentEntity.ch[fCurrentEntity.position++];
992 if ((c == '\r' ) && external) {
993 newlines++;
994 fCurrentEntity.lineNumber++;
995 fCurrentEntity.columnNumber = 1;
996 if (fCurrentEntity.position == fCurrentEntity.count) {
997 offset = 0;
998 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
999 fCurrentEntity.position = newlines;
1328 if (cc == c) {
1329 fCurrentEntity.position++;
1330 if (c == '\n') {
1331 fCurrentEntity.lineNumber++;
1332 fCurrentEntity.columnNumber = 1;
1333 }
1334 else {
1335 fCurrentEntity.columnNumber++;
1336 }
1337 return true;
1338 }
1339 else if (c == '\n' && ((cc == 0x2028 || cc == 0x85) && fCurrentEntity.isExternal())) {
1340 fCurrentEntity.position++;
1341 fCurrentEntity.lineNumber++;
1342 fCurrentEntity.columnNumber = 1;
1343 return true;
1344 }
1345 else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
1346 // handle newlines
1347 if (fCurrentEntity.position == fCurrentEntity.count) {
1348 fCurrentEntity.ch[0] = (char)cc;
1349 load(1, false, true);
1350 }
1351 int ccc = fCurrentEntity.ch[++fCurrentEntity.position];
1352 if (ccc == '\n' || ccc == 0x85) {
1353 fCurrentEntity.position++;
1354 }
1355 fCurrentEntity.lineNumber++;
1356 fCurrentEntity.columnNumber = 1;
1357 return true;
1358 }
1359
1360 // character was not skipped
1361 return false;
1362
1363 } // skipChar(int):boolean
1364
1365 /**
1366 * Skips space characters appearing immediately on the input.
1367 * <p>
1368 * <strong>Note:</strong> The characters are consumed only if they are
1369 * space characters.
1390 //it is possible that end of document is reached and
1391 //fCurrentEntity becomes null
1392 //nothing was read so entity changed 'false' should be returned.
1393 if(fCurrentEntity == null){
1394 return false ;
1395 }
1396
1397 // skip spaces
1398 int c = fCurrentEntity.ch[fCurrentEntity.position];
1399
1400 // External -- Match: S + 0x85 + 0x2028, and perform end of line normalization
1401 if (fCurrentEntity.isExternal()) {
1402 if (XML11Char.isXML11Space(c)) {
1403 do {
1404 boolean entityChanged = false;
1405 // handle newlines
1406 if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
1407 fCurrentEntity.lineNumber++;
1408 fCurrentEntity.columnNumber = 1;
1409 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
1410 fCurrentEntity.ch[0] = (char)c;
1411 entityChanged = load(1, true, true);
1412 if (!entityChanged) {
1413 // the load change the position to be 1,
1414 // need to restore it when entity not changed
1415 fCurrentEntity.startPosition = 0;
1416 fCurrentEntity.position = 0;
1417 } else if(fCurrentEntity == null){
1418 return true ;
1419 }
1420
1421 }
1422 if (c == '\r') {
1423 // REVISIT: Does this need to be updated to fix the
1424 // #x0D ^#x0A newline normalization problem? -Ac
1425 int cc = fCurrentEntity.ch[++fCurrentEntity.position];
1426 if (cc != '\n' && cc != 0x85 ) {
1427 fCurrentEntity.position--;
1428 }
1429 }
1430 }
1431 else {
|
129 * <strong>Note:</strong> The character is consumed.
130 *
131 * @throws IOException Thrown if i/o error occurs.
132 * @throws EOFException Thrown on end of file.
133 */
134 public int scanChar() throws IOException {
135
136 // load more characters, if needed
137 if (fCurrentEntity.position == fCurrentEntity.count) {
138 load(0, true, true);
139 }
140
141 // scan character
142 int c = fCurrentEntity.ch[fCurrentEntity.position++];
143 boolean external = false;
144 if (c == '\n' ||
145 ((c == '\r' || c == 0x85 || c == 0x2028) && (external = fCurrentEntity.isExternal()))) {
146 fCurrentEntity.lineNumber++;
147 fCurrentEntity.columnNumber = 1;
148 if (fCurrentEntity.position == fCurrentEntity.count) {
149 invokeListeners(1);
150 fCurrentEntity.ch[0] = (char)c;
151 load(1, false, false);
152 }
153 if (c == '\r' && external) {
154 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
155 if (cc != '\n' && cc != 0x85) {
156 fCurrentEntity.position--;
157 }
158 }
159 c = '\n';
160 }
161
162 // return character that was scanned
163 fCurrentEntity.columnNumber++;
164 return c;
165
166 } // scanChar():int
167
168 /**
169 * Returns a string matching the NMTOKEN production appearing immediately
170 * on the input as a symbol, or null if NMTOKEN Name string is present.
171 * <p>
289 *
290 * @throws IOException Thrown if i/o error occurs.
291 * @throws EOFException Thrown on end of file.
292 *
293 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
294 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
295 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
296 */
297 public String scanName() throws IOException {
298 // load more characters, if needed
299 if (fCurrentEntity.position == fCurrentEntity.count) {
300 load(0, true, true);
301 }
302
303 // scan name
304 int offset = fCurrentEntity.position;
305 char ch = fCurrentEntity.ch[offset];
306
307 if (XML11Char.isXML11NameStart(ch)) {
308 if (++fCurrentEntity.position == fCurrentEntity.count) {
309 invokeListeners(1);
310 fCurrentEntity.ch[0] = ch;
311 offset = 0;
312 if (load(1, false, false)) {
313 fCurrentEntity.columnNumber++;
314 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
315 return symbol;
316 }
317 }
318 }
319 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
320 if (++fCurrentEntity.position == fCurrentEntity.count) {
321 invokeListeners(1);
322 fCurrentEntity.ch[0] = ch;
323 offset = 0;
324 if (load(1, false, false)) {
325 --fCurrentEntity.position;
326 --fCurrentEntity.startPosition;
327 return null;
328 }
329 }
330 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
331 if ( !XMLChar.isLowSurrogate(ch2) ||
332 !XML11Char.isXML11NameStart(XMLChar.supplemental(ch, ch2)) ) {
333 --fCurrentEntity.position;
334 return null;
335 }
336 if (++fCurrentEntity.position == fCurrentEntity.count) {
337 invokeListeners(2);
338 fCurrentEntity.ch[0] = ch;
339 fCurrentEntity.ch[1] = ch2;
340 offset = 0;
341 if (load(2, false, false)) {
342 fCurrentEntity.columnNumber += 2;
343 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
344 return symbol;
345 }
346 }
347 }
348 else {
349 return null;
350 }
351
352 do {
353 ch = fCurrentEntity.ch[fCurrentEntity.position];
354 if (XML11Char.isXML11Name(ch)) {
355 if (++fCurrentEntity.position == fCurrentEntity.count) {
356 int length = fCurrentEntity.position - offset;
357 invokeListeners(length);
358 if (length == fCurrentEntity.ch.length) {
359 // bad luck we have to resize our buffer
360 char[] tmp = new char[fCurrentEntity.ch.length << 1];
361 System.arraycopy(fCurrentEntity.ch, offset,
450 * @throws IOException Thrown if i/o error occurs.
451 * @throws EOFException Thrown on end of file.
452 *
453 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
454 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCName
455 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCNameStart
456 */
457 public String scanNCName() throws IOException {
458
459 // load more characters, if needed
460 if (fCurrentEntity.position == fCurrentEntity.count) {
461 load(0, true, true);
462 }
463
464 // scan name
465 int offset = fCurrentEntity.position;
466 char ch = fCurrentEntity.ch[offset];
467
468 if (XML11Char.isXML11NCNameStart(ch)) {
469 if (++fCurrentEntity.position == fCurrentEntity.count) {
470 invokeListeners(1);
471 fCurrentEntity.ch[0] = ch;
472 offset = 0;
473 if (load(1, false, false)) {
474 fCurrentEntity.columnNumber++;
475 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
476 return symbol;
477 }
478 }
479 }
480 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
481 if (++fCurrentEntity.position == fCurrentEntity.count) {
482 invokeListeners(1);
483 fCurrentEntity.ch[0] = ch;
484 offset = 0;
485 if (load(1, false, false)) {
486 --fCurrentEntity.position;
487 --fCurrentEntity.startPosition;
488 return null;
489 }
490 }
491 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
492 if ( !XMLChar.isLowSurrogate(ch2) ||
493 !XML11Char.isXML11NCNameStart(XMLChar.supplemental(ch, ch2)) ) {
494 --fCurrentEntity.position;
495 return null;
496 }
497 if (++fCurrentEntity.position == fCurrentEntity.count) {
498 invokeListeners(2);
499 fCurrentEntity.ch[0] = ch;
500 fCurrentEntity.ch[1] = ch2;
501 offset = 0;
502 if (load(2, false, false)) {
503 fCurrentEntity.columnNumber += 2;
504 String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
505 return symbol;
506 }
507 }
508 }
509 else {
510 return null;
511 }
512
513 do {
514 ch = fCurrentEntity.ch[fCurrentEntity.position];
515 if (XML11Char.isXML11NCName(ch)) {
516 if (++fCurrentEntity.position == fCurrentEntity.count) {
517 int length = fCurrentEntity.position - offset;
518 invokeListeners(length);
519 if (length == fCurrentEntity.ch.length) {
520 // bad luck we have to resize our buffer
521 char[] tmp = new char[fCurrentEntity.ch.length << 1];
522 System.arraycopy(fCurrentEntity.ch, offset,
617 * @throws IOException Thrown if i/o error occurs.
618 * @throws EOFException Thrown on end of file.
619 *
620 * @see com.sun.org.apache.xerces.internal.util.SymbolTable
621 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
622 * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
623 */
624 public boolean scanQName(QName qname) throws IOException {
625
626 // load more characters, if needed
627 if (fCurrentEntity.position == fCurrentEntity.count) {
628 load(0, true, true);
629 }
630
631 // scan qualified name
632 int offset = fCurrentEntity.position;
633 char ch = fCurrentEntity.ch[offset];
634
635 if (XML11Char.isXML11NCNameStart(ch)) {
636 if (++fCurrentEntity.position == fCurrentEntity.count) {
637 invokeListeners(1);
638 fCurrentEntity.ch[0] = ch;
639 offset = 0;
640 if (load(1, false, false)) {
641 fCurrentEntity.columnNumber++;
642 String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
643 qname.setValues(null, name, name, null);
644 return true;
645 }
646 }
647 }
648 else if (XML11Char.isXML11NameHighSurrogate(ch)) {
649 if (++fCurrentEntity.position == fCurrentEntity.count) {
650 invokeListeners(1);
651 fCurrentEntity.ch[0] = ch;
652 offset = 0;
653 if (load(1, false, false)) {
654 --fCurrentEntity.startPosition;
655 --fCurrentEntity.position;
656 return false;
657 }
658 }
659 char ch2 = fCurrentEntity.ch[fCurrentEntity.position];
660 if ( !XMLChar.isLowSurrogate(ch2) ||
661 !XML11Char.isXML11NCNameStart(XMLChar.supplemental(ch, ch2)) ) {
662 --fCurrentEntity.position;
663 return false;
664 }
665 if (++fCurrentEntity.position == fCurrentEntity.count) {
666 invokeListeners(2);
667 fCurrentEntity.ch[0] = ch;
668 fCurrentEntity.ch[1] = ch2;
669 offset = 0;
670 if (load(2, false, false)) {
671 fCurrentEntity.columnNumber += 2;
672 String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
673 qname.setValues(null, name, name, null);
674 return true;
675 }
676 }
677 }
678 else {
679 return false;
680 }
681
682 int index = -1;
683 boolean sawIncompleteSurrogatePair = false;
684 do {
685 ch = fCurrentEntity.ch[fCurrentEntity.position];
686 if (XML11Char.isXML11Name(ch)) {
687 if (ch == ':') {
688 if (index != -1) {
689 break;
690 }
827 * to the entity scanner. Therefore, the caller is responsible for
828 * immediately using the returned character data or making a copy of
829 * the character data.
830 *
831 * @param content The content structure to fill.
832 *
833 * @return Returns the next character on the input, if known. This
834 * value may be -1 but this does <em>note</em> designate
835 * end of file.
836 *
837 * @throws IOException Thrown if i/o error occurs.
838 * @throws EOFException Thrown on end of file.
839 */
840 public int scanContent(XMLString content) throws IOException {
841
842 // load more characters, if needed
843 if (fCurrentEntity.position == fCurrentEntity.count) {
844 load(0, true, true);
845 }
846 else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
847 invokeListeners(0);
848 fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
849 load(1, false, false);
850 fCurrentEntity.position = 0;
851 fCurrentEntity.startPosition = 0;
852 }
853
854 // normalize newlines
855 int offset = fCurrentEntity.position;
856 int c = fCurrentEntity.ch[offset];
857 int newlines = 0;
858 boolean external = fCurrentEntity.isExternal();
859 if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
860 do {
861 c = fCurrentEntity.ch[fCurrentEntity.position++];
862 if ((c == '\r' ) && external) {
863 newlines++;
864 fCurrentEntity.lineNumber++;
865 fCurrentEntity.columnNumber = 1;
866 if (fCurrentEntity.position == fCurrentEntity.count) {
867 offset = 0;
868 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
869 fCurrentEntity.position = newlines;
969 * the character data.
970 *
971 * @param quote The quote character that signifies the end of the
972 * attribute value data.
973 * @param content The content structure to fill.
974 *
975 * @return Returns the next character on the input, if known. This
976 * value may be -1 but this does <em>note</em> designate
977 * end of file.
978 *
979 * @throws IOException Thrown if i/o error occurs.
980 * @throws EOFException Thrown on end of file.
981 */
982 public int scanLiteral(int quote, XMLString content)
983 throws IOException {
984 // load more characters, if needed
985 if (fCurrentEntity.position == fCurrentEntity.count) {
986 load(0, true, true);
987 }
988 else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
989 invokeListeners(0);
990 fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
991 load(1, false, false);
992 fCurrentEntity.startPosition = 0;
993 fCurrentEntity.position = 0;
994 }
995
996 // normalize newlines
997 int offset = fCurrentEntity.position;
998 int c = fCurrentEntity.ch[offset];
999 int newlines = 0;
1000 boolean external = fCurrentEntity.isExternal();
1001 if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
1002 do {
1003 c = fCurrentEntity.ch[fCurrentEntity.position++];
1004 if ((c == '\r' ) && external) {
1005 newlines++;
1006 fCurrentEntity.lineNumber++;
1007 fCurrentEntity.columnNumber = 1;
1008 if (fCurrentEntity.position == fCurrentEntity.count) {
1009 offset = 0;
1010 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
1011 fCurrentEntity.position = newlines;
1340 if (cc == c) {
1341 fCurrentEntity.position++;
1342 if (c == '\n') {
1343 fCurrentEntity.lineNumber++;
1344 fCurrentEntity.columnNumber = 1;
1345 }
1346 else {
1347 fCurrentEntity.columnNumber++;
1348 }
1349 return true;
1350 }
1351 else if (c == '\n' && ((cc == 0x2028 || cc == 0x85) && fCurrentEntity.isExternal())) {
1352 fCurrentEntity.position++;
1353 fCurrentEntity.lineNumber++;
1354 fCurrentEntity.columnNumber = 1;
1355 return true;
1356 }
1357 else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
1358 // handle newlines
1359 if (fCurrentEntity.position == fCurrentEntity.count) {
1360 invokeListeners(1);
1361 fCurrentEntity.ch[0] = (char)cc;
1362 load(1, false, false);
1363 }
1364 int ccc = fCurrentEntity.ch[++fCurrentEntity.position];
1365 if (ccc == '\n' || ccc == 0x85) {
1366 fCurrentEntity.position++;
1367 }
1368 fCurrentEntity.lineNumber++;
1369 fCurrentEntity.columnNumber = 1;
1370 return true;
1371 }
1372
1373 // character was not skipped
1374 return false;
1375
1376 } // skipChar(int):boolean
1377
1378 /**
1379 * Skips space characters appearing immediately on the input.
1380 * <p>
1381 * <strong>Note:</strong> The characters are consumed only if they are
1382 * space characters.
1403 //it is possible that end of document is reached and
1404 //fCurrentEntity becomes null
1405 //nothing was read so entity changed 'false' should be returned.
1406 if(fCurrentEntity == null){
1407 return false ;
1408 }
1409
1410 // skip spaces
1411 int c = fCurrentEntity.ch[fCurrentEntity.position];
1412
1413 // External -- Match: S + 0x85 + 0x2028, and perform end of line normalization
1414 if (fCurrentEntity.isExternal()) {
1415 if (XML11Char.isXML11Space(c)) {
1416 do {
1417 boolean entityChanged = false;
1418 // handle newlines
1419 if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
1420 fCurrentEntity.lineNumber++;
1421 fCurrentEntity.columnNumber = 1;
1422 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
1423 invokeListeners(0);
1424 fCurrentEntity.ch[0] = (char)c;
1425 entityChanged = load(1, true, false);
1426 if (!entityChanged) {
1427 // the load change the position to be 1,
1428 // need to restore it when entity not changed
1429 fCurrentEntity.startPosition = 0;
1430 fCurrentEntity.position = 0;
1431 } else if(fCurrentEntity == null){
1432 return true ;
1433 }
1434
1435 }
1436 if (c == '\r') {
1437 // REVISIT: Does this need to be updated to fix the
1438 // #x0D ^#x0A newline normalization problem? -Ac
1439 int cc = fCurrentEntity.ch[++fCurrentEntity.position];
1440 if (cc != '\n' && cc != 0x85 ) {
1441 fCurrentEntity.position--;
1442 }
1443 }
1444 }
1445 else {
|