Class Util

java.lang.Object
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
  • Field Details

    • fileSep

      static final char fileSep
  • Constructor Details

    • Util

      Util()
  • Method Details

    • 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)