PacketHistory.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * $Header: PacketHistory.java, 27/11/2005 01:57:03 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 27/11/2005 01:57:03 $
  6. * $Revision: 1 $
  7. * $Log: PacketHistory.java,v $
  8. * Revision 1 27/11/2005 01:57:03 luisantonioa
  9. * Added copyright notice
  10. *
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  25. * 02111-1307, USA.
  26. *
  27. * http://www.gnu.org/copyleft/gpl.html
  28. */
  29. package net.sf.l2j.gameserver;
  30. import java.util.Date;
  31. import java.util.Map;
  32. import javolution.xml.XMLFormat;
  33. import javolution.xml.stream.XMLStreamException;
  34. class PacketHistory
  35. {
  36. protected Map<Class<?>, Long> _info;
  37. protected long _timeStamp;
  38. protected static final XMLFormat<PacketHistory> PACKET_HISTORY_XML = new XMLFormat<PacketHistory>(PacketHistory.class)
  39. {
  40. /**
  41. * @see javolution.xml.XMLFormat#read(javolution.xml.XMLFormat.InputElement, java.lang.Object)
  42. */
  43. @Override
  44. public void read(InputElement xml, PacketHistory packetHistory) throws XMLStreamException
  45. {
  46. packetHistory._timeStamp = xml.getAttribute("time-stamp", 0);
  47. packetHistory._info = xml.<Map<Class<?>, Long>> get("info");
  48. }
  49. /**
  50. * @see javolution.xml.XMLFormat#write(java.lang.Object, javolution.xml.XMLFormat.OutputElement)
  51. */
  52. @Override
  53. public void write(PacketHistory packetHistory, OutputElement xml) throws XMLStreamException
  54. {
  55. // TODO Auto-generated method stub
  56. xml.setAttribute("time-stamp", new Date(packetHistory._timeStamp).toString());
  57. for (Class<?> cls : packetHistory._info.keySet())
  58. xml.setAttribute(cls.getSimpleName(), packetHistory._info.get(cls));
  59. }
  60. // public void format(PacketHistory packetHistory, XmlElement xml)
  61. // {
  62. // xml.setAttribute("time-stamp", new Date(packetHistory.timeStamp).toString());
  63. //
  64. // for (Class cls : packetHistory.info.keySet())
  65. // {
  66. // xml.setAttribute(cls.getSimpleName(), packetHistory.info.get(cls));
  67. // }
  68. // }
  69. //
  70. // public PacketHistory parse(XmlElement xml)
  71. // {
  72. // PacketHistory packetHistory = new PacketHistory();
  73. // packetHistory.timeStamp = xml.getAttribute("time-stamp", (long) 0);
  74. // packetHistory.info = xml.<Map<Class, Long>> get("info");
  75. // return packetHistory;
  76. // }
  77. //
  78. // public String defaultName()
  79. // {
  80. // return "packet-history";
  81. // }
  82. };
  83. }