org.eclipse.ocl.lpg
Class AbstractFormattingHelper

java.lang.Object
  extended by org.eclipse.ocl.lpg.AbstractFormattingHelper
All Implemented Interfaces:
FormattingHelper

public class AbstractFormattingHelper
extends java.lang.Object
implements FormattingHelper

Some default formatting algorithms with support for some basic OCL and Ecore constructs.

Since:
1.2

Field Summary
static AbstractFormattingHelper INSTANCE
          Shared instance implementing the default formatting algorithms.
 
Constructor Summary
AbstractFormattingHelper()
           
 
Method Summary
 java.lang.String formatClass(java.lang.Object object)
          Return the Java class name of object.
 java.lang.String formatEClassName(org.eclipse.emf.ecore.EObject eObject)
          Return the Ecore class name of object.
 java.lang.String formatName(java.lang.Object object)
          Return the name of object.
 java.lang.String formatPath(java.util.List<java.lang.String> pathName)
          Return a hierarchical path name.
 java.lang.String formatPath(java.util.List<java.lang.String> pathName, java.lang.String name)
          Return a hierarchically named name.
 java.lang.String formatQualifiedName(java.lang.Object object)
          Return the qualified name of an object.
 java.lang.String formatString(java.lang.String name)
          Return the string.
 java.lang.String formatType(java.lang.Object type)
          Return the type of object.
protected  java.lang.String getSeparator()
          Obtains the name of the separator between namespaces in a qualified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final AbstractFormattingHelper INSTANCE
Shared instance implementing the default formatting algorithms.

Constructor Detail

AbstractFormattingHelper

public AbstractFormattingHelper()
Method Detail

formatClass

public java.lang.String formatClass(java.lang.Object object)
Description copied from interface: FormattingHelper
Return the Java class name of object. e.g. "org.eclipse.ocl.FormattingHelper".

Specified by:
formatClass in interface FormattingHelper
Parameters:
object - to be formatted
Returns:
non-null string describing the class of object

formatEClassName

public java.lang.String formatEClassName(org.eclipse.emf.ecore.EObject eObject)
Description copied from interface: FormattingHelper
Return the Ecore class name of object. e.g. "EOperation"

Specified by:
formatEClassName in interface FormattingHelper
Parameters:
eObject - to be formatted
Returns:
non-null string describing the Ecore class of object

formatName

public java.lang.String formatName(java.lang.Object object)
Description copied from interface: FormattingHelper
Return the name of object. e.g. "name". The name may be obtained by using known name methods such as ENamedElement.getName().

Specified by:
formatName in interface FormattingHelper
Parameters:
object - to be formatted
Returns:
non-null string describing the name of object

getSeparator

protected java.lang.String getSeparator()
Obtains the name of the separator between namespaces in a qualified name. The default separator is "::".

Returns:
the namespace separator

formatQualifiedName

public java.lang.String formatQualifiedName(java.lang.Object object)
Description copied from interface: FormattingHelper
Return the qualified name of an object. e.g. "A::B::name".

Specified by:
formatQualifiedName in interface FormattingHelper
Parameters:
object - to be formatted
Returns:
non-null string describing the qualified name of the object

formatPath

public java.lang.String formatPath(java.util.List<java.lang.String> pathName)
Description copied from interface: FormattingHelper
Return a hierarchical path name. e.g. "A::B::C"

Specified by:
formatPath in interface FormattingHelper
Parameters:
pathName - to be formatted
Returns:
non-null string describing the pathName

formatPath

public java.lang.String formatPath(java.util.List<java.lang.String> pathName,
                                   java.lang.String name)
Description copied from interface: FormattingHelper
Return a hierarchically named name. e.g. "A::B::C.D"

Specified by:
formatPath in interface FormattingHelper
Parameters:
pathName - to be formatted
name - to be suffixed
Returns:
non-null string describing the class of object

formatString

public java.lang.String formatString(java.lang.String name)
Description copied from interface: FormattingHelper
Return the string. e.g. "string"

Specified by:
formatString in interface FormattingHelper
Parameters:
name - to be formatted
Returns:
non-null string describing string

formatType

public java.lang.String formatType(java.lang.Object type)
Description copied from interface: FormattingHelper
Return the type of object. e.g. "Set(String)". The type may be obtained by using known type methods such as ETypedElement.getType().

Specified by:
formatType in interface FormattingHelper
Parameters:
type - object to be formatted
Returns:
non-null string describing the type of object