FileDocCategorySizeDatePackage
Complainer.javaAPI DocExample2016Thu Feb 17 20:00:42 GMT 2000com.togethersoft.modules.genidl

Complainer.java

/*----------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft LLC. Patents pending. All rights reserved.
----------------------------------------------------------------------------*/

package com.togethersoft.modules.genidl;

import java.util.Hashtable;
import com.togethersoft.openapi.scriptapi.APIManager;
import com.togethersoft.openapi.scriptapi.UML.UMLClassifier;
import com.togethersoft.openapi.scriptapi.UML.UMLGeneralizableElement;
import com.togethersoft.openapi.scriptapi.UML.UMLGeneralization;
import com.togethersoft.openapi.scriptapi.UML.enums.UMLGeneralizationEnumeration;

/** Warning message producer. */
public class Complainer {
    public Complainer(APIManager apiManager, boolean suppress) {
        mySuppressMessages = suppress;
        myAPIManager = apiManager;
    }

    public void setSuppress(boolean suppress) {
        mySuppressMessages = suppress;
    }

    public void error(String msg) {
        if (!mySuppressMessages) {
            if (!errorHashtable.containsKey(msg)) {
                myAPIManager.createMessage(msg);
                errorHashtable.put(msg, voidObject);
            }
        }
    }

    public void produceInheritanceWarnings(UMLClassifier classifier, String category) {
        UMLGeneralizationEnumeration exts = classifier.getGeneralizations();
        UMLGeneralization generalization;
        UMLGeneralizableElement zuper;
        String zuperName;
        while (exts.hasMoreElements()) {
            generalization = exts.getNextUMLGeneralization();
            zuper = generalization.getSupertype();
            zuperName = zuper.getQualifiedName();
            error(category + " " + classifier.getQualifiedName() + " cannot extend " + zuperName);
        }
    }

    private Hashtable errorHashtable = new Hashtable();
    private Object voidObject = new Object();
    private APIManager myAPIManager;
    private boolean mySuppressMessages;
}