org.jupe.editors.classdiagram.model
Class Util

java.lang.Object
  extended by org.jupe.editors.classdiagram.model.Util

public final class Util
extends java.lang.Object

This class provides some basic functionality which is used in the model.

One of this functionalities are the counters for the autmatic naming of elements in a diagram which are created by clicking. The counters are implemented as simple long integers which are increased every time.

Author:
Michael Pradel

Method Summary
static NodeModelElement findInIterator(java.lang.Class type, java.util.ListIterator<NodeModelElement> iterator, java.lang.String name)
          Convenience method to search a specific element using an iterator over NodeModelElements.
static long getNewAttributeNumber()
          Calculates the next attribute number.
static long getNewClassNumber()
          Calculates the next class number.
static long getNewInterfaceNumber()
          Calculates the next interface number.
static long getNewMethodNumber()
          Calculates the next method number.
static long getNewPackageNumber()
          Calculates the next package number.
static java.lang.String resolveTypeName(java.lang.String localName, java.lang.String absoluteContainerName)
          Resolves the given local type name and returns its absolute type name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findInIterator

public static NodeModelElement findInIterator(java.lang.Class type,
                                              java.util.ListIterator<NodeModelElement> iterator,
                                              java.lang.String name)
Convenience method to search a specific element using an iterator over NodeModelElements.

Parameters:
type - The type of the element that should be searched (e.g. ClassElement.class).
iterator - The iterator over which to search. Should be the iterator of a collection of children.
name - The name of the element to search. Its the absolute name, except for AttributeElement and MethodElement as type, where the simple name is used.
Returns:
Returns the element with the given name if it was found in the iterator or in its children. Returns null if not found.

getNewClassNumber

public static long getNewClassNumber()
Calculates the next class number.

Returns:
new class number

getNewInterfaceNumber

public static long getNewInterfaceNumber()
Calculates the next interface number.

Returns:
new interface number

getNewPackageNumber

public static long getNewPackageNumber()
Calculates the next package number.

Returns:
new package number

getNewAttributeNumber

public static long getNewAttributeNumber()
Calculates the next attribute number.

Returns:
new attribute number

getNewMethodNumber

public static long getNewMethodNumber()
Calculates the next method number.

Returns:
new method number

resolveTypeName

public static java.lang.String resolveTypeName(java.lang.String localName,
                                               java.lang.String absoluteContainerName)
Resolves the given local type name and returns its absolute type name. If necessary the user has to choose it in a dialog. The given type has to exist and be resolvable.

Parameters:
localName - The local name of a type, e.g. "List". This type has to exist and be resolvable.
absoluteContainerName - The absolute name of the container of the type, i.e. its class or interface. E.g. "org.jupe.MyClass".
Returns:
The absolute name of the type, e.g. "java.util.List".