Changeset 7396
- Timestamp:
- 11/21/06 13:35:34 (5 years ago)
- Location:
- trunk/Res_Piccolo/com/bluecast/xml
- Files:
-
- 6 edited
-
DocumentEntity.java (modified) (3 diffs)
-
EntityManager.java (modified) (2 diffs)
-
Piccolo.java (modified) (2 diffs)
-
PiccoloLexer.java (modified) (2 diffs)
-
XMLReaderReader.java (modified) (3 diffs)
-
XMLStreamReader.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Res_Piccolo/com/bluecast/xml/DocumentEntity.java
r7316 r7396 73 73 readerReader = new XMLReaderReader(); 74 74 75 readerReader.reset(sourceReader ,true);75 readerReader.reset(sourceReader); 76 76 isStandalone = readerReader.isXMLStandalone(); 77 77 activeReader = readerReader; … … 84 84 if (streamReader == null) 85 85 streamReader = new XMLStreamReader(); 86 streamReader.reset(in, source.getEncoding() , true);86 streamReader.reset(in, source.getEncoding()); 87 87 isOpen = true; 88 88 isStandalone = streamReader.isXMLStandalone(); … … 99 99 if (streamReader == null) 100 100 streamReader = new XMLStreamReader(); 101 streamReader.reset(url.openStream(), encoding , true);101 streamReader.reset(url.openStream(), encoding); 102 102 isStandalone = streamReader.isXMLStandalone(); 103 103 activeReader = streamReader; -
trunk/Res_Piccolo/com/bluecast/xml/EntityManager.java
r7316 r7396 74 74 if (!isInternal()) { 75 75 if (resolver == null) { 76 reader = new XMLStreamReader((new URL(sysID)).openStream() , true);76 reader = new XMLStreamReader((new URL(sysID)).openStream()); 77 77 } else { 78 78 InputSource source = resolver.resolveEntity(pubID, sysID); 79 79 if (source == null) { 80 reader = new XMLStreamReader((new URL(sysID)).openStream() , true);80 reader = new XMLStreamReader((new URL(sysID)).openStream()); 81 81 } else { 82 82 Reader r = source.getCharacterStream(); 83 83 if (r != null) 84 reader = new XMLReaderReader(r , true);84 reader = new XMLReaderReader(r); 85 85 else { 86 86 InputStream in; … … 88 88 in = source.getByteStream(); 89 89 if (in != null) 90 reader = new XMLStreamReader(in, source.getEncoding() , true);91 else reader = new XMLStreamReader((new URL(source.getSystemId())).openStream(), source.getEncoding() , true);90 reader = new XMLStreamReader(in, source.getEncoding()); 91 else reader = new XMLStreamReader((new URL(source.getSystemId())).openStream(), source.getEncoding()); 92 92 } 93 93 } -
trunk/Res_Piccolo/com/bluecast/xml/Piccolo.java
r7369 r7396 32 32 import org.xml.sax.ext.DeclHandler; 33 33 import org.xml.sax.ext.LexicalHandler; 34 import org.xml.sax.helpers.DefaultHandler; 34 35 35 36 import com.bluecast.io.FileFormatException; … … 72 73 public static void main(String[] pArgs){ 73 74 try { 74 Piccolo vParser = new Piccolo(); 75 vParser.parse(new InputSource(new ByteArrayInputStream("<test/>".getBytes("UTF-8"))));//<?xml version=\"1.0\" encoding=\"UTF-8\"?> 75 Piccolo vParser = new Piccolo(false); 76 vParser.setContentHandler(new DefaultHandler()); 77 vParser.parse(new InputSource(new ByteArrayInputStream("<test><!-- &dpi=300--></test>".getBytes("UTF-8"))));//<?xml version=\"1.0\" encoding=\"UTF-8\"?> 76 78 } catch (Exception e) { 77 79 e.printStackTrace(); -
trunk/Res_Piccolo/com/bluecast/xml/PiccoloLexer.java
r7316 r7396 3027 3027 private int yy_currentPos_l; 3028 3028 3029 private int yy_startRead_l;3030 3031 3029 private int yy_markedPos_l; 3032 3030 … … 3083 3081 yy_action = -1; 3084 3082 3085 yy_ startRead_l = yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l;3083 yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l; 3086 3084 3087 3085 yy_state = yy_lexical_state; -
trunk/Res_Piccolo/com/bluecast/xml/XMLReaderReader.java
r7033 r7396 37 37 private static final int BUFFER_SIZE = 8192; 38 38 private Reader in; 39 private boolean rewindDeclaration;40 39 private char[] cbuf = new char[BUFFER_SIZE]; 41 40 private int cbufPos = 0, cbufEnd = 0; … … 59 58 60 59 public XMLReaderReader (Reader in) throws IOException { 61 this(in,true); 62 } 63 64 /** 65 * Creates an XMLReaderReader. 66 * 67 * @param in the input source 68 * @param rewindDeclaration a value of false will skip past any 69 * XML declaration. True will dish out the entire document. 70 */ 71 public XMLReaderReader (Reader in, boolean rewindDeclaration) 72 throws IOException { 73 reset(in,rewindDeclaration); 74 } 75 76 public void reset(Reader in, boolean rewindDeclaration) 60 reset(in); 61 } 62 63 public void reset(Reader in) 77 64 throws IOException { 78 65 79 66 super.resetInput(); 80 67 this.in = in; 81 this.rewindDeclaration = rewindDeclaration;82 68 cbufPos = cbufEnd = 0; 83 69 sawCR = false; … … 254 240 /* Read [max] characters, parse the <?xml...?> tag 255 241 * push it back onto the stream. Create a reader. Then, if there was 256 * no error parsing the declaration , eat up the declaration.242 * no error parsing the declaration. 257 243 */ 258 244 private void processXMLDecl () throws IOException { 259 int numCharsParsed = parseXMLDeclaration(cbuf,0,cbufEnd); 260 261 if (numCharsParsed > 0) { 262 // Declaration found and parsed 263 264 // Skip the XML declaration unless told otherwise 265 if (!rewindDeclaration) 266 cbufPos += numCharsParsed; 267 } 245 parseXMLDeclaration(cbuf,0,cbufEnd); 268 246 } 269 247 } -
trunk/Res_Piccolo/com/bluecast/xml/XMLStreamReader.java
r7316 r7396 68 68 * XML declaration. True will dish out the entire document. 69 69 */ 70 public XMLStreamReader (InputStream in , boolean rewindDeclaration) throws IOException70 public XMLStreamReader (InputStream in) throws IOException 71 71 { 72 this(in, null , rewindDeclaration);72 this(in, null); 73 73 } 74 74 … … 76 76 * Creates an XMLStreamReader while specifying a character encoding. 77 77 */ 78 public XMLStreamReader (InputStream in, String encoding, 79 boolean rewindDeclaration) throws IOException 78 public XMLStreamReader (InputStream in, String encoding) throws IOException 80 79 { 81 reset(in, encoding , rewindDeclaration);80 reset(in, encoding); 82 81 } 83 82 … … 85 84 * Reuses this XMLStreamReader for a different InputStream. 86 85 */ 87 public void reset (InputStream in, String encoding, 88 boolean rewindDeclaration) throws IOException { 86 public void reset (InputStream in, String encoding) throws IOException { 89 87 super.resetInput(); 90 88 this.in = in; 91 89 eofReached = false; 92 this.rewindDeclaration = rewindDeclaration;93 90 useDeclaredEncoding = false; 94 91 bbufPos = bbufEnd = 0; … … 675 672 676 673 int bbufPosTemp = bbufPos + decodeResult[0]; 677 cbufEnd= decodeResult[1];674 int cbufEndTemp = decodeResult[1]; 678 675 679 while(r == -2 && ! eofReached && cbufEnd < cbuf.length) {676 while(r == -2 && ! eofReached && cbufEndTemp < cbuf.length) { 680 677 fillByteBuffer(); 681 678 r = decoder.decodeXMLDecl(bbuf, bbufPosTemp, bbufEnd - bbufPosTemp, 682 cbuf, cbufPos+cbufEnd , cbuf.length-cbufEnd,679 cbuf, cbufPos+cbufEndTemp, cbuf.length-cbufEndTemp, 683 680 decodeResult); 684 681 bbufPosTemp += decodeResult[0]; 685 cbufEnd += decodeResult[1];686 } 687 688 int numCharsParsed = parseXMLDeclaration(cbuf,0,cbufEnd);682 cbufEndTemp += decodeResult[1]; 683 } 684 685 parseXMLDeclaration(cbuf,0,cbufEndTemp); 689 686 690 687 //if (numCharsParsed > 0) { … … 694 691 695 692 // Skip the XML declaration unless told otherwise 696 if (!rewindDeclaration)697 cbufPos += numCharsParsed;693 //if (!rewindDeclaration) 694 // cbufPos += numCharsParsed; 698 695 699 696 // If another encoding was specified, use it instead of the guess. … … 702 699 && !declaredEncoding.equalsIgnoreCase(encoding)) { 703 700 704 cbufPos = cbufEnd = 0; 701 cbufPos = cbufEndTemp = 0; 702 bbufPos = initialBBufPos; 705 703 decoder.reset(); 706 707 708 if (rewindDeclaration)709 bbufPos = initialBBufPos;710 else711 bbufPos = numCharsParsed*minBytesPerChar;712 704 713 705 setEncoding(declaredEncoding);
Note: See TracChangeset
for help on using the changeset viewer.