📄 optionsimpl.java
字号:
/** * 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.sysopts;// Global Implementation Import Statementsimport 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;public class OptionsImpl extends DefaultHandler implements Cloneable, Unmarshallable, LexicalHandler, Options { private LoginOption loginOption; private GUIOption gUIOption; private MessageOption messageOption; private OtherOption otherOption; private SyncOption syncOption; /** 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 OptionsImpl prototype = null; public static void setPrototype(OptionsImpl prototype) { OptionsImpl.prototype = prototype; } public static OptionsImpl newInstance() { try { return (prototype!=null)?(OptionsImpl)prototype.clone(): new OptionsImpl(); } catch (CloneNotSupportedException e) { return null; // never } } public OptionsImpl() { docTypeString = ""; hasDTD = false; validate = false; namespaceMappings = new HashMap(); } public LoginOption getLoginOption() { return loginOption; } public void setLoginOption(LoginOption loginOption) { this.loginOption = loginOption; } public GUIOption getGUIOption() { return gUIOption; } public void setGUIOption(GUIOption gUIOption) { this.gUIOption = gUIOption; } public MessageOption getMessageOption() { return messageOption; } public void setMessageOption(MessageOption messageOption) { this.messageOption = messageOption; } public OtherOption getOtherOption() { return otherOption; } public void setOtherOption(OtherOption otherOption) { this.otherOption = otherOption; } public SyncOption getSyncOption() { return syncOption; } public void setSyncOption(SyncOption syncOption) { this.syncOption = syncOption; } 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("<Options"); // 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 if (loginOption != null) { ((LoginOptionImpl)loginOption).writeXMLRepresentation(writer, new StringBuffer(indent).append(" ").toString()); } if (gUIOption != null) { ((GUIOptionImpl)gUIOption).writeXMLRepresentation(writer, new StringBuffer(indent).append(" ").toString()); } if (messageOption != null) { ((MessageOptionImpl)messageOption).writeXMLRepresentation(writer, new StringBuffer(indent).append(" ").toString()); } if (otherOption != null) { ((OtherOptionImpl)otherOption).writeXMLRepresentation(writer, new StringBuffer(indent).append(" ").toString()); } if (syncOption != null) { ((SyncOptionImpl)syncOption).writeXMLRepresentation(writer, new StringBuffer(indent).append(" ").toString()); } writer.write(indent); writer.write("</Options>\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(""") .append(returnValue.substring(i+1)) .toString(); } else if (ch == '&') { 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(">") .append(returnValue.substring(i+1)) .toString(); } else if (ch == '<') { returnValue = new StringBuffer() .append(returnValue.substring(0, i)) .append("<") .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("<") .append(returnValue.substring(i+1)) .toString(); } else if (ch == '&') { 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(">") .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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -