Package org.eigenbase.resgen
Class Util
- java.lang.Object
-
- org.eigenbase.resgen.Util
-
abstract class Util extends java.lang.ObjectMiscellaneous utility methods for theorg.eigenbase.resgenpackage, all themstaticand package-private.- Since:
- 3 December, 2001
- Version:
- $Id: //open/util/resgen/src/org/eigenbase/resgen/Util.java#6 $
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classUtil.DummyPrintStreamSo we know to avoid recursively callingprintStackTrace(Throwable,PrintStream).(package private) static classUtil.DummyPrintWriterSo we know to avoid recursively callingprintStackTrace(Throwable,java.io.PrintWriter).
-
Field Summary
Fields Modifier and Type Field Description (package private) static charfileSep
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.net.URLconvertPathToURL(java.io.File file)Creates a file-protocol URL for the given filename.(package private) static java.lang.StringfileNameSansLocale(java.lang.String fileName, java.lang.String suffix)Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource".(package private) static java.lang.StringfileNameToClassName(java.lang.String fileName, java.lang.String suffix)(package private) static java.lang.StringfileNameToCppClassName(java.lang.String fileName, java.lang.String suffix)(package private) static java.util.LocalefileNameToLocale(java.lang.String fileName, java.lang.String suffix)Givenhappy/BirthdayResource_en_US.xml, returns the locale "en_US".(package private) static voidfillText(java.io.PrintWriter pw, java.lang.String text, java.lang.String linePrefix, java.lang.String lineSuffix, int maxTextPerLine)Left-justify a block of text.(package private) static java.lang.StringformatError(java.lang.String template, java.lang.Object[] args)(package private) static voidgenerateCommentBlock(java.io.PrintWriter pw, java.lang.String name, java.lang.String text, java.lang.String comment)(package private) static java.lang.StringgetClassNameSansPackage(java.lang.String className, java.util.Locale locale)Returns the class name without its package name but with a locale extension, if applicable.(package private) static ResourceDef.ResourceBundleload(java.io.InputStream inStream)loads InputStream and returns set of resources(package private) static ResourceDef.ResourceBundleload(java.net.URL url)loads URL into Document and returns set of resources(package private) static java.util.LocaleparseLocale(java.lang.String localeName)Parses 'localeName' into a locale.(package private) static voidprintStackTrace(java.lang.Throwable throwable, java.io.PrintStream s)(package private) static voidprintStackTrace(java.lang.Throwable throwable, java.io.PrintWriter s)(package private) static java.lang.StringquoteForJava(java.lang.String val)(package private) static java.lang.StringquoteForJava(java.lang.String val, boolean nullMeansNull)Returnvalin double-quotes, suitable as a string in a Java or JScript program.(package private) static java.lang.StringquoteForProperties(java.lang.String val)Returns a string quoted so that it can appear in a resource file.protected static java.lang.StringremovePackage(java.lang.String s)(package private) static java.lang.StringremoveSuffix(java.lang.String s, java.lang.String suffix)(package private) static java.lang.Stringreplace(java.lang.String s, java.lang.String find, java.lang.String replace)Returnsswith every instance offindconverted toreplace.(package private) static java.net.URLstringToUrl(java.lang.String strFile)(package private) static java.lang.Throwable[]toArray(java.lang.Throwable err)Converts a chain ofThrowables into an array.(package private) static java.lang.StringtoString(java.lang.Throwable err)Formats an error, which may have chained errors, as a string.
-
-
-
Method Detail
-
load
static ResourceDef.ResourceBundle load(java.net.URL url) throws java.io.IOException
loads URL into Document and returns set of resources- Throws:
java.io.IOException
-
load
static ResourceDef.ResourceBundle load(java.io.InputStream inStream) throws java.io.IOException
loads InputStream and returns set of resources- Throws:
java.io.IOException
-
fillText
static void fillText(java.io.PrintWriter pw, java.lang.String text, java.lang.String linePrefix, java.lang.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
static java.net.URL stringToUrl(java.lang.String strFile) throws java.io.IOException- Throws:
java.io.IOException
-
convertPathToURL
static java.net.URL convertPathToURL(java.io.File file)
Creates a file-protocol URL for the given filename.
-
formatError
static java.lang.String formatError(java.lang.String template, java.lang.Object[] args)
-
replace
static java.lang.String replace(java.lang.String s, java.lang.String find, java.lang.String replace)Returnsswith every instance offindconverted toreplace.
-
quoteForJava
static java.lang.String quoteForJava(java.lang.String val, boolean nullMeansNull)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
static java.lang.String quoteForJava(java.lang.String val)
-
quoteForProperties
static java.lang.String quoteForProperties(java.lang.String val)
Returns a string quoted so that it can appear in a resource file.
-
fileNameToClassName
static java.lang.String fileNameToClassName(java.lang.String fileName, java.lang.String suffix)
-
fileNameToCppClassName
static java.lang.String fileNameToCppClassName(java.lang.String fileName, java.lang.String suffix)
-
removeSuffix
static java.lang.String removeSuffix(java.lang.String s, java.lang.String suffix)
-
fileNameToLocale
static java.util.Locale fileNameToLocale(java.lang.String fileName, java.lang.String suffix)Givenhappy/BirthdayResource_en_US.xml, returns the locale "en_US".
-
parseLocale
static java.util.Locale parseLocale(java.lang.String localeName)
Parses 'localeName' into a locale.
-
fileNameSansLocale
static java.lang.String fileNameSansLocale(java.lang.String fileName, java.lang.String suffix)Given "happy/BirthdayResource_fr_FR.properties" and ".properties", returns "happy/BirthdayResource".
-
toArray
static java.lang.Throwable[] toArray(java.lang.Throwable err)
Converts a chain ofThrowables into an array.
-
toString
static java.lang.String toString(java.lang.Throwable err)
Formats an error, which may have chained errors, as a string.
-
printStackTrace
static void printStackTrace(java.lang.Throwable throwable, java.io.PrintWriter s)
-
printStackTrace
static void printStackTrace(java.lang.Throwable throwable, java.io.PrintStream s)
-
generateCommentBlock
static void generateCommentBlock(java.io.PrintWriter pw, java.lang.String name, java.lang.String text, java.lang.String comment)
-
getClassNameSansPackage
static java.lang.String getClassNameSansPackage(java.lang.String className, java.util.Locale locale)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
protected static java.lang.String removePackage(java.lang.String s)
-
-