Output class

@param def definition
@param out Writer
@throws IOException ioException
435964
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      out.write("public class " + getClassName(def) + " implements " + def.getMbeanInterfaceClass());
      writeLeftCurlyBracket(out, 0);

      writeVars(def, out, indent);
      writeEol(out);
      writeMBeanLifecycle(def, out, indent);
      writeEol(out);
      writeMethods(def, out, indent);
      writeEol(out);
      writeGetConnection(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
916177
public void writeDefinition(final OutputStream result) throws IOException
    {
        result.write(FONT_FAMILY);
        result.write(FONT_CHARSET);
        result.write(intToByteArray(charset));
        result.write(DELIMITER);
        document.filterSpecialChar(result, fontName, true, false);
    }
1014077
private void writeGetConnection(Definition def, Writer out, int indent) throws IOException
   {
      String connInterface = def.getMcfDefs().get(0).getConnInterfaceClass();
      String cfInterface = def.getMcfDefs().get(0).getCfInterfaceClass();

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * GetConnection\n");
      writeWithIndent(out, indent, " * @return " + connInterface);
      writeEol(out);
      writeWithIndent(out, indent, " */\n");
      writeWithIndent(out, indent, "private " + connInterface + " getConnection() throws Exception");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "InitialContext context = new InitialContext();\n");
      writeIndent(out, indent + 1);
      out.write(cfInterface + " factory = (" + cfInterface +
            ")context.lookup(JNDI_NAME);\n");
      writeIndent(out, indent + 1);
      out.write(connInterface + " conn = factory.getConnection();\n");
      writeWithIndent(out, indent + 1, "if (conn == null)");
      writeLeftCurlyBracket(out, indent + 1);
      writeIndent(out, indent + 2);
      out.write("throw new RuntimeException(\"No connection\");");
      writeRightCurlyBracket(out, indent + 1);

      writeWithIndent(out, indent + 1, "return conn;");

      writeRightCurlyBracket(out, indent);
   }
983270
void generateEisCode(Definition def)
   {
      try
      {
         String clazzName = this.getClass().getPackage().getName() + ".code.TestEisCodeGen";
         String javaFile = def.getDefaultValue() + "Handler.java";
         FileWriter fw = Utils.createTestFile(javaFile, def.getRaPackage(), def.getOutputDir());

         Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
         AbstractCodeGen codeGen = (AbstractCodeGen) clazz.newInstance();

         codeGen.generate(def, fw);

         fw.flush();
         fw.close();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
1244074
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      out.write("public interface " + getClassName(def));
      if (def.isAdminObjectImplRaAssociation())
      {
         out.write(" extends Referenceable, Serializable");
      }
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      int indent = 1;
      writeConfigProps(def, out, indent);
      writeRightCurlyBracket(out, 0);
   }
141716
public void writeClassFile(OutputStream out, ClassSymbol c)
        throws IOException, PoolOverflow, StringOverflow {
        Assert.check((c.flags() & COMPOUND) == 0);
        databuf.reset();
        poolbuf.reset();
        signatureGen.reset();
        pool = c.pool;
        innerClasses = null;
        innerClassesQueue = null;
        bootstrapMethods = new LinkedHashMap<>();

        Type supertype = types.supertype(c.type);
        List<Type> interfaces = types.interfaces(c.type);
        List<Type> typarams = c.type.getTypeArguments();

        int flags;
        if (c.owner.kind == MDL) {
            flags = ACC_MODULE;
        } else {
            flags = adjustFlags(c.flags() & ~DEFAULT);
            if ((flags & PROTECTED) != 0) flags |= PUBLIC;
            flags = flags & ClassFlags & ~STRICTFP;
            if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
        }

        if (dumpClassModifiers) {
            PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
            pw.println();
            pw.println("CLASSFILE  " + c.getQualifiedName());
            pw.println("---" + flagNames(flags));
        }
        databuf.appendChar(flags);

        if (c.owner.kind == MDL) {
            PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
            databuf.appendChar(pool.put(new ClassSymbol(0, names.module_info, unnamed)));
        } else {
            databuf.appendChar(pool.put(c));
        }
        databuf.appendChar(supertype.hasTag(CLASS) ? pool.put(supertype.tsym) : 0);
        databuf.appendChar(interfaces.length());
        for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
            databuf.appendChar(pool.put(l.head.tsym));
        int fieldsCount = 0;
        int methodsCount = 0;
        for (Symbol sym : c.members().getSymbols(NON_RECURSIVE)) {
            switch (sym.kind) {
            case VAR: fieldsCount++; break;
            case MTH: if ((sym.flags() & HYPOTHETICAL) == 0) methodsCount++;
                      break;
            case TYP: enterInner((ClassSymbol)sym); break;
            default : Assert.error();
            }
        }

        if (c.trans_local != null) {
            for (ClassSymbol local : c.trans_local) {
                enterInner(local);
            }
        }

        databuf.appendChar(fieldsCount);
        writeFields(c.members());
        databuf.appendChar(methodsCount);
        writeMethods(c.members());

        int acountIdx = beginAttrs();
        int acount = 0;

        boolean sigReq =
            typarams.length() != 0 || supertype.allparams().length() != 0;
        for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail)
            sigReq = l.head.allparams().length() != 0;
        if (sigReq) {
            int alenIdx = writeAttr(names.Signature);
            if (typarams.length() != 0) signatureGen.assembleParamsSig(typarams);
            signatureGen.assembleSig(supertype);
            for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
                signatureGen.assembleSig(l.head);
            databuf.appendChar(pool.put(signatureGen.toName()));
            signatureGen.reset();
            endAttr(alenIdx);
            acount++;
        }

        if (c.sourcefile != null && emitSourceFile) {
            int alenIdx = writeAttr(names.SourceFile);
            // WHM 6/29/1999: Strip file path prefix.  We do it here at
            // the last possible moment because the sourcefile may be used
            // elsewhere in error diagnostics. Fixes 4241573.
            //databuf.appendChar(c.pool.put(c.sourcefile));
            String simpleName = PathFileObject.getSimpleName(c.sourcefile);
            databuf.appendChar(c.pool.put(names.fromString(simpleName)));
            endAttr(alenIdx);
            acount++;
        }

        if (genCrt) {
            // Append SourceID attribute
            int alenIdx = writeAttr(names.SourceID);
            databuf.appendChar(c.pool.put(names.fromString(Long.toString(getLastModified(c.sourcefile)))));
            endAttr(alenIdx);
            acount++;
            // Append CompilationID attribute
            alenIdx = writeAttr(names.CompilationID);
            databuf.appendChar(c.pool.put(names.fromString(Long.toString(System.currentTimeMillis()))));
            endAttr(alenIdx);
            acount++;
        }

        acount += writeFlagAttrs(c.flags());
        acount += writeJavaAnnotations(c.getRawAttributes());
        acount += writeTypeAnnotations(c.getRawTypeAttributes(), false);
        acount += writeEnclosingMethodAttribute(c);
        if (c.owner.kind == MDL) {
            acount += writeModuleAttribute(c);
            acount += writeFlagAttrs(c.owner.flags() & ~DEPRECATED);
        }
        acount += writeExtraClassAttributes(c);

        poolbuf.appendInt(JAVA_MAGIC);

        if (c.owner.kind == MDL) {
            // temporarily overide to force use of v53 for module-info.class
            poolbuf.appendChar(0);
            poolbuf.appendChar(53);
        } else {
            poolbuf.appendChar(target.minorVersion);
            poolbuf.appendChar(target.majorVersion);
        }

        writePool(c.pool);

        if (innerClasses != null) {
            writeInnerClasses();
            acount++;
        }

        if (!bootstrapMethods.isEmpty()) {
            writeBootstrapMethods();
            acount++;
        }

        endAttrs(acountIdx, acount);

        poolbuf.appendBytes(databuf.elems, 0, databuf.length);
        out.write(poolbuf.elems, 0, poolbuf.length);

        pool = c.pool = null; // to conserve space
     }
