FileDocCategorySizeDatePackage
CORBA_IDL.javaAPI DocExample15168Tue Dec 08 01:21:00 GMT 1998oisoft.togetherx.scripts

CORBA_IDL

public class CORBA_IDL extends Object implements oisoft.togetherx.scriptapi.Script, oisoft.togetherx.scriptapi.ScriptResources, oisoft.togetherx.scripts.idl.IDLOptioner

Fields Summary
private String
prefixIn
private String
prefixOut
private String
prefixInOut
private String[]
javaAndIdlTypes
private String[]
cppToIdlTypes
private oisoft.togetherx.scriptapi.APIManager
apiManager
private static final String
star
private static String
EOL
private static final String
idlCORBA
private Hashtable
cppToIdlTable
private Hashtable
includeFiles
private Hashtable
idlFiles
private StringBuffer
types
private PrintWriter
outputFile
private oisoft.togetherx.scriptapi.UML.UMLPackage
rootPackage
private int
countModules
private String
idlFileName
private String
extences
private String
fullQualifiedName
private String
attribute
private String
out_parameter
private String
in_out_parameter
private String
in_parameter
private String
delimiters
private String
convertedType
private String
language
private boolean
currentType
private oisoft.togetherx.scripts.idl.IDL
idlBaseFunctionality
Constructors Summary
Methods Summary
public voidcloseIdlFile(java.lang.StringBuffer outBuff, java.lang.StringBuffer exceptions)

    String strExceptions = new String( exceptions );
    String strTypes = new String( types );
    String strIdlFunctionality = new String( outBuff );

    if (! strExceptions.equals("")) outputFile.println( strExceptions );
    if (! strTypes.equals("")) outputFile.println( strTypes );
    if (! strIdlFunctionality.equals("")) outputFile.println( strIdlFunctionality );

    outputFile.println ( "  };" );
    outputFile.println ( "" );
    outputFile.println ( "#endif" );
    outputFile.println ( "" );

    for ( int i = 0; i < countModules; i++ )
      outputFile.println ( "};" );

    outputFile.flush ();
    outputFile.close ();
  
public voidconvertCppToIdlType(java.lang.String type)

    convertedType = "";
    if ((! type.endsWith( "[" )) && (! type.endsWith( "<" ))){
      convertedType = getConvertedCppType( type );
      if ( convertedType == null ){
        StringTokenizer tokenType = new StringTokenizer( type, "*&[]<>" );
        if ( tokenType.hasMoreElements() ) {
          convertedType = tokenType.nextToken();
          putIncludeFile( convertedType.trim() );
        }
      }
    }
  
public voidcreateBaseDataTables()

    types           = new StringBuffer();
    includeFiles    = new Hashtable();
  
private voidcreateCppToIdlTable()

    idlFiles        = new Hashtable();
    cppToIdlTable   = new Hashtable();
    for ( int i=0; i < ( cppToIdlTypes.length ); i++ ){
      cppToIdlTable.put( cppToIdlTypes[i][0], cppToIdlTypes[i][1] );
    }
  
public booleancreationIdlFile(java.lang.String language, java.lang.String path, java.lang.String fileName, java.lang.String extenceFiles)

    this.language = language;
    try{
      int position = fileName.lastIndexOf( idlBaseFunctionality.postfix );
      idlFileName = fileName.substring(0,position);

      extences = extenceFiles;
      putIdlFile( idlFileName );
      if ( language.equals( UMLElement.CPP )){
        path += "idl" + File.separator;
        File file = new File(path);
        if (! file.exists()) {
          file.mkdir();
        }
      }
      outputFile = new PrintWriter ( new FileWriter( path + idlFileName + ".idl" ));
      return true;
    }
    catch (Exception e){
      e.printStackTrace();
      return false;
    }
  
public voiddoIt(oisoft.togetherx.scriptapi.APIManager apiManager)

    this.apiManager = apiManager;
    rootPackage = apiManager.getUMLModel().getRootPackage();
    idlBaseFunctionality = new IDL(this);
    createCppToIdlTable();
    idlBaseFunctionality.idlFabric(apiManager, idlCORBA);
  
