/* * $Header: Test.java, 19/11/2005 00:57:51 luisantonioa Exp $ * * $Author: luisantonioa $ * $Date: 19/11/2005 00:57:51 $ * $Revision: 1 $ * $Log: Test.java,v $ * Revision 1 19/11/2005 00:57:51 luisantonioa * Added copyright notice * * * 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, 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. * * http://www.gnu.org/copyleft/gpl.html */ package net.sf.l2j.gameserver.model.inventory; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import javolution.xml.ObjectReader; import javolution.xml.ObjectWriter; import javolution.xml.XmlFormat; /** * This class ... * * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $ */ public class Test { protected static final javolution.xml.XmlFormat TEST_XML = new javolution.xml.XmlFormat(Test.class) { public void format( Test test, javolution.xml.XmlElement xml) { xml.setAttribute("item-id", test.itemID); xml.setAttribute("object-id", test.objectID); xml.setAttribute("count", test.count); xml.setAttribute("enchant-level", test.enchantLevel); xml.setAttribute("price", test.price); } public Test parse( javolution.xml.XmlElement xml) { Test test = (Test) xml.object(); test.itemID = xml.getAttribute("item-id", 0); test.objectID = xml.getAttribute("object-id", 0); test.count = xml.getAttribute("count", 0); test.enchantLevel = xml.getAttribute("enchant-level", 0); test.price = xml.getAttribute("price", 0); return test; } public String defaultName() { return "test"; } }; int itemID; int objectID; int count; int enchantLevel; int price; public static void main(String[] args) throws FileNotFoundException, IOException { Test t = new Test(); t.itemID = 1223; t.objectID = 432432343; t.count = 1; t.enchantLevel = 1; t.price = 1200; XmlFormat.setAlias(Test.class, "Test"); ObjectWriter ow = new ObjectWriter(); ow.write(t, new FileOutputStream("test.xml")); ObjectReader or = new ObjectReader(); Test t2 = or.read(new FileInputStream("test.xml")); System.out.println(t2.enchantLevel); } }