CompiledScriptHolder.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.scripting;
  16. import java.io.File;
  17. import java.io.Serializable;
  18. import javax.script.CompiledScript;
  19. /**
  20. *
  21. * @author KenM
  22. */
  23. public class CompiledScriptHolder implements Serializable
  24. {
  25. /**
  26. * Version 1
  27. */
  28. private static final long serialVersionUID = 1L;
  29. private long _lastModified;
  30. private long _size;
  31. private CompiledScript _compiledScript;
  32. /**
  33. * @param compiledScript
  34. * @param lastModified
  35. * @param size
  36. */
  37. public CompiledScriptHolder(CompiledScript compiledScript, long lastModified, long size)
  38. {
  39. _compiledScript = compiledScript;
  40. _lastModified = lastModified;
  41. _size = size;
  42. }
  43. public CompiledScriptHolder(CompiledScript compiledScript, File scriptFile)
  44. {
  45. this(compiledScript, scriptFile.lastModified(), scriptFile.length());
  46. }
  47. /**
  48. * @return Returns the lastModified.
  49. */
  50. public long getLastModified()
  51. {
  52. return _lastModified;
  53. }
  54. /**
  55. * @param lastModified The lastModified to set.
  56. */
  57. public void setLastModified(long lastModified)
  58. {
  59. _lastModified = lastModified;
  60. }
  61. /**
  62. * @return Returns the size.
  63. */
  64. public long getSize()
  65. {
  66. return _size;
  67. }
  68. /**
  69. * @param size The size to set.
  70. */
  71. public void setSize(long size)
  72. {
  73. _size = size;
  74. }
  75. /**
  76. * @return Returns the compiledScript.
  77. */
  78. public CompiledScript getCompiledScript()
  79. {
  80. return _compiledScript;
  81. }
  82. /**
  83. * @param compiledScript The compiledScript to set.
  84. */
  85. public void setCompiledScript(CompiledScript compiledScript)
  86. {
  87. _compiledScript = compiledScript;
  88. }
  89. public boolean matches(File f)
  90. {
  91. return f.lastModified() == this.getLastModified() && f.length() == this.getSize();
  92. }
  93. }