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

The following examples show how to use sun.rmi.rmic.IndentingWriter#pln() . 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: Type.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Print the "opening" of the package or module of this type.
 * @param writer The stream to print to.
 * @param useIDLNames If true, print IDL names; otherwise, print java names.
 */
protected void printPackageOpen (   IndentingWriter writer,
                                    boolean useIDLNames) throws IOException {

    if (useIDLNames) {
        String[] moduleNames = getIDLModuleNames();
        for (int i = 0; i < moduleNames.length; i++ ) {
            writer.plnI("module " + moduleNames[i] + " {");
        }
    } else {
        String packageName = getPackageName();
        if (packageName != null) {
            writer.pln("package " + packageName + ";");
        }
    }
}
 
Example 2
Source File: StubGenerator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void write_tie_thisObject_method(IndentingWriter p,
                                        Identifier idCorbaObject)
    throws IOException
{
    if(POATie){
        p.plnI("public " + idCorbaObject + " thisObject() {");
        /*
        p.pln("org.omg.CORBA.Object objref = null;");
        p.pln("try{");
        p.pln("objref = _poa().servant_to_reference(this);");
        p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
        catchWrongPolicy(p);
        p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
        catchServantNotActive(p);
        p.pln("}");
        p.pln("return objref;");
        */
        p.pln("return _this_object();");
        p.pOln("}");
    } else {
        p.plnI("public " + idCorbaObject + " thisObject() {");
        p.pln("return this;");
        p.pOln("}");
    }
}
 
Example 3
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 4
Source File: IDLGenerator.java    From hottub 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 5
Source File: IDLGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write #endif bracket into the output stream
 * @param p The output stream.
 */
protected void writeEndif(
                          IndentingWriter p )
    throws IOException {
    p.pln("#endif");
    p.pln();
}
 
Example 6
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write Module end bracketing for the given type into the output stream
 * @param t The given Type
 * @param p The output stream.
 */
protected void writeModule2(
                            Type t,
                            IndentingWriter p )
    throws IOException {
    String[] modNames = getIDLModuleNames( t );
    for ( int i=0; i < modNames.length; i++ ) p.pln( "};" );
    p.pln();
}
 
Example 7
Source File: InterfaceType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Print this type.
 * @param writer The stream to print to.
 * @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names.
 * @param useIDLNames If true, print IDL names; otherwise, print java names.
 * @param globalIDLNames If true and useIDLNames true, prepends "::".
 */
public void print ( IndentingWriter writer,
                    boolean useQualifiedNames,
                    boolean useIDLNames,
                    boolean globalIDLNames) throws IOException {

    if (isInner()) {
        writer.p("// " + getTypeDescription() + " (INNER)");
    } else {
        writer.p("// " + getTypeDescription() + "");
    }
    writer.pln(" (" + getRepositoryID() + ")\n");
    printPackageOpen(writer,useIDLNames);

    if (!useIDLNames) {
        writer.p("public ");
    }

    writer.p("interface " + getTypeName(false,useIDLNames,false));
    printImplements(writer,"",useQualifiedNames,useIDLNames,globalIDLNames);
    writer.plnI(" {");
    printMembers(writer,useQualifiedNames,useIDLNames,globalIDLNames);
    writer.pln();
    printMethods(writer,useQualifiedNames,useIDLNames,globalIDLNames);
    writer.pln();

    if (useIDLNames) {
        writer.pOln("};");
    } else {
        writer.pOln("}");
    }
    printPackageClose(writer,useIDLNames);
}
 
Example 8
Source File: IDLGenerator.java    From openjdk-jdk8u-backup 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 9
Source File: StubGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void writeIds(IndentingWriter p, CompoundType theType, boolean isTie
              ) throws IOException {
    p.plnI("private static final String[] _type_ids = {");

    String[] ids = getAllRemoteRepIDs(theType);

    if (ids.length >0 ) {
        for(int i = 0; i < ids.length; i++) {
            if (i > 0)
                p.pln(", ");
            p.p("\"" + ids[i] + "\"");
        }
    } else {
       // Must be an implementation which only implements Remote...
       p.pln("\"\"");
    }
    String qname = theType.getQualifiedName() ;
    boolean isTransactional = isTie && transactionalObjects.containsKey( qname ) ;
    // Add TransactionalObject if needed.
    if (isTransactional) {
        // Have already written an id.
        p.pln( ", " ) ;
        p.pln( "\"IDL:omg.org/CosTransactions/TransactionalObject:1.0\"" ) ;
    } else if (ids.length > 0) {
        p.pln();
    }
    p.pOln("};");
}
 
Example 10
Source File: IDLGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL constant
 * @param constant The current CompoundType.Member constant
 * @param p The output stream.
 */
protected void writeConstant(
                             CompoundType.Member constant,
                             IndentingWriter p )
    throws IOException {
    Type t = constant.getType();
    p.p( "const " );
    p.p( getQualifiedIDLName( t ) );
    p.p( " " + constant.getIDLName() + " = " + constant.getValue() );
    p.pln( ";" );
}
 
Example 11
Source File: CompoundType.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void printMembers (       IndentingWriter writer,
                                    boolean useQualifiedNames,
                                    boolean useIDLNames,
                                    boolean globalIDLNames) throws IOException {

    CompoundType.Member[] members = getMembers();

    for (int i = 0; i < members.length; i++) {
        if (!members[i].isInnerClassDeclaration()) {
            Type it = members[i].getType();
            String visibility = members[i].getVisibility();
            String name;

            if (useIDLNames) {
                name = members[i].getIDLName();
            } else {
                name = members[i].getName();
            }

            String value = members[i].getValue();

            writer.p(visibility);
            if (visibility.length() > 0) {
                writer.p(" ");
            }
            it.printTypeName(writer,useQualifiedNames,useIDLNames,globalIDLNames);
            writer.p(" " + name);

            if (value != null) {
                writer.pln(" = " + value + ";");
            } else {
                writer.pln(";");
            }
        }
    }
}
 
Example 12
Source File: StubGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void write_tie_orb_method(IndentingWriter p)
    throws IOException
{
    if(POATie){
    p.plnI("public void orb(ORB orb) {");
    /*
    p.pln("try{");
    p.pln("orb.connect(_poa().servant_to_reference(this));");
    p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
    catchWrongPolicy(p);
    p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
    catchServantNotActive(p);
    p.pln("}");
    */
    p.pln("try {");
    p.pln("    ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this);");
    p.pln("}");
    p.pln("catch(ClassCastException e) {");
    p.pln("    throw new org.omg.CORBA.BAD_PARAM");
    p.pln("        (\"POA Servant requires an instance of org.omg.CORBA_2_3.ORB\");");
    p.pln("}");
    p.pOln("}");
    } else {
    p.plnI("public void orb(ORB orb) {");
    p.pln("orb.connect(this);");
    p.pOln("}");
    }
}
 
Example 13
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 14
Source File: IDLGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write an IDL data member
 * @param data The current CompoundType.Member data member
 * @param p The output stream.
 */
protected void writeData(
                         CompoundType.Member data,
                         IndentingWriter p )
    throws IOException {
    if ( data.isInnerClassDeclaration() ) return;                      //ignore
    Type t = data.getType();
    if ( data.isPublic() )
        p.p( "public " );
    else p.p( "private " );
    p.pln( getQualifiedIDLName( t ) +  " " +
           data.getIDLName() + ";" );
}
 
Example 15
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 16
Source File: IDLGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write #ifndef guard into the output stream for a given Type
 * @param t The given Type.
 * @param dim The dimension required if t is an ArrayType.
 * @param isException true if writing an exception.
 * @param isForward. No #define needed if it's a forward declare
 * @param p The output stream.
 */
protected void writeIfndef(
                           Type t,
                           int dim,
                           boolean isException,
                           boolean isForward,
                           IndentingWriter p )
    throws IOException {
    String[] modNames = getIDLModuleNames( t );             //module name array
    String fName = unEsc( t.getIDLName() );                 //file name default
    if ( isException && t.isClass() ) {
        ClassType ct = (ClassType)t;                    //file name for Exception
        fName = unEsc( ct.getIDLExceptionName() );
    }
    if ( dim > 0 && t.isArray() ) {
        Type et = t.getElementType();                    //file name for sequence
        fName = "seq" + dim + "_" + unEsc( et.getIDLName().replace( ' ','_' ) );
    }
    p.pln();
    p.p( "#ifndef __" );
    for ( int i = 0; i < modNames.length; i++ ) p.p( modNames[i] + "_" );
    p.pln( fName + "__" );
    if ( !isForward ) {
    p.p( "#define __" );
    for ( int i = 0; i < modNames.length; i++ ) p.p( modNames[i] + "_" );
        p.pln( fName + "__" );
        p.pln();
}
}
 
Example 17
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void write_tie__ids_method(IndentingWriter p)
    throws IOException
{
    if(POATie){
    p.plnI("public String[] _all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId){");
    p.pln("return (String[]) _type_ids.clone();");
    p.pOln("}");
    } else {
    p.plnI("public String[] _ids() { ");
    p.pln("return (String[]) _type_ids.clone();");
    p.pOln("}");
    }
}
 
Example 18
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void write_tie_orb_method(IndentingWriter p)
    throws IOException
{
    if(POATie){
    p.plnI("public void orb(ORB orb) {");
    /*
    p.pln("try{");
    p.pln("orb.connect(_poa().servant_to_reference(this));");
    p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
    catchWrongPolicy(p);
    p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
    catchServantNotActive(p);
    p.pln("}");
    */
    p.pln("try {");
    p.pln("    ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this);");
    p.pln("}");
    p.pln("catch(ClassCastException e) {");
    p.pln("    throw new org.omg.CORBA.BAD_PARAM");
    p.pln("        (\"POA Servant requires an instance of org.omg.CORBA_2_3.ORB\");");
    p.pln("}");
    p.pOln("}");
    } else {
    p.plnI("public void orb(ORB orb) {");
    p.pln("orb.connect(this);");
    p.pOln("}");
    }
}
 
Example 19
Source File: CompoundType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void printMethod (CompoundType.Method it,
                            IndentingWriter writer,
                            boolean useQualifiedNames,
                            boolean useIDLNames,
                            boolean globalIDLNames) throws IOException {


    // Write visibility...

    String visibility = it.getVisibility();

    writer.p(visibility);
    if (visibility.length() > 0) {
        writer.p(" ");
    }

    // Write return type...

    it.getReturnType().printTypeName(writer,useQualifiedNames,useIDLNames,globalIDLNames);

    // Write method name...

    if (useIDLNames) {
        writer.p(" " + it.getIDLName());
    } else {
        writer.p(" " + it.getName());
    }

    // Write arguments...

    writer.p(" (");
    Type[] args = it.getArguments();
    String[] argNames = it.getArgumentNames();

    for (int i = 0; i < args.length; i++) {
        if (i > 0) {
            writer.p(", ");
        }

        if (useIDLNames) {
            writer.p("in ");
        }

        args[i].printTypeName(writer,useQualifiedNames,useIDLNames,globalIDLNames);
        writer.p(" " + argNames[i]);
    }
    writer.p(")");

    // Write exceptions...

    ClassType[] exceptions;

    if (isType(TYPE_IMPLEMENTATION)) {
        exceptions = it.getImplExceptions();
    } else {
        exceptions = it.getExceptions();
    }

    for (int i = 0; i < exceptions.length; i++) {
        if (i == 0) {
            if (useIDLNames) {
                writer.p(" raises (");
            } else {
                writer.p(" throws ");
            }
        } else {
            writer.p(", ");
        }

        if (useIDLNames) {
            if (useQualifiedNames) {
                writer.p(exceptions[i].getQualifiedIDLExceptionName(globalIDLNames));
            } else {
                writer.p(exceptions[i].getIDLExceptionName());
            }
            writer.p(" [a.k.a. ");
            exceptions[i].printTypeName(writer,useQualifiedNames,useIDLNames,globalIDLNames);
            writer.p("]");
        } else {
            exceptions[i].printTypeName(writer,useQualifiedNames,useIDLNames,globalIDLNames);
        }
    }

    if (useIDLNames && exceptions.length > 0) {
        writer.p(")");
    }

    if (it.isInherited()) {
        writer.p(" // Inherited from ");
    writer.p(it.getDeclaredBy());
    }

    writer.pln(";");
}
 
Example 20
Source File: StubGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void catchServantNotActive(IndentingWriter p) throws IOException {
    p.pln("");
}