336734
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      out.write("public class " + getClassName(def) + " implements ManagedConnection");
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      writeWithIndent(out, indent, "/** The logger */\n");
      writeWithIndent(out, indent, "private static Logger log = Logger.getLogger(" + getSelfClassName(def) + ");\n\n");

      writeWithIndent(out, indent, "/** The logwriter */\n");
      writeWithIndent(out, indent, "private PrintWriter logwriter;\n\n");

      writeWithIndent(out, indent, "/** ManagedConnectionFactory */\n");
      writeWithIndent(out, indent, "private " + def.getMcfDefs().get(getNumOfMcf()).getMcfClass() + " mcf;\n\n");

      writeWithIndent(out, indent, "/** Listeners */\n");
      writeWithIndent(out, indent, "private List<ConnectionEventListener> listeners;\n\n");

      writeWithIndent(out, indent, "/** Connections */\n");
      if (def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         writeWithIndent(out, indent,
               "private Set<" + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + "> connections;\n\n");
      else
         writeWithIndent(out, indent,
               "private Set<" + def.getMcfDefs().get(getNumOfMcf()).getConnImplClass() + "> connections;\n\n");

      if (def.isSupportEis())
      {
         writeWithIndent(out, indent, "/** Socket */\n");
         writeWithIndent(out, indent, "private Socket socket;\n\n");
      }

      //constructor
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " * @param mcf mcf\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent,
            "public " + getClassName(def) + "(" + def.getMcfDefs().get(getNumOfMcf()).getMcfClass() + " mcf)");
      if (def.isSupportEis())
      {
         out.write(" throws ResourceException");
      }
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this.mcf = mcf;\n");
      writeWithIndent(out, indent + 1, "this.logwriter = null;\n");
      writeWithIndent(out, indent + 1,
            "this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));\n");
      if (def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         writeWithIndent(out, indent + 1,
               "this.connections = new HashSet<" + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + ">();");
      else
         writeWithIndent(out, indent + 1,
               "this.connections = new HashSet<" + def.getMcfDefs().get(getNumOfMcf()).getConnImplClass() + ">();");

      if (def.isSupportEis())
      {
         writeEol(out);
         writeWithIndent(out, indent + 1, "this.socket = null; // TODO: Initialize me");
      }

      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeConnection(def, out, indent);
      writeLifecycle(def, out, indent);
      writeConnectionEventListener(def, out, indent);
      writeLogWriter(def, out, indent);
      writeTransaction(def, out, indent);
      writeMetaData(def, out, indent);
      writeMethod(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
657717
public void setClassDefinition(String name, byte[] def) {
    classDefs.put(name, ByteBuffer.wrap(def));
  }
673535
public void writeObject (ObjectOutputStream out)
        throws IOException
    {
        if (!classDefinesElementType()) {
            out.writeUTF(_elementType.getName());
        }
        out.write(_contents);
    }
502291
public void setOutputFormatClass(Class<? extends OutputFormat> cls
                                   ) throws IllegalStateException {
    ensureState(JobState.DEFINE);
    conf.setClass(OUTPUT_FORMAT_CLASS_ATTR, cls, OutputFormat.class);
  }
12247
public void writeClassAndObject (Output output, Object object) {
		if (output == null) throw new IllegalArgumentException("output cannot be null.");
		beginObject();
		try {
			if (object == null) {
				writeClass(output, null);
				return;
			}
			Registration registration = writeClass(output, object.getClass());
			if (references && writeReferenceOrNull(output, object, false)) return;
			if (TRACE || (DEBUG && depth == 1)) log("Write", object, output.position());
			registration.getSerializer().write(this, output, object);
		} finally {
			if (--depth == 0 && autoReset) reset();
		}
	}
626744
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      if (def.isUseAnnotation())
      {
         if (!def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         {
            out.write("@ConnectionDefinition(connectionFactory = " +
                  def.getMcfDefs().get(getNumOfMcf()).getCfInterfaceClass() + ".class,\n");
            writeWithIndent(out, indent,
                  " connectionFactoryImpl = " + def.getMcfDefs().get(getNumOfMcf()).getCfClass() + ".class,\n");
            writeWithIndent(out, indent,
                  " connection = " + def.getMcfDefs().get(getNumOfMcf()).getConnInterfaceClass() + ".class,\n");
            writeWithIndent(out, indent,
                  " connectionImpl = " + def.getMcfDefs().get(getNumOfMcf()).getConnImplClass() + ".class)\n");
         }
         else
         {
            out.write("@ConnectionDefinition(connectionFactory = ConnectionFactory.class,\n");
            writeWithIndent(out, indent, " connectionFactoryImpl = " +
                  def.getMcfDefs().get(getNumOfMcf()).getCciConnFactoryClass() + ".class,\n");

            writeWithIndent(out, indent, " connection = Connection.class,\n");
            writeWithIndent(out, indent,
                  " connectionImpl = " + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + ".class)\n");
         }
      }

      out.write("public class " + getClassName(def) + " implements ManagedConnectionFactory");
      if (def.getMcfDefs().get(getNumOfMcf()).isImplRaAssociation())
      {
         out.write(", ResourceAdapterAssociation");
      }
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      writeWithIndent(out, indent, "/** The serial version UID */\n");
      writeWithIndent(out, indent, "private static final long serialVersionUID = 1L;\n\n");

      writeWithIndent(out, indent, "/** The logger */\n");
      writeWithIndent(out, indent, "private static Logger log = Logger.getLogger(" + getSelfClassName(def) + ");\n\n");
      if (def.getMcfDefs().get(getNumOfMcf()).isImplRaAssociation())
      {
         writeWithIndent(out, indent, "/** The resource adapter */\n");
         writeIndent(out, indent);
         if (def.isRaSerial())
         {
            out.write("private ResourceAdapter ra;");
         }
         else
         {
            out.write("private transient ResourceAdapter ra;");
         }
         writeEol(out);
         writeEol(out);
      }

      writeWithIndent(out, indent, "/** The logwriter */\n");
      writeWithIndent(out, indent, "private PrintWriter logwriter;\n\n");

      writeConfigPropsDeclare(def, out, indent);

      writeDefaultConstructor(def, out, indent);

      writeConfigProps(def, out, indent);
      writeConnectionFactory(def, out, indent);
      writeManagedConnection(def, out, indent);
      writeLogWriter(def, out, indent);
      if (def.getMcfDefs().get(getNumOfMcf()).isImplRaAssociation())
      {
         writeResourceAdapter(def, out, indent);
      }

      writeHashCode(def, out, indent);
      writeEquals(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
87256
public static void dump(final List<Difference> sortedDifferences, final PrintStream out) {
        String currentClassName = "";
        for (final Difference difference : sortedDifferences) {
            if (!currentClassName.equals(difference.getClassName())) {
                out.println("Class "+difference.getClassName());
            }
            out.println(" "+extractActionType(difference)+" "+extractInfoType(difference.getInfo())+" "+extractDetails(difference));
            currentClassName = difference.getClassName();
        }
    }
819521
private void writeMethod(Definition def, Writer out, int indent) throws IOException
   {
      if (def.getMcfDefs().get(getNumOfMcf()).isDefineMethodInConnection())
      {
         if (def.getMcfDefs().get(getNumOfMcf()).getMethods().size() > 0)
         {
            for (MethodForConnection method : def.getMcfDefs().get(getNumOfMcf()).getMethods())
            {
               writeMethodSignature(out, indent, method);
               writeLeftCurlyBracket(out, indent);
               writeIndent(out, indent + 1);

               if (!method.getReturnType().equals("void"))
               {
                  out.write("return ");
               }
               out.write("mc." + method.getMethodName() + "(");
               int paramSize = method.getParams().size();
               for (int i = 0; i < paramSize; i++)
               {
                  MethodParam param = method.getParams().get(i);
                  out.write(param.getName());
                  if (i + 1 < paramSize)
                     out.write(", ");
               }
               out.write(");");

               writeRightCurlyBracket(out, indent);
               writeEol(out);
            }
         }
      }
      else
      {
         writeSimpleMethodSignature(out, indent, " * Call me", "public void callMe()");
         writeLeftCurlyBracket(out, indent);
         writeWithIndent(out, indent + 1, "if (mc != null)\n");
         writeWithIndent(out, indent + 2, "mc.callMe();");
         writeRightCurlyBracket(out, indent);
      }

      writeEol(out);
      writeSimpleMethodSignature(out, indent, " * Close", "public void close()");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "if (mc != null)\n");
      writeLeftCurlyBracket(out, indent + 1);
      writeWithIndent(out, indent + 2, "mc.closeHandle(this);\n");
      writeIndent(out, indent + 2);
      out.write("mc = null;");
      writeRightCurlyBracket(out, indent + 1);
      writeRightCurlyBracket(out, indent);

      writeEol(out);
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Set ManagedConnection\n");
      writeWithIndent(out, indent, " */\n");
      writeWithIndent(out, indent,
            "void setManagedConnection(" + def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc)");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this.mc = mc;");
      writeRightCurlyBracket(out, indent);
   }
1016595
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      if (def.isUseAnnotation())
      {
         if (!def.isDefaultPackageInbound())
         {
            out.write("@Activation(messageListeners = { " + def.getMlClass() + ".class })\n");
         }
         else
         {
            out.write("@Activation(messageListeners = { " + def.getRaPackage() +
                  ".inflow." + def.getMlClass() + ".class })\n");
         }
      }
      out.write("public class " + getClassName(def) + " implements ActivationSpec");
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      int indent = 1;
      writeWithIndent(out, indent, "/** The logger */\n");
      writeWithIndent(out, indent, "private static Logger log = Logger.getLogger(" + getSelfClassName(def) + ");\n\n");

      writeWithIndent(out, indent, "/** The resource adapter */\n");
      writeWithIndent(out, indent, "private ResourceAdapter ra;\n\n");

      writeConfigPropsDeclare(def, out, indent);

      writeDefaultConstructor(def, out, indent);

      writeConfigProps(def, out, indent);

      writeValidate(def, out, indent);
      writeResourceAdapter(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
885688
private void writeClass(File directory, String name, ByteBuffer def) {
    writeClass(directory, name, def, computeClassDigest(def));
  }
249407
void generateOutboundCode(Definition def)
   {
      if (def.isSupportOutbound())
      {
         if (def.getMcfDefs() == null)
            throw new IllegalStateException("Should define at least one mcf class");

         for (int num = 0; num < def.getMcfDefs().size(); num++)
         {
            generateMultiMcfClassCode(def, "Mcf", num);
            generateMultiMcfClassCode(def, "Mc", num);
            generateMultiMcfClassCode(def, "McMeta", num);

            if (!def.getMcfDefs().get(num).isUseCciConnection())
            {
               generateMultiMcfClassCode(def, "CfInterface", num);
               generateMultiMcfClassCode(def, "Cf", num);
               generateMultiMcfClassCode(def, "ConnInterface", num);
               generateMultiMcfClassCode(def, "ConnImpl", num);
            }
            else
            {
               generateMultiMcfClassCode(def, "CciConn", num);
               generateMultiMcfClassCode(def, "CciConnFactory", num);
               generateMultiMcfClassCode(def, "ConnMeta", num);
               generateMultiMcfClassCode(def, "ConnSpec", num);
            }
         }
      }
   }