jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java
changeset 22140 f2634f2bc36c
parent 12457 c348e06f0e82
child 25264 040625ce9b72
equal deleted inserted replaced
22139:f4b2aa462b46 22140:f2634f2bc36c
    59  * <http://www.apache.org/>.
    59  * <http://www.apache.org/>.
    60  */
    60  */
    61 
    61 
    62 package com.sun.org.apache.xerces.internal.impl;
    62 package com.sun.org.apache.xerces.internal.impl;
    63 
    63 
    64 import java.io.IOException;
       
    65 
       
    66 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
    64 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
       
    65 import com.sun.org.apache.xerces.internal.util.XML11Char;
    67 import com.sun.org.apache.xerces.internal.util.XMLChar;
    66 import com.sun.org.apache.xerces.internal.util.XMLChar;
    68 import com.sun.org.apache.xerces.internal.util.XML11Char;
       
    69 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
    67 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
    70 import com.sun.org.apache.xerces.internal.xni.QName;
    68 import com.sun.org.apache.xerces.internal.xni.QName;
    71 import com.sun.org.apache.xerces.internal.xni.XMLString;
    69 import com.sun.org.apache.xerces.internal.xni.XMLString;
       
    70 import java.io.IOException;
    72 
    71 
    73 /**
    72 /**
    74  * Implements the entity scanner methods in
    73  * Implements the entity scanner methods in
    75  * the context of XML 1.1.
    74  * the context of XML 1.1.
    76  *
    75  *
    77  * @xerces.internal
    76  * @xerces.internal
    78  *
    77  *
    79  * @author Michael Glavassevich, IBM
    78  * @author Michael Glavassevich, IBM
    80  * @author Neil Graham, IBM
    79  * @author Neil Graham, IBM
       
    80  * @version $Id: XML11EntityScanner.java,v 1.5 2010-11-01 04:39:40 joehw Exp $
    81  */
    81  */
    82 
    82 
    83 public class XML11EntityScanner
    83 public class XML11EntityScanner
    84     extends XMLEntityScanner {
    84     extends XMLEntityScanner {
    85 
    85 
   106      */
   106      */
   107     public int peekChar() throws IOException {
   107     public int peekChar() throws IOException {
   108 
   108 
   109         // load more characters, if needed
   109         // load more characters, if needed
   110         if (fCurrentEntity.position == fCurrentEntity.count) {
   110         if (fCurrentEntity.position == fCurrentEntity.count) {
   111             load(0, true);
   111             load(0, true, true);
   112         }
   112         }
   113 
   113 
   114         // peek at character
   114         // peek at character
   115         int c = fCurrentEntity.ch[fCurrentEntity.position];
   115         int c = fCurrentEntity.ch[fCurrentEntity.position];
   116 
   116 
   134      */
   134      */
   135     public int scanChar() throws IOException {
   135     public int scanChar() throws IOException {
   136 
   136 
   137         // load more characters, if needed
   137         // load more characters, if needed
   138         if (fCurrentEntity.position == fCurrentEntity.count) {
   138         if (fCurrentEntity.position == fCurrentEntity.count) {
   139             load(0, true);
   139             load(0, true, true);
   140         }
   140         }
   141 
   141 
   142         // scan character
   142         // scan character
   143         int c = fCurrentEntity.ch[fCurrentEntity.position++];
   143         int c = fCurrentEntity.ch[fCurrentEntity.position++];
   144         boolean external = false;
   144         boolean external = false;
   146             ((c == '\r' || c == 0x85 || c == 0x2028) && (external = fCurrentEntity.isExternal()))) {
   146             ((c == '\r' || c == 0x85 || c == 0x2028) && (external = fCurrentEntity.isExternal()))) {
   147             fCurrentEntity.lineNumber++;
   147             fCurrentEntity.lineNumber++;
   148             fCurrentEntity.columnNumber = 1;
   148             fCurrentEntity.columnNumber = 1;
   149             if (fCurrentEntity.position == fCurrentEntity.count) {
   149             if (fCurrentEntity.position == fCurrentEntity.count) {
   150                 fCurrentEntity.ch[0] = (char)c;
   150                 fCurrentEntity.ch[0] = (char)c;
   151                 load(1, false);
   151                 load(1, false, true);
   152             }
   152             }
   153             if (c == '\r' && external) {
   153             if (c == '\r' && external) {
   154                 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
   154                 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
   155                 if (cc != '\n' && cc != 0x85) {
   155                 if (cc != '\n' && cc != 0x85) {
   156                     fCurrentEntity.position--;
   156                     fCurrentEntity.position--;
   181      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
   181      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
   182      */
   182      */
   183     public String scanNmtoken() throws IOException {
   183     public String scanNmtoken() throws IOException {
   184         // load more characters, if needed
   184         // load more characters, if needed
   185         if (fCurrentEntity.position == fCurrentEntity.count) {
   185         if (fCurrentEntity.position == fCurrentEntity.count) {
   186             load(0, true);
   186             load(0, true, true);
   187         }
   187         }
   188 
   188 
   189         // scan nmtoken
   189         // scan nmtoken
   190         int offset = fCurrentEntity.position;
   190         int offset = fCurrentEntity.position;
   191 
   191 
   192         do {
   192         do {
   193             char ch = fCurrentEntity.ch[fCurrentEntity.position];
   193             char ch = fCurrentEntity.ch[fCurrentEntity.position];
   194             if (XML11Char.isXML11Name(ch)) {
   194             if (XML11Char.isXML11Name(ch)) {
   195                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   195                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   196                     int length = fCurrentEntity.position - offset;
   196                     int length = fCurrentEntity.position - offset;
       
   197                     invokeListeners(length);
   197                     if (length == fCurrentEntity.ch.length) {
   198                     if (length == fCurrentEntity.ch.length) {
   198                         // bad luck we have to resize our buffer
   199                         // bad luck we have to resize our buffer
   199                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   200                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   200                         System.arraycopy(fCurrentEntity.ch, offset,
   201                         System.arraycopy(fCurrentEntity.ch, offset,
   201                                          tmp, 0, length);
   202                                          tmp, 0, length);
   204                     else {
   205                     else {
   205                         System.arraycopy(fCurrentEntity.ch, offset,
   206                         System.arraycopy(fCurrentEntity.ch, offset,
   206                                          fCurrentEntity.ch, 0, length);
   207                                          fCurrentEntity.ch, 0, length);
   207                     }
   208                     }
   208                     offset = 0;
   209                     offset = 0;
   209                     if (load(length, false)) {
   210                     if (load(length, false, false)) {
   210                         break;
   211                         break;
   211                     }
   212                     }
   212                 }
   213                 }
   213             }
   214             }
   214             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   215             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   215                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   216                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   216                     int length = fCurrentEntity.position - offset;
   217                     int length = fCurrentEntity.position - offset;
       
   218                     invokeListeners(length);
   217                     if (length == fCurrentEntity.ch.length) {
   219                     if (length == fCurrentEntity.ch.length) {
   218                         // bad luck we have to resize our buffer
   220                         // bad luck we have to resize our buffer
   219                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   221                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   220                         System.arraycopy(fCurrentEntity.ch, offset,
   222                         System.arraycopy(fCurrentEntity.ch, offset,
   221                                          tmp, 0, length);
   223                                          tmp, 0, length);
   224                     else {
   226                     else {
   225                         System.arraycopy(fCurrentEntity.ch, offset,
   227                         System.arraycopy(fCurrentEntity.ch, offset,
   226                                          fCurrentEntity.ch, 0, length);
   228                                          fCurrentEntity.ch, 0, length);
   227                     }
   229                     }
   228                     offset = 0;
   230                     offset = 0;
   229                     if (load(length, false)) {
   231                     if (load(length, false, false)) {
   230                         --fCurrentEntity.startPosition;
   232                         --fCurrentEntity.startPosition;
   231                         --fCurrentEntity.position;
   233                         --fCurrentEntity.position;
   232                         break;
   234                         break;
   233                     }
   235                     }
   234                 }
   236                 }
   238                     --fCurrentEntity.position;
   240                     --fCurrentEntity.position;
   239                     break;
   241                     break;
   240                 }
   242                 }
   241                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   243                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   242                     int length = fCurrentEntity.position - offset;
   244                     int length = fCurrentEntity.position - offset;
       
   245                     invokeListeners(length);
   243                     if (length == fCurrentEntity.ch.length) {
   246                     if (length == fCurrentEntity.ch.length) {
   244                         // bad luck we have to resize our buffer
   247                         // bad luck we have to resize our buffer
   245                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   248                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   246                         System.arraycopy(fCurrentEntity.ch, offset,
   249                         System.arraycopy(fCurrentEntity.ch, offset,
   247                                          tmp, 0, length);
   250                                          tmp, 0, length);
   250                     else {
   253                     else {
   251                         System.arraycopy(fCurrentEntity.ch, offset,
   254                         System.arraycopy(fCurrentEntity.ch, offset,
   252                                          fCurrentEntity.ch, 0, length);
   255                                          fCurrentEntity.ch, 0, length);
   253                     }
   256                     }
   254                     offset = 0;
   257                     offset = 0;
   255                     if (load(length, false)) {
   258                     if (load(length, false, false)) {
   256                         break;
   259                         break;
   257                     }
   260                     }
   258                 }
   261                 }
   259             }
   262             }
   260             else {
   263             else {
   292      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
   295      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
   293      */
   296      */
   294     public String scanName() throws IOException {
   297     public String scanName() throws IOException {
   295         // load more characters, if needed
   298         // load more characters, if needed
   296         if (fCurrentEntity.position == fCurrentEntity.count) {
   299         if (fCurrentEntity.position == fCurrentEntity.count) {
   297             load(0, true);
   300             load(0, true, true);
   298         }
   301         }
   299 
   302 
   300         // scan name
   303         // scan name
   301         int offset = fCurrentEntity.position;
   304         int offset = fCurrentEntity.position;
   302         char ch = fCurrentEntity.ch[offset];
   305         char ch = fCurrentEntity.ch[offset];
   303 
   306 
   304         if (XML11Char.isXML11NameStart(ch)) {
   307         if (XML11Char.isXML11NameStart(ch)) {
   305             if (++fCurrentEntity.position == fCurrentEntity.count) {
   308             if (++fCurrentEntity.position == fCurrentEntity.count) {
   306                 fCurrentEntity.ch[0] = ch;
   309                 fCurrentEntity.ch[0] = ch;
   307                 offset = 0;
   310                 offset = 0;
   308                 if (load(1, false)) {
   311                 if (load(1, false, true)) {
   309                     fCurrentEntity.columnNumber++;
   312                     fCurrentEntity.columnNumber++;
   310                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   313                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   311                     return symbol;
   314                     return symbol;
   312                 }
   315                 }
   313             }
   316             }
   314         }
   317         }
   315         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   318         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   316             if (++fCurrentEntity.position == fCurrentEntity.count) {
   319             if (++fCurrentEntity.position == fCurrentEntity.count) {
   317                 fCurrentEntity.ch[0] = ch;
   320                 fCurrentEntity.ch[0] = ch;
   318                 offset = 0;
   321                 offset = 0;
   319                 if (load(1, false)) {
   322                 if (load(1, false, true)) {
   320                     --fCurrentEntity.position;
   323                     --fCurrentEntity.position;
   321                     --fCurrentEntity.startPosition;
   324                     --fCurrentEntity.startPosition;
   322                     return null;
   325                     return null;
   323                 }
   326                 }
   324             }
   327             }
   330             }
   333             }
   331             if (++fCurrentEntity.position == fCurrentEntity.count) {
   334             if (++fCurrentEntity.position == fCurrentEntity.count) {
   332                 fCurrentEntity.ch[0] = ch;
   335                 fCurrentEntity.ch[0] = ch;
   333                 fCurrentEntity.ch[1] = ch2;
   336                 fCurrentEntity.ch[1] = ch2;
   334                 offset = 0;
   337                 offset = 0;
   335                 if (load(2, false)) {
   338                 if (load(2, false, true)) {
   336                     fCurrentEntity.columnNumber += 2;
   339                     fCurrentEntity.columnNumber += 2;
   337                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   340                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   338                     return symbol;
   341                     return symbol;
   339                 }
   342                 }
   340             }
   343             }
   346         do {
   349         do {
   347             ch = fCurrentEntity.ch[fCurrentEntity.position];
   350             ch = fCurrentEntity.ch[fCurrentEntity.position];
   348             if (XML11Char.isXML11Name(ch)) {
   351             if (XML11Char.isXML11Name(ch)) {
   349                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   352                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   350                     int length = fCurrentEntity.position - offset;
   353                     int length = fCurrentEntity.position - offset;
       
   354                     invokeListeners(length);
   351                     if (length == fCurrentEntity.ch.length) {
   355                     if (length == fCurrentEntity.ch.length) {
   352                         // bad luck we have to resize our buffer
   356                         // bad luck we have to resize our buffer
   353                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   357                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   354                         System.arraycopy(fCurrentEntity.ch, offset,
   358                         System.arraycopy(fCurrentEntity.ch, offset,
   355                                          tmp, 0, length);
   359                                          tmp, 0, length);
   358                     else {
   362                     else {
   359                         System.arraycopy(fCurrentEntity.ch, offset,
   363                         System.arraycopy(fCurrentEntity.ch, offset,
   360                                          fCurrentEntity.ch, 0, length);
   364                                          fCurrentEntity.ch, 0, length);
   361                     }
   365                     }
   362                     offset = 0;
   366                     offset = 0;
   363                     if (load(length, false)) {
   367                     if (load(length, false, false)) {
   364                         break;
   368                         break;
   365                     }
   369                     }
   366                 }
   370                 }
   367             }
   371             }
   368             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   372             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   369                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   373                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   370                     int length = fCurrentEntity.position - offset;
   374                     int length = fCurrentEntity.position - offset;
       
   375                     invokeListeners(length);
   371                     if (length == fCurrentEntity.ch.length) {
   376                     if (length == fCurrentEntity.ch.length) {
   372                         // bad luck we have to resize our buffer
   377                         // bad luck we have to resize our buffer
   373                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   378                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   374                         System.arraycopy(fCurrentEntity.ch, offset,
   379                         System.arraycopy(fCurrentEntity.ch, offset,
   375                                          tmp, 0, length);
   380                                          tmp, 0, length);
   378                     else {
   383                     else {
   379                         System.arraycopy(fCurrentEntity.ch, offset,
   384                         System.arraycopy(fCurrentEntity.ch, offset,
   380                                          fCurrentEntity.ch, 0, length);
   385                                          fCurrentEntity.ch, 0, length);
   381                     }
   386                     }
   382                     offset = 0;
   387                     offset = 0;
   383                     if (load(length, false)) {
   388                     if (load(length, false, false)) {
   384                         --fCurrentEntity.position;
   389                         --fCurrentEntity.position;
   385                         --fCurrentEntity.startPosition;
   390                         --fCurrentEntity.startPosition;
   386                         break;
   391                         break;
   387                     }
   392                     }
   388                 }
   393                 }
   392                     --fCurrentEntity.position;
   397                     --fCurrentEntity.position;
   393                     break;
   398                     break;
   394                 }
   399                 }
   395                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   400                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   396                     int length = fCurrentEntity.position - offset;
   401                     int length = fCurrentEntity.position - offset;
       
   402                     invokeListeners(length);
   397                     if (length == fCurrentEntity.ch.length) {
   403                     if (length == fCurrentEntity.ch.length) {
   398                         // bad luck we have to resize our buffer
   404                         // bad luck we have to resize our buffer
   399                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   405                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   400                         System.arraycopy(fCurrentEntity.ch, offset,
   406                         System.arraycopy(fCurrentEntity.ch, offset,
   401                                          tmp, 0, length);
   407                                          tmp, 0, length);
   404                     else {
   410                     else {
   405                         System.arraycopy(fCurrentEntity.ch, offset,
   411                         System.arraycopy(fCurrentEntity.ch, offset,
   406                                          fCurrentEntity.ch, 0, length);
   412                                          fCurrentEntity.ch, 0, length);
   407                     }
   413                     }
   408                     offset = 0;
   414                     offset = 0;
   409                     if (load(length, false)) {
   415                     if (load(length, false, false)) {
   410                         break;
   416                         break;
   411                     }
   417                     }
   412                 }
   418                 }
   413             }
   419             }
   414             else {
   420             else {
   447      */
   453      */
   448     public String scanNCName() throws IOException {
   454     public String scanNCName() throws IOException {
   449 
   455 
   450         // load more characters, if needed
   456         // load more characters, if needed
   451         if (fCurrentEntity.position == fCurrentEntity.count) {
   457         if (fCurrentEntity.position == fCurrentEntity.count) {
   452             load(0, true);
   458             load(0, true, true);
   453         }
   459         }
   454 
   460 
   455         // scan name
   461         // scan name
   456         int offset = fCurrentEntity.position;
   462         int offset = fCurrentEntity.position;
   457         char ch = fCurrentEntity.ch[offset];
   463         char ch = fCurrentEntity.ch[offset];
   458 
   464 
   459         if (XML11Char.isXML11NCNameStart(ch)) {
   465         if (XML11Char.isXML11NCNameStart(ch)) {
   460             if (++fCurrentEntity.position == fCurrentEntity.count) {
   466             if (++fCurrentEntity.position == fCurrentEntity.count) {
   461                 fCurrentEntity.ch[0] = ch;
   467                 fCurrentEntity.ch[0] = ch;
   462                 offset = 0;
   468                 offset = 0;
   463                 if (load(1, false)) {
   469                 if (load(1, false, true)) {
   464                     fCurrentEntity.columnNumber++;
   470                     fCurrentEntity.columnNumber++;
   465                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   471                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   466                     return symbol;
   472                     return symbol;
   467                 }
   473                 }
   468             }
   474             }
   469         }
   475         }
   470         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   476         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   471             if (++fCurrentEntity.position == fCurrentEntity.count) {
   477             if (++fCurrentEntity.position == fCurrentEntity.count) {
   472                 fCurrentEntity.ch[0] = ch;
   478                 fCurrentEntity.ch[0] = ch;
   473                 offset = 0;
   479                 offset = 0;
   474                 if (load(1, false)) {
   480                 if (load(1, false, true)) {
   475                     --fCurrentEntity.position;
   481                     --fCurrentEntity.position;
   476                     --fCurrentEntity.startPosition;
   482                     --fCurrentEntity.startPosition;
   477                     return null;
   483                     return null;
   478                 }
   484                 }
   479             }
   485             }
   485             }
   491             }
   486             if (++fCurrentEntity.position == fCurrentEntity.count) {
   492             if (++fCurrentEntity.position == fCurrentEntity.count) {
   487                 fCurrentEntity.ch[0] = ch;
   493                 fCurrentEntity.ch[0] = ch;
   488                 fCurrentEntity.ch[1] = ch2;
   494                 fCurrentEntity.ch[1] = ch2;
   489                 offset = 0;
   495                 offset = 0;
   490                 if (load(2, false)) {
   496                 if (load(2, false, true)) {
   491                     fCurrentEntity.columnNumber += 2;
   497                     fCurrentEntity.columnNumber += 2;
   492                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   498                     String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   493                     return symbol;
   499                     return symbol;
   494                 }
   500                 }
   495             }
   501             }
   501         do {
   507         do {
   502             ch = fCurrentEntity.ch[fCurrentEntity.position];
   508             ch = fCurrentEntity.ch[fCurrentEntity.position];
   503             if (XML11Char.isXML11NCName(ch)) {
   509             if (XML11Char.isXML11NCName(ch)) {
   504                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   510                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   505                     int length = fCurrentEntity.position - offset;
   511                     int length = fCurrentEntity.position - offset;
       
   512                     invokeListeners(length);
   506                     if (length == fCurrentEntity.ch.length) {
   513                     if (length == fCurrentEntity.ch.length) {
   507                         // bad luck we have to resize our buffer
   514                         // bad luck we have to resize our buffer
   508                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   515                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   509                         System.arraycopy(fCurrentEntity.ch, offset,
   516                         System.arraycopy(fCurrentEntity.ch, offset,
   510                                          tmp, 0, length);
   517                                          tmp, 0, length);
   513                     else {
   520                     else {
   514                         System.arraycopy(fCurrentEntity.ch, offset,
   521                         System.arraycopy(fCurrentEntity.ch, offset,
   515                                          fCurrentEntity.ch, 0, length);
   522                                          fCurrentEntity.ch, 0, length);
   516                     }
   523                     }
   517                     offset = 0;
   524                     offset = 0;
   518                     if (load(length, false)) {
   525                     if (load(length, false, false)) {
   519                         break;
   526                         break;
   520                     }
   527                     }
   521                 }
   528                 }
   522             }
   529             }
   523             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   530             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   524                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   531                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   525                     int length = fCurrentEntity.position - offset;
   532                     int length = fCurrentEntity.position - offset;
       
   533                     invokeListeners(length);
   526                     if (length == fCurrentEntity.ch.length) {
   534                     if (length == fCurrentEntity.ch.length) {
   527                         // bad luck we have to resize our buffer
   535                         // bad luck we have to resize our buffer
   528                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   536                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   529                         System.arraycopy(fCurrentEntity.ch, offset,
   537                         System.arraycopy(fCurrentEntity.ch, offset,
   530                                          tmp, 0, length);
   538                                          tmp, 0, length);
   533                     else {
   541                     else {
   534                         System.arraycopy(fCurrentEntity.ch, offset,
   542                         System.arraycopy(fCurrentEntity.ch, offset,
   535                                          fCurrentEntity.ch, 0, length);
   543                                          fCurrentEntity.ch, 0, length);
   536                     }
   544                     }
   537                     offset = 0;
   545                     offset = 0;
   538                     if (load(length, false)) {
   546                     if (load(length, false, false)) {
   539                         --fCurrentEntity.startPosition;
   547                         --fCurrentEntity.startPosition;
   540                         --fCurrentEntity.position;
   548                         --fCurrentEntity.position;
   541                         break;
   549                         break;
   542                     }
   550                     }
   543                 }
   551                 }
   547                     --fCurrentEntity.position;
   555                     --fCurrentEntity.position;
   548                     break;
   556                     break;
   549                 }
   557                 }
   550                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   558                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   551                     int length = fCurrentEntity.position - offset;
   559                     int length = fCurrentEntity.position - offset;
       
   560                     invokeListeners(length);
   552                     if (length == fCurrentEntity.ch.length) {
   561                     if (length == fCurrentEntity.ch.length) {
   553                         // bad luck we have to resize our buffer
   562                         // bad luck we have to resize our buffer
   554                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   563                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   555                         System.arraycopy(fCurrentEntity.ch, offset,
   564                         System.arraycopy(fCurrentEntity.ch, offset,
   556                                          tmp, 0, length);
   565                                          tmp, 0, length);
   559                     else {
   568                     else {
   560                         System.arraycopy(fCurrentEntity.ch, offset,
   569                         System.arraycopy(fCurrentEntity.ch, offset,
   561                                          fCurrentEntity.ch, 0, length);
   570                                          fCurrentEntity.ch, 0, length);
   562                     }
   571                     }
   563                     offset = 0;
   572                     offset = 0;
   564                     if (load(length, false)) {
   573                     if (load(length, false, false)) {
   565                         break;
   574                         break;
   566                     }
   575                     }
   567                 }
   576                 }
   568             }
   577             }
   569             else {
   578             else {
   608      */
   617      */
   609     public boolean scanQName(QName qname) throws IOException {
   618     public boolean scanQName(QName qname) throws IOException {
   610 
   619 
   611         // load more characters, if needed
   620         // load more characters, if needed
   612         if (fCurrentEntity.position == fCurrentEntity.count) {
   621         if (fCurrentEntity.position == fCurrentEntity.count) {
   613             load(0, true);
   622             load(0, true, true);
   614         }
   623         }
   615 
   624 
   616         // scan qualified name
   625         // scan qualified name
   617         int offset = fCurrentEntity.position;
   626         int offset = fCurrentEntity.position;
   618         char ch = fCurrentEntity.ch[offset];
   627         char ch = fCurrentEntity.ch[offset];
   619 
   628 
   620         if (XML11Char.isXML11NCNameStart(ch)) {
   629         if (XML11Char.isXML11NCNameStart(ch)) {
   621             if (++fCurrentEntity.position == fCurrentEntity.count) {
   630             if (++fCurrentEntity.position == fCurrentEntity.count) {
   622                 fCurrentEntity.ch[0] = ch;
   631                 fCurrentEntity.ch[0] = ch;
   623                 offset = 0;
   632                 offset = 0;
   624                 if (load(1, false)) {
   633                 if (load(1, false, true)) {
   625                     fCurrentEntity.columnNumber++;
   634                     fCurrentEntity.columnNumber++;
   626                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   635                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
   627                     qname.setValues(null, name, name, null);
   636                     qname.setValues(null, name, name, null);
   628                     return true;
   637                     return true;
   629                 }
   638                 }
   631         }
   640         }
   632         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   641         else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   633             if (++fCurrentEntity.position == fCurrentEntity.count) {
   642             if (++fCurrentEntity.position == fCurrentEntity.count) {
   634                 fCurrentEntity.ch[0] = ch;
   643                 fCurrentEntity.ch[0] = ch;
   635                 offset = 0;
   644                 offset = 0;
   636                 if (load(1, false)) {
   645                 if (load(1, false, true)) {
   637                     --fCurrentEntity.startPosition;
   646                     --fCurrentEntity.startPosition;
   638                     --fCurrentEntity.position;
   647                     --fCurrentEntity.position;
   639                     return false;
   648                     return false;
   640                 }
   649                 }
   641             }
   650             }
   647             }
   656             }
   648             if (++fCurrentEntity.position == fCurrentEntity.count) {
   657             if (++fCurrentEntity.position == fCurrentEntity.count) {
   649                 fCurrentEntity.ch[0] = ch;
   658                 fCurrentEntity.ch[0] = ch;
   650                 fCurrentEntity.ch[1] = ch2;
   659                 fCurrentEntity.ch[1] = ch2;
   651                 offset = 0;
   660                 offset = 0;
   652                 if (load(2, false)) {
   661                 if (load(2, false, true)) {
   653                     fCurrentEntity.columnNumber += 2;
   662                     fCurrentEntity.columnNumber += 2;
   654                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   663                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
   655                     qname.setValues(null, name, name, null);
   664                     qname.setValues(null, name, name, null);
   656                     return true;
   665                     return true;
   657                 }
   666                 }
   672                     }
   681                     }
   673                     index = fCurrentEntity.position;
   682                     index = fCurrentEntity.position;
   674                 }
   683                 }
   675                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   684                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   676                     int length = fCurrentEntity.position - offset;
   685                     int length = fCurrentEntity.position - offset;
       
   686                     invokeListeners(length);
   677                     if (length == fCurrentEntity.ch.length) {
   687                     if (length == fCurrentEntity.ch.length) {
   678                         // bad luck we have to resize our buffer
   688                         // bad luck we have to resize our buffer
   679                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   689                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   680                         System.arraycopy(fCurrentEntity.ch, offset,
   690                         System.arraycopy(fCurrentEntity.ch, offset,
   681                                          tmp, 0, length);
   691                                          tmp, 0, length);
   687                     }
   697                     }
   688                     if (index != -1) {
   698                     if (index != -1) {
   689                         index = index - offset;
   699                         index = index - offset;
   690                     }
   700                     }
   691                     offset = 0;
   701                     offset = 0;
   692                     if (load(length, false)) {
   702                     if (load(length, false, false)) {
   693                         break;
   703                         break;
   694                     }
   704                     }
   695                 }
   705                 }
   696             }
   706             }
   697             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   707             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
   698                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   708                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   699                     int length = fCurrentEntity.position - offset;
   709                     int length = fCurrentEntity.position - offset;
       
   710                     invokeListeners(length);
   700                     if (length == fCurrentEntity.ch.length) {
   711                     if (length == fCurrentEntity.ch.length) {
   701                         // bad luck we have to resize our buffer
   712                         // bad luck we have to resize our buffer
   702                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   713                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   703                         System.arraycopy(fCurrentEntity.ch, offset,
   714                         System.arraycopy(fCurrentEntity.ch, offset,
   704                                          tmp, 0, length);
   715                                          tmp, 0, length);
   710                     }
   721                     }
   711                     if (index != -1) {
   722                     if (index != -1) {
   712                         index = index - offset;
   723                         index = index - offset;
   713                     }
   724                     }
   714                     offset = 0;
   725                     offset = 0;
   715                     if (load(length, false)) {
   726                     if (load(length, false, false)) {
   716                         sawIncompleteSurrogatePair = true;
   727                         sawIncompleteSurrogatePair = true;
   717                         --fCurrentEntity.startPosition;
   728                         --fCurrentEntity.startPosition;
   718                         --fCurrentEntity.position;
   729                         --fCurrentEntity.position;
   719                         break;
   730                         break;
   720                     }
   731                     }
   726                     --fCurrentEntity.position;
   737                     --fCurrentEntity.position;
   727                     break;
   738                     break;
   728                 }
   739                 }
   729                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   740                 if (++fCurrentEntity.position == fCurrentEntity.count) {
   730                     int length = fCurrentEntity.position - offset;
   741                     int length = fCurrentEntity.position - offset;
       
   742                     invokeListeners(length);
   731                     if (length == fCurrentEntity.ch.length) {
   743                     if (length == fCurrentEntity.ch.length) {
   732                         // bad luck we have to resize our buffer
   744                         // bad luck we have to resize our buffer
   733                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   745                         char[] tmp = new char[fCurrentEntity.ch.length << 1];
   734                         System.arraycopy(fCurrentEntity.ch, offset,
   746                         System.arraycopy(fCurrentEntity.ch, offset,
   735                                          tmp, 0, length);
   747                                          tmp, 0, length);
   741                     }
   753                     }
   742                     if (index != -1) {
   754                     if (index != -1) {
   743                         index = index - offset;
   755                         index = index - offset;
   744                     }
   756                     }
   745                     offset = 0;
   757                     offset = 0;
   746                     if (load(length, false)) {
   758                     if (load(length, false, false)) {
   747                         break;
   759                         break;
   748                     }
   760                     }
   749                 }
   761                 }
   750             }
   762             }
   751             else {
   763             else {
   818      */
   830      */
   819     public int scanContent(XMLString content) throws IOException {
   831     public int scanContent(XMLString content) throws IOException {
   820 
   832 
   821         // load more characters, if needed
   833         // load more characters, if needed
   822         if (fCurrentEntity.position == fCurrentEntity.count) {
   834         if (fCurrentEntity.position == fCurrentEntity.count) {
   823             load(0, true);
   835             load(0, true, true);
   824         }
   836         }
   825         else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
   837         else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
   826             fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
   838             fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
   827             load(1, false);
   839             load(1, false, true);
   828             fCurrentEntity.position = 0;
   840             fCurrentEntity.position = 0;
   829             fCurrentEntity.startPosition = 0;
   841             fCurrentEntity.startPosition = 0;
   830         }
   842         }
   831 
   843 
   832         // normalize newlines
   844         // normalize newlines
   844                     if (fCurrentEntity.position == fCurrentEntity.count) {
   856                     if (fCurrentEntity.position == fCurrentEntity.count) {
   845                         offset = 0;
   857                         offset = 0;
   846                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   858                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   847                         fCurrentEntity.position = newlines;
   859                         fCurrentEntity.position = newlines;
   848                         fCurrentEntity.startPosition = newlines;
   860                         fCurrentEntity.startPosition = newlines;
   849                         if (load(newlines, false)) {
   861                         if (load(newlines, false, true)) {
   850                             break;
   862                             break;
   851                         }
   863                         }
   852                     }
   864                     }
   853                     int cc = fCurrentEntity.ch[fCurrentEntity.position];
   865                     int cc = fCurrentEntity.ch[fCurrentEntity.position];
   854                     if (cc == '\n' || cc == 0x85) {
   866                     if (cc == '\n' || cc == 0x85) {
   867                     if (fCurrentEntity.position == fCurrentEntity.count) {
   879                     if (fCurrentEntity.position == fCurrentEntity.count) {
   868                         offset = 0;
   880                         offset = 0;
   869                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   881                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   870                         fCurrentEntity.position = newlines;
   882                         fCurrentEntity.position = newlines;
   871                         fCurrentEntity.startPosition = newlines;
   883                         fCurrentEntity.startPosition = newlines;
   872                         if (load(newlines, false)) {
   884                         if (load(newlines, false, true)) {
   873                             break;
   885                             break;
   874                         }
   886                         }
   875                     }
   887                     }
   876                 }
   888                 }
   877                 else {
   889                 else {
   959      */
   971      */
   960     public int scanLiteral(int quote, XMLString content)
   972     public int scanLiteral(int quote, XMLString content)
   961         throws IOException {
   973         throws IOException {
   962         // load more characters, if needed
   974         // load more characters, if needed
   963         if (fCurrentEntity.position == fCurrentEntity.count) {
   975         if (fCurrentEntity.position == fCurrentEntity.count) {
   964             load(0, true);
   976             load(0, true, true);
   965         }
   977         }
   966         else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
   978         else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
   967             fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
   979             fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
   968             load(1, false);
   980             load(1, false, true);
   969             fCurrentEntity.startPosition = 0;
   981             fCurrentEntity.startPosition = 0;
   970             fCurrentEntity.position = 0;
   982             fCurrentEntity.position = 0;
   971         }
   983         }
   972 
   984 
   973         // normalize newlines
   985         // normalize newlines
   985                     if (fCurrentEntity.position == fCurrentEntity.count) {
   997                     if (fCurrentEntity.position == fCurrentEntity.count) {
   986                         offset = 0;
   998                         offset = 0;
   987                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   999                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
   988                         fCurrentEntity.position = newlines;
  1000                         fCurrentEntity.position = newlines;
   989                         fCurrentEntity.startPosition = newlines;
  1001                         fCurrentEntity.startPosition = newlines;
   990                         if (load(newlines, false)) {
  1002                         if (load(newlines, false, true)) {
   991                             break;
  1003                             break;
   992                         }
  1004                         }
   993                     }
  1005                     }
   994                     int cc = fCurrentEntity.ch[fCurrentEntity.position];
  1006                     int cc = fCurrentEntity.ch[fCurrentEntity.position];
   995                     if (cc == '\n' || cc == 0x85) {
  1007                     if (cc == '\n' || cc == 0x85) {
  1008                     if (fCurrentEntity.position == fCurrentEntity.count) {
  1020                     if (fCurrentEntity.position == fCurrentEntity.count) {
  1009                         offset = 0;
  1021                         offset = 0;
  1010                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1022                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1011                         fCurrentEntity.position = newlines;
  1023                         fCurrentEntity.position = newlines;
  1012                         fCurrentEntity.startPosition = newlines;
  1024                         fCurrentEntity.startPosition = newlines;
  1013                         if (load(newlines, false)) {
  1025                         if (load(newlines, false, true)) {
  1014                             break;
  1026                             break;
  1015                         }
  1027                         }
  1016                     }
  1028                     }
  1017                 }
  1029                 }
  1018                 else {
  1030                 else {
  1111         char charAt0 = delimiter.charAt(0);
  1123         char charAt0 = delimiter.charAt(0);
  1112         boolean external = fCurrentEntity.isExternal();
  1124         boolean external = fCurrentEntity.isExternal();
  1113         do {
  1125         do {
  1114             // load more characters, if needed
  1126             // load more characters, if needed
  1115             if (fCurrentEntity.position == fCurrentEntity.count) {
  1127             if (fCurrentEntity.position == fCurrentEntity.count) {
  1116                 load(0, true);
  1128                 load(0, true, false);
  1117             }
  1129             }
  1118 
  1130 
  1119             boolean bNextEntity = false;
  1131             boolean bNextEntity = false;
  1120 
  1132 
  1121             while ((fCurrentEntity.position >= fCurrentEntity.count - delimLen)
  1133             while ((fCurrentEntity.position >= fCurrentEntity.count - delimLen)
  1125                                fCurrentEntity.position,
  1137                                fCurrentEntity.position,
  1126                                fCurrentEntity.ch,
  1138                                fCurrentEntity.ch,
  1127                                0,
  1139                                0,
  1128                                fCurrentEntity.count - fCurrentEntity.position);
  1140                                fCurrentEntity.count - fCurrentEntity.position);
  1129 
  1141 
  1130               bNextEntity = load(fCurrentEntity.count - fCurrentEntity.position, false);
  1142               bNextEntity = load(fCurrentEntity.count - fCurrentEntity.position, false, false);
  1131               fCurrentEntity.position = 0;
  1143               fCurrentEntity.position = 0;
  1132               fCurrentEntity.startPosition = 0;
  1144               fCurrentEntity.startPosition = 0;
  1133             }
  1145             }
  1134 
  1146 
  1135             if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
  1147             if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
  1138                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
  1150                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
  1139                 fCurrentEntity.columnNumber += fCurrentEntity.count;
  1151                 fCurrentEntity.columnNumber += fCurrentEntity.count;
  1140                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1152                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1141                 fCurrentEntity.position = fCurrentEntity.count;
  1153                 fCurrentEntity.position = fCurrentEntity.count;
  1142                 fCurrentEntity.startPosition = fCurrentEntity.count;
  1154                 fCurrentEntity.startPosition = fCurrentEntity.count;
  1143                 load(0,true);
  1155                 load(0,true, false);
  1144                 return false;
  1156                 return false;
  1145             }
  1157             }
  1146 
  1158 
  1147             // normalize newlines
  1159             // normalize newlines
  1148             int offset = fCurrentEntity.position;
  1160             int offset = fCurrentEntity.position;
  1158                         if (fCurrentEntity.position == fCurrentEntity.count) {
  1170                         if (fCurrentEntity.position == fCurrentEntity.count) {
  1159                             offset = 0;
  1171                             offset = 0;
  1160                             fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1172                             fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1161                             fCurrentEntity.position = newlines;
  1173                             fCurrentEntity.position = newlines;
  1162                             fCurrentEntity.startPosition = newlines;
  1174                             fCurrentEntity.startPosition = newlines;
  1163                             if (load(newlines, false)) {
  1175                             if (load(newlines, false, true)) {
  1164                                 break;
  1176                                 break;
  1165                             }
  1177                             }
  1166                         }
  1178                         }
  1167                         int cc = fCurrentEntity.ch[fCurrentEntity.position];
  1179                         int cc = fCurrentEntity.ch[fCurrentEntity.position];
  1168                         if (cc == '\n' || cc == 0x85) {
  1180                         if (cc == '\n' || cc == 0x85) {
  1182                             offset = 0;
  1194                             offset = 0;
  1183                             fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1195                             fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
  1184                             fCurrentEntity.position = newlines;
  1196                             fCurrentEntity.position = newlines;
  1185                             fCurrentEntity.startPosition = newlines;
  1197                             fCurrentEntity.startPosition = newlines;
  1186                             fCurrentEntity.count = newlines;
  1198                             fCurrentEntity.count = newlines;
  1187                             if (load(newlines, false)) {
  1199                             if (load(newlines, false, true)) {
  1188                                 break;
  1200                                 break;
  1189                             }
  1201                             }
  1190                         }
  1202                         }
  1191                     }
  1203                     }
  1192                     else {
  1204                     else {
  1307      */
  1319      */
  1308     public boolean skipChar(int c) throws IOException {
  1320     public boolean skipChar(int c) throws IOException {
  1309 
  1321 
  1310         // load more characters, if needed
  1322         // load more characters, if needed
  1311         if (fCurrentEntity.position == fCurrentEntity.count) {
  1323         if (fCurrentEntity.position == fCurrentEntity.count) {
  1312             load(0, true);
  1324             load(0, true, true);
  1313         }
  1325         }
  1314 
  1326 
  1315         // skip character
  1327         // skip character
  1316         int cc = fCurrentEntity.ch[fCurrentEntity.position];
  1328         int cc = fCurrentEntity.ch[fCurrentEntity.position];
  1317         if (cc == c) {
  1329         if (cc == c) {
  1333         }
  1345         }
  1334         else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
  1346         else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
  1335             // handle newlines
  1347             // handle newlines
  1336             if (fCurrentEntity.position == fCurrentEntity.count) {
  1348             if (fCurrentEntity.position == fCurrentEntity.count) {
  1337                 fCurrentEntity.ch[0] = (char)cc;
  1349                 fCurrentEntity.ch[0] = (char)cc;
  1338                 load(1, false);
  1350                 load(1, false, true);
  1339             }
  1351             }
  1340             int ccc = fCurrentEntity.ch[++fCurrentEntity.position];
  1352             int ccc = fCurrentEntity.ch[++fCurrentEntity.position];
  1341             if (ccc == '\n' || ccc == 0x85) {
  1353             if (ccc == '\n' || ccc == 0x85) {
  1342                 fCurrentEntity.position++;
  1354                 fCurrentEntity.position++;
  1343             }
  1355             }
  1367      */
  1379      */
  1368     public boolean skipSpaces() throws IOException {
  1380     public boolean skipSpaces() throws IOException {
  1369 
  1381 
  1370         // load more characters, if needed
  1382         // load more characters, if needed
  1371         if (fCurrentEntity.position == fCurrentEntity.count) {
  1383         if (fCurrentEntity.position == fCurrentEntity.count) {
  1372             load(0, true);
  1384             load(0, true, true);
  1373         }
  1385         }
  1374 
  1386 
  1375 
  1387 
  1376         //we are doing this check only in skipSpace() because it is called by
  1388         //we are doing this check only in skipSpace() because it is called by
  1377         //fMiscDispatcher and we want the parser to exit gracefully when document
  1389         //fMiscDispatcher and we want the parser to exit gracefully when document
  1395                     if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
  1407                     if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
  1396                         fCurrentEntity.lineNumber++;
  1408                         fCurrentEntity.lineNumber++;
  1397                         fCurrentEntity.columnNumber = 1;
  1409                         fCurrentEntity.columnNumber = 1;
  1398                         if (fCurrentEntity.position == fCurrentEntity.count - 1) {
  1410                         if (fCurrentEntity.position == fCurrentEntity.count - 1) {
  1399                             fCurrentEntity.ch[0] = (char)c;
  1411                             fCurrentEntity.ch[0] = (char)c;
  1400                             entityChanged = load(1, true);
  1412                             entityChanged = load(1, true, true);
  1401                             if (!entityChanged) {
  1413                             if (!entityChanged) {
  1402                                 // the load change the position to be 1,
  1414                                 // the load change the position to be 1,
  1403                                 // need to restore it when entity not changed
  1415                                 // need to restore it when entity not changed
  1404                                 fCurrentEntity.startPosition = 0;
  1416                                 fCurrentEntity.startPosition = 0;
  1405                                 fCurrentEntity.position = 0;
  1417                                 fCurrentEntity.position = 0;
  1422                     }
  1434                     }
  1423                     // load more characters, if needed
  1435                     // load more characters, if needed
  1424                     if (!entityChanged)
  1436                     if (!entityChanged)
  1425                         fCurrentEntity.position++;
  1437                         fCurrentEntity.position++;
  1426                     if (fCurrentEntity.position == fCurrentEntity.count) {
  1438                     if (fCurrentEntity.position == fCurrentEntity.count) {
  1427                         load(0, true);
  1439                         load(0, true, true);
  1428 
  1440 
  1429                         if(fCurrentEntity == null){
  1441                         if(fCurrentEntity == null){
  1430                         return true ;
  1442                         return true ;
  1431                         }
  1443                         }
  1432 
  1444 
  1443                 if (c == '\n') {
  1455                 if (c == '\n') {
  1444                     fCurrentEntity.lineNumber++;
  1456                     fCurrentEntity.lineNumber++;
  1445                     fCurrentEntity.columnNumber = 1;
  1457                     fCurrentEntity.columnNumber = 1;
  1446                     if (fCurrentEntity.position == fCurrentEntity.count - 1) {
  1458                     if (fCurrentEntity.position == fCurrentEntity.count - 1) {
  1447                         fCurrentEntity.ch[0] = (char)c;
  1459                         fCurrentEntity.ch[0] = (char)c;
  1448                         entityChanged = load(1, true);
  1460                         entityChanged = load(1, true, true);
  1449                         if (!entityChanged) {
  1461                         if (!entityChanged) {
  1450                             // the load change the position to be 1,
  1462                             // the load change the position to be 1,
  1451                             // need to restore it when entity not changed
  1463                             // need to restore it when entity not changed
  1452                             fCurrentEntity.startPosition = 0;
  1464                             fCurrentEntity.startPosition = 0;
  1453                             fCurrentEntity.position = 0;
  1465                             fCurrentEntity.position = 0;
  1461                 }
  1473                 }
  1462                 // load more characters, if needed
  1474                 // load more characters, if needed
  1463                 if (!entityChanged)
  1475                 if (!entityChanged)
  1464                     fCurrentEntity.position++;
  1476                     fCurrentEntity.position++;
  1465                 if (fCurrentEntity.position == fCurrentEntity.count) {
  1477                 if (fCurrentEntity.position == fCurrentEntity.count) {
  1466                     load(0, true);
  1478                     load(0, true, true);
  1467 
  1479 
  1468                     if(fCurrentEntity == null){
  1480                     if(fCurrentEntity == null){
  1469                         return true ;
  1481                         return true ;
  1470                     }
  1482                     }
  1471 
  1483 
  1494      */
  1506      */
  1495     public boolean skipString(String s) throws IOException {
  1507     public boolean skipString(String s) throws IOException {
  1496 
  1508 
  1497         // load more characters, if needed
  1509         // load more characters, if needed
  1498         if (fCurrentEntity.position == fCurrentEntity.count) {
  1510         if (fCurrentEntity.position == fCurrentEntity.count) {
  1499             load(0, true);
  1511             load(0, true, true);
  1500         }
  1512         }
  1501 
  1513 
  1502         // skip string
  1514         // skip string
  1503         final int length = s.length();
  1515         final int length = s.length();
  1504         for (int i = 0; i < length; i++) {
  1516         for (int i = 0; i < length; i++) {
  1506             if (c != s.charAt(i)) {
  1518             if (c != s.charAt(i)) {
  1507                 fCurrentEntity.position -= i + 1;
  1519                 fCurrentEntity.position -= i + 1;
  1508                 return false;
  1520                 return false;
  1509             }
  1521             }
  1510             if (i < length - 1 && fCurrentEntity.position == fCurrentEntity.count) {
  1522             if (i < length - 1 && fCurrentEntity.position == fCurrentEntity.count) {
       
  1523                 invokeListeners(0);
  1511                 System.arraycopy(fCurrentEntity.ch, fCurrentEntity.count - i - 1, fCurrentEntity.ch, 0, i + 1);
  1524                 System.arraycopy(fCurrentEntity.ch, fCurrentEntity.count - i - 1, fCurrentEntity.ch, 0, i + 1);
  1512                 // REVISIT: Can a string to be skipped cross an
  1525                 // REVISIT: Can a string to be skipped cross an
  1513                 //          entity boundary? -Ac
  1526                 //          entity boundary? -Ac
  1514                 if (load(i + 1, false)) {
  1527                 if (load(i + 1, false, false)) {
  1515                     fCurrentEntity.startPosition -= i + 1;
  1528                     fCurrentEntity.startPosition -= i + 1;
  1516                     fCurrentEntity.position -= i + 1;
  1529                     fCurrentEntity.position -= i + 1;
  1517                     return false;
  1530                     return false;
  1518                 }
  1531                 }
  1519             }
  1532             }