org.riverock.dbrevision.utils
Class Utils

java.lang.Object
  extended by org.riverock.dbrevision.utils.Utils

public class Utils
extends Object

Common utils

Author:
Sergei Maslyukov Date: 14.12.2006 Time: 16:37:21

$Id$


Constructor Summary
Utils()
           
 
Method Summary
static Object createCustomObject(String s)
           
static byte[] getBytesUTF(String s)
           
static Timestamp getCurrentTime()
          Get current time as java.sql.Timestamp
static Date getDateWithMask(String date, String mask)
           
static
<T> T
getObjectFromXml(Class<T> classType, InputStream is)
           
static
<T> T
getObjectFromXml(Class<T> classType, InputStream is, javax.xml.bind.ValidationEventHandler handler)
           
static
<T> T
getObjectFromXml(Class<T> classType, Source inSrc, javax.xml.bind.ValidationEventHandler handler)
           
static
<T> T
getObjectFromXml(Class<T> classType, String str)
           
static int getStartUTF(byte[] b, int maxByte)
           
static int getStartUTF(byte[] b, int maxByte, int offset)
           
static int getStartUTF(String s, int maxByte)
           
static String getStringDate(Calendar c, String mask)
          convert given Calendar with mask to String.
static String getStringDate(Calendar c, String mask, Locale loc)
          convert given Calendar with mask and locale to String
static String getStringDate(Date date, String mask, Locale loc, TimeZone tz)
           
static String getTempDir()
           
static byte[] getXml(Object obj, String rootElement)
           
static byte[] getXml(Object obj, String rootElement, String encoding)
           
static byte[] getXml(Object obj, String rootElement, String encoding, boolean isIndent, com.sun.xml.bind.marshaller.NamespacePrefixMapper[] namespacePrefixMappers)
           
static void putKey(Map<String,Object> map, String key, Object value)
          Put value in map.
static String replaceStringArray(String str_, String[][] repl)
           
static void writeMarshalToOutputStream(Object obj, String encoding, String rootElement, OutputStream fos, boolean isIndent, com.sun.xml.bind.marshaller.NamespacePrefixMapper[] namespacePrefixMappers)
           
static void writeObjectAsXml(Object obj, OutputStream outputStream, String encoding)
           
static void writeObjectAsXml(Object obj, OutputStream outputStream, String rootElement, String encoding)
           
static void writeToFile(Object obj, String fileName)
           
