Output class

@param def definition
@param out Writer
@throws IOException ioException
777596
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;

      out.write("public interface " + getClassName(def));
      writeLeftCurlyBracket(out, 0);

      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);
               out.write(";\n");
            }
         }
      }
      else
      {
         writeSimpleMethodSignature(out, indent, " * Call me", "public void callMe();");
      }

      writeEol(out);
      writeSimpleMethodSignature(out, indent, " * Close", "public void close();");

      writeRightCurlyBracket(out, 0);
   }
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);
   }
1062736
public void writeDefinition(final OutputStream result) throws IOException
    {
        result.write(DocWriter.getISOBytes("{"));
        result.write(DocWriter.getISOBytes("\\stylesheet"));
        result.write(RtfBasicElement.DELIMITER);
        this.document.outputDebugLinebreak(result);
        Iterator it = this.styleMap.values().iterator();
        while(it.hasNext()) {
        	RtfParagraphStyle rps = (RtfParagraphStyle)it.next();
        	rps.writeDefinition(result);
        }
        result.write(DocWriter.getISOBytes("}"));
        this.document.outputDebugLinebreak(result);  	
    }
322370
@Override
   public void writeImport(Definition def, Writer out) throws IOException
   {
      out.write("package " + def.getRaPackage() + ".mbean;\n\n");
      out.write("import javax.management.MBeanServer;\n");
      out.write("import javax.management.ObjectName;\n");
      out.write("import javax.naming.InitialContext;\n\n");

      out.write("import " + def.getRaPackage() + "." + def.getMcfDefs().get(0).getConnInterfaceClass() + ";\n");
      out.write("import " + def.getRaPackage() + "." + def.getMcfDefs().get(0).getCfInterfaceClass() + ";\n\n");
   }
694408
@Override
   public void writeImport(Definition def, Writer out) throws IOException
   {
      out.write("package " + def.getRaPackage() + ";");

      writeEol(out);
      writeEol(out);
      importLogging(def, out);
      out.write("import javax.naming.NamingException;\n");
      out.write("import javax.naming.Reference;\n\n");
      out.write("import javax.resource.ResourceException;\n");
      out.write("import javax.resource.spi.ConnectionManager;\n\n");
   }
517720
void writeSimple(Class<?> declaredType, Object value) throws IOException {
        // simple types have no need to write a type object
        Class<?> realType = value.getClass();
        if (realType == Integer.class) {
            output.writeInt(((Integer) value).intValue());
            return;
        } else if (realType == Double.class) {
            output.writeDouble(((Double) value).doubleValue());
            return;
        } else if (realType == Float.class) {
            output.writeFloat(((Float) value).floatValue());
            return;
        } else if (realType == Boolean.class) {
            output.writeBoolean(((Boolean) value).booleanValue());
            return;
        }

        // handle no declared type and subclasses
        Class<?> effectiveType = getAndSerializeEffectiveTypeIfRequired(value, declaredType);

        // long/short/byte only processed now to ensure that a distinction can be made between Integer and Long
        if (realType == Long.class) {
            output.writeLong(((Long) value).longValue());
            return;
        } else if (realType == Short.class) {
            output.writeInt(((Short) value).shortValue());
            return;
        } else if (realType == Byte.class) {
            output.writeInt(((Byte) value).byteValue());
            return;
        } else if (realType == byte[].class) {
            output.writeBytes((byte[]) value);
            return;
        }

        // write as a string
        try {
            writeObjectAsString(value, effectiveType);
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
        }
    }
1143369
@Override
   void writeEquals(Definition def, Writer out, int indent) throws IOException
   {
      writeIndent(out, indent);
      out.write("/** \n");
      writeIndent(out, indent);
      out.write(" * Indicates whether some other object is equal to this one.\n");
      writeIndent(out, indent);
      out.write(" * @param other The reference object with which to compare.\n");
      writeIndent(out, indent);
      out.write(" * @return true if this object is the same as the obj argument, false otherwise.\n");
      writeIndent(out, indent);
      out.write(" */\n");

      writeIndent(out, indent);
      out.write("@Override\n");
      writeIndent(out, indent);
      out.write("public boolean equals(Object other)");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "if (other == null)\n");
      writeWithIndent(out, indent + 2, "return false;\n");
      writeWithIndent(out, indent + 1, "if (other == this)\n");
      writeWithIndent(out, indent + 2, "return true;\n");
      writeWithIndent(out, indent + 1, "if (!(other instanceof " + getClassName(def) + "))\n");
      writeWithIndent(out, indent + 2, "return false;\n");

      writeWithIndent(out, indent + 1, "boolean result = true;\n");

      if (getConfigProps(def).size() > 0)
      {
         writeIndent(out, indent + 1);
         out.write(getClassName(def) + " obj = (" + getClassName(def) + ")other;\n");
      }

      for (int i = 0; i < getConfigProps(def).size(); i++)
      {
         writeWithIndent(out, indent + 1, "if (result)");
         writeLeftCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 2, "if (" + getConfigProps(def).get(i).getName() + " == null)\n");
         writeWithIndent(out, indent + 3,
               "result = obj.get" + upcaseFirst(getConfigProps(def).get(i).getName()) + "() == null;\n");

         writeWithIndent(out, indent + 2, "else\n");
         writeWithIndent(out, indent + 3, "result = " + getConfigProps(def).get(i).getName() + ".equals(obj.get" +
               upcaseFirst(getConfigProps(def).get(i).getName()) + "());");
         writeRightCurlyBracket(out, indent + 1);
      }
      writeWithIndent(out, indent + 1, "return result;");
      writeRightCurlyBracket(out, indent);
      //writeEol(out);
   }
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);
   }
