Output class import

@param def definition
@param out Writer
@throws IOException ioException
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");
   }
1030084
public void write(XMLStreamWriter writer, AttributeDefinition<?> def, String name) throws XMLStreamException {
      Attribute<?> attribute = attribute(def);
      attribute.write(writer, name);
   }
984054
void writeConfigProps(Definition def, Writer out, int indent) throws IOException
   {
      if (getConfigProps(def) == null)
         return;

      for (int i = 0; i < getConfigProps(def).size(); i++)
      {
         String name = getConfigProps(def).get(i).getName();
         String upcaseName = upcaseFirst(name);
         //set
         writeWithIndent(out, indent, "/** \n");
         writeWithIndent(out, indent, " * Set " + name);
         writeEol(out);
         writeWithIndent(out, indent, " * @param " + name + " The value\n");
         writeWithIndent(out, indent, " */\n");

         writeWithIndent(out, indent, "public void set" +
               upcaseName +
               "(" +
               getConfigProps(def).get(i).getType() +
               " " +
               name +
               ")");
         writeLeftCurlyBracket(out, indent);
         writeWithIndent(out, indent + 1, "this." + name + " = " + name + ";");
         writeRightCurlyBracket(out, indent);
         writeEol(out);

         //get
         writeWithIndent(out, indent, "/** \n");
         writeWithIndent(out, indent, " * Get " + name);
         writeEol(out);
         writeWithIndent(out, indent, " * @return The value\n");
         writeWithIndent(out, indent, " */\n");
         writeWithIndent(out, indent, "public " +
               getConfigProps(def).get(i).getType() +
               " get" +
               upcaseName +
               "()");
         writeLeftCurlyBracket(out, indent);
         writeWithIndent(out, indent + 1, "return " + name + ";");
         writeRightCurlyBracket(out, indent);
         writeEol(out);
      }
   }
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);
   }
1336173
void writeClassComment(Definition def, Writer out) throws IOException
   {
      out.write("/**\n");
      out.write(" * " + getClassName(def));
      writeEol(out);
      out.write(" *\n");
      out.write(" * @version $Revision: $\n");
      out.write(" */\n");
   }
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);
   }
791532
protected void importLogging(Definition def, Writer out) throws IOException
   {
      if (def.isSupportJbossLogging())
      {
         out.write("import org.jboss.logging.Logger;");
         writeEol(out);
         writeEol(out);
      }
      else
      {
         out.write("import java.util.logging.Logger;");
         writeEol(out);
         writeEol(out);
      }
   }
1063514
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

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

      writeDefaultConstructor(def, out, indent);

      writeEIS(def, out, indent);
      writeUsername(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
100093
private 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) {
            double dbl = ((Double) value).doubleValue();
            if (Double.isNaN(dbl) == false && Double.isInfinite(dbl) == false) {
                output.writeDouble(dbl);
                return;
            }
        } else if (realType == Boolean.class) {
            output.writeBoolean(((Boolean) value).booleanValue());
            return;
        }
        
        // handle no declared type and subclasses
        Class<?> effectiveType = declaredType;
        boolean requiresClose = false;
        if (declaredType == Object.class) {
            if (realType != String.class) {
                effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
                String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
                output.writeObjectStart();
                output.writeObjectKeyValue(TYPE, typeStr);
                output.writeObjectKey(VALUE);
                requiresClose = true;
            } else {
                effectiveType = realType;
            }
        } else if (settings.getConverter().isConvertible(declaredType) == false) {
            effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
            String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
            output.writeObjectStart();
            output.writeObjectKeyValue(TYPE, typeStr);
            output.writeObjectKey(VALUE);
            requiresClose = true;
        }
        
        // long/short/byte/float only processed now to ensure that exact numeric type can be identified
        if (realType == Long.class) {
            output.writeLong(((Long) value).longValue());
            
        } else if (realType == Short.class) {
            output.writeInt(((Short) value).shortValue());
            
        } else if (realType == Byte.class) {
            output.writeInt(((Byte) value).byteValue());
            
        } else if (realType == Float.class) {
            output.writeFloat(((Float) value).floatValue());
            
        } else {
            // write as a string
            try {
                String converted = settings.getConverter().convertToString(effectiveType, value);
                if (converted == null) {
                    throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
                }
                output.writeString(converted);
            } catch (RuntimeException ex) {
                throw new IllegalArgumentException(
                        "Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
            }
        }
        
        // close open map
        if (requiresClose) {
            output.writeObjectEnd();
        }
    }
