/src/com/google/appengine/datanucleus/SerializationStrategy.java

http://datanucleus-appengine.googlecode.com/ · Java · 45 lines · 6 code · 4 blank · 35 comment · 0 complexity · af0952af1a69b4514511fe86b4ae1521 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus;
  14. import com.google.appengine.api.datastore.Blob;
  15. /**
  16. * A strategy for serializing objects to the datastore.
  17. *
  18. * This class is part of the public interface of the DataNucleus App Engine
  19. * Plugin and can be safely referenced in user code.
  20. *
  21. * @author Max Ross <maxr@google.com>
  22. */
  23. public interface SerializationStrategy {
  24. /**
  25. * Transforms the given object into a {@link Blob}.
  26. * @param obj The object to be transformed.
  27. * @return The {@link Blob} representation of the given object.
  28. */
  29. Blob serialize(Object obj);
  30. /**
  31. * Transforms the given blob into an object of the given class.
  32. * @param blob The blob to be transformed.
  33. * @param targetClass The class of the object into which the blob should be
  34. * transformed.
  35. * @return The <code>targetClass</code> representation of the given blob.
  36. */
  37. Object deserialize(Blob blob, Class<?> targetClass);
  38. }