< prev index next >
src/jdk.xml.bind/share/classes/com/sun/xml/internal/dtdparser/InputEntity.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 34,53 ****
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Locale;
/**
* This is how the parser talks to its input entities, of all kinds.
* The entities are in a stack.
! * <p/>
* <P> For internal entities, the character arrays are referenced here,
* and read from as needed (they're read-only). External entities have
* mutable buffers, that are read into as needed.
! * <p/>
* <P> <em>Note:</em> This maps CRLF (and CR) to LF without regard for
* whether it's in an external (parsed) entity or not. The XML 1.0 spec
* is inconsistent in explaining EOL handling; this is the sensible way.
*
* @author David Brownell
--- 34,54 ----
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
+ import java.util.Arrays;
import java.util.Locale;
/**
* This is how the parser talks to its input entities, of all kinds.
* The entities are in a stack.
! * <p>
* <P> For internal entities, the character arrays are referenced here,
* and read from as needed (they're read-only). External entities have
* mutable buffers, that are read into as needed.
! * <p>
* <P> <em>Note:</em> This maps CRLF (and CR) to LF without regard for
* whether it's in an external (parsed) entity or not. The XML 1.0 spec
* is inconsistent in explaining EOL handling; this is the sensible way.
*
* @author David Brownell
*** 146,160 ****
if (reader == null) {
InputStream bytes = in.getByteStream();
if (bytes == null)
! reader = XmlReader.createReader(new URL(in.getSystemId())
! .openStream());
else if (in.getEncoding() != null)
! reader = XmlReader.createReader(in.getByteStream(),
! in.getEncoding());
else
reader = XmlReader.createReader(in.getByteStream());
}
next = stack;
buf = new char[BUFSIZ];
--- 147,162 ----
if (reader == null) {
InputStream bytes = in.getByteStream();
if (bytes == null)
! if (Boolean.valueOf(System.getProperty("enableExternalEntityProcessing")))
! reader = XmlReader.createReader(new URL(in.getSystemId()).openStream());
! else
! fatal("P-082", new Object[] {in.getSystemId()});
else if (in.getEncoding() != null)
! reader = XmlReader.createReader(in.getByteStream(), in.getEncoding());
else
reader = XmlReader.createReader(in.getByteStream());
}
next = stack;
buf = new char[BUFSIZ];
*** 167,177 ****
//
public void init(char b [], String name, InputEntity stack, boolean isPE)
throws SAXException {
next = stack;
! buf = b;
finish = b.length;
this.name = name;
this.isPE = isPE;
checkRecursion(stack);
}
--- 169,179 ----
//
public void init(char b [], String name, InputEntity stack, boolean isPE)
throws SAXException {
next = stack;
! buf = Arrays.copyOf(b, b.length);
finish = b.length;
this.name = name;
this.isPE = isPE;
checkRecursion(stack);
}
*** 382,395 ****
/**
* normal content; whitespace in markup may be handled
* specially if the parser uses the content model.
! * <p/>
* <P> content terminates with markup delimiter characters,
* namely ampersand (&amp;) and left angle bracket (&lt;).
! * <p/>
* <P> the document handler's characters() method is called
* on all the content found
*/
public boolean parsedContent(DTDEventListener docHandler
/*ElementValidator validator*/)
--- 384,397 ----
/**
* normal content; whitespace in markup may be handled
* specially if the parser uses the content model.
! * <p>
* <P> content terminates with markup delimiter characters,
* namely ampersand (&amp;) and left angle bracket (&lt;).
! * <p>
* <P> the document handler's characters() method is called
* on all the content found
*/
public boolean parsedContent(DTDEventListener docHandler
/*ElementValidator validator*/)
*** 545,559 ****
return true;
}
/**
! * CDATA -- character data, terminated by "]]>" and optionally
* including unescaped markup delimiters (ampersand and left angle
* bracket). This should otherwise be exactly like character data,
* modulo differences in error report details.
! * <p/>
* <P> The document handler's characters() or ignorableWhitespace()
* methods are invoked on all the character data found
*
* @param docHandler gets callbacks for character data
* @param ignorableWhitespace if true, whitespace characters will
--- 547,561 ----
return true;
}
/**
! * CDATA -- character data, terminated by {@code "]]>"} and optionally
* including unescaped markup delimiters (ampersand and left angle
* bracket). This should otherwise be exactly like character data,
* modulo differences in error report details.
! * <p>
* <P> The document handler's characters() or ignorableWhitespace()
* methods are invoked on all the character data found
*
* @param docHandler gets callbacks for character data
* @param ignorableWhitespace if true, whitespace characters will
*** 618,628 ****
// As above, we can't repeat CR/CRLF --> LF mapping
if (isInternal())
continue;
if (white) {
! if (whitespaceInvalidMessage != null)
errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale,
whitespaceInvalidMessage), null));
docHandler.ignorableWhitespace(buf, start,
last - start);
docHandler.ignorableWhitespace(newline, 0, 1);
--- 620,630 ----
// As above, we can't repeat CR/CRLF --> LF mapping
if (isInternal())
continue;
if (white) {
! if (whitespaceInvalidMessage != null && errHandler != null)
errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale,
whitespaceInvalidMessage), null));
docHandler.ignorableWhitespace(buf, start,
last - start);
docHandler.ignorableWhitespace(newline, 0, 1);
*** 657,667 ****
//last--;
break;
}
}
if (white) {
! if (whitespaceInvalidMessage != null)
errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale,
whitespaceInvalidMessage), null));
docHandler.ignorableWhitespace(buf, start, last - start);
} else {
// validator.text ();
--- 659,669 ----
//last--;
break;
}
}
if (white) {
! if (whitespaceInvalidMessage != null && errHandler != null)
errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale,
whitespaceInvalidMessage), null));
docHandler.ignorableWhitespace(buf, start, last - start);
} else {
// validator.text ();
*** 699,709 ****
}
/**
* whitespace in markup (flagged to app, discardable)
! * <p/>
* <P> the document handler's ignorableWhitespace() method
* is called on all the whitespace found
*/
public boolean ignorableWhitespace(DTDEventListener handler)
throws IOException, SAXException {
--- 701,711 ----
}
/**
* whitespace in markup (flagged to app, discardable)
! * <p>
* <P> the document handler's ignorableWhitespace() method
* is called on all the whitespace found
*/
public boolean ignorableWhitespace(DTDEventListener handler)
throws IOException, SAXException {
*** 757,767 ****
}
/**
* returns false iff 'next' string isn't as provided,
* else skips that text and returns true.
! * <p/>
* <P> NOTE: two alternative string representations are
* both passed in, since one is faster.
*/
public boolean peek(String next, char chars [])
throws IOException, SAXException {
--- 759,769 ----
}
/**
* returns false iff 'next' string isn't as provided,
* else skips that text and returns true.
! * <p>
* <P> NOTE: two alternative string representations are
* both passed in, since one is faster.
*/
public boolean peek(String next, char chars [])
throws IOException, SAXException {
*** 808,819 ****
// fail to be peeked is where it's a symbol ... e.g. for an
// </EndTag> construct. That knowledge could also be applied
// to get rid of the symbol length constraint, since having
// the wrong symbol is a fatal error anyway ...
//
! if (len > buf.length)
! fatal("P-077", new Object[]{new Integer(buf.length)});
fillbuf();
return peek(next, chars);
}
--- 810,822 ----
// fail to be peeked is where it's a symbol ... e.g. for an
// </EndTag> construct. That knowledge could also be applied
// to get rid of the symbol length constraint, since having
// the wrong symbol is a fatal error anyway ...
//
! if (len > buf.length) {
! fatal("P-077", new Object[]{Integer.valueOf(buf.length)});
! }
fillbuf();
return peek(next, chars);
}
*** 982,990 ****
--- 985,995 ----
SAXParseException x = new SAXParseException(DTDParser.messages.getMessage(locale, messageId, params), null);
// not continuable ... e.g. WF errors
close();
+ if (errHandler != null) {
errHandler.fatalError(x);
+ }
throw x;
}
}
< prev index next >