## org.eclipse.emf.codegen.util
Class CodeGenUtil

    java.lang.Object
      org.eclipse.emf.codegen.util.CodeGenUtil

    public class CodeGenUtil

extends java.lang.Object

This class contains convenient static methods for EMF code generation. Methods in the `EclipseHelper` inner class may only be used running under Eclipse. The same applies to those that are deprecated and replaced by methods in the inner class, too. All other methods can be used in a stand-alone scenario, too.

This class, like much of the code in this plug-in, is currently undergoing change and should not be considered API.

Nested Class Summary
`static class` `CodeGenUtil.EclipseUtil`
`static class` `CodeGenUtil.StreamProgressMonitor` Deprecated. As of EMF 2.2, moved to `EcoreUtil`.

Field Summary
`protected static java.util.regex.Pattern` `BRACE_LINE_PATTERN`
`protected static java.lang.String` `MATCH_LINE_SEPARATOR`

Constructor Summary
`CodeGenUtil()`

Method Summary
`static void` `addClasspathEntries(java.util.Collection classpathEntries, java.lang.String pluginID)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String)` instead.
`static void` `addClasspathEntries(java.util.Collection classpathEntries, java.lang.String variableName, java.lang.String pluginID)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String, String)` instead.
`static java.lang.String` `capName(java.lang.String name)`
`static java.lang.String` `capName(java.lang.String name, java.util.Locale locale)`
`static java.lang.String` `convertFormat(java.lang.String tabReplacement, boolean convertToStandardBraceStyle, java.lang.String value)`
`static Monitor` `createMonitor(Monitor monitor, int ticks)`
`static IContainer` `findOrCreateContainer(IPath path, boolean forceRefresh, IPath localLocation, IProgressMonitor progressMonitor)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.findOrCreateContainer(IPath, boolean, IPath, IProgressMonitor)` instead.
`static IContainer` `findOrCreateContainer(IPath path, boolean forceRefresh, IProjectDescription projectDescription, IProgressMonitor progressMonitor)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.findOrCreateContainer(IPath, boolean, IProjectDescription, IProgressMonitor)` instead.
`static java.lang.String` `format(java.lang.String name, char separator, java.lang.String prefix, boolean includePrefix)` Deprecated. In 2.2. Please use `format(String, char, String, boolean, boolean)` instead.
`static java.lang.String` `format(java.lang.String name, char separator, java.lang.String prefix, boolean includePrefix, boolean includeLeadingSeparator)` Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them using the specified separator.
`static java.util.List<java.lang.String>` `getClasspathPaths(java.lang.String pluginID)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.getClasspathPaths(java.lang.String)` instead.
`static java.util.Set<java.lang.String>` `getJavaDefaultTypes()` Returns the short names of the primitives and types in java.lang (i.e. those that don't need qualification).
`static java.util.Set<java.lang.String>` `getJavaReservedWords()` Returns the set of all Java's keywords and textual literals, as of Java 5.0.
`static java.lang.String` `getPackageName(java.lang.String qualifiedClassName)` Returns the package name for a qualified class name, i.e., a substring from the first char until the last ".
`static java.lang.String` `getSimpleClassName(java.lang.String qualifiedClassName)` Returns the simple class name for a qualified class name, i.e., a substring from starting after the last ".
`static FacadeHelper` `instantiateFacadeHelper(java.lang.String facadeHelperClass)`
`static boolean` `isInJavaOutput(IResource resource)` Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.isInJavaOutput(org.eclipse.core.resources.IResource)` instead.
`static boolean` `isJavaDefaultType(java.lang.String s)` Tests whether the given string is the name of a primitive or java.lang type.
`static boolean` `isJavaLangType(java.lang.String s)` Tests whether the given string is the name of a java.lang type.
`static boolean` `isJavaPrimitiveType(java.lang.String s)` Tests whether the given string is the name of a primitive type.
`static boolean` `isJavaReservedWord(java.lang.String s)` Tests whether a given string is a Java reserved word.
`static char` `parseChar(java.lang.String c)`
`static java.util.List<java.lang.String>` `parseName(java.lang.String sourceName, char separator)` This method breaks sourceName into words delimited by separator and/or mixed-case naming.
`static java.lang.String` `parseString(java.lang.String s)`
`static java.lang.String` `safeName(java.lang.String name)`
`static java.lang.String` `uncapName(java.lang.String name)`
`static java.lang.String` `uncapName(java.lang.String name, java.util.Locale locale)`
`static java.lang.String` `uncapPrefixedName(java.lang.String name, boolean forceDifferent)`
`static java.lang.String` `uncapPrefixedName(java.lang.String name, boolean forceDifferent, java.util.Locale locale)`
`static java.lang.String` `unicodeEscapeEncode(java.lang.String unicode)` Performs escape encoding on the given string so that it can be represented using 1-byte characters.
`static java.lang.String` `upperName(java.lang.String name)`
`static java.lang.String` `upperName(java.lang.String name, java.util.Locale locale)`
`static java.lang.String` `validJavaIdentifier(java.lang.String name)`
`static java.lang.String` `validPluginID(java.lang.String base)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MATCH_LINE_SEPARATOR

    protected static final java.lang.String MATCH_LINE_SEPARATOR

See Also:
  Constant Field Values

### BRACE_LINE_PATTERN

    protected static final java.util.regex.Pattern BRACE_LINE_PATTERN

Constructor Detail

### CodeGenUtil

    public CodeGenUtil()

Method Detail

### getJavaReservedWords

    public static java.util.Set<java.lang.String> getJavaReservedWords()

  Returns the set of all Java's keywords and textual literals, as of Java 5.0.

### getJavaDefaultTypes

    public static java.util.Set<java.lang.String> getJavaDefaultTypes()

  Returns the short names of the primitives and types in java.lang (i.e. those that don't need qualification).

### isJavaReservedWord

    public static boolean isJavaReservedWord(java.lang.String s)

  Tests whether a given string is a Java reserved word.

### isJavaDefaultType

    public static boolean isJavaDefaultType(java.lang.String s)

  Tests whether the given string is the name of a primitive or java.lang type.

### isJavaLangType

    public static boolean isJavaLangType(java.lang.String s)

  Tests whether the given string is the name of a java.lang type.

### isJavaPrimitiveType

    public static boolean isJavaPrimitiveType(java.lang.String s)

  Tests whether the given string is the name of a primitive type.

### parseString

    public static java.lang.String parseString(java.lang.String s)

### parseChar

    public static char parseChar(java.lang.String c)

### validJavaIdentifier

    public static java.lang.String validJavaIdentifier(java.lang.String name)

### capName

    public static java.lang.String capName(java.lang.String name,
                                           java.util.Locale locale)

  Since:
    2.4

### capName

    public static java.lang.String capName(java.lang.String name)

### uncapName

    public static java.lang.String uncapName(java.lang.String name,
                                             java.util.Locale locale)

### uncapName

    public static java.lang.String uncapName(java.lang.String name)

### uncapPrefixedName

    public static java.lang.String uncapPrefixedName(java.lang.String name,
                                                     boolean forceDifferent,
                                                     java.util.Locale locale)

  Since:
    2.4

### uncapPrefixedName

    public static java.lang.String uncapPrefixedName(java.lang.String name,
                                                     boolean forceDifferent)

### safeName

    public static java.lang.String safeName(java.lang.String name)

### upperName

    public static java.lang.String upperName(java.lang.String name,
                                             java.util.Locale locale)

  Since:
    2.6

### upperName

    public static java.lang.String upperName(java.lang.String name)

  Since:
    2.6

### format

    @Deprecated
    public static java.lang.String format(java.lang.String name,
                                                     char separator,
                                                     java.lang.String prefix,
                                                     boolean includePrefix)

  Deprecated. In 2.2. Please use `format(String, char, String, boolean, boolean)` instead.

### format

    public static java.lang.String format(java.lang.String name,
                                          char separator,
                                          java.lang.String prefix,
                                          boolean includePrefix,
                                          boolean includeLeadingSeparator)

  Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed. Leading underscores can be ignored or can cause a leading separator to be prepended.

  Since:
    2.2

### parseName

    public static java.util.List<java.lang.String> parseName(java.lang.String sourceName,
                                                             char separator)

  This method breaks sourceName into words delimited by separator and/or mixed-case naming.

### isInJavaOutput

    @Deprecated
    public static boolean isInJavaOutput(IResource resource)

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.isInJavaOutput(org.eclipse.core.resources.IResource)` instead.

### findOrCreateContainer

    @Deprecated
    public static IContainer findOrCreateContainer(IPath path,
                                                              boolean forceRefresh,
                                                              IPath localLocation,
                                                              IProgressMonitor progressMonitor)
                                            throws CoreException

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.findOrCreateContainer(IPath, boolean, IPath, IProgressMonitor)` instead.

  Throws:
    `CoreException`

### findOrCreateContainer

    @Deprecated
    public static IContainer findOrCreateContainer(IPath path,
                                                              boolean forceRefresh,
                                                              IProjectDescription projectDescription,
                                                              IProgressMonitor progressMonitor)
                                            throws CoreException

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.findOrCreateContainer(IPath, boolean, IProjectDescription, IProgressMonitor)` instead.

  Throws:
    `CoreException`

### getClasspathPaths

    @Deprecated
    public static java.util.List<java.lang.String> getClasspathPaths(java.lang.String pluginID)
                                                              throws JETException

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.getClasspathPaths(java.lang.String)` instead.

  Throws:
    `JETException`

### addClasspathEntries

    @Deprecated
    public static void addClasspathEntries(java.util.Collection classpathEntries,
                                                      java.lang.String variableName,
                                                      java.lang.String pluginID)
                                    throws JETException

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String, String)` instead.

  Throws:
    `JETException`

### addClasspathEntries

    @Deprecated
    public static void addClasspathEntries(java.util.Collection classpathEntries,
                                                      java.lang.String pluginID)
                                    throws java.lang.Exception

  Deprecated. in 2.2. Please use `CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String)` instead.

  Throws:
    `java.lang.Exception`

### getPackageName

    public static java.lang.String getPackageName(java.lang.String qualifiedClassName)

  Returns the package name for a qualified class name, i.e., a substring from the first char until the last ".". If the argument is `null` or a non-qualified name, this method returns `null`.

  Parameters:
    `qualifiedClassName` -
  Returns:
    String

### getSimpleClassName

    public static java.lang.String getSimpleClassName(java.lang.String qualifiedClassName)

  Returns the simple class name for a qualified class name, i.e., a substring from starting after the last ".". If the argument is a non-qualified name, this method returns the argument.

  Parameters:
    `qualifiedClassName` -
  Returns:
    String

### createMonitor

    public static Monitor createMonitor(Monitor monitor,
                                        int ticks)

### convertFormat

    public static java.lang.String convertFormat(java.lang.String tabReplacement,
                                                 boolean convertToStandardBraceStyle,
                                                 java.lang.String value)

### unicodeEscapeEncode

    public static java.lang.String unicodeEscapeEncode(java.lang.String unicode)

  Performs escape encoding on the given string so that it can be represented using 1-byte characters. Any characters higher than 0xFF are replaced with an escape of the form \\uXXXX, where XXXX is the four-digit hex representation of the Unicode code point.

### instantiateFacadeHelper

    public static FacadeHelper instantiateFacadeHelper(java.lang.String facadeHelperClass)

### validPluginID

    public static java.lang.String validPluginID(java.lang.String base)

  Since:
    2.5

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.