xmlBlaster 2.2.0 client API

org.xmlBlaster.util.protocol
Class ProtoConverter

java.lang.Object
  extended by org.xmlBlaster.util.protocol.ProtoConverter

public class ProtoConverter
extends java.lang.Object

This is a utility class used to convert general xmlBlaster data to data is protocol-specific. This is necessary in cases where the protocol does not support a particular data type. This class is used extensively in the xml-rpc protocol where user-defined classes are not supported.

Author:
Michele Laghi

Constructor Summary
ProtoConverter()
           
 
Method Summary
static void main(java.lang.String[] args)
          For testing ...
static java.util.Vector<java.lang.Object> messageUnit2Vector(boolean contentAsString, MsgUnitRaw msg)
          Converts a single MsgUnitRaw to a Vector.
static java.util.Vector<java.lang.Object> messageUnitArray2Vector(boolean contentAsString, MsgUnitRaw[] msgs)
          Converts a MsgUnitRaw[] object into a Vector.
static MsgUnitRaw objArray2MsgUnitRaw(java.lang.Object[] inObj)
          Converts an Object[3] to a MsgUnitRaw.
static MsgUnitRaw[] objMatrix2MsgUnitRawArray(java.lang.Object[] in)
          Converts an Object[][] to a MsgUnitRaw[].
static java.lang.String[] objToStringArray(java.lang.Object obj)
           
static java.util.Vector<java.lang.String> stringArray2Vector(java.lang.String[] strings)
          Converts a String[] into a Vector object.
static MsgUnitRaw vector2MsgUnitRaw(java.util.Vector<java.lang.Object> vec)
          Converts a Vector to a MsgUnitRaw.
static MsgUnitRaw[] vector2MsgUnitRawArray(java.util.Vector vec)
          Converts a Vector to a MsgUnitRaw[].
static java.lang.String vector2String(java.util.Vector<java.lang.String> vec)
          Converts one element of a Vector to a String object.
static java.lang.String[] vector2StringArray(java.util.Vector<java.lang.String> vec)
          Converts a Vector to a String[] object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProtoConverter

public ProtoConverter()
Method Detail

vector2MsgUnitRaw

public static MsgUnitRaw vector2MsgUnitRaw(java.util.Vector<java.lang.Object> vec)
                                    throws XmlBlasterException
Converts a Vector to a MsgUnitRaw. The first element in vec must be a String object corresponding to the literal for MsgUnitRaw.xmlKey, the second element is a byte[] object corresponding to MsgUnitRaw.content. The third (and last) element is a String corresponding to the literal of MsgUnitRaw.qos.

Parameters:
vec - the vector to convert
Returns:
the MsgUnitRaw to which the vector has been converted to.
Throws:
XmlBlasterException - if the size of vec is different from 3, or if the type of the vector elements does not correspond to the MsgUnitRaw equivalent.

objArray2MsgUnitRaw

public static MsgUnitRaw objArray2MsgUnitRaw(java.lang.Object[] inObj)
                                      throws XmlBlasterException
Converts an Object[3] to a MsgUnitRaw. The first element must be a String object corresponding to the literal for MsgUnitRaw.xmlKey, the second element is a byte[] object corresponding to MsgUnitRaw.content. The third (and last) element is a String corresponding to the literal of MsgUnitRaw.qos.

Parameters:
inObj - the Object[3] to convert
Returns:
the MsgUnitRaw to which the vector has been converted to.
Throws:
XmlBlasterException - if the size of vec is different from 3, or if the type of the vector elements does not correspond to the MsgUnitRaw equivalent.

messageUnit2Vector

public static java.util.Vector<java.lang.Object> messageUnit2Vector(boolean contentAsString,
                                                                    MsgUnitRaw msg)
Converts a single MsgUnitRaw to a Vector.

Parameters:
msg - the MsgUnitRaw to convert to a Vector.
Returns:
the Vector object containing three elements [String, byte[], String] representing the MsgUnitRaw.

vector2MsgUnitRawArray

public static MsgUnitRaw[] vector2MsgUnitRawArray(java.util.Vector vec)
                                           throws XmlBlasterException
Converts a Vector to a MsgUnitRaw[]. The input Vector must contain elements of the type Vector. Each of such (sub)Vectors must have three elements fullfilling the requirements for the Vector objects in vector2MsgUnitRaw.

Parameters:
vec - the input Vector (of Vector).
Returns:
the MsgUnitRaw[].
Throws:
XmlBlasterException - if the types in the input vector are not consistent with the required types.

objMatrix2MsgUnitRawArray

public static MsgUnitRaw[] objMatrix2MsgUnitRawArray(java.lang.Object[] in)
                                              throws XmlBlasterException
Converts an Object[][] to a MsgUnitRaw[]. The input Vector must contain elements of the type Object[][]. Each of such (sub)Objects must have three elements.

Parameters:
vec - the input Object[][].
Returns:
the MsgUnitRaw[].
Throws:
XmlBlasterException - if the types in the input vector are not consistent with the required types.

messageUnitArray2Vector

public static java.util.Vector<java.lang.Object> messageUnitArray2Vector(boolean contentAsString,
                                                                         MsgUnitRaw[] msgs)
Converts a MsgUnitRaw[] object into a Vector.

Parameters:
msgs - The array of MsgUnitRaw objects to convert to a Vector object.
Returns:
the Vector containing all information about the msgs parameter.

objToStringArray

public static java.lang.String[] objToStringArray(java.lang.Object obj)
                                           throws XmlBlasterException
Throws:
XmlBlasterException

vector2StringArray

public static java.lang.String[] vector2StringArray(java.util.Vector<java.lang.String> vec)
                                             throws XmlBlasterException
Converts a Vector to a String[] object. All elements of the Vector must be valid String objects.

Parameters:
vec - vector containing the Strings to be converted.
Returns:
an array of String objects.
Throws:
XmlBlasterException - if the elements in the Vector where not valid String objects.

vector2String

public static java.lang.String vector2String(java.util.Vector<java.lang.String> vec)
                                      throws XmlBlasterException
Converts one element of a Vector to a String object.

Parameters:
vec - vector containing the String to be converted.
Returns:
The String object.
Throws:
XmlBlasterException - if the element in the Vector is not a valid String object.

stringArray2Vector

public static java.util.Vector<java.lang.String> stringArray2Vector(java.lang.String[] strings)
Converts a String[] into a Vector object.

Parameters:
strings - array of String objects to convert to a Vector.
Returns:
a Vector object containing all the elements of the input array.

main

public static void main(java.lang.String[] args)
For testing ...


xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.