net.sf.ginp.util
Class GinpUtil

java.lang.Object
  extended by net.sf.ginp.util.GinpUtil

public class GinpUtil
extends java.lang.Object

Internationalization stuff These are for server side messages that won't go out to the client so we can use whatever the JVM's locale is.

Author:
Justin Sher

Field Summary
static java.lang.String CREATE_CONFIG_ERROR
          CREATE_CONFIG_ERROR - if there's an error creating the config
 
Constructor Summary
GinpUtil()
           
 
Method Summary
static boolean empty(java.lang.String adminPassword)
           
static java.lang.String getConfigFileRealPath()
           
static java.lang.String message(java.lang.String key)
          Get a normal internationalied message
static java.lang.String message(java.lang.String key, java.lang.Object[] args)
          Get an Internationalized Message encoded with a Message Format.
static int parseInteger(javax.servlet.http.HttpServletRequest req, java.lang.String param, int defaultVal)
          Parse an integer from a string and handle exceptions gracefully
static int parseInteger(java.lang.String value, int defaultVal)
           
static java.lang.String readBufferIntoMemory(java.io.InputStream stream)
          Reads the input stream into memory
static org.dom4j.Document transform(java.lang.String stylePath, org.dom4j.Document visitDoc)
           
static void writeInputStreamToOutputStream(java.io.OutputStream sos, java.io.InputStream is)
          Writes the entire input stream to the output stream then closes the input stream
static void writeScaledImageToStream(java.io.OutputStream sos, java.io.InputStream is, int width, int height)
          Take a jpeg from an input stream and write it to an output stream with a scaled width and height
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATE_CONFIG_ERROR

public static final java.lang.String CREATE_CONFIG_ERROR
CREATE_CONFIG_ERROR - if there's an error creating the config

See Also:
Constant Field Values
Constructor Detail

GinpUtil

public GinpUtil()
Method Detail

message

public static java.lang.String message(java.lang.String key,
                                       java.lang.Object[] args)
Get an Internationalized Message encoded with a Message Format.

Parameters:
key - the message key
args - keys for messageformat
Returns:
the i18n message

message

public static java.lang.String message(java.lang.String key)
Get a normal internationalied message

Parameters:
key - the key
Returns:
the i18n message

readBufferIntoMemory

public static java.lang.String readBufferIntoMemory(java.io.InputStream stream)
                                             throws java.io.IOException
Reads the input stream into memory

Parameters:
stream - the stream
Returns:
a reader for the string represeting the data read from the input stream
Throws:
java.io.IOException

transform

public static org.dom4j.Document transform(java.lang.String stylePath,
                                           org.dom4j.Document visitDoc)
                                    throws javax.xml.transform.TransformerException
Parameters:
stylePath - the classpath resource name of the transforming xsl doc
visitDoc - the doc to transform
Returns:
the transformed document
Throws:
javax.xml.transform.TransformerException

empty

public static boolean empty(java.lang.String adminPassword)
Parameters:
adminPassword - a string
Returns:
whether a string is empty

parseInteger

public static int parseInteger(javax.servlet.http.HttpServletRequest req,
                               java.lang.String param,
                               int defaultVal)
Parse an integer from a string and handle exceptions gracefully

Parameters:
req - the servlet request to get the parameter from
param - the name of the parameter
defaultVal - the default value if parsing fails
Returns:
the parsed value or the default if parsing failed

parseInteger

public static int parseInteger(java.lang.String value,
                               int defaultVal)

writeScaledImageToStream

public static void writeScaledImageToStream(java.io.OutputStream sos,
                                            java.io.InputStream is,
                                            int width,
                                            int height)
                                     throws java.io.IOException
Take a jpeg from an input stream and write it to an output stream with a scaled width and height

Parameters:
sos - output stream for image
is - input stream for image
width - width
height - height
Throws:
java.io.IOException - if there is an error writing or reading

writeInputStreamToOutputStream

public static void writeInputStreamToOutputStream(java.io.OutputStream sos,
                                                  java.io.InputStream is)
                                           throws java.io.IOException
Writes the entire input stream to the output stream then closes the input stream

Parameters:
sos - output stream
is - input stream
Throws:
java.io.IOException - if there is an error reading or writing

getConfigFileRealPath

public static java.lang.String getConfigFileRealPath()


Copyright © 2004-2007 null. All Rights Reserved.