📄 mobileimpl.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.mobiles;// 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 MobileImpl extends DefaultHandler implements Cloneable, Unmarshallable, LexicalHandler, Mobile { private String name; private boolean zeus_NameSet; private String number; private boolean zeus_NumberSet; /** 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 MobileImpl prototype = null; public static void setPrototype(MobileImpl prototype) { MobileImpl.prototype = prototype; } public static MobileImpl newInstance() { try { return (prototype!=null)?(MobileImpl)prototype.clone(): new MobileImpl(); } catch (CloneNotSupportedException e) { return null; // never } } public MobileImpl() { zeus_NameSet = false; zeus_NumberSet = false; docTypeString = ""; hasDTD = false; validate = false; namespaceMappings = new HashMap(); } public String getName() { if(name == null) return ""; else return name; } public void setName(String name) { this.name = name; zeus_NameSet = true; } public String getNumber() { if(number == null) return ""; else return number; } public void setNumber(String number) { this.number = number; zeus_NumberSet = true; } 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("<Mobile"); // 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) if (zeus_NameSet) { writer.write(" name=\""); writer.write(escapeAttributeValue(name)); writer.write("\""); } if (zeus_NumberSet) { writer.write(" number=\""); writer.write(escapeAttributeValue(number)); writer.write("\""); } writer.write("/>\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. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -