📄 minml.java
字号:
} else {
radix = 10;
}
int charRef = Character.digit((char)currentChar, radix);
while (true) {
currentChar = buffer.read();
final int digit = Character.digit((char)currentChar, radix);
if (digit == -1) break;
charRef = (char)((charRef * radix) + digit);
}
if (currentChar == ';' && charRef != -1) {
buffer.write(charRef);
break;
}
fatalError("invalid Character Entitiy", this.lineNumber, this.columnNumber);
} else {
currentChar = buffer.read();
}
} else {
crefState = ("\u0001\u000b\u0006\u00ff\u00ff\u00ff\u00ff\u00ff\u00ff\u00ff\u00ff" +
// # a m p ; & p o s ; '
// 0 1 2 3 4 5 6 7 8 9 a
"\u0011\u00ff\u00ff\u00ff\u00ff\u00ff\u0015\u00ff\u00ff\u00ff" +
// q u o t ; " g t ; >
// b b d e f 10 11 12 13 14
"\u00ff\u00ff\u00ff").charAt(crefState);
// l t ;
// 15 16 17
if (crefState == 255) fatalError("invalid Character Entitiy", this.lineNumber, this.columnNumber);
}
}
break;
case parseError:
// report fatal error
fatalError(operand, this.lineNumber, this.columnNumber);
// drop through to exit parser
case exitParser:
// exit parser
return;
case writeCdata:
// write character data
// this will also write any skipped whitespace
buffer.write(currentChar);
break; // change state to operand
case discardAndChange:
// throw saved characters away and change state
buffer.reset();
break; // change state to operand
case discardSaveAndChange:
// throw saved characters away, save character and change state
buffer.reset();
// drop through to save character and change state
case saveAndChange:
// save character and change state
buffer.saveChar((char)currentChar);
break; // change state to operand
case change:
// change state to operand
break; // change state to operand
}
state = operand;
}
}
catch (final IOException e) {
this.errorHandler.fatalError(new SAXParseException(e.toString(), null, null, this.lineNumber, this.columnNumber, e));
}
finally {
this.errorHandler = this;
this.documentHandler = this.extDocumentHandler = this;
this.tags.removeAllElements();
}
}
public void parse(final InputSource source) throws SAXException, IOException {
if (source.getCharacterStream() != null)
parse(source.getCharacterStream());
else if (source.getByteStream() != null)
parse(new InputStreamReader(source.getByteStream()));
else
parse(new InputStreamReader(new URL(source.getSystemId()).openStream()));
}
public void parse(final String systemId) throws SAXException, IOException {
parse(new InputSource(systemId));
}
public void setLocale(final Locale locale) throws SAXException {
throw new SAXException("Not supported");
}
public void setEntityResolver(final EntityResolver resolver) {
// not supported
}
public void setDTDHandler(final DTDHandler handler) {
// not supported
}
public void setDocumentHandler(final org.xml.sax.DocumentHandler handler) {
this.documentHandler = (handler == null) ? this : handler;
this.extDocumentHandler = this;
}
public void setDocumentHandler(final DocumentHandler handler) {
this.documentHandler = this.extDocumentHandler = (handler == null) ? this : handler;
this.documentHandler.setDocumentLocator(this);
}
public void setErrorHandler(final ErrorHandler handler) {
this.errorHandler = (handler == null) ? this : handler;
}
public void setDocumentLocator(final Locator locator) {
}
public void startDocument() throws SAXException {
}
public Writer startDocument(final Writer writer) throws SAXException {
this.documentHandler.startDocument();
return writer;
}
public void endDocument() throws SAXException {
}
public void startElement(final String name, final AttributeList attributes) throws SAXException {
}
public Writer startElement(final String name, final AttributeList attributes, final Writer writer)
throws SAXException
{
this.documentHandler.startElement(name, attributes);
return writer;
}
public void endElement(final String name) throws SAXException {
}
public void characters(final char ch[], final int start, final int length) throws SAXException {
}
public void ignorableWhitespace(final char ch[], final int start, final int length) throws SAXException {
}
public void processingInstruction(final String target, final String data) throws SAXException {
}
public void warning(final SAXParseException e) throws SAXException {
}
public void error(final SAXParseException e) throws SAXException {
}
public void fatalError(final SAXParseException e) throws SAXException {
throw e;
}
public String getPublicId() {
return "";
}
public String getSystemId() {
return "";
}
public int getLineNumber () {
return this.lineNumber;
}
public int getColumnNumber () {
return this.columnNumber;
}
private void fatalError(final String msg, final int lineNumber, final int columnNumber) throws SAXException {
this.errorHandler.fatalError(new SAXParseException(msg, null, null, lineNumber, columnNumber));
}
private class MinMLBuffer extends Writer {
public MinMLBuffer(final Reader in) {
this.in = in;
}
public void close() throws IOException {
flush();
}
public void flush() throws IOException {
try {
_flush();
if (writer != this) writer.flush();
}
finally {
flushed = true;
}
}
public void write(final int c) throws IOException {
written = true;
chars[count++] = (char)c;
}
public void write(final char[] cbuf, final int off, final int len) throws IOException {
written = true;
System.arraycopy(cbuf, off, chars, count, len);
count += len;
}
public void saveChar(final char c) {
written = false;
chars[count++] = c;
}
public void pushWriter(final Writer writer) {
MinML.this.tags.push(this.writer);
this.writer = (writer == null) ? this : writer;
flushed = written = false;
}
public Writer getWriter() {
return writer;
}
public void popWriter() throws IOException {
try {
if (!flushed && writer != this) writer.flush();
}
finally {
writer = (Writer)MinML.this.tags.pop();
flushed = written = false;
}
}
public String getString() {
final String result = new String(chars, 0, count);
count = 0;
return result;
}
public void reset() {
count = 0;
}
public int read() throws IOException {
if (nextIn == lastIn) {
if (count != 0) {
if (written) {
_flush();
} else if (count >= (chars.length - MinML.this.bufferIncrement)) {
final char[] newChars = new char[chars.length + MinML.this.bufferIncrement];
System.arraycopy(chars, 0, newChars, 0, count);
chars = newChars;
}
}
final int numRead = in.read(chars, count, chars.length - count);
if (numRead == -1) return -1;
nextIn = count;
lastIn = count + numRead;
}
return chars[nextIn++];
}
private void _flush() throws IOException {
if (count != 0) {
try {
if (writer == this) {
try {
MinML.this.documentHandler.characters(chars, 0, count);
}
catch (final SAXException e) {
throw new IOException(e.toString());
}
} else {
writer.write(chars, 0, count);
}
}
finally {
count = 0;
}
}
}
private int nextIn = 0, lastIn = 0;
private char[] chars = new char[MinML.this.initialBufferSize];
private final Reader in;
private int count = 0;
private Writer writer = this;
private boolean flushed = false;
private boolean written = false;
}
private DocumentHandler extDocumentHandler = this;
private org.xml.sax.DocumentHandler documentHandler = this;
private ErrorHandler errorHandler = this;
private final Stack tags = new Stack();
private int lineNumber = 1;
private int columnNumber = 0;
private final int initialBufferSize;
private final int bufferIncrement;
private static final byte[] charClasses = {
// EOF
13,
// \t \n \r
-1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 12, -1, -1, 12, -1, -1,
//
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// SP ! " # $ % & ' ( ) * + , - . /
12, 8, 7, 14, 14, 14, 3, 6, 14, 14, 14, 14, 14, 11, 14, 2,
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 5, 1, 4,
//
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
// [ \ ]
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 9, 14, 10
};
private static final String[] operands = {
"\u0d15\u1611\u1611\u1611\u1611\u1611\u1611\u1611\u1611\u1611\u1611\u1611\u0015\u0010\u1611",
"\u1711\u1000\u0b00\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u0114\u0200\u1811\u0114",
"\u1711\u1001\u0b01\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u0215\u1811\u0414",
"\u1711\u1001\u0b01\u1711\u1911\u1911\u1911\u1911\u1911\u1911\u1911\u1911\u0315\u1811\u0414",
"\u1911\u1911\u1911\u1911\u1911\u0606\u1911\u1911\u1911\u1911\u1911\u0414\u0515\u1811\u0414",
"\u1911\u1911\u1911\u1911\u1911\u0606\u1911\u1911\u1911\u1911\u1911\u1911\u0515\u1811\u1911",
"\u1a11\u1a11\u1a11\u1a11\u1a11\u1a11\u0715\u0815\u1a11\u1a11\u1a11\u1a11\u0615\u1811\u1a11",
"\u0714\u0714\u0714\u070e\u0714\u0714\u0307\u0714\u0714\u0714\u0714\u0714\u0714\u1811\u0714",
"\u0814\u0814\u0814\u080e\u0814\u0814\u0814\u0307\u0814\u0814\u0814\u0814\u0814\u1811\u0814",
"\u1711\u1002\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u0914\u0915\u1811\u0914",
"\u1b11\u1b11\u0904\u1b11\u1b11\u1b11\u1b11\u1b11\u1215\u1b11\u1b11\u1b11\u1b11\u1811\u0105",
"\u1711\u1012\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1711\u1811\u1711",
"\u1711\u1c11\u0912\u1711\u0e12\u1711\u1711\u1711\u1212\u1711\u1711\u1711\u1711\u1811\u0113",
"\u1711\u1c11\u0912\u1711\u0e12\u1711\u1711\u1711\u1212\u1711\u1711\u1711\u1711\u1811\u0113",
"\u0e15\u0e15\u0e15\u0e15\u0f15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u1811\u0e15",
"\u0e15\u0015\u0e15\u0e15\u0f15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u0e15\u1811\u0e15",
"\u0c03\u110f\u110f\u110e\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u1014\u1811\u110f",
"\u0a15\u110f\u110f\u110e\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u1811\u110f",
"\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u130c\u1d11\u1408\u1d11\u1811\u1515",
"\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u110d\u130f\u130f\u1811\u130f",
"\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u0009\u1415\u1811\u1415",
"\u150a\u000b\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1811\u1515",
"expected Element",
"unexpected character in tag",
"unexpected end of file found",
"attribute name not followed by '='",
"invalid attribute value",
"expecting end tag",
"empty tag",
"unexpected character after <!"
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -