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

📄 proxiesimpl.java

📁 java写的qq代码实现qq的部分功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * This class was generated from a set of XML constraints
 *   by the Enhydra Zeus XML Data Binding Framework. All
 *   source code in this file is constructed specifically
 *   to work with other Zeus-generated classes. If you
 *   modify this file by hand, you run the risk of breaking
 *   this interoperation, as well as introducing errors in
 *   source code compilation.
 *
 * * * * * MODIFY THIS FILE AT YOUR OWN RISK * * * * *
 *
 * To find out more about the Enhydra Zeus framework, you
 *   can point your browser at <http://zeus.enhydra.org>
 *   where you can download releases, join and discuss Zeus
 *   on user and developer mailing lists, and access source
 *   code. Please report any bugs through that website.
 */
package edu.tsinghua.lumaqq.xml.proxies;

// Global Implementation Import Statements
import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;

// Local Implementation Import Statements
import java.util.List;
import java.util.LinkedList;

public class ProxiesImpl extends DefaultHandler implements Cloneable, Unmarshallable, LexicalHandler, Proxies {

    private List Socks5ProxyList;
    private List HttpProxyList;

    /** Any DOCTYPE reference/statements. */
    private String docTypeString;

    /** The encoding for the output document */
    private String outputEncoding;

    /** The current node in unmarshalling */
    private Unmarshallable zeus_currentUNode;

    /** The parent node in unmarshalling */
    private Unmarshallable zeus_parentUNode;

    /** Whether this node has been handled */
    private boolean zeus_thisNodeHandled = false;

    /** Whether a DTD exists for an unmarshal call */
    private boolean hasDTD;

    /** Whether validation is occurring */
    private boolean validate;

    /** The namespace mappings on this element */
    private Map namespaceMappings;

    /** The EntityResolver for SAX parsing to use */
    private static EntityResolver entityResolver;

    /** The ErrorHandler for SAX parsing to use */
    private static ErrorHandler errorHandler;

    private static ProxiesImpl prototype = null;

    public static void setPrototype(ProxiesImpl prototype) {
        ProxiesImpl.prototype = prototype;
    }
    public static ProxiesImpl newInstance() {
        try {
            return (prototype!=null)?(ProxiesImpl)prototype.clone(): new ProxiesImpl();
        } catch (CloneNotSupportedException e) {
            return null; // never
        }
    }
    public ProxiesImpl() {
        Socks5ProxyList = new LinkedList();
        HttpProxyList = new LinkedList();
        docTypeString = "";
        hasDTD = false;
        validate = false;
        namespaceMappings = new HashMap();
    }

    public List getSocks5ProxyList() {
        return Socks5ProxyList;
    }

    public void setSocks5ProxyList(List Socks5ProxyList) {
        this.Socks5ProxyList = Socks5ProxyList;
    }

    public void addSocks5Proxy(Socks5Proxy Socks5Proxy) {
        Socks5ProxyList.add(Socks5Proxy);
    }

    public void removeSocks5Proxy(Socks5Proxy Socks5Proxy) {
        Socks5ProxyList.remove(Socks5Proxy);
    }

    public List getHttpProxyList() {
        return HttpProxyList;
    }

    public void setHttpProxyList(List HttpProxyList) {
        this.HttpProxyList = HttpProxyList;
    }

    public void addHttpProxy(HttpProxy HttpProxy) {
        HttpProxyList.add(HttpProxy);
    }

    public void removeHttpProxy(HttpProxy HttpProxy) {
        HttpProxyList.remove(HttpProxy);
    }

    public void setDocType(String name, String publicID, String systemID) {
        try {
            startDTD(name, publicID, systemID);
        } catch (SAXException neverHappens) { }
    }

    public void setOutputEncoding(String outputEncoding) {
        this.outputEncoding = outputEncoding;
    }

