Output get activation spec method

@param def    definition
@param out    Writer
@param indent space number
@throws IOException ioException
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);
   }
1270048
private static void emitFinishCommentIndentN(PrintWriter fp, int indent) {
		final String spaces = "                                                                   ";
		synchronized (lock) {
			String comment = spaces.substring(0, indent) + " */";
			fp.println(comment);
		}
	}
740468
private void writeConnectionFactory(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Creates a Connection Factory instance. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param cxManager ConnectionManager to be "
            + "associated with created EIS connection factory instance\n");
      writeWithIndent(out, indent, " * @return EIS-specific Connection Factory instance or "
            + "javax.resource.cci.ConnectionFactory instance\n");
      writeWithIndent(out, indent, " * @throws ResourceException Generic exception\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent,
            "public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException");
      writeLeftCurlyBracket(out, indent);
      writeLogging(def, out, indent + 1, "trace", "createConnectionFactory", "cxManager");
      writeIndent(out, indent + 1);
      if (def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         out.write("return new " + def.getMcfDefs().get(getNumOfMcf()).getCciConnFactoryClass() + "(cxManager);");
      else
         out.write("return new " + def.getMcfDefs().get(getNumOfMcf()).getCfClass() + "(this, cxManager);");

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

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Creates a Connection Factory instance. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @return EIS-specific Connection Factory instance or "
            + "javax.resource.cci.ConnectionFactory instance\n");
      writeWithIndent(out, indent, " * @throws ResourceException Generic exception\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public Object createConnectionFactory() throws ResourceException");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1,
            "throw new ResourceException(\"This resource adapter doesn't support non-managed environments\");");

      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);
   }
853396
@Override
   public void writeImport(Definition def, Writer out) throws IOException
   {
      out.write("package " + def.getRaPackage() + ".inflow;\n\n");
      importLogging(def, out);

      if (def.isUseAnnotation())
      {
         out.write("import javax.resource.spi.Activation;");
         writeEol(out);
      }
      out.write("import javax.resource.spi.ActivationSpec;\n");
      if (def.isUseAnnotation())
      {
         importConfigProperty(def, out);
      }
      out.write("import javax.resource.spi.InvalidPropertyException;\n");
      out.write("import javax.resource.spi.ResourceAdapter;\n");

      if (def.isUseAnnotation())
      {
         for (int i = 0; i < getConfigProps(def).size(); i++)
         {
            if (getConfigProps(def).get(i).isRequired())
            {
               out.write("import javax.validation.constraints.NotNull;\n");
               break;
            }
         }
      }
   }
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);
   }
27649
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      out.write("public interface " + getClassName(def));
      writeLeftCurlyBracket(out, 0);
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Receive message\n");
      writeWithIndent(out, indent, " * @param msg String.\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public void onMessage(String msg);");

      writeRightCurlyBracket(out, 0);
   }
101586
protected void writeSimpleMethodSignature(Writer out, int indent, String javadoc, String signature)
         throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeIndent(out, indent);
      out.write(javadoc);
      writeEol(out);
      writeWithIndent(out, indent, " */\n");

      writeIndent(out, indent);
      out.write(signature);
   }
492639
def tosieve(self, indentlevel=0, target=sys.stdout):
        
        self.__print(self.name, indentlevel, nocr=True, target=target)
        if self.has_arguments():
            for arg in self.args_definition:
                if not arg["name"] in self.arguments:
                    continue
                target.write(" ")
                value = self.arguments[arg["name"]]
                atype = arg["type"]
                if "tag" in atype:
                    target.write(value)
                    if arg["name"] in self.extra_arguments:
                        value = self.extra_arguments[arg["name"]]
                        atype = arg["extra_arg"]["type"]
                        target.write(" ")
                    else:
                        continue

                if type(value) == list:
                    if self.__get_arg_type(arg["name"]) == ["testlist"]:
                        target.write("(")
                        for t in value:
                            t.tosieve(target=target)
                            if value.index(t) != len(value) - 1:
                                target.write(", ")
                        target.write(")")
                    else:
                        target.write(
                            "[{}]".format(", ".join(
                                ['"%s"' % v.strip('"') for v in value])
                            )
                        )
                    continue
                if isinstance(value, Command):
                    value.tosieve(indentlevel, target=target)
                    continue

                if "string" in atype:
                    target.write(value)
                    if not value.startswith('"') and not value.startswith("["):
                        target.write("\n")
                else:
                    target.write(value)

        if not self.accept_children:
            if self.get_type() != "test":
                target.write(";\n")
            return
        if self.get_type() != "control":
            return
        target.write(" {\n")
        for ch in self.children:
            ch.tosieve(indentlevel + 4, target=target)
        self.__print("}", indentlevel, target=target)
