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 classSo we know to avoid recursively callingprintStackTrace(Throwable,PrintStream).(package private) static classSo we know to avoid recursively callingprintStackTrace(Throwable,java.io.PrintWriter). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static URLconvertPathToURL(File file) Creates a file-protocol URL for the given filename.(package private) static StringfileNameSansLocale(String fileName, String suffix) Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource".(package private) static StringfileNameToClassName(String fileName, String suffix) (package private) static StringfileNameToCppClassName(String fileName, String suffix) (package private) static LocalefileNameToLocale(String fileName, String suffix) Givenhappy/BirthdayResource_en_US.xml, returns the locale "en_US".(package private) static voidfillText(PrintWriter pw, String text, String linePrefix, String lineSuffix, int maxTextPerLine) Left-justify a block of text.(package private) static StringformatError(String template, Object[] args) (package private) static voidgenerateCommentBlock(PrintWriter pw, String name, String text, String comment) (package private) static StringgetClassNameSansPackage(String className, Locale locale) Returns the class name without its package name but with a locale extension, if applicable.(package private) static ResourceDef.ResourceBundleload(InputStream inStream) loads InputStream and returns set of resources(package private) static ResourceDef.ResourceBundleloads URL into Document and returns set of resources(package private) static LocaleparseLocale(String localeName) Parses 'localeName' into a locale.(package private) static voidprintStackTrace(Throwable throwable, PrintStream s) (package private) static voidprintStackTrace(Throwable throwable, PrintWriter s) (package private) static StringquoteForJava(String val) (package private) static StringquoteForJava(String val, boolean nullMeansNull) Returnvalin double-quotes, suitable as a string in a Java or JScript program.(package private) static StringquoteForProperties(String val) Returns a string quoted so that it can appear in a resource file.protected static String(package private) static StringremoveSuffix(String s, String suffix) (package private) static StringReturnsswith every instance offindconverted toreplace.(package private) static URLstringToUrl(String strFile) (package private) static Throwable[]Converts a chain ofThrowables into an array.(package private) static StringFormats 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
Returnsswith every instance offindconverted toreplace. -
quoteForJava
Returnvalin 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 ofThrowables 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
-