Output MetaData method

@param def    definition
@param out    Writer
@param indent space number
@throws IOException ioException
321490
private void writeMetaData(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent,
            " * Gets the information on the underlying EIS instance represented through an active connection.\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent,
            " * @return ConnectionMetaData instance representing information about the EIS instance\n");
      writeWithIndent(out, indent,
            " * @throws ResourceException Failed to get information about the connected EIS instance. \n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
104396
private void writeInbound(Definition def, Writer out, int indent) throws IOException
   {
      writeIndent(out, indent);
      out.write("<inbound-resourceadapter>");
      writeEol(out);
      writeIndent(out, indent + 1);
      out.write("<messageadapter>");
      writeEol(out);
      writeIndent(out, indent + 2);
      out.write("<messagelistener>");
      writeEol(out);
      writeIndent(out, indent + 3);
      if (!def.isDefaultPackageInbound())
      {
         out.write("<messagelistener-type>" + def.getMlClass() + "</messagelistener-type>");
      }
      else
      {
         out.write("<messagelistener-type>" + def.getRaPackage() +
               ".inflow." + def.getMlClass() + "</messagelistener-type>");
      }
      writeEol(out);
      writeIndent(out, indent + 3);
      out.write("<activationspec>");
      writeEol(out);
      writeIndent(out, indent + 4);
      out.write("<activationspec-class>" + def.getRaPackage() +
            ".inflow." + def.getAsClass() + "</activationspec-class>");
      writeEol(out);

      writeAsConfigPropsXml(def.getAsConfigProps(), out, indent + 4);
      writeIndent(out, indent + 3);
      out.write("</activationspec>");
      writeEol(out);
      writeIndent(out, indent + 2);
      out.write("</messagelistener>");
      writeEol(out);
      writeIndent(out, indent + 1);
      out.write("</messageadapter>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("</inbound-resourceadapter>");
      writeEol(out);
   }
785304
public static void indent(int num, StringBuilder out) {
        if (num <= SIXTY_FOUR) {
            out.append(SIXTY_FOUR_SPACES, 0, num);
            return;
        } else if (num <= 128){
            // avoid initializing loop counters if only one iteration
            out.append(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            out.append(SIXTY_FOUR_SPACES, 0, num - SIXTY_FOUR);
        } else {
            int times = num / SIXTY_FOUR;
            int rem = num % SIXTY_FOUR;
            for (int i = 0; i< times; i++) {
                out.append(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            }
            out.append(SIXTY_FOUR_SPACES, 0, rem);
            return;
        }
    }
223281
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

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

      writeDefaultConstructor(def, out, indent);

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

      writeWithIndent(out, indent, "public " + getClassName(def) + "(ConnectionSpec connSpec)");
      writeLeftCurlyBracket(out, indent);
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeClose(def, out, indent);
      writeInteraction(def, out, indent);
      writeLocalTransaction(def, out, indent);
      writeMetaData(def, out, indent);
      writeResultSetInfo(def, 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);
      writeRightCurlyBracket(out, indent);

      writeRightCurlyBracket(out, 0);
   }
1227995
public void writeDefinition(final OutputStream result) throws IOException 
    {
        result.write(DocWriter.getISOBytes("{"));
        result.write(DocWriter.getISOBytes("\\style"));
        result.write(DocWriter.getISOBytes("\\s"));
        result.write(intToByteArray(this.styleNumber));
        result.write(RtfBasicElement.DELIMITER);
        writeParagraphSettings(result);
        super.writeBegin(result);
        result.write(RtfBasicElement.DELIMITER);
        result.write(DocWriter.getISOBytes(this.styleName));
        result.write(DocWriter.getISOBytes(";"));
        result.write(DocWriter.getISOBytes("}"));
        this.document.outputDebugLinebreak(result);   	
    }
481493
private void writeGetAs(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Get activation spec class\n");
      writeWithIndent(out, indent, " * @return Activation spec\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public " + def.getAsClass() + " getActivationSpec()");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "return spec;");

      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
1012747
public static void indent(int num, PrintWriter out) {
        if (num <= SIXTY_FOUR) {
            out.write(SIXTY_FOUR_SPACES, 0, num);
            return;
        } else if (num <= 128){
            out.write(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            out.write(SIXTY_FOUR_SPACES, 0, num - SIXTY_FOUR);
        } else {
            int times = num / SIXTY_FOUR;
            int rem = num % SIXTY_FOUR;
            for (int i = 0; i< times; i++) {
                out.write(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            }
            out.write(SIXTY_FOUR_SPACES, 0, rem);
            return;
        }
    }
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);
   }
1093852
public void generate(Definition def, Writer out) throws IOException
   {
      writeHeader(def, out);
      writeImport(def, out);
      writeClassComment(def, out);
      writeClassBody(def, out);
   }
559610
public static void write(Node node, OutputStream out, String charset, int indent) {
		transform(new DOMSource(node), new StreamResult(out), charset, indent);
	}
1003666
void writeConfigPropsDeclare(Definition def, Writer out, int indent) throws IOException
   {
      if (getConfigProps(def) == null)
         return;

      for (int i = 0; i < getConfigProps(def).size(); i++)
      {
         writeWithIndent(out, indent, "/** " + getConfigProps(def).get(i).getName() + " */\n");

         if (def.isUseAnnotation())
         {
            writeIndent(out, indent);
            out.write("@ConfigProperty(defaultValue = \"" + getConfigProps(def).get(i).getValue() + "\")");
            if (getConfigProps(def).get(i).isRequired())
            {
               out.write(" @NotNull");
            }
            writeEol(out);
         }
         writeWithIndent(out, indent, "private " +
               getConfigProps(def).get(i).getType() +
               " " +
               getConfigProps(def).get(i).getName() +
               ";\n\n");
      }
   }
138426
public void writeDefinition(final OutputStream result) throws IOException
    {
        result.write(COLOR_RED);
        result.write(intToByteArray(red));
        result.write(COLOR_GREEN);
        result.write(intToByteArray(green));
        result.write(COLOR_BLUE);
        result.write(intToByteArray(blue));
        result.write(COLON);    	
    }
990588
public <T> void write(final OutputStream stream, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) {
		try {
			jsonFormat.write(stream, object, descriptor, indent);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
943062
private void writeEndpointLifecycle(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * This is called during the activation of a message endpoint.\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param endpointFactory A message endpoint factory instance.\n");
      writeWithIndent(out, indent, " * @param spec An activation spec JavaBean instance.\n");
      writeWithIndent(out, indent, " * @throws ResourceException generic exception \n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public void endpointActivation(MessageEndpointFactory endpointFactory,\n");
      writeWithIndent(out, indent + 1, "ActivationSpec spec) throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      if (def.isSupportInbound())
      {
         writeIndent(out, indent + 1);
         out.write(def.getActivationClass() + " activation = new " + def.getActivationClass() +
               "(this, endpointFactory, (" + def.getAsClass() + ")spec);\n");
         writeWithIndent(out, indent + 1, "activations.put((" + def.getAsClass() + ")spec, activation);\n");
         writeWithIndent(out, indent + 1, "activation.start();\n\n");
      }

      writeLogging(def, out, indent + 1, "trace", "endpointActivation", "endpointFactory", "spec");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * This is called when a message endpoint is deactivated. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param endpointFactory A message endpoint factory instance.\n");
      writeWithIndent(out, indent, " * @param spec An activation spec JavaBean instance.\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public void endpointDeactivation(MessageEndpointFactory endpointFactory,\n");
      writeWithIndent(out, indent + 1, "ActivationSpec spec)");
      writeLeftCurlyBracket(out, indent);

      if (def.isSupportInbound())
      {
         writeIndent(out, indent + 1);
         out.write(def.getActivationClass() + " activation = activations.remove(spec);\n");
         writeWithIndent(out, indent + 1, "if (activation != null)\n");
         writeWithIndent(out, indent + 2, "activation.stop();\n\n");
      }
      writeLogging(def, out, indent + 1, "trace", "endpointDeactivation", "endpointFactory");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
1121740
private void writeResourceAdapter(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Get the resource adapter\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @return The handle\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public ResourceAdapter getResourceAdapter()");
      writeLeftCurlyBracket(out, indent);

      writeLogging(def, out, indent + 1, "trace", "getResourceAdapter");

      writeIndent(out, indent + 1);
      out.write("return ra;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Set the resource adapter\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param ra The handle\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public void setResourceAdapter(ResourceAdapter ra)");
      writeLeftCurlyBracket(out, indent);

      writeLogging(def, out, indent + 1, "trace", "setResourceAdapter", "ra");

      writeIndent(out, indent + 1);
      out.write("this.ra = ra;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
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);
   }
1320774
void generateMavenXml(Definition def, String outputDir)
   {
      try
      {
         FileWriter pomfw = Utils.createFile("pom.xml", outputDir);
         PomXmlGen pxGen = new PomXmlGen();
         pxGen.generate(def, pomfw);
         pomfw.close();
      }
      catch (IOException ioe)
      {
         ioe.printStackTrace();
      }
   }