890798
public static void print(Object o, OutputStream outs, boolean typeheader) throws IOException {
		OutputStreamWriter w=new OutputStreamWriter(outs,"UTF-8");
		print(o,w,typeheader);
		w.flush();
	}
151263
void generateMultiAdminObjectClassCode(Definition def, String className, int num)
   {
      if (className == null || className.equals(""))
         return;

      try
      {
         String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";

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

         String javaFile = "";
         if (codeGen instanceof AoImplCodeGen)
         {
            ((AoImplCodeGen) codeGen).setNumOfAo(num);
            javaFile = def.getAdminObjects().get(num).getAdminObjectClass() + ".java";
         }
         else if (codeGen instanceof AoInterfaceCodeGen)
         {
            ((AoInterfaceCodeGen) codeGen).setNumOfAo(num);
            javaFile = def.getAdminObjects().get(num).getAdminObjectInterface() + ".java";
         }

         FileWriter fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
         codeGen.generate(def, fw);

         fw.flush();
         fw.close();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
516374
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      if (def.isUseAnnotation())
      {
         out.write("@AdministeredObject(adminObjectInterfaces = { ");
         out.write(def.getAdminObjects().get(numOfAo).getAdminObjectInterface());
         out.write(".class })\n");
      }
      out.write("public class " + getClassName(def) + " implements " +
            def.getAdminObjects().get(numOfAo).getAdminObjectInterface());
      if (def.isAdminObjectImplRaAssociation())
      {
         out.write(",\n");
         writeIndent(out, 1);
         out.write("ResourceAdapterAssociation, Referenceable, Serializable");
      }
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeIndent(out, indent);
      out.write("/** Serial version uid */\n");
      writeIndent(out, indent);
      out.write("private static final long serialVersionUID = 1L;\n\n");

      if (def.isAdminObjectImplRaAssociation())
      {
         writeWithIndent(out, indent, "/** The resource adapter */\n");
         writeIndent(out, indent);
         if (def.isRaSerial())
         {
            out.write("private ResourceAdapter ra;\n\n");
         }
         else
         {
            out.write("private transient ResourceAdapter ra;\n\n");
         }

         writeWithIndent(out, indent, "/** Reference */\n");
         writeWithIndent(out, indent, "private Reference reference;\n\n");
      }
      writeConfigPropsDeclare(def, out, indent);

      writeDefaultConstructor(def, out, indent);

      writeConfigProps(def, out, indent);

      if (def.isAdminObjectImplRaAssociation())
      {
         writeResourceAdapter(def, out, indent);
         writeReference(def, out, indent);
      }
      writeHashCode(def, out, indent);
      writeEquals(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
431092
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public class " + getClassName(def) + " implements ConnectionFactory");
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeWithIndent(out, indent, "private Reference reference;\n\n");

      writeDefaultConstructor(def, out, indent);

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

      writeWithIndent(out, indent, "public " + getClassName(def) + "(ConnectionManager cxManager)");
      writeLeftCurlyBracket(out, indent);
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeConnection(def, out, indent);
      writeMetaData(def, out, indent);
      writeRecordFactory(def, out, indent);
      writeReference(def, out, indent);
      writeRightCurlyBracket(out, 0);
   }
584785
@Override
   public void generate(Definition def)
   {
      generatePackageInfo(def, "main", null);

      generateRaCode(def);
      generateOutboundCode(def);
      generateInboundCode(def);

      generateTestCode(def);

      switch (def.getBuild())
      {
         case "ivy":
            generateAntIvyXml(def, def.getOutputDir());
            break;
         case "maven":
            generateMavenXml(def, def.getOutputDir());
            break;
         case "gradle":
            generateGradle(def, def.getOutputDir());
            break;
         default:
            generateAntXml(def, def.getOutputDir());
            break;
      }

      generateRaXml(def, def.getOutputDir());
      if (def.isSupportOutbound())
         generateIronjacamarXml(def, def.getOutputDir());

      if (def.isGenMbean() &&
            def.isSupportOutbound() &&
            !def.getMcfDefs().get(0).isUseCciConnection())
      {
         generateMBeanCode(def);
         generateMbeanXml(def, def.getOutputDir());
      }

      if (def.isSupportEis() &&
            def.isSupportOutbound() &&
            !def.getMcfDefs().get(0).isUseCciConnection())
      {
         generateEisCode(def);
      }
   }
1030084
public void write(XMLStreamWriter writer, AttributeDefinition<?> def, String name) throws XMLStreamException {
      Attribute<?> attribute = attribute(def);
      attribute.write(writer, name);
   }
345536
private void writeConnection(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/** \n");
      writeWithIndent(out, indent, " * Get connection from factory\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent,
            " * @return " + def.getMcfDefs().get(getNumOfMcf()).getConnInterfaceClass() + " instance\n");
      writeWithIndent(out, indent, " * @exception ResourceException Thrown if a connection can't be obtained\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public " + def.getMcfDefs().get(getNumOfMcf()).getConnInterfaceClass() +
            " getConnection() throws ResourceException");
      writeLeftCurlyBracket(out, indent);
      writeLogging(def, out, indent + 1, "trace", "getConnection");

      writeWithIndent(out, indent + 1, "return (" + def.getMcfDefs().get(getNumOfMcf()).getConnInterfaceClass() +
            ")connectionManager.allocateConnection(mcf, null);");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
307922
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeConnection(def, out, indent);
      writeRightCurlyBracket(out, 0);
   }
502291
public void setOutputFormatClass(Class<? extends OutputFormat> cls
                                   ) throws IllegalStateException {
    ensureState(JobState.DEFINE);
    conf.setClass(OUTPUT_FORMAT_CLASS_ATTR, cls, OutputFormat.class);
  }