421267
@GwtIncompatible("Unnecessary")
  void writeOutput(
      Appendable out,
      Compiler compiler,
      @Nullable JSModule module,
      String wrapper,
      String codePlaceholder,
      @Nullable Function<String, String> escaper)
      throws IOException {
    if (compiler.getOptions().outputJs == OutputJs.SENTINEL) {
      out.append("// No JS output because the compiler was run in checks-only mode.\n");
      return;
    }
    checkState(compiler.getOptions().outputJs == OutputJs.NORMAL);

    String code = module == null ? compiler.toSource() : compiler.toSource(module);
    writeOutput(out, compiler, code, wrapper, codePlaceholder, escaper);
  }
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");
      }
   }
844528
@Override
   public void writeXmlBody(Definition def, Writer out) throws IOException
   {
      writeConnectorVersion(out);

      int indent = 1;
      writeIndent(out, indent);
      out.write("<display-name>Display Name</display-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<vendor-name>Red Hat Inc</vendor-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<spec-version>1.0</spec-version>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<eis-type>Test RA</eis-type>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<version>0.1</version>");
      writeEol(out);

      writeIndent(out, indent);
      out.write("<resourceadapter>");
      writeEol(out);

      writeOutbound(def, out, indent + 1);

      writeIndent(out, indent);
      out.write("</resourceadapter>");
      writeEol(out);
      out.write("</connector>");
      writeEol(out);
   }
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);
   }
904017
private Writer doWrite(Writer writer, int indentFactor, int indent) throws IOException {
		writer.write(CharUtil.DELIM_START);
		boolean isFirst = true;
		final boolean isIgnoreNullValue = this.config.isIgnoreNullValue();
		final int newIndent = indent + indentFactor;
		for (Entry<String, Object> entry : this.entrySet()) {
			if (ObjectUtil.isNull(entry.getKey()) || (ObjectUtil.isNull(entry.getValue()) && isIgnoreNullValue)) {
				continue;
			}

			if (isFirst) {
				isFirst = false;
			} else {
				// 键值对分隔
				writer.write(CharUtil.COMMA);
			}
			// 换行缩进
			if (indentFactor > 0) {
				writer.write(CharUtil.LF);
			}

			InternalJSONUtil.indent(writer, newIndent);
			writer.write(JSONUtil.quote(entry.getKey().toString()));
			writer.write(CharUtil.COLON);
			if (indentFactor > 0) {
				// 冒号后的空格
				writer.write(CharUtil.SPACE);
			}
			InternalJSONUtil.writeValue(writer, entry.getValue(), indentFactor, newIndent, this.config);
		}

		// 结尾符
		if (indentFactor > 0) {
			writer.write(CharUtil.LF);
		}
		InternalJSONUtil.indent(writer, indent);
		writer.write(CharUtil.DELIM_END);
		return writer;
	}
612095
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      if (def.isUseAnnotation())
      {
         out.write("@Connector");
         if (def.isSupportOutbound())
         {
            out.write("(\n");
            if (def.getAuthenMechanisms() != null && def.getAuthenMechanisms().size() > 0)
            {
               writeWithIndent(out, 1, "authMechanisms = {\n");
               for (int i = 0; i < def.getAuthenMechanisms().size(); i++)
               {
                  writeWithIndent(out, 2, "@AuthenticationMechanism(");
                  out.write("authMechanism = \"" + def.getAuthenMechanisms().get(i).getAuthMechanism());
                  out.write("\", credentialInterface = CredentialInterface." + def.getAuthenMechanisms().get(i)
                        .getCredentialInterface());
                  if (i + 1 < def.getAuthenMechanisms().size())
                     out.write("),");
                  else
                     out.write(")},");
                  writeEol(out);
               }
            }
            writeIndent(out, 1);
            out.write("reauthenticationSupport = " + def.isSupportReauthen() + ",\n");
            if (def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
            {
               writeWithIndent(out, 1, "securityPermissions = {\n");

               for (int i = 0; i < def.getSecurityPermissions().size(); i++)
               {
                  writeWithIndent(out, 2, "@SecurityPermission(");
                  out.write("permissionSpec = \"" +
                        def.getSecurityPermissions().get(i).getPermissionSpec() + "\")");
                  if (i + 1 < def.getSecurityPermissions().size())
                     out.write(",");
                  else
                     out.write("},");
                  writeEol(out);
               }
            }
            writeIndent(out, 1);
            out.write("transactionSupport = TransactionSupport.TransactionSupportLevel." +
                  def.getSupportTransaction() + ")");
         }
         writeEol(out);
      }
      out.write("public class " + getClassName(def) + " implements ResourceAdapter");
      if (def.isRaSerial())
      {
         out.write(", java.io.Serializable");
      }
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      int indent = 1;

      if (def.isRaSerial())
      {
         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.isSupportInbound())
      {
         writeWithIndent(out, indent, "/** The activations by activation spec */\n");
         writeWithIndent(out, indent, "private ");
         if (def.getVersion().equals("1.6") || def.getVersion().equals("1.7"))
         {
            out.write("ConcurrentHash");
         }
         out.write("Map<" + def.getAsClass() + ", " + def.getActivationClass() + "> activations;\n\n");
      }

      writeConfigPropsDeclare(def, out, indent);

      writeSimpleMethodSignature(out, indent, " * Default constructor", "public " + getClassName(def) + "()");
      writeLeftCurlyBracket(out, indent);
      if (def.isSupportInbound())
      {
         if (def.getVersion().equals("1.6") || def.getVersion().equals("1.7"))
         {
            writeWithIndent(out, indent + 1, "this.activations = new ConcurrentHashMap<" +
                  def.getAsClass() + ", " + def.getActivationClass() + ">();\n");
         }
         else
         {
            writeWithIndent(out, indent + 1, "this.activations = Collections.synchronizedMap(new HashMap<" +
                  def.getAsClass() + ", " + def.getActivationClass() + ">());\n");
         }
      }
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeConfigProps(def, out, indent);
      writeEndpointLifecycle(def, out, indent);
      writeLifecycle(def, out, indent);
      writeXAResource(def, out, indent);
      writeHashCode(def, out, indent);
      writeEquals(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
125393
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      out.write("public class " + getClassName(def));
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      int indent = 1;

      writeWithIndent(out, indent, "/** The resource adapter */\n");
      writeWithIndent(out, indent, "private " + def.getRaClass() + " ra;\n\n");

      writeWithIndent(out, indent, "/** Activation spec */\n");
      writeWithIndent(out, indent, "private " + def.getAsClass() + " spec;\n\n");

      writeWithIndent(out, indent, "/** The message endpoint factory */\n");
      writeWithIndent(out, indent, "private MessageEndpointFactory endpointFactory;\n\n");

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " * @exception ResourceException Thrown if an error occurs\n");
      writeWithIndent(out, indent, " */\n");
      writeWithIndent(out, indent, "public " + getClassName(def) + "() throws ResourceException");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this(null, null, null);");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      //constructor
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Constructor\n");
      writeWithIndent(out, indent, " * @param ra " + def.getRaClass());
      writeEol(out);
      writeWithIndent(out, indent, " * @param endpointFactory MessageEndpointFactory\n");
      writeWithIndent(out, indent, " * @param spec " + def.getAsClass());
      writeEol(out);
      writeWithIndent(out, indent, " * @exception ResourceException Thrown if an error occurs\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public " + getClassName(def) + "(" + def.getRaClass() + " ra, \n");
      writeWithIndent(out, indent + 1, "MessageEndpointFactory endpointFactory,\n");
      writeWithIndent(out, indent + 1, def.getAsClass() + " spec) throws ResourceException\n");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this.ra = ra;\n");
      writeWithIndent(out, indent + 1, "this.endpointFactory = endpointFactory;\n");
      writeWithIndent(out, indent + 1, "this.spec = spec;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeGetAs(def, out, indent);
      writeMef(def, out, indent);
      writeStartStop(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }
716228
void generateClassCode(Definition def, String className, String subDir)
   {
      if (className == null || className.equals(""))
         return;

      try
      {
         String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";
         String javaFile =
               Definition.class.getMethod("get" + className + "Class").invoke(def, (Object[]) null) + ".java";
         FileWriter fw;
         if (subDir == null)
            fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
         else
            fw = Utils.createSrcFile(javaFile, def.getRaPackage() + "." + subDir, 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();
      }
   }