Java Code Examples for sun.rmi.rmic.IndentingWriter#pO()

The following examples show how to use sun.rmi.rmic.IndentingWriter#pO() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write an exception.
 * @param t Given ClassType representing the exception.
 * @param p The output stream.
 */
protected void writeException(
                              ClassType t,
                              IndentingWriter p)
    throws IOException {
    writeBanner( t,0,isException,p );
    writeIfndef( t,0,isException,!isForward,p );
    writeForwardReference( t,p );
    writeModule1( t,p );
    p.pln();p.pI();

    p.pln( "exception " + t.getIDLExceptionName() + " {" );
    p.pln();p.pI();
    p.pln( t.getIDLName() + " value;" );
    p.pO();p.pln();
    p.pln( "};" );

    p.pO();p.pln();
    writeModule2( t,p );
    writeInclude( t,0,!isThrown,p );               //include valuetype idl file
    writeEndif( p );
}
 
Example 2
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write an IDL interface definition for a Java implementation class
 * @param t The current ImplementationType
 * @param p The output stream.
 */
protected void writeImplementation(
                                   ImplementationType t,
                                   IndentingWriter p )
    throws IOException {
    Hashtable inhHash = new Hashtable();
    Hashtable refHash = new Hashtable();
    getInterfaces( t,inhHash );                            //collect interfaces

    writeBanner( t,0,!isException,p );
    writeInheritedIncludes( inhHash,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeIncOrb( p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.p( "interface " + t.getIDLName() );
    writeInherits( inhHash,!forValuetype,p );

    p.pln( " {" );
    p.pln( "};" );

    p.pO();p.pln();
    writeModule2( t,p );
    writeEpilog( t,refHash,p );
}
 
Example 3
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write forward reference for given type
 * @param t Given type
 * @param p The output stream.
 */
protected void writeForwardReference(
                                     Type t,
                                     IndentingWriter p )
    throws IOException {
    String qName = t.getQualifiedName();
    if ( "java.lang.String".equals( qName ) ) ;
    else if ( "org.omg.CORBA.Object".equals( qName ) ) return ;    //no fwd dcl

    writeIfndef( t,0,!isException,isForward,p );
        writeModule1( t,p );
        p.pln();p.pI();
        switch ( t.getTypeCode() ) {
    case TYPE_NC_CLASS:
        case TYPE_NC_INTERFACE: p.p( "abstract valuetype " ); break;
        case TYPE_ABSTRACT:     p.p( "abstract interface " ); break;
        case TYPE_VALUE:        p.p( "valuetype " ); break;
    case TYPE_REMOTE:
    case TYPE_CORBA_OBJECT: p.p( "interface " ); break;
        default: ;                              //all other types were filtered
        }
        p.pln( t.getIDLName() + ";" );
        p.pO();p.pln();
        writeModule2( t,p );
    writeEndif( p );
    }
 
Example 4
Source File: IDLGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write an exception.
 * @param t Given ClassType representing the exception.
 * @param p The output stream.
 */
protected void writeException(
                              ClassType t,
                              IndentingWriter p)
    throws IOException {
    writeBanner( t,0,isException,p );
    writeIfndef( t,0,isException,!isForward,p );
    writeForwardReference( t,p );
    writeModule1( t,p );
    p.pln();p.pI();

    p.pln( "exception " + t.getIDLExceptionName() + " {" );
    p.pln();p.pI();
    p.pln( t.getIDLName() + " value;" );
    p.pO();p.pln();
    p.pln( "};" );

    p.pO();p.pln();
    writeModule2( t,p );
    writeInclude( t,0,!isThrown,p );               //include valuetype idl file
    writeEndif( p );
}
 
Example 5
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * java.io.Externalizable.
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeJavaIoExternalizable(
                                         Type t,
                                         IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef any Externalizable;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 6
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL interface definition for either:
 * 1) a conforming Java remote interface (RemoteType)..or
 * 2) a non-conforming Java interface whose methods all throw
 *     java.rmi.RemoteException (AbstractType)
 * @param t The current RemoteType
 * @param p The output stream.
 */
protected void writeRemote(
                           RemoteType t,
                           IndentingWriter p )
    throws IOException {
    Vector conVec = getConstants( t );                      //collect constants
    Vector mthVec = getMethods( t );                          //collect methods
    Hashtable inhHash = new Hashtable();
    Hashtable refHash = new Hashtable();
    Hashtable spcHash = new Hashtable();
    Hashtable arrHash = new Hashtable();
    Hashtable excHash = new Hashtable();
    getInterfaces( t,inhHash );                            //collect interfaces
    getMethodReferences( mthVec,refHash,spcHash,arrHash,excHash );

    writeProlog( t,refHash,spcHash,arrHash,excHash,inhHash,p );
    writeModule1( t,p );
    p.pln();p.pI();
    if ( t.getTypeCode() == TYPE_ABSTRACT ) p.p( "abstract " );
    p.p( "interface " + t.getIDLName() );
    writeInherits( inhHash,!forValuetype,p );

    p.pln( " {" );
    if ( conVec.size() + mthVec.size() > 0 ) {      //any constants or methods?
        p.pln();p.pI();
        for ( int i1 = 0; i1 < conVec.size(); i1++ )                  //constants
            writeConstant( (CompoundType.Member)conVec.elementAt( i1 ),p );
        for ( int i1 = 0; i1 < mthVec.size(); i1++ )        //methods, attributes
            writeMethod( (CompoundType.Method)mthVec.elementAt( i1 ),p );
        p.pO();p.pln();
    }
    p.pln( "};" );

    p.pO();p.pln();
    writeRepositoryID ( t,p );
    p.pln();
    writeModule2( t,p );
    writeEpilog( t,refHash,p );
}
 
Example 7
Source File: IDLGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write forward reference for boxed valuetype for single dimension of IDL
 * sequence.
 * If the dimension is <1 and the element is a CompoundType, write a
 * forward declare for the element
 * @param at ArrayType for forward declare
 * @param dim The dimension to write
 * @param p The output stream.
 */
protected void writeForwardReference(
                                     ArrayType at,
                                     int dim,
                                     IndentingWriter p)
    throws IOException {
    Type et = at.getElementType();
    if ( dim < 1 ) {
        if ( et.isCompound() ) {
            CompoundType ct = (CompoundType)et;
            writeForwardReference( et,p);
}
        return;
    }
    String fName = unEsc( et.getIDLName() ).replace( ' ','_' );

    writeIfndef( at,dim,!isException,isForward,p );
    writeModule1( at,p );
    p.pln();p.pI();
    switch ( et.getTypeCode() ) {
    case TYPE_NC_CLASS:
    case TYPE_NC_INTERFACE: p.p( "abstract valuetype " ); break;
    case TYPE_ABSTRACT:     p.p( "abstract interface " ); break;
    case TYPE_VALUE:        p.p( "valuetype " ); break;
    case TYPE_REMOTE:
    case TYPE_CORBA_OBJECT: p.p( "interface " ); break;
    default: ;                              //all other types were filtered
    }
    p.pln( "seq" + dim + "_" + fName + ";" );
    p.pO();p.pln();
    writeModule2( at,p );
    writeEndif( p );
}
 
Example 8
Source File: IDLGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * java.rmi.Remote.
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeJavaRmiRemote(
                                  Type t,
                                  IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef Object Remote;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 9
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL interface definition for either:
 * 1) a conforming Java remote interface (RemoteType)..or
 * 2) a non-conforming Java interface whose methods all throw
 *     java.rmi.RemoteException (AbstractType)
 * @param t The current RemoteType
 * @param p The output stream.
 */
protected void writeRemote(
                           RemoteType t,
                           IndentingWriter p )
    throws IOException {
    Vector conVec = getConstants( t );                      //collect constants
    Vector mthVec = getMethods( t );                          //collect methods
    Hashtable inhHash = new Hashtable();
    Hashtable refHash = new Hashtable();
    Hashtable spcHash = new Hashtable();
    Hashtable arrHash = new Hashtable();
    Hashtable excHash = new Hashtable();
    getInterfaces( t,inhHash );                            //collect interfaces
    getMethodReferences( mthVec,refHash,spcHash,arrHash,excHash );

    writeProlog( t,refHash,spcHash,arrHash,excHash,inhHash,p );
    writeModule1( t,p );
    p.pln();p.pI();
    if ( t.getTypeCode() == TYPE_ABSTRACT ) p.p( "abstract " );
    p.p( "interface " + t.getIDLName() );
    writeInherits( inhHash,!forValuetype,p );

    p.pln( " {" );
    if ( conVec.size() + mthVec.size() > 0 ) {      //any constants or methods?
        p.pln();p.pI();
        for ( int i1 = 0; i1 < conVec.size(); i1++ )                  //constants
            writeConstant( (CompoundType.Member)conVec.elementAt( i1 ),p );
        for ( int i1 = 0; i1 < mthVec.size(); i1++ )        //methods, attributes
            writeMethod( (CompoundType.Method)mthVec.elementAt( i1 ),p );
        p.pO();p.pln();
    }
    p.pln( "};" );

    p.pO();p.pln();
    writeRepositoryID ( t,p );
    p.pln();
    writeModule2( t,p );
    writeEpilog( t,refHash,p );
}
 
