PageRenderTime 23ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/goodworkalan/fossil/Fossil.java

https://github.com/defunct/fossil
Java | 62 lines | 19 code | 8 blank | 35 comment | 0 complexity | 251fdbda86bccd90a5e8efb271e989bb MD5 | raw file
  1. /* Copyright Alan Gutierrez 2006 */
  2. package com.goodworkalan.fossil;
  3. import com.goodworkalan.pack.Mutator;
  4. import com.goodworkalan.stash.Stash;
  5. /**
  6. * Static methods to initiate the type-safe container of out of band data with
  7. * fossil specific data.
  8. *
  9. * @author Alan Gutierrez
  10. *
  11. */
  12. public class Fossil
  13. {
  14. /**
  15. * The key to of the mutator in the type-safe collection of out of band
  16. * data.
  17. */
  18. final static Stash.Key MUTATOR = new Stash.Key();
  19. /** The size in bytes of a primitive short. */
  20. final static int SIZEOF_SHORT = Short.SIZE / Byte.SIZE;
  21. /** The size in bytes of a primitive integer. */
  22. final static int SIZEOF_INTEGER = Integer.SIZE / Byte.SIZE;
  23. /** The size in bytes of a primitive long. */
  24. final static int SIZEOF_LONG = Long.SIZE / Byte.SIZE;
  25. /**
  26. * Add the given mutator to the given type-safe container of out of band
  27. * data so that it can be retrieved by the classes in the fossil package.
  28. *
  29. * @param stash
  30. * A type-safe container of out of band data.
  31. * @param mutator
  32. * A pack file mutator.
  33. * @return The given type-safe container of out of band data.
  34. */
  35. public static Stash initialize(Stash stash, Mutator mutator)
  36. {
  37. stash.put(MUTATOR, Mutator.class, mutator);
  38. return stash;
  39. }
  40. /**
  41. * Create type-safe container of out of band data and add the given mutator
  42. * so that it can be retrieved by the classes in the fossil package.
  43. *
  44. * @param mutator
  45. * A pack file mutator.
  46. * @return The a new type-safe container of out of band data containing the
  47. * mutator.
  48. */
  49. public static Stash newStash(Mutator mutator)
  50. {
  51. return initialize(new Stash(), mutator);
  52. }
  53. }
  54. /* vim: set et sw=4 ts=4 ai tw=80 nowrap: */