Package org.eigenbase.resgen
Class Util
java.lang.Object
org.eigenbase.resgen.Util
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
Nested ClassesModifier and TypeClassDescription(package private) static class
So we know to avoid recursively callingprintStackTrace(Throwable,PrintStream)
.(package private) static class
So we know to avoid recursively callingprintStackTrace(Throwable,java.io.PrintWriter)
. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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) Givenhappy/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
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) Returnval
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
(package private) static String
removeSuffix
(String s, String suffix) (package private) static String
Returnss
with every instance offind
converted toreplace
.(package private) static URL
stringToUrl
(String strFile) (package private) static Throwable[]
Converts a chain ofThrowable
s into an array.(package private) static String
Formats an error, which may have chained errors, as a string.
-
Field Details
-
fileSep
static final char fileSep
-
-
Constructor Details
-
Util
Util()
-
-
Method Details
-
load
loads URL into Document and returns set of resources- Throws:
IOException
-
load
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 texttext
- the text to be writtenlinePrefix
- a string to prepend to each output linelineSuffix
- a string to append to each output linemaxTextPerLine
- the maximum number of characters to place on each line, not counting the prefix and suffix. If this is -1, never break lines.
-
stringToUrl
- Throws:
IOException
-
convertPathToURL
Creates a file-protocol URL for the given filename. -
formatError
-
replace
Returnss
with every instance offind
converted toreplace
. -
quoteForJava
Returnval
in double-quotes, suitable as a string in a Java or JScript program.- Parameters:
val
- the valuenullMeansNull
- whether to print a null value asnull
(the default), as opposed to""
-
quoteForJava
-
quoteForProperties
Returns a string quoted so that it can appear in a resource file. -
fileNameToClassName
-
fileNameToCppClassName
-
removeSuffix
-
fileNameToLocale
Givenhappy/BirthdayResource_en_US.xml
, returns the locale "en_US". -
parseLocale
Parses 'localeName' into a locale. -
fileNameSansLocale
Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource". -
toArray
Converts a chain ofThrowable
s into an array. -
toString
Formats an error, which may have chained errors, as a string. -
printStackTrace
-
printStackTrace
-
generateCommentBlock
-
getClassNameSansPackage
Returns the class name without its package name but with a locale extension, if applicable. For example, if class name ishappy.BirthdayResource
, and locale isen_US
, returnsBirthdayResource_en_US
. -
removePackage
-