class XMLSocketWriter extends XMLWriter {

    private SocketConnection connection;

    public XMLSocketWriter(Writer writer, SocketConnection connection) {
        super( writer, DEFAULT_FORMAT );
        this.connection = connection;
    }

    /**
     * Flushes the underlying writer making sure that if the connection is dead then the thread
     * that is flushing does not end up in an endless wait.
     *
     * @throws IOException if an I/O error occurs while flushing the writer.
     */
    @Override
    public void flush() throws IOException {<FILL_FUNCTION_BODY>}
}

        // Register that we have started sending data
        connection.writeStarted();
        try {
            super.flush();
        }
        finally {
            // Register that we have finished sending data
            connection.writeFinished();
        }
    
<methods>public void <init>(java.io.Writer) ,public void <init>(java.io.Writer, OutputFormat) ,public void <init>() throws java.io.UnsupportedEncodingException,public void <init>(java.io.OutputStream) throws java.io.UnsupportedEncodingException,public void <init>(java.io.OutputStream, OutputFormat) throws java.io.UnsupportedEncodingException,public void <init>(OutputFormat) throws java.io.UnsupportedEncodingException,public void characters(char[], int, int) throws org.xml.sax.SAXException,public void close() throws java.io.IOException,public void comment(char[], int, int) throws org.xml.sax.SAXException,public void endCDATA() throws org.xml.sax.SAXException,public void endDTD() throws org.xml.sax.SAXException,public void endDocument() throws org.xml.sax.SAXException,public void endElement(java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void endEntity(java.lang.String) throws org.xml.sax.SAXException,public void endPrefixMapping(java.lang.String) throws org.xml.sax.SAXException,public void flush() throws java.io.IOException,public org.xml.sax.ext.LexicalHandler getLexicalHandler() ,public int getMaximumAllowedCharacter() ,public java.lang.Object getProperty(java.lang.String) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException,public void ignorableWhitespace(char[], int, int) throws org.xml.sax.SAXException,public boolean isEscapeText() ,public void notationDecl(java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void parse(org.xml.sax.InputSource) throws java.io.IOException, org.xml.sax.SAXException,public void println() throws java.io.IOException,public void processingInstruction(java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public boolean resolveEntityRefs() ,public void setDocumentLocator(org.xml.sax.Locator) ,public void setEscapeText(boolean) ,public void setIndentLevel(int) ,public void setLexicalHandler(org.xml.sax.ext.LexicalHandler) ,public void setMaximumAllowedCharacter(int) ,public void setOutputStream(java.io.OutputStream) throws java.io.UnsupportedEncodingException,public void setProperty(java.lang.String, java.lang.Object) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException,public void setResolveEntityRefs(boolean) ,public void setWriter(java.io.Writer) ,public void startCDATA() throws org.xml.sax.SAXException,public void startDTD(java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void startDocument() throws org.xml.sax.SAXException,public void startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) throws org.xml.sax.SAXException,public void startEntity(java.lang.String) throws org.xml.sax.SAXException,public void startPrefixMapping(java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void write(Attribute) throws java.io.IOException,public void write(Document) throws java.io.IOException,public void write(Element) throws java.io.IOException,public void write(CDATA) throws java.io.IOException,public void write(Comment) throws java.io.IOException,public void write(DocumentType) throws java.io.IOException,public void write(Entity) throws java.io.IOException,public void write(Namespace) throws java.io.IOException,public void write(ProcessingInstruction) throws java.io.IOException,public void write(java.lang.String) throws java.io.IOException,public void write(Text) throws java.io.IOException,public void write(Node) throws java.io.IOException,public void write(java.lang.Object) throws java.io.IOException,public void writeClose(Element) throws java.io.IOException,public void writeOpen(Element) throws java.io.IOException<variables>protected static final OutputFormat DEFAULT_FORMAT,protected static final java.lang.String[] LEXICAL_HANDLER_NAMES,private static final Logger Log,private static final java.lang.String PAD_TEXT,private boolean autoFlush,private java.lang.StringBuilder buffer,private boolean charactersAdded,private boolean escapeText,private OutputFormat format,private boolean inDTD,private int indentLevel,private char lastChar,protected int lastOutputNodeType,private org.xml.sax.ext.LexicalHandler lexicalHandler,private int maximumAllowedCharacter,private NamespaceStack namespaceStack,private Map<java.lang.String,java.lang.String> namespacesMap,protected boolean preserve,private boolean resolveEntityRefs,private boolean showCommentsInDTDs,protected java.io.Writer writer