|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.dna.connector.store.jpa.util.Serializer
public class Serializer
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. |
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Serializer.LargeValues NO_LARGE_VALUES
public static final Serializer.ReferenceValues NO_REFERENCES_VALUES
Constructor Detail |
---|
public Serializer(ExecutionContext context, boolean excludeUuidProperty)
Method Detail |
---|
public void serializeProperties(ObjectOutputStream stream, int number, Iterable<Property> properties, Serializer.LargeValues largeValues, Serializer.ReferenceValues references) throws IOException
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.
stream
- the stream where the properties' values are to be serialized; may not be nullnumber
- the number of properties exposed by the supplied properties
iterator; must be 0 or positiveproperties
- the iterator over the properties that are to be serialized; may not be nulllargeValues
- the interface to use for writing large values; may not be nullreferences
- the interface to use for recording which Reference
values were found during serialization, or
null if the references do not need to be accumulated
IOException
- if there is an error writing to the stream
or largeValues
deserializeAllProperties(ObjectInputStream, Collection, LargeValues)
,
deserializeSomeProperties(ObjectInputStream, Collection, LargeValues, LargeValues, Name...)
,
serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)
public boolean serializeProperty(ObjectOutputStream stream, Property property, Serializer.LargeValues largeValues, Serializer.ReferenceValues references) throws IOException
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.
stream
- the stream where the property's values are to be serialized; may not be nullproperty
- the property to be serialized; may not be nulllargeValues
- the interface to use for writing large values; may not be nullreferences
- the interface to use for recording which Reference
values were found during serialization, or
null if the references do not need to be accumulated
IOException
- if there is an error writing to the stream
or largeValues
serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)
,
deserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)
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
input
- the stream from which the existing properties are to be deserialized; may not be nulloutput
- the stream to which the updated properties are to be serialized; may not be nullupdatedProperties
- the properties that are being updated (or removed, if there are no values); may not be nulllargeValues
- the interface to use for writing large values; may not be nullremovedLargeValues
- the interface to use for recording the large values that were removed; may not be nullcreatedProperties
- the set into which should be placed the names of the properties that were created; may not be nullreferences
- the interface to use for recording which Reference
values were found during serialization, or
null if the references do not need to be accumulated
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be foundpublic void adjustReferenceProperties(ObjectInputStream input, ObjectOutputStream output, Map<String,String> oldUuidToNewUuid) throws IOException, ClassNotFoundException
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.)
input
- the stream from which the existing properties are to be deserialized; may not be nulloutput
- the stream to which the updated properties are to be serialized; may not be nulloldUuidToNewUuid
- the map of old-to-new UUIDs; may not be null
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be foundpublic void deserializeAllProperties(ObjectInputStream stream, Collection<Property> properties, Serializer.LargeValues largeValues) throws IOException, ClassNotFoundException
stream
- the stream that contains the serialized properties; may not be nullproperties
- the collection into which each deserialized property is to be placed; may not be nulllargeValues
- the interface to use for writing large values; may not be null
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be founddeserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)
,
serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)
public void deserializeSomeProperties(ObjectInputStream stream, Collection<Property> properties, Serializer.LargeValues largeValues, Serializer.LargeValues skippedLargeValues, Name... names) throws IOException, ClassNotFoundException
stream
- the stream that contains the serialized properties; may not be nullproperties
- the collection into which each deserialized property is to be placed; may not be nullnames
- the names of the properties that should be deserialized; should not be null or emptylargeValues
- the interface to use for writing large values; may not be nullskippedLargeValues
- the interface to use for recording the large values that were skipped; may not be null
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be founddeserializePropertyValues(ObjectInputStream, Name, boolean, LargeValues, LargeValues, ReferenceValues)
,
serializeProperties(ObjectOutputStream, int, Iterable, LargeValues, ReferenceValues)
public Property deserializeProperty(ObjectInputStream stream, Serializer.LargeValues largeValues) throws IOException, ClassNotFoundException
stream
- the stream that contains the serialized properties; may not be nulllargeValues
- the interface to use for writing large values; may not be null
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be founddeserializeAllProperties(ObjectInputStream, Collection, LargeValues)
,
serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)
public Object[] deserializePropertyValues(ObjectInputStream stream, Name propertyName, boolean skip, Serializer.LargeValues largeValues, Serializer.LargeValues skippedLargeValues, Serializer.ReferenceValues references) throws IOException, ClassNotFoundException
stream
- the stream that contains the serialized properties; may not be nullpropertyName
- the name of the property being deserializedskip
- true if the values don't need to be read, or false if they are to be readlargeValues
- the interface to use for writing large values; may not be nullskippedLargeValues
- the interface to use for recording the large values that were skipped; may not be nullreferences
- the interface to use for recording which Reference
values were found (and/or removed) during
deserialization; may not be null
IOException
- if there is an error writing to the stream
or largeValues
ClassNotFoundException
- if the class for the value's object could not be founddeserializeAllProperties(ObjectInputStream, Collection, LargeValues)
,
serializeProperty(ObjectOutputStream, Property, LargeValues, ReferenceValues)
public byte[] computeHash(String value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |