org.eigenbase.resgen
Class Util

java.lang.Object
  extended by org.eigenbase.resgen.Util

abstract class Util
extends Object

Miscellaneous utility methods for the org.eigenbase.resgen package, all them static and package-private.

Since:
3 December, 2001
Version:
$Id: //open/util/resgen/src/org/eigenbase/resgen/Util.java#6 $
Author:
jhyde

Nested Class Summary
(package private) static class Util.DummyPrintStream
          So we know to avoid recursively calling printStackTrace(Throwable,PrintStream).
(package private) static class Util.DummyPrintWriter
          So we know to avoid recursively calling printStackTrace(Throwable,java.io.PrintWriter).
 
Field Summary
(package private) static char fileSep
           
 
Constructor Summary
Util()
           
 
Method Summary
(package private) static URL convertPathToURL(File file)
          Creates a file-protocol URL for the given filename.
(package private) static String fileNameSansLocale(String fileName, String suffix)
          Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource".
(package private) static String fileNameToClassName(String fileName, String suffix)
           
(package private) static String fileNameToCppClassName(String fileName, String suffix)
           
(package private) static Locale fileNameToLocale(String fileName, String suffix)
          Given happy/BirthdayResource_en_US.xml, returns the locale "en_US".
(package private) static void fillText(PrintWriter pw, String text, String linePrefix, String lineSuffix, int maxTextPerLine)
          Left-justify a block of text.
(package private) static String formatError(String template, Object[] args)
           
(package private) static void generateCommentBlock(PrintWriter pw, String name, String text, String comment)
           
(package private) static String getClassNameSansPackage(String className, Locale locale)
          Returns the class name without its package name but with a locale extension, if applicable.
(package private) static ResourceDef.ResourceBundle load(InputStream inStream)
          loads InputStream and returns set of resources
(package private) static ResourceDef.ResourceBundle load(URL url)
          loads URL into Document and returns set of resources
(package private) static Locale parseLocale(String localeName)
          Parses 'localeName' into a locale.
(package private) static void printStackTrace(Throwable throwable, PrintStream s)
           
(package private) static void printStackTrace(Throwable throwable, PrintWriter s)
           
(package private) static String quoteForJava(String val)
           
(package private) static String quoteForJava(String val, boolean nullMeansNull)
          Return val in double-quotes, suitable as a string in a Java or JScript program.
(package private) static String quoteForProperties(String val)
          Returns a string quoted so that it can appear in a resource file.
protected static String removePackage(String s)
           
(package private) static String removeSuffix(String s, String suffix)
           
(package private) static String replace(String s, String find, String replace)
          Returns s with every instance of find converted to replace.
(package private) static URL stringToUrl(String strFile)
           
(package private) static Throwable[] toArray(Throwable err)
          Converts a chain of Throwables into an array.
(package private) static String toString(Throwable err)
          Formats an error, which may have chained errors, as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileSep

static final char fileSep
Constructor Detail

Util

Util()
Method Detail

load

static ResourceDef.ResourceBundle load(URL url)
                                throws IOException
loads URL into Document and returns set of resources

Throws:
IOException

load

static ResourceDef.ResourceBundle load(InputStream inStream)
                                throws IOException
loads InputStream and returns set of resources

Throws:
IOException

fillText

static void fillText(PrintWriter pw,
                     String text,
                     String linePrefix,
                     String lineSuffix,
                     int maxTextPerLine)
Left-justify a block of text. Line breaks are preserved, but long lines are broken.

Parameters:
pw - where to output the formatted text
text - the text to be written
linePrefix - a string to prepend to each output line
lineSuffix - a string to append to each output line
maxTextPerLine - the maximum number of characters to place on each line, not counting the prefix and suffix. If this is -1, never break lines.

stringToUrl

static URL stringToUrl(String strFile)
                throws IOException
Throws:
IOException

convertPathToURL

static URL convertPathToURL(File file)
Creates a file-protocol URL for the given filename.


formatError

static String formatError(String template,
                          Object[] args)

replace

static String replace(String s,
                      String find,
                      String replace)
Returns s with every instance of find converted to replace.


quoteForJava

static String quoteForJava(String val,
                           boolean nullMeansNull)
Return val in double-quotes, suitable as a string in a Java or JScript program.

Parameters:
val - the value
nullMeansNull - whether to print a null value as null (the default), as opposed to ""

quoteForJava

static String quoteForJava(String val)

quoteForProperties

static String quoteForProperties(String val)
Returns a string quoted so that it can appear in a resource file.


fileNameToClassName

static String fileNameToClassName(String fileName,
                                  String suffix)

fileNameToCppClassName

static String fileNameToCppClassName(String fileName,
                                     String suffix)

removeSuffix

static String removeSuffix(String s,
                           String suffix)

fileNameToLocale

static Locale fileNameToLocale(String fileName,
                               String suffix)
Given happy/BirthdayResource_en_US.xml, returns the locale "en_US".


parseLocale

static Locale parseLocale(String localeName)
Parses 'localeName' into a locale.


fileNameSansLocale

static String fileNameSansLocale(String fileName,
                                 String suffix)
Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource".


toArray

static Throwable[] toArray(Throwable err)
Converts a chain of Throwables into an array.


toString

static String toString(Throwable err)
Formats an error, which may have chained errors, as a string.


printStackTrace

static void printStackTrace(Throwable throwable,
                            PrintWriter s)

printStackTrace

static void printStackTrace(Throwable throwable,
                            PrintStream s)

generateCommentBlock

static void generateCommentBlock(PrintWriter pw,
                                 String name,
                                 String text,
                                 String comment)

getClassNameSansPackage

static String getClassNameSansPackage(String className,
                                      Locale locale)
Returns the class name without its package name but with a locale extension, if applicable. For example, if class name is happy.BirthdayResource, and locale is en_US, returns BirthdayResource_en_US.


removePackage

protected static String removePackage(String s)

SourceForge.net_Logo