# JUDE API User Guide

## [How to get Model Information]

This section describes you how to get model information simply with examples using Class Diagrams, Object Diagrams and sample programs in this paragraph.
Please refer to JUDE API JavaDoc for details of each interface and method.

1. How to get Model Information of Class Diagram
2. How to get Model Information of Activity Diagram
3. How to get Model Information of Sequence Diagram
4. How to get Model Information of Statemachine Diagram
5. How to get Model Information of Data Flow Diagram
6. How to get Model Information of CRUD
7. How to get Diagrams
8. How to get Alias
9. How to get Hyperlink
10. How to get basic elements in Flowchart

### [How to get Model Information of Class Diagram]

This section describes how to get model information with examples using class diagram and object diagram.

#### How to get Attribute information of class

You can get the array of Attributes by calling Class (IClass) Method getAttributes().
In case the class is associated with other classes, the information of the association end will be also included in Attribute information objects.
For example, if Class0 has attribute0 and is associated with Class1 (association end role name class1), the attribute information of Class0 will be shown like this figure.

#### How to get Operation information of class

You can get the array of Operations by calling Class (IClass) Method getOperations()

#### How to get Dependency information of class

You can get the array of all Dependencies of the selected class by calling Class (IClass) Method getClientDependencies(). By calling getSupplier(), you can get the supplier class of the selected class.
For example, in case that Class0 depends on Class1, the information will be shown like this figure.

#### How to get Realization information of class

You can get the array of Realizations between the selected class and the realized interfaces by calling Class (IClass) Method getClientRealizations(). By calling getSupplier(), you can get the realized interfaces.
For example, in case that Class1 realizes Class0, the information will be shown like this figure.

#### How to get Generalization information of class

You can get the array of Generalizations between the selected class and its superclass by calling Class (IClass) Method getGeneralizations(). By calling getSuperType(), you can get its superclass information.
For example, in case that Class1 inherits Class0, the information will be like this figure.

#### How to get Template Class of a class

You can get the array of templateBindings (ITemplateBinding) by calling Class (IClass) Method getTemplateBindings(). By calling getTemplate() of templateBindings (ITemplateBinding), you can get its template class

#### How to get Template Parameter of a template class

You can get the array of templateParameters (ITemplateParameter) by calling Class (IClass) Method getTemplateParameters(). By calling getTemplate() of templateBindings (ITemplateBinding), you can get its template class

####

#### How to get a model of project accessor

All model information in JUDE Project file is stored under the model of project accessor (Project model) in a tree structure.
First, get the ProjectAccessor object and open JUDE project file, then get Project Model (IModel Class object).
ClassDefinitionBuilder.java

     // Open project file and get project model
     ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();
     prjAccessor.open(inputFile);
     IModel iModel = prjAccessor.getProject();

#### How to get packages under Package recursively

It is defined that Package we call here would include Subsystems and Models that inherit IPackage.
You can get all model elements directly under the package (IPackage) in an array by calling getOwnedElements() and get only packages abstracted from it. By doing so, you can get all packages recursively.
ClassDefinitionBuilder.java

        /**
         * Get packages under Package recursively.
         *
         * @param iPackage
         *     Selected Package
         * @param iPackages
         *     The list of all stored packages
         * @return The list of all stored packages
         */
        private List getPackages(IPackage iPackage, List iPackages) {
     INamedElement[] iNamedElements = iPackage.getOwnedElements();
     for (int i = 0; i < iNamedElements.length; i++) {
         INamedElement iNamedElement = iNamedElements[i];
         if (iNamedElement instanceof IPackage) {
    iPackages.add(iNamedElement);
    getPackages((IPackage)iNamedElement, iPackages);
         }
     }
     return iPackages;
        }

#### How to get Classes under Package

You can get all model elements directly under the package in an array by calling getOwnedElements() and get only classes abstracted from it.
ClassDefinitionBuilder.java

        /**
         * Get classes under the selected Package.
         *
         * @param iPackage
         *     Selected package
         * @return the list of all stored classes
         */
        private List getIClasses(IPackage iPackage) {
     List iClasses = new ArrayList();
     INamedElement[] iNamedElements = iPackage.getOwnedElements();
     for (int i = 0; i < iNamedElements.length; i++) {
         INamedElement iNamedElement = iNamedElements[i];
         if (iNamedElement instanceof IClass) {
    iClasses.add(iNamedElement);
         }
     }
     return iClasses;
        }

#### How to get Full Path Name of class