public voidgenereateIdlFileTitle()

    outputFile.println ( "" );
    outputFile.println ( "// Generated by Together" );
    outputFile.println ( "" );
    outputFile.println ( "" );
    countModules = 0;
    int iPreviousPos = 0;
    int iCurrentPos = fullQualifiedName.indexOf( "." );
    while ( iCurrentPos >= 0 ){
      String strNamePackage = fullQualifiedName.substring( iPreviousPos, iCurrentPos );
      iPreviousPos = iCurrentPos + 1;
      iCurrentPos = fullQualifiedName.indexOf( ".", iPreviousPos );
      outputFile.println ( "module " + strNamePackage + " {" );
      countModules++;
    }
    if (! language.equals( UMLElement.CPP )){
      outputFile.println ( "module idl { " );
      countModules++;
    }
    outputFile.println ( "" );
    outputFile.println ( "#ifndef " + idlFileName + "_idl" );
    outputFile.println ( "#define " + idlFileName + "_idl" );
    outputFile.println ( "" );
    outputFile.println ( "interface " + idlFileName + ";");

    Enumeration files = getIncludeFiles().elements();
    while ( files.hasMoreElements()){
      String fileName = (String) files.nextElement();
      if (! idlFileName.equals( fileName ))
        outputFile.println ( "#include " + "\"" + fileName + ".idl" + "\"" );
    }
    outputFile.println ( "" );
    outputFile.println ( "// ---------------------------------------- " );
    outputFile.println ( "" );
    outputFile.println ( "// ---------------------------------------- " );
    outputFile.println ( "" );
    outputFile.print   ( "  interface " + idlFileName );
    if (! extences.equals("")) outputFile.print ( " : " + extences );
    outputFile.println ( " {" );
  
public java.lang.StringgetArrayDeclaration(int countElements, java.lang.String typeDeclaration, java.lang.String memberName)

    String type = "type_" + memberName;
    String arrayDeclaration = ( countElements > 0 ) ?
			 ("  typedef " + typeDeclaration + " " + type + "[" + countElements + "];" ):
			 ("  typedef sequence<" + typeDeclaration + "> " + type + ";");
    types.append( EOL );
    types.append( arrayDeclaration );
    return type;
  
public java.lang.StringgetAttributeTitle()

    return attribute;
  
public java.lang.StringgetConvertedCppType(java.lang.String type)

    return (String) cppToIdlTable.get( type );
  
public java.lang.StringgetDelimiters()

    return delimiters;
  
public java.lang.StringgetIdlType()

    if (convertedType == null) return "";
    else return convertedType;
  
public java.util.HashtablegetIncludeFiles()

    return includeFiles;
  
public java.util.HashtablegetJavaToIdlTable()

    includeFiles = new Hashtable();
    types    = new StringBuffer();
    Hashtable Javahashtable = new Hashtable();
    for ( int i=0; i < javaAndIdlTypes.length; i++ ){
      Javahashtable.put( javaAndIdlTypes[i][0], javaAndIdlTypes[i][1]);
    }
    return Javahashtable;
  
public java.lang.StringgetMenuItem()

  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
    
		 return "IDL for CORBA...";
  
public java.lang.StringgetOperationDeclaration(java.lang.String type, java.lang.String name, java.lang.String parameters, java.lang.String exception)

    return (type +" "+ name +"("+ parameters +")"+ exception +";" );
  
public java.lang.StringgetParameterModificator(java.lang.String parameter, java.lang.String memberType, boolean arrayAttribute)

    String parameterModificator = "";
    if ( parameter.startsWith( prefixInOut )){
      parameterModificator = in_out_parameter;
    }
    else if ( parameter.startsWith( prefixIn )){
      parameterModificator = in_parameter;
    }
    else if ( parameter.startsWith( prefixOut )){
      parameterModificator = out_parameter;
    }
    else {
        if ((memberType.indexOf("&") >= 0) || (memberType.indexOf("*") >= 0)) {
          parameterModificator = in_out_parameter;
        }
        else {
          parameterModificator = in_parameter;
        }
    }

    return parameterModificator;
  
public booleanisCorrectType()

    return currentType;
  
public voidputIdlFile(java.lang.String idlFile)

    idlFile.trim();
    idlFiles.put( idlFile, idlFile );
  
public voidputIncludeFile(java.lang.String includeFile)

    if ( includeFile.endsWith( idlBaseFunctionality.postfix )){
      int position = includeFile.lastIndexOf( idlBaseFunctionality.postfix );
      String strIDLName = includeFile.substring(0,position);
      includeFiles.put( strIDLName, strIDLName );
    }
    else{
      setCorrectType( false );
      apiManager.createMessage("IDL","Type of "+ includeFile +" is unknown.","");
    }
  
public voidsetCorrectType(boolean state)

    currentType = state;
  
public voidsetPackages(java.lang.String packages)

    fullQualifiedName = packages;