Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.connector.store.jpa.util
Class Serializer

    java.lang.Object
      org.modeshape.connector.store.jpa.util.Serializer

    public class Serializer

extends Object

A class that is responsible for serializing and deserializing properties.

Nested Class Summary
`static interface` | `Serializer.LargeValues` Interface that represents the location where "large" objects are stored.
`protected static class` | `Serializer.NoLargeValues`
`protected static class` | `Serializer.NoReferenceValues`
`static interface` | `Serializer.ReferenceValues` Interface used to record how Reference values are processed during serialization and deserialization.

Field Summary
`static Serializer.LargeValues` | `NO_LARGE_VALUES`
`static Serializer.ReferenceValues` | `NO_REFERENCES_VALUES`

Constructor Summary
`Serializer(ExecutionContext context, boolean excludeUuidProperty)`

Method Summary
`void` | `adjustReferenceProperties(ObjectInputStream input, ObjectOutputStream output, Map<String,String> oldUuidToNewUuid)` Deserialize the properties, adjust all `Reference` values that point to an "old" UUID to point to the corresponding "new" UUID, and reserialize the properties.
`byte[]` | `computeHash(String value)`
`void` | `deserializeAllProperties(ObjectInputStream stream, Collection<Property> properties, Serializer.LargeValues largeValues)` Deserialize the serialized properties on the supplied object stream.
`Property` | `deserializeProperty(ObjectInputStream stream, Serializer.LargeValues largeValues)` Deserialize the serialized property on the supplied object stream.
`Object[]` | `deserializePropertyValues(ObjectInputStream stream, Name propertyName, boolean skip, Serializer.LargeValues largeValues, Serializer.LargeValues skippedLargeValues, Serializer.ReferenceValues references)` Deserialize the serialized property on the supplied object stream.
`void` | `deserializeSomeProperties(ObjectInputStream stream, Collection<Property> properties, Serializer.LargeValues largeValues, Serializer.LargeValues skippedLargeValues, Name... names)` Deserialize the serialized properties on the supplied object stream.
`int` | `reserializeProperties(ObjectInputStream input, ObjectOutputStream output, Map<Name,Property> updatedProperties, Serializer.LargeValues largeValues, Serializer.LargeValues removedLargeValues, Set<Name> createdProperties, Serializer.ReferenceValues references)` Deserialize the existing properties from the supplied input stream, update the properties, and then serialize the updated properties to the output stream.
`void` | `serializeProperties(ObjectOutputStream stream, int number, Iterable<Property> properties, Serializer.LargeValues largeValues, Serializer.ReferenceValues references)` Serialize the properties' values to the object stream.
`boolean` | `serializeProperty(ObjectOutputStream stream, Property property, Serializer.LargeValues largeValues, Serializer.ReferenceValues references)` Serialize the property's values to the object stream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NO_LARGE_VALUES

    public static final Serializer.LargeValues NO_LARGE_VALUES

### NO_REFERENCES_VALUES

    public static final Serializer.ReferenceValues NO_REFERENCES_VALUES

Constructor Detail

### Serializer

    public Serializer(ExecutionContext context,
                      boolean excludeUuidProperty)

Method Detail

### serializeProperties

    public void serializeProperties(ObjectOutputStream stream,
                                    int number,
                                    Iterable<Property> properties,
                                    Serializer.LargeValues largeValues,
                                    Serializer.ReferenceValues references)
                             throws IOException

  Serialize the properties' values to the object stream.

  If any of the property values are considered `large`, the value's hash and length of the property value will be written to the object stream, but the property value will be sent to the supplied `LargeValueEntity` object.

  This method does not automatically write each property value to the stream using `ObjectOutputStream.writeObject(Object)`, but instead serializes the primitive values that make up the property value object with a code that describes the `property's type`. This is more efficient, since most of the property values are really non-primitive objects, and writing to the stream using `ObjectOutputStream.writeObject(Object)` would include larger class metadata.

  Parameters:
    `stream` - the stream where the properties' values are to be serialized; may not be null
    `number` - the number of properties exposed by the supplied `properties` iterator; must be 0 or positive
    `properties` - the iterator over the properties that are to be serialized; may not be null
    `largeValues` - the interface to use for writing large values; may not be null
    `references` - the interface to use for recording which `Reference` values were found during serialization, or null if the references do not need to be accumulated
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
  See Also:
    `deserializeAllProperties(ObjectInputStream, Collection, LargeValues)`, `deserializeSomeProperties(ObjectInputStream, Collection, LargeValues, LargeValues, Name...)`, `serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)`

### serializeProperty

    public boolean serializeProperty(ObjectOutputStream stream,
                                     Property property,
                                     Serializer.LargeValues largeValues,
                                     Serializer.ReferenceValues references)
                              throws IOException

  Serialize the property's values to the object stream.

  If any of the property values are considered `large`, the value's hash and length of the property value will be written to the object stream, but the property value will be sent to the supplied `LargeValueEntity` object.

  This method does not automatically write each property value to the stream using `ObjectOutputStream.writeObject(Object)`, but instead serializes the primitive values that make up the property value object with a code that describes the `property's type`. This is more efficient, since most of the property values are really non-primitive objects, and writing to the stream using `ObjectOutputStream.writeObject(Object)` would include larger class metadata.

  Parameters:
    `stream` - the stream where the property's values are to be serialized; may not be null
    `property` - the property to be serialized; may not be null
    `largeValues` - the interface to use for writing large values; may not be null
    `references` - the interface to use for recording which `Reference` values were found during serialization, or null if the references do not need to be accumulated
  Returns:
    true if the property was serialized, or false if it was not
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
  See Also:
    `serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)`, `deserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)`

