PacketHistory.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 it under
  13. * the terms of the GNU General Public License as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option) any later
  15. * version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License along with
  23. * this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. package com.l2jserver.gameserver;
  26. import java.util.Date;
  27. import java.util.Map;
  28. import javolution.xml.XMLFormat;
  29. import javolution.xml.stream.XMLStreamException;
  30. class PacketHistory
  31. {
  32. protected Map<Class<?>, Long> _info;
  33. protected long _timeStamp;
  34. protected static final XMLFormat<PacketHistory> PACKET_HISTORY_XML = new XMLFormat<PacketHistory>(PacketHistory.class)
  35. {
  36. @Override
  37. public void read(InputElement xml, PacketHistory packetHistory) throws XMLStreamException
  38. {
  39. packetHistory._timeStamp = xml.getAttribute("time-stamp", 0);
  40. packetHistory._info = xml.<Map<Class<?>, Long>> get("info");
  41. }
  42. @Override
  43. public void write(PacketHistory packetHistory, OutputElement xml) throws XMLStreamException
  44. {
  45. xml.setAttribute("time-stamp", new Date(packetHistory._timeStamp).toString());
  46. for (Class<?> cls : packetHistory._info.keySet())
  47. xml.setAttribute(cls.getSimpleName(), packetHistory._info.get(cls));
  48. }
  49. // public void format(PacketHistory packetHistory, XmlElement xml)
  50. // {
  51. // xml.setAttribute("time-stamp", new Date(packetHistory.timeStamp).toString());
  52. //
  53. // for (Class cls : packetHistory.info.keySet())
  54. // {
  55. // xml.setAttribute(cls.getSimpleName(), packetHistory.info.get(cls));
  56. // }
  57. // }
  58. //
  59. // public PacketHistory parse(XmlElement xml)
  60. // {
  61. // PacketHistory packetHistory = new PacketHistory();
  62. // packetHistory.timeStamp = xml.getAttribute("time-stamp", (long) 0);
  63. // packetHistory.info = xml.<Map<Class, Long>> get("info");
  64. // return packetHistory;
  65. // }
  66. //
  67. // public String defaultName()
  68. // {
  69. // return "packet-history";
  70. // }
  71. };
  72. }