org.objectweb.dream.util
Class Util

java.lang.Object
  extended by org.objectweb.dream.util.Util

public final class Util
extends Object

This class defines utility methods.


Field Summary
static Object NULL_OBJECT
          A null object.
 
Method Summary
static Component getComponentByName(ContentController cc, String name)
          Retrieves the sub component with the specified name from the content of a composite.
static Message partiallyDuplicateMessage(Message message, MessageManager messageManagerItf, Logger logger)
          This method implements a "partial duplication" of messages.
static byte[] readExternalByteArray(DataInput in)
          Reads and returns an array of bytes from an ObjectInput object.
static int[] readExternalIntArray(DataInput in)
          Reads and returns an array of integer from a DataInput object.
static long[] readExternalLongArray(DataInput in)
          Reads and returns an array of long from a DataInput object.
static Object[] readExternalObjectArray(ObjectInput in)
          Reads and returns an array of objects from an ObjectInput object.
static String[] readExternalStringArray(ObjectInput in)
          Reads and returns an array of strings from an ObjectInput object.
static Object[][] readExternalTwoDimensionsObjectArray(ObjectInput in)
          Reads and returns a two-dimensions array of objects from an ObjectInput object.
static String[][] readExternalTwoDimensionsStringArray(ObjectInput in)
          Reads and returns a two-dimensions array of strings from an ObjectInput object.
static Object readObject(ObjectInput input)
          Read the given object from the given ObjectInput.
static void writeExternalByteArray(DataOutput out, byte[] array)
          Writes an array of bytes on a DataOutput object.
static void writeExternalExternalizableObjectArray(ObjectOutput out, Object[] array)
          Writes an array of externalizable objects on an ObjectOutput object.
static void writeExternalIntArray(DataOutput out, int[] array)
          Writes an array of integer on a DataOutput object.
static void writeExternalLongArray(DataOutput out, long[] array)
          Writes an array of long on a DataOutput object.
static void writeExternalObjectArray(ObjectOutput out, Object[] array)
          Writes an array of objects on an ObjectOutput object.
static void writeExternalStringArray(ObjectOutput out, String[] array)
          Writes an array of strings on an ObjectOutput object.
static void writeExternalTwoDimensionsObjectArray(ObjectOutput out, Object[][] twoDimensionsArray)
          Writes a two-dimensions array of objects on an ObjectOutput object.
static void writeExternalTwoDimensionsStringArray(ObjectOutput out, String[][] twoDimensionsArray)
          Writes a two-dimensions array of strings on an ObjectOutput object.
static void writeObject(ObjectOutput output, Object o)
          Write the given object on the given ObjectOutput.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_OBJECT

public static final Object NULL_OBJECT
A null object. Useful for Map values when only the key is meaningful.

Method Detail

getComponentByName

public static Component getComponentByName(ContentController cc,
                                           String name)
Retrieves the sub component with the specified name from the content of a composite. Name must have the form "comp1/comp2/comp3".

Parameters:
cc - the content controller of the composite.
name - the name of the component to be retrieved.
Returns:
the subcomponent with the specified name, null if no component with the specified name exists.

partiallyDuplicateMessage

public static Message partiallyDuplicateMessage(Message message,
                                                MessageManager messageManagerItf,
                                                Logger logger)
This method implements a "partial duplication" of messages. It creates a new message and adds into this message chunks and sub messages of the duplicated message. Sub messages a duplicated by reference (see MessageManager.duplicateMessage(Message, boolean))

Parameters:
message - the message to be "partially duplicated".
messageManagerItf - the message manager to be used.
logger - the logger to be used to log errors.
Returns:
a partial duplicate of the message.

writeExternalByteArray

public static void writeExternalByteArray(DataOutput out,
                                          byte[] array)
                                   throws IOException
Writes an array of bytes on a DataOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array to write.
Throws:
IOException - if an error occurs.

readExternalByteArray

public static byte[] readExternalByteArray(DataInput in)
                                    throws IOException
Reads and returns an array of bytes from an ObjectInput object.

Parameters:
in - the input from which to read.
Returns:
an array of byte.
Throws:
IOException - if an error occurs.

writeExternalIntArray

public static void writeExternalIntArray(DataOutput out,
                                         int[] array)
                                  throws IOException
Writes an array of integer on a DataOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array to write.
Throws:
IOException - if an error occurs.

readExternalIntArray

public static int[] readExternalIntArray(DataInput in)
                                  throws IOException
Reads and returns an array of integer from a DataInput object.

Parameters:
in - the input from which to read.
Returns:
an array of integer.
Throws:
IOException - if an error occurs.