### reserializeProperties

    public int reserializeProperties(ObjectInputStream input,
                                     ObjectOutputStream output,
                                     Map<Name,Property> updatedProperties,
                                     Serializer.LargeValues largeValues,
                                     Serializer.LargeValues removedLargeValues,
                                     Set<Name> createdProperties,
                                     Serializer.ReferenceValues references)
                              throws IOException,
                                     ClassNotFoundException

  Deserialize the existing properties from the supplied input stream, update the properties, and then serialize the updated properties to the output stream.

  Parameters:
    `input` - the stream from which the existing properties are to be deserialized; may not be null
    `output` - the stream to which the updated properties are to be serialized; may not be null
    `updatedProperties` - the properties that are being updated (or removed, if there are no values); may not be null
    `largeValues` - the interface to use for writing large values; may not be null
    `removedLargeValues` - the interface to use for recording the large values that were removed; may not be null
    `createdProperties` - the set into which should be placed the names of the properties that were created; may not be null
    `references` - the interface to use for recording which `Reference` values were found during serialization, or null if the references do not need to be accumulated
  Returns:
    the number of properties
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found

### adjustReferenceProperties

    public void adjustReferenceProperties(ObjectInputStream input,
                                          ObjectOutputStream output,
                                          Map<String,String> oldUuidToNewUuid)
                                   throws IOException,
                                          ClassNotFoundException

  Deserialize the properties, adjust all `Reference` values that point to an "old" UUID to point to the corresponding "new" UUID, and reserialize the properties. If any reference is to a UUID not in the map, it is left untouched.

  This is an efficient method that (for the most part) reads from the input stream and directly writes to the output stream. The exception is when a Reference value is read, that Reference is attempted to be remapped to a new Reference and written in place of the old reference. (Of course, if the Reference is to a UUID that is not in the "old" to "new" map, the old is written directly.)

  Parameters:
    `input` - the stream from which the existing properties are to be deserialized; may not be null
    `output` - the stream to which the updated properties are to be serialized; may not be null
    `oldUuidToNewUuid` - the map of old-to-new UUIDs; may not be null
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found

### deserializeAllProperties

    public void deserializeAllProperties(ObjectInputStream stream,
                                         Collection<Property> properties,
                                         Serializer.LargeValues largeValues)
                                  throws IOException,
                                         ClassNotFoundException

  Deserialize the serialized properties on the supplied object stream.

  Parameters:
    `stream` - the stream that contains the serialized properties; may not be null
    `properties` - the collection into which each deserialized property is to be placed; may not be null
    `largeValues` - the interface to use for writing large values; may not be null
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found
  See Also:
    `deserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)`, `serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)`

### deserializeSomeProperties

    public void deserializeSomeProperties(ObjectInputStream stream,
                                          Collection<Property> properties,
                                          Serializer.LargeValues largeValues,
                                          Serializer.LargeValues skippedLargeValues,
                                          Name... names)
                                   throws IOException,
                                          ClassNotFoundException

  Deserialize the serialized properties on the supplied object stream.

  Parameters:
    `stream` - the stream that contains the serialized properties; may not be null
    `properties` - the collection into which each deserialized property is to be placed; may not be null
    `names` - the names of the properties that should be deserialized; should not be null or empty
    `largeValues` - the interface to use for writing large values; may not be null
    `skippedLargeValues` - the interface to use for recording the large values that were skipped; may not be null
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found
  See Also:
    `deserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)`, `serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)`

### deserializeProperty

    public Property deserializeProperty(ObjectInputStream stream,
                                        Serializer.LargeValues largeValues)
                                 throws IOException,
                                        ClassNotFoundException

  Deserialize the serialized property on the supplied object stream.

  Parameters:
    `stream` - the stream that contains the serialized properties; may not be null
    `largeValues` - the interface to use for writing large values; may not be null
  Returns:
    the deserialized property; never null
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found
  See Also:
    `deserializeAllProperties(ObjectInputStream, Collection, LargeValues)`, `serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)`

### deserializePropertyValues

    public Object[] deserializePropertyValues(ObjectInputStream stream,
                                              Name propertyName,
                                              boolean skip,
                                              Serializer.LargeValues largeValues,
                                              Serializer.LargeValues skippedLargeValues,
                                              Serializer.ReferenceValues references)
                                       throws IOException,
                                              ClassNotFoundException

  Deserialize the serialized property on the supplied object stream.

  Parameters:
    `stream` - the stream that contains the serialized properties; may not be null
    `propertyName` - the name of the property being deserialized
    `skip` - true if the values don't need to be read, or false if they are to be read
    `largeValues` - the interface to use for writing large values; may not be null
    `skippedLargeValues` - the interface to use for recording the large values that were skipped; may not be null
    `references` - the interface to use for recording which `Reference` values were found (and/or removed) during deserialization; may not be null
  Returns:
    the deserialized property values, or an empty list if there are no values
  Throws:
    `IOException` - if there is an error writing to the `stream` or `largeValues`
    `ClassNotFoundException` - if the class for the value's object could not be found
  See Also:
    `deserializeAllProperties(ObjectInputStream, Collection, LargeValues)`, `serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)`

### computeHash

    public byte[] computeHash(String value)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.