PacketHistory.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /**
  37. * @see javolution.xml.XMLFormat#read(javolution.xml.XMLFormat.InputElement, java.lang.Object)
  38. */
  39. @Override
  40. public void read(InputElement xml, PacketHistory packetHistory) throws XMLStreamException
  41. {
  42. packetHistory._timeStamp = xml.getAttribute("time-stamp", 0);
  43. packetHistory._info = xml.<Map<Class<?>, Long>> get("info");
  44. }
  45. /**
  46. * @see javolution.xml.XMLFormat#write(java.lang.Object, javolution.xml.XMLFormat.OutputElement)
  47. */
  48. @Override
  49. public void write(PacketHistory packetHistory, OutputElement xml) throws XMLStreamException
  50. {
  51. // TODO Auto-generated method stub
  52. xml.setAttribute("time-stamp", new Date(packetHistory._timeStamp).toString());
  53. for (Class<?> cls : packetHistory._info.keySet())
  54. xml.setAttribute(cls.getSimpleName(), packetHistory._info.get(cls));
  55. }
  56. // public void format(PacketHistory packetHistory, XmlElement xml)
  57. // {
  58. // xml.setAttribute("time-stamp", new Date(packetHistory.timeStamp).toString());
  59. //
  60. // for (Class cls : packetHistory.info.keySet())
  61. // {
  62. // xml.setAttribute(cls.getSimpleName(), packetHistory.info.get(cls));
  63. // }
  64. // }
  65. //
  66. // public PacketHistory parse(XmlElement xml)
  67. // {
  68. // PacketHistory packetHistory = new PacketHistory();
  69. // packetHistory.timeStamp = xml.getAttribute("time-stamp", (long) 0);
  70. // packetHistory.info = xml.<Map<Class, Long>> get("info");
  71. // return packetHistory;
  72. // }
  73. //
  74. // public String defaultName()
  75. // {
  76. // return "packet-history";
  77. // }
  78. };
  79. }