static void writeToFile(Object obj, String fileName, String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

putKey

public static void putKey(Map<String,Object> map,
                          String key,
                          Object value)
Put value in map. If map already contained value for specified key, this value and previous value inserted in list and this list associated with given key

Parameters:
map - map
key - key
value - value

getCurrentTime

public static Timestamp getCurrentTime()
Get current time as java.sql.Timestamp

Returns:
current time

getStringDate

public static String getStringDate(Calendar c,
                                   String mask,
                                   Locale loc)
convert given Calendar with mask and locale to String

Parameters:
c - calendar
mask - format mask
loc - locale
Returns:
date as String

getStringDate

public static String getStringDate(Calendar c,
                                   String mask)
convert given Calendar with mask to String.

Parameters:
c - calendar
mask - format mask
Returns:
date as String

getDateWithMask

public static Date getDateWithMask(String date,
                                   String mask)
                            throws ParseException
Parameters:
date -
mask -
Returns:
Throws:
ParseException

getStringDate

public static String getStringDate(Date date,
                                   String mask,
                                   Locale loc,
                                   TimeZone tz)
Parameters:
date -
mask -
loc -
tz -
Returns:

getXml

public static byte[] getXml(Object obj,
                            String rootElement)
                     throws Exception
Parameters:
obj -
rootElement -
Returns:
Throws:
Exception

getXml

public static byte[] getXml(Object obj,
                            String rootElement,
                            String encoding)
                     throws javax.xml.bind.JAXBException
Parameters:
obj -
rootElement -
encoding -
Returns:
Throws:
javax.xml.bind.JAXBException

getXml

public static byte[] getXml(Object obj,
                            String rootElement,
                            String encoding,
                            boolean isIndent,
                            com.sun.xml.bind.marshaller.NamespacePrefixMapper[] namespacePrefixMappers)
                     throws javax.xml.bind.JAXBException
Parameters:
obj -
rootElement -
encoding -
isIndent -
namespacePrefixMappers -
Returns:
Throws:
javax.xml.bind.JAXBException

writeMarshalToOutputStream

public static void writeMarshalToOutputStream(Object obj,
                                              String encoding,
                                              String rootElement,
                                              OutputStream fos,
                                              boolean isIndent,
                                              com.sun.xml.bind.marshaller.NamespacePrefixMapper[] namespacePrefixMappers)
                                       throws javax.xml.bind.JAXBException
Parameters:
obj -
encoding -
rootElement -
fos -
Throws:
javax.xml.bind.JAXBException

writeToFile

public static void writeToFile(Object obj,
                               String fileName)
                        throws javax.xml.bind.JAXBException,
                               FileNotFoundException
Parameters:
obj -
fileName -
Throws:
javax.xml.bind.JAXBException
FileNotFoundException

writeToFile

public static void writeToFile(Object obj,
                               String fileName,
                               String encoding)
                        throws FileNotFoundException,
                               javax.xml.bind.JAXBException
Parameters:
obj -
fileName -
encoding -
Throws:
FileNotFoundException
javax.xml.bind.JAXBException

writeObjectAsXml

public static void writeObjectAsXml(Object obj,
                                    OutputStream outputStream,
                                    String encoding)
                             throws javax.xml.bind.JAXBException
Parameters:
obj -
outputStream -
encoding -
Throws:
javax.xml.bind.JAXBException

writeObjectAsXml

public static void writeObjectAsXml(Object obj,
                                    OutputStream outputStream,
                                    String rootElement,
                                    String encoding)
                             throws javax.xml.bind.JAXBException
Parameters:
obj -
outputStream -
rootElement -
encoding -
Throws:
javax.xml.bind.JAXBException

getObjectFromXml

public static <T> T getObjectFromXml(Class<T> classType,
                                     String str)
                          throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getObjectFromXml

public static <T> T getObjectFromXml(Class<T> classType,
                                     InputStream is)
                          throws javax.xml.bind.JAXBException
Parameters:
classType -
is -
Returns:
Throws:
javax.xml.bind.JAXBException - on error

getObjectFromXml

public static <T> T getObjectFromXml(Class<T> classType,
                                     InputStream is,
                                     javax.xml.bind.ValidationEventHandler handler)
                          throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

getObjectFromXml

public static <T> T getObjectFromXml(Class<T> classType,
                                     Source inSrc,
                                     javax.xml.bind.ValidationEventHandler handler)
                          throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

createCustomObject

public static Object createCustomObject(String s)
                                 throws ClassNotFoundException,
                                        InstantiationException,
                                        IllegalAccessException
Parameters:
s -
Returns:
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

replaceStringArray

public static String replaceStringArray(String str_,
                                        String[][] repl)
Parameters:
str_ - source string
repl - array of values for search and replace
Returns:
resulting string

getBytesUTF

public static byte[] getBytesUTF(String s)
Parameters:
s -
Returns:

getStartUTF

public static int getStartUTF(String s,
                              int maxByte)
Parameters:
s -
maxByte -
Returns:

getStartUTF

public static int getStartUTF(byte[] b,
                              int maxByte)
Parameters:
b -
maxByte -
Returns:

getStartUTF

public static int getStartUTF(byte[] b,
                              int maxByte,
                              int offset)
Parameters:
b -
maxByte -
offset -
Returns:

getTempDir

public static String getTempDir()
Returns:


Copyright © 2008 Riverock community. All Rights Reserved.