⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guioptionimpl.java

📁 java写的qq代码实现qq的部分功能
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                returnValue = new StringBuffer()                    .append(returnValue.substring(0, i))                    .append("&amp;")                    .append(returnValue.substring(i+1))                    .toString();            } else if (ch == '>') {                returnValue = new StringBuffer()                    .append(returnValue.substring(0, i))                    .append("&gt;")                    .append(returnValue.substring(i+1))                    .toString();            }        }        return returnValue;    }    /**     * <p>     *  This sets a SAX <code>EntityResolver</code> for this unmarshalling process.     * </p>     *     * @param resolver the entity resolver to use.     */    public static void setEntityResolver(EntityResolver resolver) {        entityResolver = resolver;    }    /**     * <p>     *  This sets a SAX <code>ErrorHandler</code> for this unmarshalling process.     * </p>     *     * @param handler the entity resolver to use.     */    public static void setErrorHandler(ErrorHandler handler) {        errorHandler = handler;    }    public static String getInputEncoding(BufferedReader reader) throws IOException {        String inputEncoding = "utf-8";        String aLine = null;        while ( (aLine = reader.readLine()) != null ) {            aLine = aLine.trim().toLowerCase();            if (aLine.length() == 0)                continue;            if (!aLine.startsWith("<"))                break;            aLine = aLine.substring(1).trim();            if (!aLine.startsWith("?"))                break;            int index = aLine.indexOf("encoding");            if (index == -1)                break;            aLine = aLine.substring(index+8).trim();            if (!aLine.startsWith("="))                break;            aLine = aLine.substring(1).trim();            if (!aLine.startsWith("\""))                break;            if (aLine.indexOf("\"", 1) == -1)                break;            inputEncoding = aLine.substring(1, aLine.indexOf("\"", 1));            break;        }        reader.close();        return inputEncoding;    }    public static GUIOption unmarshal(File file) throws IOException {        // Delegate to the unmarshal(Reader) method        String encoding = getInputEncoding( new BufferedReader(new InputStreamReader(new FileInputStream(file), "ISO-8859-1")) );        return unmarshal(new InputStreamReader(new FileInputStream(file), encoding));    }    public static GUIOption unmarshal(File file, boolean validate) throws IOException {        // Delegate to the unmarshal(Reader) method        String encoding = getInputEncoding( new BufferedReader(new InputStreamReader(new FileInputStream(file), "ISO-8859-1")) );        return unmarshal(new InputStreamReader(new FileInputStream(file), encoding), validate);    }    public static GUIOption unmarshal(InputStream inputStream) throws IOException {        // Delegate to the unmarshal(Reader) method                String encoding = getInputEncoding( new BufferedReader(new InputStreamReader(inputStream, "ISO-8859-1")) );        return unmarshal(new InputStreamReader(inputStream, encoding));    }    public static GUIOption unmarshal(InputStream inputStream, boolean validate) throws IOException {        // Delegate to the unmarshal(Reader) method                String encoding = getInputEncoding( new BufferedReader(new InputStreamReader(inputStream, "ISO-8859-1")) );        return unmarshal(new InputStreamReader(inputStream, encoding), validate);    }    public static GUIOption unmarshal(Reader reader) throws IOException {        // Delegate with default validation value        return unmarshal(reader, false);    }    public static GUIOption unmarshal(Reader reader, boolean validate) throws IOException {        GUIOptionImpl gUIOption = GUIOptionImpl.newInstance();        gUIOption.setValidating(validate);        gUIOption.setCurrentUNode(gUIOption);        gUIOption.setParentUNode(null);        // Load the XML parser        XMLReader parser = null;        String parserClass = System.getProperty("org.xml.sax.driver",            "org.apache.xerces.parsers.SAXParser");        try {            parser = XMLReaderFactory.createXMLReader(parserClass);            // Set entity resolver, if needed            if (entityResolver != null) {                parser.setEntityResolver(entityResolver);            }            // Set error handler            parser.setErrorHandler(gUIOption);            // Register lexical handler            parser.setProperty("http://xml.org/sax/properties/lexical-handler", gUIOption);            // Register content handler            parser.setContentHandler(gUIOption);        } catch (SAXException e) {            throw new IOException("Could not load XML parser: " +                 e.getMessage());        }        InputSource inputSource = new InputSource(reader);        try {            parser.setFeature("http://xml.org/sax/features/validation", new Boolean(validate).booleanValue());            parser.setFeature("http://xml.org/sax/features/namespaces", true);            parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);            parser.parse(inputSource);        } catch (SAXException e) {            throw new IOException("Error parsing XML document: " +                 e.getMessage());        }        // Return the resultant object        return gUIOption;    }    public Unmarshallable getParentUNode() {        return zeus_parentUNode;    }    public void setParentUNode(Unmarshallable parentUNode) {        this.zeus_parentUNode = parentUNode;    }    public Unmarshallable getCurrentUNode() {        return zeus_currentUNode;    }    public void setCurrentUNode(Unmarshallable currentUNode) {        this.zeus_currentUNode = currentUNode;    }    public void setValidating(boolean validate) {        this.validate = validate;    }    public void startDocument() throws SAXException {        // no-op    }    public void setDocumentLocator(Locator locator) {        // no-op    }    public void startPrefixMapping(String prefix, String uri)        throws SAXException {        namespaceMappings.put(prefix, uri);    }    public void startElement(String namespaceURI, String localName,                             String qName, org.xml.sax.Attributes atts)        throws SAXException {        // Feed this to the correct ContentHandler        Unmarshallable current = getCurrentUNode();        if (current != this) {            current.startElement(namespaceURI, localName, qName, atts);            return;        }        // See if we handle, or we delegate        if ((localName.equals("GUIOption")) && (!zeus_thisNodeHandled)) {            // Handle ourselves            for (int i=0, len=atts.getLength(); i<len; i++) {                String attName= atts.getLocalName(i);                String attValue = atts.getValue(i);                if (attName.equals("blue")) {                    setBlue(attValue);                }                if (attName.equals("onlineTipLocationY")) {                    setOnlineTipLocationY(attValue);                }                if (attName.equals("onlineTipLocationX")) {                    setOnlineTipLocationX(attValue);                }                if (attName.equals("fontSize")) {                    setFontSize(attValue);                }                if (attName.equals("groupBackground")) {                    setGroupBackground(attValue);                }                if (attName.equals("italic")) {                    setItalic(attValue);                }                if (attName.equals("showOnlineTip")) {                    setShowOnlineTip(attValue);                }                if (attName.equals("red")) {                    setRed(attValue);                }                if (attName.equals("autoHide")) {                    setAutoHide(attValue);                }                if (attName.equals("showNick")) {                    setShowNick(attValue);                }                if (attName.equals("green")) {                    setGreen(attValue);                }                if (attName.equals("showOnlineOnly")) {                    setShowOnlineOnly(attValue);                }                if (attName.equals("locationY")) {                    setLocationY(attValue);                }                if (attName.equals("locationX")) {                    setLocationX(attValue);                }                if (attName.equals("fontName")) {                    setFontName(attValue);                }                if (attName.equals("height")) {                    setHeight(attValue);                }                if (attName.equals("bold")) {                    setBold(attValue);                }                if (attName.equals("width")) {                    setWidth(attValue);                }                if (attName.equals("showViewBar")) {                    setShowViewBar(attValue);                }                if (attName.equals("showTip")) {                    setShowTip(attValue);                }                if (attName.equals("smallFace")) {                    setSmallFace(attValue);                }            }            zeus_thisNodeHandled = true;            return;        } else {            // Delegate handling        }    }    public void endElement(String namespaceURI, String localName,                           String qName)        throws SAXException {        Unmarshallable current = getCurrentUNode();        if (current != this) {            current.endElement(namespaceURI, localName, qName);            return;        }        Unmarshallable parent = getCurrentUNode().getParentUNode();        if (parent != null) {            parent.setCurrentUNode(parent);        }    }    public void characters(char[] ch, int start, int len)        throws SAXException {        // Feed this to the correct ContentHandler        Unmarshallable current = getCurrentUNode();        if (current != this) {            current.characters(ch, start, len);            return;        }        String text = new String(ch, start, len);    }    public void comment(char ch[], int start, int len) throws SAXException {        // Currently no-op    }    public void warning(SAXParseException e) throws SAXException {        if (errorHandler != null) {            errorHandler.warning(e);        }    }    public void error(SAXParseException e) throws SAXException {        if ((validate) && (!hasDTD)) {            throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");        }        if (errorHandler != null) {            errorHandler.error(e);        }    }    public void fatalError(SAXParseException e) throws SAXException {        if ((validate) && (!hasDTD)) {            throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");        }        if (errorHandler != null) {            errorHandler.fatalError(e);        }    }    public void startDTD(String name, String publicID, String systemID)        throws SAXException {        if ((name == null) || (name.equals(""))) {            docTypeString = "";            return;        }        hasDTD = true;        StringBuffer docTypeSB = new StringBuffer();        boolean hasPublic = false;        docTypeSB.append("<!DOCTYPE ")                 .append(name);        if ((publicID != null) && (!publicID.equals(""))) {            docTypeSB.append(" PUBLIC \"")                     .append(publicID)                     .append("\"");            hasPublic = true;        }        if ((systemID != null) && (!systemID.equals(""))) {            if (!hasPublic) {                docTypeSB.append(" SYSTEM");            }            docTypeSB.append(" \"")                     .append(systemID)                     .append("\"");        }        docTypeSB.append(">");        docTypeString = docTypeSB.toString();    }    public void endDTD() throws SAXException {        // Currently no-op    }    public void startEntity(String name) throws SAXException {        // Currently no-op    }    public void endEntity(String name) throws SAXException {        // Currently no-op    }    public void startCDATA() throws SAXException {        // Currently no-op    }    public void endCDATA() throws SAXException {        // Currently no-op    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -