package nu.fw.jeti.backend; import java.util.Map; /* * Jeti, a Java Jabber client, Copyright (C) 2002 E.S. de Boer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For questions, comments etc, * use the website at http://jeti.jabberstudio.org * or mail/IM me at jeti@jabber.org */ public abstract class XMLDataFile { int tabDepth=0; public XMLDataFile() { } private void addTabs(StringBuffer xml) { xml.append("\r\n"); for(int i =0;itoString is a serializer for the data contained in the * object to an equivalent snippet of XML stream. * * @return a String value which contains the XML * representation of this object */ public String toString() { StringBuffer retval=new StringBuffer(); appendToXML(retval); return new String(retval); } /** * appendToXML appends the XML representation of the * current packet data to the specified StringBuffer. * * @param xml The StringBuffer to append to */ public abstract void appendToXML(StringBuffer xml); protected final void appendHeader(StringBuffer xml) { xml.append(""); } protected final void appendOpenTag(StringBuffer xml,String name) { //xml.append("\r\n"); addTabs(xml); tabDepth++; xml.append(name); } protected final void appendCloseTag(StringBuffer xml,String name) { //xml.append("\r\n"); tabDepth--; addTabs(xml); xml.append(name); } protected final void appendCloseSymbol(StringBuffer xml) { tabDepth--; xml.append("/>"); } protected final boolean appendElement(StringBuffer xml,String name,String value) { //xml.append("\r\n"); addTabs(xml); boolean result = HelpXMLData.appendElement(xml,name,value); //xml.append('\n'); return result; } protected final boolean appendElement(StringBuffer xml,String name,boolean value) { //xml.append("\r\n"); addTabs(xml); return HelpXMLData.appendElement(xml,name,value); } protected final boolean appendElement(StringBuffer xml,Map map) { //xml.append("\r\n"); addTabs(xml); return HelpXMLData.appendElement(xml,map); } protected final boolean appendAttribute(StringBuffer xml,String name,String value) { return HelpXMLData.appendAttribute(xml,name,value); } protected final boolean appendAttribute(StringBuffer xml,String name,Object value) { return HelpXMLData.appendAttribute(xml,name,value); } abstract static class HelpXMLData extends XMLData { } } /* * Overrides for emacs * Local variables: * tab-width: 4 * End: */