    public void marshal(File file) throws IOException {
        // Delegate to the marshal(Writer) method
        if (outputEncoding != null) {
                marshal(new OutputStreamWriter(new FileOutputStream(file), outputEncoding));
        } else {
                marshal(new OutputStreamWriter(new FileOutputStream(file), "utf-8"));
        }
    }

    public void marshal(OutputStream outputStream) throws IOException {
        // Delegate to the marshal(Writer) method
        if (outputEncoding != null) {
                marshal(new OutputStreamWriter(outputStream, outputEncoding));
        } else {
                marshal(new OutputStreamWriter(outputStream, "utf-8"));
        }
    }

    public void marshal(Writer writer) throws IOException {
        // Write out the XML declaration
        writer.write("<?xml version=\"1.0\" ");
        if (outputEncoding != null) {
            writer.write("encoding=\"");
            writer.write(outputEncoding);
            writer.write("\"?>\n\n");

        } else {
            writer.write("encoding=\"UTF-8\"?>\n\n");

        }
        // Handle DOCTYPE declaration
        writer.write(docTypeString);
        writer.write("\n");
        // Now start the recursive writing
        writeXMLRepresentation(writer, "");

        // Close up
        writer.flush();
        writer.close();
    }

    protected void writeXMLRepresentation(Writer writer,
                                          String indent)
        throws IOException {

        writer.write(indent);
        writer.write("<Proxies");

        // Handle namespace mappings (if needed)
        for (Iterator i = namespaceMappings.keySet().iterator(); i.hasNext(); ) {
            String prefix = (String)i.next();
            String uri = (String)namespaceMappings.get(prefix);
            writer.write(" xmlns");
            if (!prefix.trim().equals("")) {
                writer.write(":");
                writer.write(prefix);
            }
            writer.write("=\"");
            writer.write(uri);
            writer.write("\"\n        ");
        }

        // Handle attributes (if needed)
        writer.write(">");
        writer.write("\n");

        // Handle child elements
        for (Iterator i=Socks5ProxyList.iterator(); i.hasNext(); ) {
            Socks5ProxyImpl socks5Proxy = (Socks5ProxyImpl)i.next();
            socks5Proxy.writeXMLRepresentation(writer,
                new StringBuffer(indent).append("  ").toString());
        }
        for (Iterator i=HttpProxyList.iterator(); i.hasNext(); ) {
            HttpProxyImpl httpProxy = (HttpProxyImpl)i.next();
            httpProxy.writeXMLRepresentation(writer,
                new StringBuffer(indent).append("  ").toString());
        }
        writer.write(indent);
        writer.write("</Proxies>\n");
    }

    private String escapeAttributeValue(String attributeValue) {
        String returnValue = attributeValue;
        for (int i = 0; i < returnValue.length(); i++) {
            char ch = returnValue.charAt(i);
            if (ch < 0x20) {
                if ( (ch != 0x09) && (ch != 0x0a) && (ch != 0x0d) ) {
                    returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append(' ')
                    .append(returnValue.substring(i+1))
                    .toString();
                }
            } else if (ch == '"') {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append("&quot;")
                    .append(returnValue.substring(i+1))
                    .toString();
            } else if (ch == '&') {
                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();
            } else if (ch == '<') {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append("&lt;")
                    .append(returnValue.substring(i+1))
                    .toString();
            }
        }
        return returnValue;
    }

    private String escapeTextValue(String textValue) {
        String returnValue = textValue;
        for (int i = 0; i < returnValue.length(); i++) {
            char ch = returnValue.charAt(i);
            if (ch < 0x20) {
                if ( (ch != 0x09) && (ch != 0x0a) && (ch != 0x0d) ) {
                    returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append(' ')
                    .append(returnValue.substring(i+1))
                    .toString();
                }
            } else if (ch == '<') {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append("&lt;")
                    .append(returnValue.substring(i+1))
                    .toString();
            } else if (ch == '&') {
                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.
     */

⌨️ 快捷键说明

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