📄 minml2.java
字号:
fatalError("end tag </" + elementName + "> does not match begin tag <" + begin + ">", this.lineNumber, this.columnNumber); } else { this.contentHandler.endElement((String)this.stack.pop(), (String)this.stack.pop(), begin); String namespaceName; while ((namespaceName = (String)this.stack.pop()) != null) { final String elementURI; if((elementURI = (String)this.stack.pop()) == null) { this.namespaces.remove(namespaceName); } else { if (namespaceName.length() == 0) this.defaultNamespace = elementURI; else this.namespaces.put(namespaceName, elementURI); } this.contentHandler.endPrefixMapping(namespaceName); } if (this.stack.empty()) { this.contentHandler.endDocument(); return; } } } catch (final EmptyStackException e) { fatalError("end tag at begining of document", this.lineNumber, this.columnNumber); } if (mixedContentLevel != -1) --mixedContentLevel; break; // change state to operand case emitCharacters: // emit characters buffer.flush(); break; // change state to operand case emitCharactersSave: // emit characters and save current character if (mixedContentLevel == -1) mixedContentLevel = 0; buffer.flush(); buffer.saveChar((char)currentChar); break; // change state to operand case possiblyEmitCharacters: // write any skipped whitespace if in mixed content if (mixedContentLevel != -1) buffer.flush(); break; // change state to operand case saveAttributeName: // save attribute name attributeName = buffer.getString(); break; // change state to operand case saveAttributeValue: { final String value = buffer.getString(); if (attributeName.equals("xmlns")) { this.stack.push(this.defaultNamespace); this.stack.push(""); this.defaultNamespace = value; this.contentHandler.startPrefixMapping("", value); } else if (attributeName.startsWith("xmlns:")) { final String namespaceName = attributeName.substring(6); this.stack.push(this.namespaces.put(namespaceName, value)); this.stack.push(namespaceName); this.contentHandler.startPrefixMapping(namespaceName, value); } else { final int colonIndex = attributeName.indexOf(':'); if (colonIndex != -1) { attributeURIs.addElement(attributeName.substring(0, colonIndex)); attributeLocalNames.addElement(attributeName.substring(colonIndex + 1)); } else { attributeURIs.addElement(null); attributeLocalNames.addElement(attributeName); } attributeQNames.addElement(attributeName); attributeValues.addElement(value); } break; // change state to operand } case startComment: // change state if we have found "<!--" if (buffer.read() != '-') continue; // not "<!--" break; // change state to operand case endComment: // change state if we find "-->" if ((currentChar = buffer.read()) == '-') { // deal with the case where we might have "------->" while ((currentChar = buffer.read()) == '-'); if (currentChar == '>') break; // end of comment, change state to operand } continue; // not end of comment, don't change state case incLevel: level++; break; case decLevel: if (level == 0) break; // outer level <> change state level--; continue; // in nested <>, don't change state case startCDATA: // change state if we have found "<![CDATA[" if (buffer.read() != 'C') continue; // don't change state if (buffer.read() != 'D') continue; // don't change state if (buffer.read() != 'A') continue; // don't change state if (buffer.read() != 'T') continue; // don't change state if (buffer.read() != 'A') continue; // don't change state if (buffer.read() != '[') continue; // don't change state break; // change state to operand case endCDATA: // change state if we find "]]>" if ((currentChar = buffer.read()) == ']') { // deal with the case where we might have "]]]]]]]>" while ((currentChar = buffer.read()) == ']') buffer.write(']'); if (currentChar == '>') break; // end of CDATA section, change state to operand buffer.write(']'); } buffer.write(']'); buffer.write(currentChar); continue; // not end of CDATA section, don't change state case processCharRef: // process character entity int crefState = 0; currentChar = buffer.read(); while (true) { if ("#amp;&pos;'quot;\"gt;>lt;<".charAt(crefState) == currentChar) { crefState++; if (currentChar == ';') { buffer.write("#amp;&pos;'quot;\"gt;>lt;<".charAt(crefState)); break; } else if (currentChar == '#') { final int radix; currentChar = buffer.read(); if (currentChar == 'x') { radix = 16; currentChar = buffer.read(); } 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.contentHandler = this.extContentHandler = this; this.errorHandler = this; this.stack.removeAllElements(); this.namespaces.clear(); this.defaultNamespace = ""; } } 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{ String str=source.getSystemId(); HttpConnection hc=null; InputStream is=null; try{ hc=(HttpConnection)(Connector.open(str)); hc.setRequestMethod(HttpConnection.GET); hc.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0"); is=hc.openDataInputStream(); parse(new InputStreamReader(is)); }finally { is.close(); hc.close(); } } } public void parse(final String systemId) throws SAXException, IOException { parse(new InputSource(systemId)); } public void setContentHandler(final org.xml.sax.ContentHandler handler) { if (this.contentHandler == null) throw new NullPointerException(); this.contentHandler = handler; } public void setContentHandler(final ContentHandler handler) { contentHandler = this.extContentHandler = (handler == null) ? this : handler; this.contentHandler.setDocumentLocator(this); } public org.xml.sax.ContentHandler getContentHandler() { return this.contentHandler; } public void setErrorHandler(final ErrorHandler handler) { this.errorHandler = (handler == null) ? this : handler; } public ErrorHandler getErrorHandler() { return this.errorHandler; } public void setDocumentLocator(final Locator locator) { }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -