FileDocCategorySizeDatePackage
ProcessTags.javaAPI DocExample17827Thu Feb 17 20:00:42 GMT 2000com.togethersoft.modules.genidl.idl

ProcessTags

public final class ProcessTags extends Object implements com.togethersoft.openapi.scriptapi.TagsProcessing
The processor of special pseudocomment tags.

Fields Summary
private Vector
typedefs
private Vector
includes
private Hashtable
paramtypes
private com.togethersoft.modules.genidl.ScopeProcessor
myScopeProcessor
private com.togethersoft.modules.genidl.Complainer
myComplainer
private String
startPositionOnString
private int
moduleCount
Constructors Summary
public ProcessTags(com.togethersoft.modules.genidl.ScopeProcessor scopeProcessor, com.togethersoft.modules.genidl.Complainer complainer)

        startPositionOnString = "";
        moduleCount = 0;
        myScopeProcessor = scopeProcessor;
        myComplainer = complainer;
    
Methods Summary
public java.util.VectorgetIncludes()

 // only for umlClassifier'a
        return includes;
    
public intgetModuleNumber()

        return moduleCount;
    
public java.util.HashtablegetParamtypes()

        return paramtypes;
    
public java.lang.StringgetPosition()

        return startPositionOnString;
    
public java.lang.StringgetPropertyValue(com.togethersoft.openapi.scriptapi.UML.UMLElement umlElement, java.lang.String propertyName)
Receive properties from UMLClassifier exepts next : idlTypedef, idlParamtype, idlInclude. They are processed in next method as these declarations could be several times in one comment.

        UMLPropertyEnumeration properties = umlElement.getDocProperties();
        while (properties.hasMoreElements()) {
            UMLProperty property = properties.getNextUMLProperty();
            String name = property.getPropertyName();
            String value = property.getPropertyValue();
            if ((name != null) && (name.equals(propertyName))) {

                /*
                  //    we must receive Boolean tags:((
                  if( name.equals("idlOneway")&& value.equals("true"))
                  return value;
                  if( name.equals("idlReadonly") && value.equals("true"))
                  return "true";
                  if( name.equals("idlNative") && value.equals("true"))
                  return "true";
                */

                if (value != null) {
                    return value;
                }
                else {
                    return "";
                }
            }
        }
        return "";
    
public java.util.VectorgetTypedefs()

        return typedefs;
    
public java.lang.StringgetValueByKey(java.lang.String key)

        if (paramtypes.containsKey(key)) {
            return paramtypes.get(key).toString();
        }
        else {
            return "";
        }
    
public voidprocessProperties(com.togethersoft.openapi.scriptapi.UML.UMLElement umlElem, boolean isFirst, boolean isMember)
Process idlTypedef, idlParamtype, idlInclude tags.

        typedefs = new Vector();
        includes = new Vector();
        paramtypes = new Hashtable();
        UMLPropertyEnumeration properties = umlElem.getDocProperties();
        while (properties.hasMoreElements()) {
            UMLProperty property = properties.getNextUMLProperty();
            String name = property.getPropertyName();
            String value = property.getPropertyValue();
            if (name != null && value != null) {
                if (name.equals(IdlTags.IDLTYPEDEF)) {
                    processingTag_idlTypedef(umlElem, value, isFirst, isMember);
                }
                if (name.equals("idlParamtype")) {
                    processingTag_idlParamtype(value, isFirst);
                }
                if (name.equals("idlInclude")) {
                    processingTag_idlInclude(value, isFirst);
                }
            }
        }
    
public java.lang.StringprocessingTag_idlCaseLabel(java.lang.String idlCaseLabel)
Processs attribute in interface which have 'union' stereotype. For second parsing.

        return "";
    
public java.lang.StringprocessingTag_idlCode(java.lang.String idlCode, boolean isMember)
Process 'idlCode' tag for all members of UMLModel

        if (isMember) // scope is interface
                return idlCode;
        else {
            // scope is undefined
            if (idlCode.trim().startsWith("interface") || idlCode.trim().startsWith("global") || idlCode.trim().startsWith("module")) {
                // here we cut substrign without "module" or " interface" or" global"
                if (idlCode.trim().startsWith("interface")) {
                    return idlCode.trim().substring(9, idlCode.length());
                }
                else {
                    return idlCode.trim().substring(6, idlCode.length());
                }
            }
            return idlCode; // default scope == "module"
        }
    
public java.lang.StringprocessingTag_idlConst(java.lang.String idlConst, java.lang.String attrInitExpression)
Process 'idlConst' tag If constExpression in absent in this tag - it must be taken from native expression... ( int n_attr = 6; // we'll take '6')

        String value = idlConst;
        if (idlConst.trim().startsWith("interface") || idlConst.trim().startsWith("global") || idlConst.trim().startsWith("module")) {
            // here we cut substring without "module" or "interface" or "global"
            if (idlConst.trim().startsWith("interface")) {
                value = idlConst.trim().substring(9, idlConst.length());
            }
            else {
                value = idlConst.trim().substring(6, idlConst.length());
            }
        }
        if (!value.trim().equals("")) // default scope == "module" and we don't cut ...
                return value.trim();
        else { // tag was : @idlConst <scope>
            // only for java project's
            if (attrInitExpression != null && !attrInitExpression.trim().equals("")) {
                return attrInitExpression.trim();
            }
            else {
                return "";
            }
        }
    
public java.lang.StringprocessingTag_idlContext(java.lang.String idlContext)
Process 'idlContext' tag.

deprecated

        return "";
    
public java.lang.StringprocessingTag_idlFixed(java.lang.String idlFixed)
Process 'idlFixed' tag.

deprecated,
use idlType

        String value = "fixed";
        int count = 0;
        StringTokenizer token = new StringTokenizer(idlFixed.trim(), " ");
        while (token.hasMoreElements()) {
            count++;
            if (count == 1) {
                value += "< " + token.nextElement();
            }
            if (count == 2) {
                value += ", " + token.nextElement() + " >";
            }
            if (count > 2) {
                break;
            }
        }
        if (count != 2) {
            myComplainer.error(" Wrong type declaration  : " + "fixed " + idlFixed);
            return " ";
        }
        return value;
    
public voidprocessingTag_idlInclude(java.lang.String value, boolean isFirst)
Add to include files from this tag. This tag can be not alone...

        if (!isFirst) {
            myScopeProcessor.putIncludeFile(value);
        }
    
public java.lang.StringprocessingTag_idlInherites(com.togethersoft.openapi.scriptapi.UML.UMLElement elem, java.lang.String value, boolean isFirst)
Process additional inherites... At first pass receive files to be added to include... At second pass match existing interfaces

        if (isFirst) { // add include files
            // nada
        }
        else { // return string of inheritance or error message
            //   if this class is absent in cache
            StringTokenizer token = new StringTokenizer(value, ",");
            String fileName = "";
            String className = "";
            while (token.hasMoreElements()) {
                //         add to include Cache
                className = token.nextToken().trim();
                fileName = myScopeProcessor.getFileByClass(className);
                if (fileName != null || className.startsWith("CORBA::")) {
                    if (fileName != null) {
                        //             if( fileName.endsWith("_bo"))
                        //               incName = fileName.substring( 0, fileName.length() - 3 );
                        //             else
                        //               incName = fileName + myConfigLoader.getInterfaceSuffix();
                        if (fileName != null && !fileName.equals("")) {
                            fileName += ".idl";
                            myScopeProcessor.putIncludeFile("\"" + fileName + "\"");
                        }
                    }
                }
                else {
                    myComplainer.error("Interface " + className + " inherited in " + elem.getName() + " not found.");
                }
            }
            return value.trim();
        }
        return "";
    
public java.lang.StringprocessingTag_idlModule(java.lang.String idlModule)
Receive scopes and long file name if is nessesary...

return
globalName for idlFile...

        resetSettings();
        StringTokenizer token = new StringTokenizer(idlModule, "::");
        StringBuffer stringValue = new StringBuffer();
        //     boolean flag = true;
        while (token.hasMoreElements()) {
            stringValue.append(token.nextToken().toString());
            stringValue.append("_");
            //       if ( !flag ){
            startPositionOnString += "  "; // shift on 2 "_"
            moduleCount++;
            //       }
            //       flag = false;
        }
        return new String(stringValue);
    
public java.lang.StringprocessingTag_idlNative(java.lang.String idlNative)
Process 'idlNative' tag.

deprecated,
use idlType

        return "native";
    
public java.lang.StringprocessingTag_idlOneway(java.lang.String idlOneway)
Process 'idlOneway' tag.

deprecated

        return "";
    
public java.lang.StringprocessingTag_idlParameters(java.lang.String idlParameters, boolean isFirst)
Process 'idlParameters' tag

        if (isFirst) { // add include files
        }
        else { // return string of type or error message
            //   if this class is absent in caching classes and
            //   typedefs
            if (idlParameters != null) {
                StringTokenizer tokenAll = new StringTokenizer(idlParameters, ",");
                StringTokenizer tokenParm;
                String parmType = "";
                while (tokenAll.hasMoreElements()) {
                    tokenParm = new StringTokenizer(tokenAll.nextToken().trim(), " ");
                    if (tokenParm.hasMoreElements()) {
                        tokenParm.nextToken(); // skip parm attribute
                    }
                    if (tokenParm.hasMoreElements()) {
                        parmType = tokenParm.nextToken().trim();
                        myScopeProcessor.checkTypeAndConvert(false, myScopeProcessor.getCurrentScope(), parmType);
                    }
                }
            }
        }
        return "";
    
public voidprocessingTag_idlParamtype(java.lang.String value, boolean isFirst)
Is to process 'idlParamtype' tag This tag can be not alone...

        if (isFirst) { // add include files
        }
        else { // return string of type or error message
            //   if this class is absent in cached classes and
            //   typedefs
            paramtypes.put(value.substring(0, value.trim().lastIndexOf(" ") + 1).trim(),
                value.substring(value.trim().lastIndexOf(" ") + 1, value.length()).trim());
        }
    
public java.lang.StringprocessingTag_idlRaise(java.lang.String idlRaise)
Process 'idlRaises' tag.

        StringTokenizer token = new StringTokenizer(idlRaise, ",");
        String exceptionName = "";
        String fileName = "";
        while (token.hasMoreElements()) {
            exceptionName = token.nextToken().trim();
            System.err.println("Exception name = " + exceptionName);
            System.err.println("Scope = " + myScopeProcessor.getCurrentScope());
            fileName = myScopeProcessor.getExceptionsFile(myScopeProcessor.getCurrentScope(), exceptionName);
            if (fileName != null) {
                myScopeProcessor.putIncludeFile("\"" + fileName + ".idl" + "\"");
            }
        }
        return "";
    
public java.lang.StringprocessingTag_idlReadonly(java.lang.String idlReadonly)
Process 'idlReadonly' tag.

deprecated

        return "";
    
public java.lang.StringprocessingTag_idlSequence(java.lang.String idlSequence)
Process 'idlSequence' tag

        return "";
    
public java.lang.StringprocessingTag_idlStringcapacity(java.lang.String idlStringcapacity)
Process 'idlStringcapacity'tag. For 'string' attribute only.

        return idlStringcapacity.trim();
    
public java.lang.StringprocessingTag_idlType(java.lang.String idlType, boolean isFirst)
Process 'idlType' tag...

        if (isFirst) { // add include files
        }
        else { // return string of type or error message
            //   if this class is absent in caching classes and
            //   typedefs
        }
        return idlType;
    
public voidprocessingTag_idlTypedef(com.togethersoft.openapi.scriptapi.UML.UMLElement elem, java.lang.String avalue, boolean isFirst, boolean isMember)
Process 'idlTypedef' tag for all member of UMLModel This tag can be not alone...

        String value = avalue.trim();
        if (isFirst) {
            String cacheVal = "::";
            if (!isMember) { // interface
                cacheVal = myScopeProcessor.getDestFQ((UMLClassifier)elem, false);
            }
            else { // it's member
                cacheVal = myScopeProcessor.getCurrentScope();
            }
            // simple cut last word in the string
            String newType = "";
            int point = value.lastIndexOf(" ");
            if (point != -1) {
                newType = value.substring(point + 1, value.length());
            }
            // add info to cache
            if (!cacheVal.equals("::")) {
                cacheVal += "::";
            }
            myScopeProcessor.addTypedefToScope(cacheVal + newType, myScopeProcessor.getFileName());
            // example : ( file1::CORBA::haha::myType, file1::CORBA::haha)
        }
        else {
            if (isMember) {
                if (!value.trim().startsWith("interface") && !value.trim().startsWith("global") && !value.trim().startsWith("module")) {
                    myScopeProcessor.addTypedefBeforeMember(value);
                    return;
                }
            }
            if (value.startsWith("interface") || value.startsWith("global") || value.startsWith("module")) {
                // here we cut substrign without "module" or " interface" or" global"
                if (value.trim().startsWith("interface"))
                    myScopeProcessor.addTypedefToInterface(value.substring(9, value.length()));
                else if (value.trim().startsWith("global")) {
                    myScopeProcessor.addTypedefToFile(value.substring(6, value.length()));
                }
                else {
                    if (value.trim().startsWith("module")) {
                        myScopeProcessor.addTypedefToModule(value.substring(6, value.length()));
                    }
                }
                return;
            }
            System.err.println("TagsProcessor: adding typedef to module: " + value);
            myScopeProcessor.addTypedefToModule(value);
        } // else
    
public java.lang.StringprocessingTag_idlUnionSelector(java.lang.String idlUnionSelector)
Process tag unionSelector for interface with 'union' stereoType

        return "";
    
public voidresetSettings()

        startPositionOnString = ""; // shift on 2 "_"
        moduleCount = 0;