Example 10
Source File: IDLGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL valuetype definition for
 * 1) a nonconforming Java class
 * 2) a nonconforming Java interface (that is not an AbstractType)
 * @param t The current NC Type (NCClassType or NCInterfaceType)
 * @param p The output stream.
 */
protected void writeNCType(
                           CompoundType t,
                           IndentingWriter p )
    throws IOException {
    Vector conVec = getConstants( t );                      //collect constants
    Vector mthVec = getMethods( t );                          //collect methods
    Hashtable inhHash = new Hashtable();
    Hashtable refHash = new Hashtable();
    Hashtable spcHash = new Hashtable();
    Hashtable arrHash = new Hashtable();
    Hashtable excHash = new Hashtable();
    getInterfaces( t,inhHash );                            //collect interfaces
    getInheritance( t,inhHash );                              //add inheritance
    getMethodReferences( mthVec,refHash,spcHash,arrHash,excHash );

    writeProlog( t,refHash,spcHash,arrHash,excHash,inhHash,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.p( "abstract valuetype " + t.getIDLName() );
    writeInherits( inhHash,!forValuetype,p );

    p.pln( " {" );
    if ( conVec.size() + mthVec.size() > 0 ) {                   //any content?
        p.pln();p.pI();
        for ( int i1 = 0; i1 < conVec.size(); i1++ )            //write constants
            writeConstant( (CompoundType.Member)conVec.elementAt( i1 ),p );
        for ( int i1 = 0; i1 < mthVec.size(); i1++ )              //write methods
            writeMethod( (CompoundType.Method)mthVec.elementAt( i1 ),p );
        p.pO();p.pln();
    }
    p.pln( "};" );

            p.pO();p.pln();
    writeModule2( t,p );
    writeEpilog( t,refHash,p );
}
 
Example 11
Source File: IDLGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * java.lang.Object.
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeJavaLangObject(
                                   Type t,
                                   IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef any _Object;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 12
Source File: IDLGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * org.omg.CORBA.portable.IDLEntity
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeIDLEntity(
                              Type t,
                              IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef any IDLEntity;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 13
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write valuetype for a boxed IDLEntity.
 * @param t Given CompoundType representing the IDLEntity.
 * @param p The output stream.
 */
protected void writeBoxedIDL(
                             CompoundType t,
                             IndentingWriter p)
    throws IOException {
    String[] boxNames = getIDLModuleNames( t );
    int len = boxNames.length;
    String[] modNames = new String[len - 3];               //remove box modules
    for ( int i1 = 0; i1 < len - 3; i1++ ) modNames[i1] = boxNames[i1 + 3];
    String tName = unEsc( t.getIDLName() );

    writeBanner( t,0,!isException,p );
    writeInclude( t,modNames,tName,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();

    p.p( "valuetype " + tName + " " );
    for ( int i1 = 0; i1 < modNames.length; i1++ )
        p.p( IDL_NAME_SEPARATOR + modNames[i1] );
    p.pln( IDL_NAME_SEPARATOR + tName + ";" );

    p.pO();p.pln();
    writeRepositoryID( t,p );
    p.pln();
    writeModule2( t,p );
    writeEndif( p );
    }
 
Example 14
Source File: IDLGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write valuetype for a boxed IDLEntity.
 * @param t Given CompoundType representing the IDLEntity.
 * @param p The output stream.
 */
protected void writeBoxedIDL(
                             CompoundType t,
                             IndentingWriter p)
    throws IOException {
    String[] boxNames = getIDLModuleNames( t );
    int len = boxNames.length;
    String[] modNames = new String[len - 3];               //remove box modules
    for ( int i1 = 0; i1 < len - 3; i1++ ) modNames[i1] = boxNames[i1 + 3];
    String tName = unEsc( t.getIDLName() );

    writeBanner( t,0,!isException,p );
    writeInclude( t,modNames,tName,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();

    p.p( "valuetype " + tName + " " );
    for ( int i1 = 0; i1 < modNames.length; i1++ )
        p.p( IDL_NAME_SEPARATOR + modNames[i1] );
    p.pln( IDL_NAME_SEPARATOR + tName + ";" );

    p.pO();p.pln();
    writeRepositoryID( t,p );
    p.pln();
    writeModule2( t,p );
    writeEndif( p );
    }
 
Example 15
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write valuetype for a boxed IDLEntity.
 * @param t Given CompoundType representing the IDLEntity.
 * @param p The output stream.
 */
protected void writeBoxedIDL(
                             CompoundType t,
                             IndentingWriter p)
    throws IOException {
    String[] boxNames = getIDLModuleNames( t );
    int len = boxNames.length;
    String[] modNames = new String[len - 3];               //remove box modules
    for ( int i1 = 0; i1 < len - 3; i1++ ) modNames[i1] = boxNames[i1 + 3];
    String tName = unEsc( t.getIDLName() );

    writeBanner( t,0,!isException,p );
    writeInclude( t,modNames,tName,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();

    p.p( "valuetype " + tName + " " );
    for ( int i1 = 0; i1 < modNames.length; i1++ )
        p.p( IDL_NAME_SEPARATOR + modNames[i1] );
    p.pln( IDL_NAME_SEPARATOR + tName + ";" );

    p.pO();p.pln();
    writeRepositoryID( t,p );
    p.pln();
    writeModule2( t,p );
    writeEndif( p );
    }
 
Example 16
Source File: IDLGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * java.io.Externalizable.
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeJavaIoExternalizable(
                                         Type t,
                                         IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef any Externalizable;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 17
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a hard-coded IDL typedef definition for the special case
 * java.lang.Object.
 * @param t The current Type
 * @param p The output stream.
 */
protected void writeJavaLangObject(
                                   Type t,
                                   IndentingWriter p )
    throws IOException {
    writeBanner( t,0,!isException,p );
    writeIfndef( t,0,!isException,!isForward,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.pln( "typedef any _Object;" );
    p.pO();p.pln();
    writeModule2( t,p );
    writeEndif( p );
}
 
Example 18
Source File: IDLGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL valuetype definition for
 * 1) a nonconforming Java class
 * 2) a nonconforming Java interface (that is not an AbstractType)
 * @param t The current NC Type (NCClassType or NCInterfaceType)
 * @param p The output stream.
 */
protected void writeNCType(
                           CompoundType t,
                           IndentingWriter p )
    throws IOException {
    Vector conVec = getConstants( t );                      //collect constants
    Vector mthVec = getMethods( t );                          //collect methods
    Hashtable inhHash = new Hashtable();
    Hashtable refHash = new Hashtable();
    Hashtable spcHash = new Hashtable();
    Hashtable arrHash = new Hashtable();
    Hashtable excHash = new Hashtable();
    getInterfaces( t,inhHash );                            //collect interfaces
    getInheritance( t,inhHash );                              //add inheritance
    getMethodReferences( mthVec,refHash,spcHash,arrHash,excHash );

    writeProlog( t,refHash,spcHash,arrHash,excHash,inhHash,p );
    writeModule1( t,p );
    p.pln();p.pI();
    p.p( "abstract valuetype " + t.getIDLName() );
    writeInherits( inhHash,!forValuetype,p );

    p.pln( " {" );
    if ( conVec.size() + mthVec.size() > 0 ) {                   //any content?
        p.pln();p.pI();
        for ( int i1 = 0; i1 < conVec.size(); i1++ )            //write constants
            writeConstant( (CompoundType.Member)conVec.elementAt( i1 ),p );
        for ( int i1 = 0; i1 < mthVec.size(); i1++ )              //write methods
            writeMethod( (CompoundType.Method)mthVec.elementAt( i1 ),p );
        p.pO();p.pln();
    }
    p.pln( "};" );

            p.pO();p.pln();
    writeModule2( t,p );
    writeEpilog( t,refHash,p );
}
 
Example 19
Source File: IDLGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write boxedRMI valuetype for a single dimension of an IDL sequence
 * indicated by the given OutputType.
 * The filename for the OutputType is of the form "seqn_elemName" where n
 * is the dimension required.
 * @param ot Given OutputType.
 * @param p The output stream.
 */
protected void writeSequence(
                             OutputType ot,
                             IndentingWriter p)
    throws IOException {
    ArrayType at = (ArrayType)ot.getType();
    Type et = at.getElementType();
    String fName = ot.getName();
    int dim = Integer.parseInt( fName.substring( 3,fName.indexOf( "_" ) ) );
    String idlName = unEsc( et.getIDLName() ).replace( ' ','_' );
    String qIdlName = getQualifiedIDLName( et );
    String qName = et.getQualifiedName();

    String repID = at.getRepositoryID();
    int rix1 = repID.indexOf( '[' );                       //edit repository id
    int rix2 = repID.lastIndexOf( '[' ) + 1;
        StringBuffer rid = new StringBuffer(
                                        repID.substring( 0,rix1 ) +
                                        repID.substring( rix2 ) );
    for ( int i1 = 0; i1 < dim; i1++ ) rid.insert( rix1,'[' );

    String vtName = "seq" + dim + "_" + idlName;
    boolean isFromIDL = false;
    if ( et.isCompound() ) {
        CompoundType ct = (CompoundType)et;
        isFromIDL = ct.isIDLEntity() || ct.isCORBAObject();
    }
    boolean isForwardInclude =
        et.isCompound() &&
        !isSpecialReference( et ) &&
        dim == 1 &&
        !isFromIDL &&
        !"org.omg.CORBA.Object".equals(qName) &&
        !"java.lang.String".equals(qName);

    writeBanner( at,dim,!isException,p );
    if ( dim == 1 && "java.lang.String".equals(qName) )          //special case
        writeIncOrb( p );
    if ( dim == 1 && "org.omg.CORBA.Object".equals(qName) ) ;
    else if ( isSpecialReference( et ) || dim > 1 || isFromIDL )
        writeInclude( at,dim-1,!isThrown,p );               //"trivial" include
    writeIfndef( at,dim,!isException,!isForward,p );
    if ( isForwardInclude )
        writeForwardReference( at,dim-1,p );                    //forward declare
    writeModule1( at,p );
            p.pln();p.pI();
            p.p( "valuetype " + vtName );
            p.p( " sequence<" );
    if ( dim == 1 ) p.p( qIdlName );
            else {
        p.p( "seq" + ( dim - 1 ) + "_"  );
                p.p( idlName );
            }
            p.pln( ">;" );
            p.pO();p.pln();
            p.pln( "#pragma ID " + vtName + " \"" + rid + "\"" );
            p.pln();
    writeModule2( at,p );
    if ( isForwardInclude )
        writeInclude( at,dim-1,!isThrown,p );      //#include for forward declare
            writeEndif( p );
        }
 
Example 20
Source File: IDLGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write boxedRMI valuetype for a single dimension of an IDL sequence
 * indicated by the given OutputType.
 * The filename for the OutputType is of the form "seqn_elemName" where n
 * is the dimension required.
 * @param ot Given OutputType.
 * @param p The output stream.
 */
protected void writeSequence(
                             OutputType ot,
                             IndentingWriter p)
    throws IOException {
    ArrayType at = (ArrayType)ot.getType();
    Type et = at.getElementType();
    String fName = ot.getName();
    int dim = Integer.parseInt( fName.substring( 3,fName.indexOf( "_" ) ) );
    String idlName = unEsc( et.getIDLName() ).replace( ' ','_' );
    String qIdlName = getQualifiedIDLName( et );
    String qName = et.getQualifiedName();

    String repID = at.getRepositoryID();
    int rix1 = repID.indexOf( '[' );                       //edit repository id
    int rix2 = repID.lastIndexOf( '[' ) + 1;
        StringBuffer rid = new StringBuffer(
                                        repID.substring( 0,rix1 ) +
                                        repID.substring( rix2 ) );
    for ( int i1 = 0; i1 < dim; i1++ ) rid.insert( rix1,'[' );

    String vtName = "seq" + dim + "_" + idlName;
    boolean isFromIDL = false;
    if ( et.isCompound() ) {
        CompoundType ct = (CompoundType)et;
        isFromIDL = ct.isIDLEntity() || ct.isCORBAObject();
    }
    boolean isForwardInclude =
        et.isCompound() &&
        !isSpecialReference( et ) &&
        dim == 1 &&
        !isFromIDL &&
        !"org.omg.CORBA.Object".equals(qName) &&
        !"java.lang.String".equals(qName);

    writeBanner( at,dim,!isException,p );
    if ( dim == 1 && "java.lang.String".equals(qName) )          //special case
        writeIncOrb( p );
    if ( dim == 1 && "org.omg.CORBA.Object".equals(qName) ) ;
    else if ( isSpecialReference( et ) || dim > 1 || isFromIDL )
        writeInclude( at,dim-1,!isThrown,p );               //"trivial" include
    writeIfndef( at,dim,!isException,!isForward,p );
    if ( isForwardInclude )
        writeForwardReference( at,dim-1,p );                    //forward declare
    writeModule1( at,p );
            p.pln();p.pI();
            p.p( "valuetype " + vtName );
            p.p( " sequence<" );
    if ( dim == 1 ) p.p( qIdlName );
            else {
        p.p( "seq" + ( dim - 1 ) + "_"  );
                p.p( idlName );
            }
            p.pln( ">;" );
            p.pO();p.pln();
            p.pln( "#pragma ID " + vtName + " \"" + rid + "\"" );
            p.pln();
    writeModule2( at,p );
    if ( isForwardInclude )
        writeInclude( at,dim-1,!isThrown,p );      //#include for forward declare
            writeEndif( p );
        }