com.partnersoft.cog
Class CogLib

java.lang.Object
  extended by com.partnersoft.cog.CogLib
All Implemented Interfaces:
Lib

public class CogLib
extends java.lang.Object
implements Lib

Handy Cog functions.

Copyright 2006-2009 Partner Software, Inc.

Version:
$Id: CogLib.java 2114 2009-09-21 20:57:28Z paul $
Author:
Paul Reavis

Method Summary
static java.lang.String bytesToString(byte[] bytes)
           
static Cog convertToCog(java.lang.Object pojo)
          Convert from a regular Java object to a Cog.
static java.lang.Object convertToObject(Cog node)
          Convert from a Cog to a regular Java object.
static Coggable instantiateCoggable(java.lang.Class classy, Cog cog)
          Instantiates a new Coggable object from he given class and state.
static boolean isIndexPart(java.lang.String part)
          Returns true if the path part is an index identifier like [1].
static int parseIndexFrom(java.lang.String part)
          Returns the integer index parsed from an index path part like [1].
static java.lang.String[] parseParameterizedTypeName(java.lang.String typeName)
          Converts a parameterized type name to an array of Strings.
static byte[] stringToBytes(java.lang.String byteString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertToCog

public static Cog convertToCog(java.lang.Object pojo)
Convert from a regular Java object to a Cog. If the object is a data structure, converts components as well. If the object is already a Cog, just returns it.

Parameters:
pojo - Object to convert.
Returns:
Cog representation of input object's state

convertToObject

public static java.lang.Object convertToObject(Cog node)
Convert from a Cog to a regular Java object. The Cog must be associated with a CogSchema so that it knows what classes to generate.

Parameters:
node - Cog to convert.
Returns:
Object derived from input state.

parseParameterizedTypeName

public static java.lang.String[] parseParameterizedTypeName(java.lang.String typeName)
Converts a parameterized type name to an array of Strings. Each item in the array is a base type. The format is e.g. "SortedList-of-Color" and can be extended indefinitely, e.g. "SortedNaming-of-List-of-Color".

Parameters:
typeName - parameterized type name
Returns:
String array containing the individual base types

instantiateCoggable

public static Coggable instantiateCoggable(java.lang.Class classy,
                                           Cog cog)
Instantiates a new Coggable object from he given class and state.

Parameters:
cog -
Returns:

stringToBytes

public static byte[] stringToBytes(java.lang.String byteString)

bytesToString

public static java.lang.String bytesToString(byte[] bytes)

isIndexPart

public static boolean isIndexPart(java.lang.String part)
Returns true if the path part is an index identifier like [1].

Parameters:
part -
Returns:

parseIndexFrom

public static int parseIndexFrom(java.lang.String part)
Returns the integer index parsed from an index path part like [1].

Parameters:
part -
Returns: