static void writeMovesToFile() {
   PrintWriter moveWriter = null;
   try {
     moveWriter = new PrintWriter("games/" + getCurrentTime() + ".moves", "UTF-8");
   } catch (FileNotFoundException | UnsupportedEncodingException exception) {
     exception.printStackTrace();
   }
   List<String> firstPlayerMoves = null;
   List<String> secondPlayerMoves = null;
   if (humanAsWhite) {
     firstPlayerMoves = humanMoves;
     secondPlayerMoves = computerMoves;
   } else {
     firstPlayerMoves = computerMoves;
     secondPlayerMoves = humanMoves;
   }
   for (int i = 0; i < firstPlayerMoves.size(); i++) {
     moveWriter.print((i + 1) + " " + firstPlayerMoves.get(i) + " ");
     if (i <= secondPlayerMoves.size() - 1) {
       moveWriter.print(secondPlayerMoves.get(i));
     }
     moveWriter.println();
   }
   moveWriter.close();
 }
Exemplo n.º 2
0
  /**
   * 用户登录
   *
   * @param uname
   * @param pwd
   * @return
   */
  @RequestMapping(value = "/user/login")
  public void userLogin(
      String uname,
      String pwd,
      String code,
      HttpServletRequest request,
      HttpServletResponse response) {
    // TODO 验证码系统
    try {
      PrintWriter out = response.getWriter();
      UserInfo user = this.userService.getUserInfoByName(uname);
      if (user != null) {

        if (pwd.equals(user.getPassword())) {
          WebUtil.setLoginCookie(user.getId() + "", response);
          out.print("0"); // 登陆成功
          return;
        } else {
          out.print("1"); // 密码错误
          return;
        }
      } else {
        out.print("2"); // 用户不存在
        return;
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 3
0
  protected void processDocument(Document document, PrintWriter writer) {
    String type = new StencilSetUtil().getStencilSet(document);
    SyntaxChecker checker = null;
    if (type != null) {
      if (type.equals("bpmn.json") || type.equals("bpmneec.json"))
        checker = getCheckerBPMN(document);
      else if (type.equals("bpmn1.1.json")) checker = getCheckerBPMN11(document);
      else if (type.equals("ibpmn.json")) checker = getCheckerIBPMN(document);
      else if (type.equals("interactionpetrinets.json")) checker = getCheckerIPN(document);
      else if (type.equals("epc.json")) checker = getCheckerEPC(document);
    }

    if (checker == null) { // try eRDF
      try {
        NamedNodeMap map =
            XPathAPI.selectSingleNode(document, "//a[@rel='oryx-stencilset']").getAttributes();
        type = map.getNamedItem("href").getNodeValue();
      } catch (TransformerException e) {
        e.printStackTrace();
      }
      if (type != null && type.endsWith("petrinet.json")) {
        checker = getCheckerPetriNet(document);
      }
    }

    if (checker == null) {
      writer.print("{}");
    } else {
      checker.checkSyntax();
      writer.print(checker.getErrorsAsJson().toString());
    }
  }
Exemplo n.º 4
0
  public static void main(String[] args) {
    PrintWriter pw = new PrintWriter(System.out);

    final int MAX = 10000001;
    boolean[] primes = seive(MAX);

    while (sc.hasNext()) {
      int n = sc.nextInt();

      if (n < 8) {
        pw.println("Impossible.");
      } else {
        if (n % 2 == 0) {
          pw.print("2 2 ");
          n -= 4;
        } else {
          pw.print("2 3 ");
          n -= 5;
        }

        int i;
        for (i = 2; i < n; ++i) {
          if (!primes[i] && !primes[n - i]) {
            break;
          }
        }

        pw.println(i + " " + (n - i));
      }
    }

    pw.flush();
  }
Exemplo n.º 5
0
  private void sendProcessingError(Throwable t, ServletResponse response) {
    String stackTrace = getStackTrace(t);

    if (stackTrace != null && !stackTrace.equals("")) {
      try {
        response.setContentType("text/html");
        PrintStream ps = new PrintStream(response.getOutputStream());
        PrintWriter pw = new PrintWriter(ps);
        pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); // NOI18N

        // PENDING! Localize this for next official release
        pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
        pw.print(stackTrace);
        pw.print("</pre></body>\n</html>"); // NOI18N
        pw.close();
        ps.close();
        response.getOutputStream().close();
      } catch (Exception ex) {
      }
    } else {
      try {
        PrintStream ps = new PrintStream(response.getOutputStream());
        t.printStackTrace(ps);
        ps.close();
        response.getOutputStream().close();
      } catch (Exception ex) {
      }
    }
  }
Exemplo n.º 6
0
 public void OutputAnnotationList(PrintWriter Fout, char c) {
   Fout.print(this.access);
   ArrayList<Integer> Ann = new ArrayList<Integer>();
   for (Integer i : Annotation) Ann.add(i);
   Collections.sort(Ann);
   for (Integer i : Ann) Fout.print(proteinCommon.GOInt2Str(i) + c);
 }
Exemplo n.º 7
0
  public static void main(String args[]) {

    wmatrix wmatrix = new wmatrix();
    wmatrix.start();
    try {
      PrintWriter profilefout =
          new PrintWriter(
              new BufferedWriter(
                  new FileWriter(
                      "profile_"
                          + Data.kinease
                          + "_"
                          + Data.code
                          + "_"
                          + Data.windows_size
                          + ".csv")));

      profilefout.print("Position=");
      for (int j = 0; j < Data.windows_size; j++) {
        profilefout.print("," + (j - Data.windows_size / 2));
      }
      profilefout.println();

      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < Data.windows_size; j++) {
          profilefout.print("," + wm[i][j]);
        }
        profilefout.println();
      }
      profilefout.close();

    } catch (IOException ex) {

    }
  }
Exemplo n.º 8
0
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    out = new PrintWriter(System.out);

    int n = in.readInt();
    int[] arr = new int[n + 1];
    int[] par = new int[n];

    for (int i = 1; i <= n; i++) {
      arr[i] = in.readInt();
    }

    int max = 0;

    for (int i = 1; i < n; i++) {
      int num = in.readInt();
      if (arr[num] == 1) {
        par[num] = par[num - 1] + 1;
        if (par[num] > max) {
          max = par[num];
        }
      } else par[num] = 0;
    }

    for (int i : par) {
      out.print(i + " ");
    }

    out.print(max);
    out.flush();
  }
  public ExecutionCounterFileSafeView(
      Simulation simul, String fileName, TimeStamp warmUp, TimeStamp period) {
    super(simul, "executionCounter");
    this.dayUnit = simul.getTimeUnit().convert(period);
    this.warmUp = simul.getTimeUnit().convert(warmUp);
    // The time slot is initialized to the next day
    this.timeSlot = dayUnit;
    busy = new AtomicBoolean(false);
    try {
      buffer = new PrintWriter(new BufferedWriter(new FileWriter(fileName)), true);
    } catch (IOException e) {
      e.printStackTrace();
    }
    for (int i = 0; i < simul.getActivityList().size(); i++)
      buffer.print("\tA:" + simul.getActivity(i).getDescription() + "\t\t");
    for (int i = 0; i < simul.getElementTypeList().size(); i++)
      buffer.print("\tET:" + simul.getElementType(i).getDescription() + "\t\t");
    buffer.println();

    actExCounter = new ActivityCounters[3][];
    for (int i = 0; i < 3; i++) {
      actExCounter[i] = new ActivityCounters[simul.getActivityList().size()];
      for (int j = 0; j < simul.getActivityList().size(); j++)
        actExCounter[i][j] = new ActivityCounters(simul.getActivity(j));
    }
    etExCounter = new AtomicIntegerArray[3];
    for (int i = 0; i < 3; i++)
      etExCounter[i] = new AtomicIntegerArray(simul.getElementTypeList().size());
    addEntrance(ElementActionInfo.class);
    addEntrance(SimulationEndInfo.class);
  }
  protected Result describeMbean(
      @Nonnull MBeanServerConnection mbeanServer, @Nonnull ObjectName objectName)
      throws IntrospectionException, ReflectionException, InstanceNotFoundException, IOException {
    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    out.println("# MBEAN");
    out.println(objectName.toString());
    out.println();
    out.println("## OPERATIONS");
    List<MBeanOperationInfo> operations = Arrays.asList(mbeanInfo.getOperations());
    Collections.sort(
        operations,
        new Comparator<MBeanOperationInfo>() {
          @Override
          public int compare(MBeanOperationInfo o1, MBeanOperationInfo o2) {
            return o1.getName().compareTo(o1.getName());
          }
        });

    for (MBeanOperationInfo opInfo : operations) {
      out.print("* " + opInfo.getName() + "(");
      MBeanParameterInfo[] signature = opInfo.getSignature();
      for (int i = 0; i < signature.length; i++) {
        MBeanParameterInfo paramInfo = signature[i];
        out.print(paramInfo.getType() + " " + paramInfo.getName());
        if (i < signature.length - 1) {
          out.print(", ");
        }
      }

      out.print("):" + opInfo.getReturnType() /* + " - " + opInfo.getDescription() */);
      out.println();
    }
    out.println();
    out.println("## ATTRIBUTES");
    List<MBeanAttributeInfo> attributes = Arrays.asList(mbeanInfo.getAttributes());
    Collections.sort(
        attributes,
        new Comparator<MBeanAttributeInfo>() {
          @Override
          public int compare(MBeanAttributeInfo o1, MBeanAttributeInfo o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    for (MBeanAttributeInfo attrInfo : attributes) {
      out.println(
          "* "
              + attrInfo.getName()
              + ": "
              + attrInfo.getType()
              + " - "
              + (attrInfo.isReadable() ? "r" : "")
              + (attrInfo.isWritable() ? "w" : "") /* + " - " +
                    attrInfo.getDescription() */);
    }

    String description = sw.getBuffer().toString();
    return new Result(objectName, description, description);
  }
  /**
   * Print network and network statistics to file.
   *
   * @param outputDir location to write files to
   * @param summary whether to print network statistics as well as the network itself
   */
  public void printNetwork(String outputDir, boolean summary) {
    try {

      PrintWriter pw = new PrintWriter(outputDir + "/network.txt");
      pw.print(this);
      pw.close();

      if (summary) {

        pw = new PrintWriter(outputDir + "/transitivity.txt");
        pw.print(getTransitivity());
        pw.close();

        Arrays.printToFile(getGeodesicDistances(), outputDir + "/geodesic-distances.txt");
        Arrays.printToFile(getVertexInwardConnectedness(), outputDir + "/inward-connectedness.txt");
        Arrays.printToFile(
            getVertexOutwardConnectedness(), outputDir + "/outward-connectedness.txt");

        Arrays.printToFile(getVertexInDegrees(), outputDir + "/in-degree.txt");
        Arrays.printToFile(getVertexOutDegrees(), outputDir + "/out-degree.txt");
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }
Exemplo n.º 12
0
  public void process(JCas jCas) throws AnalysisEngineProcessException {

    TriageScore doc = JCasUtil.selectSingle(jCas, TriageScore.class);
    String code = doc.getInOutCode();

    File outFile = new File(baseData.getPath() + "/" + code + ".txt");

    try {

      PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outFile, true)));

      out.print(doc.getVpdmfId() + "	");

      for (Sentence sentence : JCasUtil.select(jCas, Sentence.class)) {
        List<Token> tokens = JCasUtil.selectCovered(jCas, Token.class, sentence);
        if (tokens.size() <= 0) {
          continue;
        }

        List<String> tokenStrings = JCasUtil.toText(tokens);
        for (int i = 0; i < tokens.size(); i++) {
          out.print(tokenStrings.get(i) + " ");
        }
      }

      out.print("\n");
      out.close();

    } catch (IOException e) {

      throw new AnalysisEngineProcessException(e);
    }
  }
Exemplo n.º 13
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    CommentService commentService = CommentServiceImpl.getInstance();
    String content = request.getParameter("content");
    int productid = Integer.parseInt(request.getParameter("productid"));
    User user = (User) request.getSession().getAttribute("user");
    int userid = user.getId();

    PrintWriter out = response.getWriter();

    Comment comment = new Comment();
    comment.setContent(content);
    comment.setUserid(userid);
    comment.setProductid(productid);
    int result = commentService.addComment(comment);
    if (result == 1) {
      out.print("添加成功");
    } else {
      out.print("添加失败");
    }

    out.flush();
    out.close();
  }
Exemplo n.º 14
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    try {
      response.setContentType("text/plain");
      PrintWriter out = response.getWriter();
      DBConnection db = new DBConnection();
      Connection con = db.getConnection();
      Statement st = con.createStatement();
      HttpSession s = request.getSession();

      String bname = s.getAttribute("bname").toString();
      String uname = s.getAttribute("uname").toString();
      ResultSet rs =
          st.executeQuery(
              "select * from player_details where player_name='"
                  + uname
                  + "' and orderNo=1 and game_name='"
                  + bname
                  + "';");
      if (rs.next()) {
        out.print("1");
      } else {
        out.print("0");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 15
0
  /** Convenience method to print a string nicely and does character conversion to entities. */
  void formatted(PrintWriter pw, int left, int width, String s) {
    int pos = width + 1;
    s = s.trim();

    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      if (i == 0 || (Character.isWhitespace(c) && pos > width - 3)) {
        pw.print("\n");
        spaces(pw, left);
        pos = 0;
      }
      switch (c) {
        case '<':
          pw.print("&lt;");
          pos += 4;
          break;
        case '>':
          pw.print("&gt;");
          pos += 4;
          break;
        case '&':
          pw.print("&amp;");
          pos += 5;
          break;
        default:
          pw.print(c);
          pos++;
          break;
      }
    }
  }
Exemplo n.º 16
0
 public void solve(final int testNumber, final InputReader in, final PrintWriter out) {
   int counter = in.nextInt();
   double[] max = in.nextDoubleArray(counter);
   double[] min = in.nextDoubleArray(counter);
   double[] smin = new double[counter + 1];
   double[] smax = new double[counter + 1];
   for (int i = 1; i <= counter; ++i) {
     smin[i] = smin[i - 1] + min[i - 1];
     smax[i] = smax[i - 1] + max[i - 1];
   }
   double[] p = new double[counter + 1];
   p[0] = 0;
   for (int i = 1; i <= counter; ++i) {
     double B = (smin[i] + smax[i]);
     double C = smax[i];
     double D = B * B - 4 * C;
     p[i] = (B + Math.sqrt(D)) / 2.0;
   }
   for (int i = counter - 1; i > 0; --i) {
     p[i + 1] -= p[i];
     if (p[i + 1] < 1e-9) p[i + 1] = 0;
   }
   for (int i = 1; i <= counter; ++i) {
     out.print(p[i] + " ");
   }
   out.println();
   for (int i = 1; i <= counter; ++i) {
     out.print((min[i - 1] + max[i - 1] - p[i]) + " ");
   }
 }
Exemplo n.º 17
0
  /** @see prefuse.data.io.TableWriter#writeTable(prefuse.data.Table, java.io.OutputStream) */
  public void writeTable(Table table, OutputStream os) throws DataIOException {
    try {
      // get print stream
      PrintWriter out = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));

      // write out header row
      if (m_printHeader) {
        for (int i = 0; i < table.getColumnCount(); ++i) {
          if (i > 0) out.print(',');
          out.print(makeCSVSafe(table.getColumnName(i)));
        }
        out.println();
      }

      // write out data
      for (IntIterator rows = table.rows(); rows.hasNext(); ) {
        int row = rows.nextInt();
        for (int i = 0; i < table.getColumnCount(); ++i) {
          if (i > 0) out.print(',');
          String str = table.getString(row, table.getColumnName(i));
          out.print(makeCSVSafe(str));
        }
        out.println();
      }

      // finish up
      out.flush();
    } catch (Exception e) {
      throw new DataIOException(e);
    }
  }
Exemplo n.º 18
0
 @Override
 protected void execute(
     final @NonNull KernelHttpRequest request, final @NonNull KernelHttpResponse response) {
   if (!request.isPrivileged()) throw new AdminAccessException();
   final String queryType = request.getParameter("queryType");
   final PrintWriter writer = response.getWriter();
   writer.print("[");
   try {
     final ValidatingKernel kernel = getKernel();
     final BeginTransactionResult btr = kernel.beginTransaction();
     final NodesTransaction txn = btr.getTxn();
     boolean commit = false;
     try {
       final Processor processor = processors.get(queryType);
       if (processor == null) writer.println("Query type '" + queryType + "' not found");
       else processor.process(txn, request, writer);
       commit = true;
     } finally {
       txn.finish(commit);
     }
     writer.print("]");
   } finally {
     writer.close();
   }
 }
Exemplo n.º 19
0
  public void run() {
    Parser parser = ((InternalEnvironment) env).parser();
    PrintWriter writer = env.writer();

    // General help: list all commands
    if (args.size() == 0) {
      List<String> commands = parser.availableCommands();
      writer.print("Commands available:\n");
      UTIL.printColumns(commands, writer, 4);
      writer.printf("\n");
      return;
    }

    // Help for specified command if available
    Class<? extends Command> cmdClass = parser.byName(args.get(0));
    try {
      UserHelp uh = (UserHelp) cmdClass.newInstance();
      writer.print(uh.help());
      writer.flush();
    } catch (InstantiationException e) {
      writer.print("No help available");
    } catch (IllegalAccessException e) {
      writer.print("No help available");
    }
  }
Exemplo n.º 20
0
  public static void main(String args[]) throws Exception {
    BufferedReader in = new BufferedReader(new FileReader("important.in"));
    PrintWriter out = new PrintWriter("important.out");

    int n = rInt(in.readLine(), 1, MaxN);

    boolean[] t = new boolean[26];

    for (int i = 0; i < n; i++) {
      String s = in.readLine();
      if (s.length() > MaxL) throw new Exception("String is too long");
      char f = checkFormula(s.trim());
      t[f - 'A'] = true;
    }
    ;

    out.println("Yes");

    boolean flag = false;
    for (int i = 0; i < 26; i++)
      if (t[i]) {
        if (flag) out.print(" | ");
        String let = "" + (char) (i + 'A');
        out.print(let + " | ~" + let);
        flag = true;
      }
    ;

    out.close();
  };
  private void startTraceData() {
    getWorldView().addEventListener(TraceResponse.class, traceResponseListener);

    FileWriter rayFileWriter;
    try {
      rayFileWriter = new FileWriter("DM-Awkward3_rays.txt");
      rayFile = new PrintWriter(rayFileWriter);
      // writing the angle information as the first line
      for (int angle = 0; angle < 360; angle += 10) {
        if (angle == 350) rayFile.print(angle);
        else rayFile.print(angle + " ");
      }
      rayFile.println();
      rayFile.flush();

      // send rays for every cell
      for (int x = -2048, i = 1; x < 2048; x += 128, i++) {
        for (int y = -2048, j = 1; y < 2048; y += 128, j++) {
          int index = (i - 1) * 32 + j;
          Location from =
              new Location(x + 64, y + 64, -462); // z axis is -462 when the user stands still
          System.out.println(index + ") " + (x + 64) + ", " + (y + 64));
          sendRays2(index, from);
        }
      }

    } catch (Exception ex) {
      System.err.println("File can't be set up");
    }
  }
Exemplo n.º 22
0
  private static void printSSLTaggedComponent(TaggedComponent taggedComponent, PrintWriter out) {
    org.omg.SSLIOP.SSL ssl = null;
    if (taggedComponent.tag == 20) {
      CDRInputStream in = new CDRInputStream(taggedComponent.component_data);
      try {
        in.openEncapsulatedArray();
        ssl = org.omg.SSLIOP.SSLHelper.read(in);
      } catch (Exception ex) {
        return;
      }
      int ssl_port = ssl.port;
      if (ssl_port < 0) {
        ssl_port += 65536;
      }

      out.print("\t\ttarget_supports\t:\t");
      // dump               ( ssl.target_supports );
      decodeAssociationOption(ssl.target_supports, out);
      out.println();
      out.print("\t\ttarget_requires\t:\t");
      // dump               ( ssl.target_requires );
      decodeAssociationOption(ssl.target_requires, out);
      out.println();
      out.println("\t\tSSL Port\t:\t" + ssl_port);
    }
  }
Exemplo n.º 23
0
  public void printBrowserForm(PrintWriter pw, DAS das) {

    /*-----------------------------------------------------
    // C++ implementation looks like this...

    os << "<b>Sequence " << name() << "</b><br>\n";
    os << "<dl><dd>\n";

    for (Pix p = first_var(); p; next_var(p)) {
        var(p)->print_val(os, "", print_decls);
        wo.write_variable_attributes(var(p), global_das);
        os << "<p><p>\n";
    }

    os << "</dd></dl>\n";
    -----------------------------------------------------*/

    pw.print("<b>Sequence " + getName() + "</b><br>\n" + "<dl><dd>\n");

    wwwOutPut wOut = new wwwOutPut(pw);

    Enumeration e = getVariables();
    while (e.hasMoreElements()) {
      BaseType bt = (BaseType) e.nextElement();

      ((BrowserForm) bt).printBrowserForm(pw, das);

      wOut.writeVariableAttributes(bt, das);
      pw.print("<p><p>\n");
    }
    pw.println("</dd></dl>\n");
  }
Exemplo n.º 24
0
 public void cutPlaylist() throws Exception {
   if (logger.isDebugEnabled()) logger.debug("Cut Playlist.");
   String st;
   PrintWriter pw =
       new PrintWriter(new BufferedWriter(new FileWriter(new File(this.NAME + ".dec"))));
   BufferedReader br = new BufferedReader(new FileReader(new File(this.NAME)));
   if ((st = br.readLine()) != null) {
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   while ((st = br.readLine()) != null) {
     pw.println();
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   pw.close();
   br.close();
 }
Exemplo n.º 25
0
  /**
   * 检查用户名是否存在
   *
   * @param uname
   * @param request
   * @param response
   */
  @RequestMapping(value = "/user/checkUid")
  public void checkUid(String uname, HttpServletRequest request, HttpServletResponse response) {

    PrintWriter out;
    try {
      out = response.getWriter();

      if (uname == null || "".equals(uname.trim())) {
        out.print("1");
      }
      Stats.USER_CHECK_NAME_DUPLICATED result =
          this.userService.checkUserNameDuplicated(uname, null);
      if (Stats.USER_CHECK_NAME_DUPLICATED.name_duplicated == result) {
        out.print("2");
      } else if (Stats.USER_CHECK_NAME_DUPLICATED.unduplicated == result) {
        out.print("0");
      } else {
        out.print("3");
      }

      return;

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemplo n.º 26
0
  public void printMethod(PrintWriter ps, String classname, boolean is_local, boolean is_abstract) {
    /* in some cases generated name have an underscore prepended for the
    mapped java name. On the wire, we must use the original name */

    String idl_name = (name.startsWith("_") ? name.substring(1) : name);

    ps.print("\tpublic " + opTypeSpec.toString() + " " + name + "(");

    Enumeration e = paramDecls.elements();
    if (e.hasMoreElements()) ((ParamDecl) e.nextElement()).print(ps);

    for (; e.hasMoreElements(); ) {
      ps.print(", ");
      ((ParamDecl) e.nextElement()).print(ps);
    }

    ps.print(")");
    raisesExpr.print(ps);
    ps.println(Environment.NL + "\t{");

    if (parser.generateDiiStubs) {
      printDIIBody(ps, classname, idl_name, is_local, is_abstract);
    } else {
      printStreamBody(ps, classname, idl_name, is_local, is_abstract);
    }

    ps.println("\t}" + Environment.NL); // end method^M
  }
Exemplo n.º 27
0
  /** Metodo que escreve os clientes num ficheiro */
  public void escreveLocalidades(String fileLocalidades, String fileLigacoes, int nrlocalidades)
      throws FileNotFoundException, IOException {
    PrintWriter printloc = new PrintWriter(fileLocalidades);
    PrintWriter printlig = new PrintWriter(fileLigacoes);

    Collection<Localidade> coll = this.localidades.values();

    for (Localidade l : coll) {
      printloc.print(l.get_Codigopostal() + "|" + l.get_Nome());

      Map<String, Ligacao> ligacoes = l.get_Ligacoes();
      int nrligacoes = ligacoes.size();

      Collection<Ligacao> colllig = ligacoes.values();

      for (Ligacao lig : colllig) {
        printloc.print("|1");
        printlig.println(
            l.get_Codigopostal()
                + "|"
                + lig.get_Localidaded()
                + "|"
                + lig.get_Distancia()
                + "|"
                + lig.get_Taxas());
      }
      printloc.print("\n");

      nrlocalidades--;
      if (nrlocalidades == 0) break;
    }

    printloc.close();
    printlig.close();
  }
Exemplo n.º 28
0
  /**
   * Perform the action of the plugin.
   *
   * @param document the current document.
   */
  public boolean perform(Document document) throws IOException {
    // Interact with the user to get the layer tag/

    Tag layerTag = getLayerTagFromUser(document);
    if (layerTag == null) return false; // User cancled.
    Tag endTag = new Tag(layerTag.getName(), false);
    // Get the output stream to hold the new document text.
    PrintWriter out = new PrintWriter(document.getOutput());
    // Create a lexical stream to tokenize the old document text.
    LexicalStream in = new LexicalStream(new SelectedHTMLReader(document.getInput(), out));
    for (; ; ) {
      // Get the next token of the document.
      Token token = in.next();
      if (token == null) break; //  Null means we've finished the document.
      else if (token instanceof Comment) {
        Comment comment = (Comment) token;
        if (comment.isSelectionStart()) {
          out.print(layerTag);
        } else if (comment.isSelectionEnd()) {
          out.print(comment);
          out.print(endTag);
          continue; // So comment isn't printed twice.
        }
      }
      out.print(token);
    }
    out.close();
    return true;
  }
Exemplo n.º 29
0
  protected void processDocument(
      String jsonDocument,
      PrintWriter writer,
      List<Class<? extends AbstractBpmnFactory>> factoryClasses)
      throws JSONException, BpmnConverterException {
    Diagram diagram = DiagramBuilder.parseJson(jsonDocument);

    // TODO: validate edges that are not in the java object model
    //		ArrayList<Shape> edges =
    this.getEdgesFromDiagram(diagram.getChildShapes());

    String type = diagram.getStencilset().getNamespace();
    SyntaxChecker checker = null;

    if (type != null
        && (type.equals("http://b3mn.org/stencilset/bpmn2.0#")
            || type.equals("http://b3mn.org/stencilset/bpmn2.0choreography#")
            || type.equals("http://b3mn.org/stencilset/bpmn2.0conversation#"))) {
      checker = getCheckerBPMN2(diagram, factoryClasses);
    }

    if (checker == null) {
      writer.print("{}");
    } else {
      checker.checkSyntax();
      writer.print(checker.getErrorsAsJson().toString());
    }
  }
Exemplo n.º 30
0
 @Override
 public Void visitTypeParameterList(TypeParameterList node) {
   writer.print('<');
   visitList(node.getTypeParameters(), ", ");
   writer.print('>');
   return null;
 }