writeExternalLongArray

public static void writeExternalLongArray(DataOutput out,
                                          long[] array)
                                   throws IOException
Writes an array of long on a DataOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array to write.
Throws:
IOException - if an error occurs.

readExternalLongArray

public static long[] readExternalLongArray(DataInput in)
                                    throws IOException
Reads and returns an array of long from a DataInput object.

Parameters:
in - the input from which to read.
Returns:
an array of long.
Throws:
IOException - if an error occurs.

writeExternalObjectArray

public static void writeExternalObjectArray(ObjectOutput out,
                                            Object[] array)
                                     throws IOException
Writes an array of objects on an ObjectOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array to write.
Throws:
IOException - if an error occurs.

readExternalObjectArray

public static Object[] readExternalObjectArray(ObjectInput in)
                                        throws IOException,
                                               ClassNotFoundException
Reads and returns an array of objects from an ObjectInput object.

Parameters:
in - the input from which to read.
Returns:
an array of objects.
Throws:
IOException - if an error occurs.
ClassNotFoundException - if the class of read objects is not found.

writeExternalExternalizableObjectArray

public static void writeExternalExternalizableObjectArray(ObjectOutput out,
                                                          Object[] array)
                                                   throws IOException
Writes an array of externalizable objects on an ObjectOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array of externalizable objects to write.
Throws:
IOException - if an error occurs.

writeExternalStringArray

public static void writeExternalStringArray(ObjectOutput out,
                                            String[] array)
                                     throws IOException
Writes an array of strings on an ObjectOutput object.

Note: if the array is null,-1 is written.

Parameters:
out - the output on which to write.
array - the array to write.
Throws:
IOException - if an error occurs.

readExternalStringArray

public static String[] readExternalStringArray(ObjectInput in)
                                        throws IOException,
                                               ClassNotFoundException
Reads and returns an array of strings from an ObjectInput object.

Parameters:
in - the input from which to read.
Returns:
an array of strings.
Throws:
IOException - if an error occurs.
ClassNotFoundException - if the class of read objects is not found.

writeExternalTwoDimensionsObjectArray

public static void writeExternalTwoDimensionsObjectArray(ObjectOutput out,
                                                         Object[][] twoDimensionsArray)
                                                  throws IOException
Writes a two-dimensions array of objects on an ObjectOutput object.

Note: if the array (of one of its sub-arrays) is null, -1 is written.

Parameters:
out - the output on which to write.
twoDimensionsArray - the two-dimensions array to write.
Throws:
IOException - if an error occurs.

readExternalTwoDimensionsObjectArray

public static Object[][] readExternalTwoDimensionsObjectArray(ObjectInput in)
                                                       throws IOException,
                                                              ClassNotFoundException
Reads and returns a two-dimensions array of objects from an ObjectInput object.

Parameters:
in - the input from which to read.
Returns:
a two-dimensions array of objects.
Throws:
IOException - if an error occurs.
ClassNotFoundException - if the class of read objects is not found.

writeExternalTwoDimensionsStringArray

public static void writeExternalTwoDimensionsStringArray(ObjectOutput out,
                                                         String[][] twoDimensionsArray)
                                                  throws IOException
Writes a two-dimensions array of strings on an ObjectOutput object.

Note: if the array (of one of its sub-arrays) is null, -1 is written.

Parameters:
out - the output on which to write.
twoDimensionsArray - the two-dimensions array to write.
Throws:
IOException - if an error occurs.

readExternalTwoDimensionsStringArray

public static String[][] readExternalTwoDimensionsStringArray(ObjectInput in)
                                                       throws IOException,
                                                              ClassNotFoundException
Reads and returns a two-dimensions array of strings from an ObjectInput object.

Parameters:
in - the input from which to read.
Returns:
a two-dimensions array of strings.
Throws:
IOException - if an error occurs.
ClassNotFoundException - if the class of read objects is not found.

writeObject

public static void writeObject(ObjectOutput output,
                               Object o)
                        throws IOException
Write the given object on the given ObjectOutput. If the given output is an ObjectOutputStream, then use the ObjectOutputStream.writeUnshared(Object)method, else use the normal ObjectOutput.writeObject(Object)method.

Throws:
IOException
See Also:
ObjectOutput.writeObject(Object)

readObject

public static Object readObject(ObjectInput input)
                         throws IOException,
                                ClassNotFoundException
Read the given object from the given ObjectInput. If the given input is an ObjectInputStream, then use the ObjectInputStream.readUnshared()method, else use the normal ObjectInput.readObject()method.

Throws:
IOException
ClassNotFoundException
See Also:
ObjectInput.readObject()


Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.