You can get the name of class by calling getName() in case they are subclasses of INamedElement (i.g. IClass).
In addition, by calling getOwner() that obtains the owned model elements, you can get the Full Path name from the project model.
ClassDefinitionBuilder.java

        /**
         * Get the class name with Full Path
         *
         * @param iClass
         *     Class
         * @return Class name (Full Path)
         */
        private String getFullName(IClass iClass) {
     StringBuffer sb = new StringBuffer();
     IElement owner = iClass.getOwner();
     while (owner != null && owner instanceof INamedElement && owner.getOwner() != null) {
         sb.insert(0, ((INamedElement) owner).getName() + "::");
         owner = owner.getOwner();
     }
     sb.append(iClass.getName());
     return sb.toString();
        }

### [How to get Model Information of Activity Diagram]

This section describes how to get model information with examples using class diagram and object diagram.

#### How to get Partition

You can get the array of partitions (IPartition) by calling getPartitions() Method of IActivity.
By calling getSuperPartition() and getSuperPartition(), you can get hierarchy information of partitions.
For example, in case of Partition0 and Partition1, the information will be like this figure.

#### How to get Control Flow

You can get the array of control flow (IFlow) by calling getFlows() Method of IActivity.
By calling getIncomings() and getOutgoings(), you can get information of control flow of actions.
For example, in case of two control flows, the information will be like this figure.

#### How to get Actions and Start Point

You can get the array of ActivityNode (IActivityNode) by calling getActivityNode() Method of IActivity.
By calling getActivityNode() of Partition (IPartition), you can get actions' information in a partition.
For example, the information for actions0 and start point will be like this figure.

### [How to get Model Information of Sequence Diagram]

This section describes how to get model information with examples using class diagram and object diagram.

#### How to get Lifeline

You can get the array of Lifeline (ILifeline) by calling getLifelines() Method of Interaction(IInteraction).
For example, the information of LifeLine0 will be like this figure.

#### How to get CompoundFragment

You can get the array of CombinedFragment (ICombinedFragment) and Message (IMessage) by calling getFragments() Method of Interaction(IInteraction).
For example, the information of alt compound fragment will be like this figure.

#### How to get Operand

You can get the array of InteractionOperand (IInteractionOperand) by calling getInteractionOperands() Method of CombinedFragment(ICombinedFragment).
For example, the information of two compound fragments in alt compound fragment will be like this figure.

#### How to get Message

You can get the array of CombinedFragment(ICombinedFragment) and Message (IMessage) by calling getFragments() Method of Interaction(IInteraction).
For example, the information of Message0 will be like this figure.

### [How to get Model Information of Statemachine Diagram]

This section describes you how to get model information of statemachine diagram.

#### How to get State and SubmachineState

You can get the statemachine (IStateMachine) by calling getStateMachine() Method of statemachine diagram (IStateMachineDiagram).
You can get the state (IState) by calling getVertexes() Method of statemachine (IStateMachine) .
Submachine state can be judged by isSubmachineState() of state (IState).

#### How to get InitialPseudoState, DeepHistoryPseudoState, ForkPseudoState,etc

You can get the statemachine (IStateMachine) by calling getStateMachine() Method of statemachine diagram (IStateMachineDiagram).
You can get the pseudoState (IPseudoState) by calling getVertexes() Method of statemachine (IStateMachine) .
DeepHistoryPseudostate or forkPseudoState can be judged by isForkPseudostate() of state (IPseudoState).

### [How to get Model Information of Data Flow Diagram]

This section describes how to get model information of dataflow diagram.

#### How to get Process

You can get the process (IProcessBox) by calling getDataFlowNodes() Method of dataFlow diagram (IDataFlowDiagram).
You can get the dataFlowDiagram(IDataFlowDiagram) of process by calling getDataFlowDiagram() Method of process(IProcessBox) .

#### How to get DataFlow

You can get the dataflow (IDataFlow) by calling getIncomings() Method and getOutgoings() of processBox (IProcessBox).

#### How to get ExternalEntity

You can get the external entity (IExternalEntity) by calling geDataFlowNodes() Method of dataFlowDiagram (IDataFlowDiagram).

#### How to get DataStore

You can get the dataStore (IDataStore) by calling geDataFlowNodes() Method of dataFlowDiagram (IDataFlowDiagram).

### [How to get Model Information of CRUD]

This section describes how to get model information of CRUD.

#### How to get Header Cells

You can get the header cell (IHeaderCell) by calling getColumnHeaders() Method and getRowHeaders() Method of CRUD (IMatrixDiagram).

#### How to get Value Cells

You can get the value cell (IValueCell) by calling getShowValueCell (row, column) Method of CRUD diagram (IMatrixDiagram).

### [How to get Diagrams]

NamedElement (INamedElement) is the parent of diagram (IDiagram) and package (IPackage), partion (IPartition) etc.
All diagrams can be got by getDiagrams() of an namedElement.

Example: How to get an activity diagram

    public List getActivityDiagram(IPackage iPackage) {
        List activityDiagrams = new ArrayList();

        IDiagram[] dgms = iPackage.getDiagrams();
        for (int i = 0; i < dgms.length; i++) {
     IDiagram dgm = dgms[i];
     if (dgm instanceof IActivityDiagram
    && !((IActivityDiagram )dgm).isFlowChart()) {
     activityDiagrams.add(dgm);
     }
        }
        return activityDiagrams;
    }

Example: How to get an sequence diagram

    public List getFlowCharts(IPackage iPackage) {
        List flowCharts = new ArrayList();

        IDiagram[] dgms = iPackage.getDiagrams();
        for (int i = 0; i < dgms.length; i++) {
     IDiagram dgm = dgms[i];
     if (dgm instanceof IActivityDiagram
    && ((IActivityDiagram )dgm).isFlowChart()) {
         flowCharts.add(dgm);
     }
        }
        return flowCharts ;
    }

### [How to get Alias]

Alias is hold by taggedValue in a JUDE model.TaggedValues can be got by ITaggedValue
If key of alias1 is "jude.multi_language.alias1" and key of alias2 is "jude.multi_language.alias2",
you can get them by codes below.

Example: How to get alias1

    private static final String KEY_ALIAS1 = "jude.multi_language.alias1";

    private String geAlias1(INamedElement element) {
        ITaggedValue[] tvs = element.getTaggedValues();
        for (int i = 0; i < tvs.length; i++) {
     ITaggedValue tv = tvs[i];
     if (KEY_ALIAS1.equals(tv.getKey())) {
         return tv.getValue();
     }
        }
        return null;
    }

### [How to get Hyperlink]

IHyperlinkOwner is generalized by INamedElement and IPresentation.
A list containing IHyperlinks of an IHyperlinkOwner can be got by getHyperlinks() method.

Example for getting hyperlink

    private void showHyperlinkStrings(INamedElement element) {

        IHyperlink[] links = element.getHyperlinks();
        for (int i = 0; i < links.length; i++) {
     IHyperlink link = links[i];
     if(link.isFile()) {
         System.out.println(link.getName());
         System.out.println(link.getPath());
         System.out.println(link.getComment());
     } else if(link.isModel()) {
         System.out.println(link.getName());
         System.out.println(link.getPath());
         System.out.println(link.getComment());
     } else if(link.isURL()) {
         System.out.println(link.getName());
         System.out.println(link.getPath());
         System.out.println(link.getComment());
     }
         }
    }

Just like the example below, name of a model is id which can be got by getId() of IElementImp.

Example: How to get hyperlink

    type=file,name=jude.log,path=C:/Documents and Settings,comment= Target is a file
    type=url,name=http://www.change-vision.com,path=http://,comment= Target is a web page
    type=model,name=9a1411-1112fec29a5-0804d01aa6c5fb9fe2aab956b4ca593a,path=,comment= Target is a Jude model

### [How to get basic elements in Flowchart]

Flow chart is a kind of activity diagram in JUDE. Basic elements in a flowchart are action with stereotypes.

How to get loop start element

    private static final String LOOP_START_ELEMENT = "loop_start";

    public List getLoopStartElements(IActivityDiagram iActivityDiagram) {
       List loopStartElements = new ArrayList();

       IActivity iActivity = iActivityDiagram.getActivity();
       IActivityNode[] activityNodes = iActivity.getActivityNodes();
       for (int i = 0; i < activityNodes.length; i++) {
     IActivityNode node = activityNodes[i];
     String[] stereotypes = node.getStereotypes();
     for (int j = 0; j < stereotypes.length; j++) {
        if (LOOP_START_ELEMENT.equals(stereotypes[j])) {
     loopStartElements.add(node);
     break;
        }
     }
        }
        return loopStartElements;
    }

#### Stereotype list of basic elements

process1 (As standard process, there is no stereotype)
process2 (flow_process)
Predefined Process (predefined_process)
Hand Work (hand_work)
Preparation (preparation)
Server(server)
Machine(machine)
Data(data)
Stored Data(stored_data)
Internal Storage(internal_storage)
Sequential Storage(sequential_storage)
Disk(disk)
Database(database)
Document(document)
Hand Inputting(hand_inputting)
Display(display)
Judgement(judgement)
Loop Start(loop_start)
Loop End(loop_end)
Internal Connector(internal_connector)
External Connector(external_connector)

Home