1104711
@Override
    public void write(DataOutput out) throws IOException
    {
        addSignatureIfNeed();
        out.writeInt(magic);
        out.writeShort(minor_version);
        out.writeShort(major_version);
        out.writeShort(constant_pool.size()+1);
        for (ConstantInfo ci : constant_pool)
        {
            ci.write(out);
        }
        int modifier = ClassFlags.getModifier(getModifiers());
        modifier |= ClassFlags.ACC_SYNTHETIC | ClassFlags.ACC_PUBLIC | ClassFlags.ACC_SUPER;
        out.writeShort(modifier);
        out.writeShort(this_class);
        out.writeShort(super_class);
        out.writeShort(interfaces.size());
        for (int ii : interfaces)
        {
            out.writeShort(ii);
        }
        out.writeShort(fields.size());
        for (FieldInfo fi : fields)
        {
            fi.write(out);
        }
        out.writeShort(methods.size());
        for (MethodInfo mi : methods)
        {
            mi.write(out);
        }
        out.writeShort(attributes.size());
        for (AttributeInfo ai : attributes)
        {
            ai.write(out);
        }

    }
66535
void generateInboundCode(Definition def)
   {
      if (def.isSupportInbound())
      {
         if (def.isDefaultPackageInbound())
            generateClassCode(def, "Ml", "inflow");
         generateClassCode(def, "As", "inflow");
         generateClassCode(def, "Activation", "inflow");
         generatePackageInfo(def, "main", "inflow");
      }
   }
1354076
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public class " + getClassName(def) + " implements " +
            def.getMcfDefs().get(getNumOfMcf()).getConnInterfaceClass());
      writeLeftCurlyBracket(out, 0);
      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, "/** ManagedConnection */\n");
      writeWithIndent(out, indent, "private " + def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc;\n\n");

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

      //constructor
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " * @param mc " + def.getMcfDefs().get(getNumOfMcf()).getMcClass());
      writeEol(out);
      writeWithIndent(out, indent, " * @param mcf " + def.getMcfDefs().get(getNumOfMcf()).getMcfClass());
      writeEol(out);
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public " + getClassName(def) + "(" +
            def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc, " +
            def.getMcfDefs().get(getNumOfMcf()).getMcfClass() + " mcf)");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this.mc = mc;\n");
      writeWithIndent(out, indent + 1, "this.mcf = mcf;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeMethod(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);
   }
345957
public void write(Output dest) throws IOException {
        int i, max;

        dest.writeU2(Access.toFlags(accessFlags));
        dest.writeClassRef(thisClass);
        if (superClass != null) {
            dest.writeClassRef(superClass);
        } else {
            dest.writeU2(0);
        }

        max = interfaces.size();
        dest.writeU2(max);
        for (i = 0; i < max; i++) {
            dest.writeClassRef(interfaces.get(i));
        }
        max = fields.size();
        dest.writeU2(max);
        for (i = 0; i < max; i++) {
            fields.get(i).write(dest);
        }
        max = methods.size();
        dest.writeU2(max);
        for (i = 0; i < max; i++) {
            methods.get(i).write(dest);
        }
        max = attributes.size();
        dest.writeU2(max);
        for (i = 0; i < max; i++) {
            attributes.get(i).write(dest);
        }
    }
1328538
public void generateOutput(Writer outputWriter) throws IOException {
        String s = generateOutput();
        outputWriter.write(s);
    }
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);
      }
   }
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);
   }