xmlBlaster 1.6.2 client API

org.xmlBlaster.util.protocol
Class ProtoConverter

java.lang.Object
  extended byorg.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 messageUnit2Vector(MsgUnitRaw msg)
          Converts a single MsgUnitRaw to a Vector.
static java.util.Vector messageUnitArray2Vector(MsgUnitRaw[] msgs)
          Converts a MsgUnitRaw[] object into a Vector.
static java.util.Vector stringArray2Vector(java.lang.String[] strings)
          Converts a String[] into a Vector object.
static MsgUnitRaw vector2MsgUnitRaw(java.util.Vector 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 vec)
          Converts one element of a Vector to a String object.
static java.lang.String[] vector2StringArray(java.util.Vector 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 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.

messageUnit2Vector

public static java.util.Vector messageUnit2Vector(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.

messageUnitArray2Vector

public static java.util.Vector messageUnitArray2Vector(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.

vector2StringArray

public static java.lang.String[] vector2StringArray(java.util.Vector 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 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 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 1.6.2 client API

Copyright © 1999-2007 The xmlBlaster.org contributers.