org.eclipse.emf.codegen.util
Class CodeGenUtil

java.lang.Object
  extended byorg.eclipse.emf.codegen.util.CodeGenUtil

public class CodeGenUtil
extends 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 standalone 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 Pattern braceLine
           
protected static Pattern leadingTabs
           
protected static String lineSeparator
           
 
Constructor Summary
CodeGenUtil()
           
 
Method Summary
static void addClasspathEntries(Collection classpathEntries, String pluginID)
          Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String) instead.
static void addClasspathEntries(Collection classpathEntries, String variableName, String pluginID)
          Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String, String) instead.
static String capName(String name)
           
static String convertFormat(String tabReplacement, boolean convertToStandardBraceStyle, 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 String format(String name, char separator, String prefix, boolean includePrefix)
          Deprecated. In 2.2. Please use format(String, char, String, boolean, boolean) instead.
static String format(String name, char separator, 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 List getClasspathPaths(String pluginID)
          Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.getClasspathPaths(java.lang.String) instead.
static Set getJavaDefaultTypes()
          Returns the short names of the primitives and types in java.lang (i.e. those that don't need qualification).
static Set getJavaReservedWords()
          Returns the set of all Java's keywords and textual literals, as of Java 5.0.
static String getPackageName(String qualifiedClassName)
          Returns the package name for a qualified class name, ie, a substring from the first char until the last ".
static String getSimpleClassName(String qualifiedClassName)
          Returns the simple class name for a qualified class name, ie, a substring from starting after the last ".
static FacadeHelper instantiateFacadeHelper(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(String s)
          Tests whether the given string is the name of a primitive or java.lang type.
static boolean isJavaLangType(String s)
          Tests whether the given string is the name of a java.lang type.
static boolean isJavaPrimitiveType(String s)
          Tests whether the given string is the name of a primitive type.
static boolean isJavaReservedWord(String s)
          Tests whether a given string is a Java reserved word.
static char parseChar(String c)
           
static List parseName(String sourceName, char separator)
          This method breaks sourceName into words delimited by separator and/or mixed-case naming.
static String parseString(String s)
           
static String safeName(String name)
           
static String uncapName(String name)
           
static String uncapPrefixedName(String name, boolean forceDifferent)
           
static String unicodeEscapeEncode(String unicode)
          Performs escape encoding on the given string so that it can be represented using 1-byte characters.
static String validJavaIdentifier(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineSeparator

protected static String lineSeparator

braceLine

protected static Pattern braceLine

leadingTabs

protected static Pattern leadingTabs
Constructor Detail

CodeGenUtil

public CodeGenUtil()
Method Detail

getJavaReservedWords

public static Set getJavaReservedWords()
Returns the set of all Java's keywords and textual literals, as of Java 5.0.


getJavaDefaultTypes

public static Set 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(String s)
Tests whether a given string is a Java reserved word.


isJavaDefaultType

public static boolean isJavaDefaultType(String s)
Tests whether the given string is the name of a primitive or java.lang type.


isJavaLangType

public static boolean isJavaLangType(String s)
Tests whether the given string is the name of a java.lang type.


isJavaPrimitiveType

public static boolean isJavaPrimitiveType(String s)
Tests whether the given string is the name of a primitive type.


parseString

public static String parseString(String s)

parseChar

public static char parseChar(String c)

validJavaIdentifier

public static String validJavaIdentifier(String name)

capName

public static String capName(String name)

uncapName

public static String uncapName(String name)

uncapPrefixedName

public static String uncapPrefixedName(String name,
                                       boolean forceDifferent)

safeName

public static String safeName(String name)

format

public static String format(String name,
                            char separator,
                            String prefix,
                            boolean includePrefix)
Deprecated. In 2.2. Please use format(String, char, String, boolean, boolean) instead.


format

public static String format(String name,
                            char separator,
                            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 List parseName(String sourceName,
                             char separator)
This method breaks sourceName into words delimited by separator and/or mixed-case naming.


isInJavaOutput

public static boolean isInJavaOutput(IResource resource)
Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.isInJavaOutput(org.eclipse.core.resources.IResource) instead.


findOrCreateContainer

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

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

public static List getClasspathPaths(String pluginID)
                              throws JETException
Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.getClasspathPaths(java.lang.String) instead.

Throws:
JETException

addClasspathEntries

public static void addClasspathEntries(Collection classpathEntries,
                                       String variableName,
                                       String pluginID)
                                throws JETException
Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String, String) instead.

Throws:
JETException

addClasspathEntries

public static void addClasspathEntries(Collection classpathEntries,
                                       String pluginID)
                                throws Exception
Deprecated. in 2.2. Please use CodeGenUtil.EclipseUtil.addClasspathEntries(Collection, String) instead.

Throws:
Exception

getPackageName

public static String getPackageName(String qualifiedClassName)
Returns the package name for a qualified class name, ie, 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 String getSimpleClassName(String qualifiedClassName)
Returns the simple class name for a qualified class name, ie, 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 String convertFormat(String tabReplacement,
                                   boolean convertToStandardBraceStyle,
                                   String value)

unicodeEscapeEncode

public static String unicodeEscapeEncode(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(String facadeHelperClass)

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