コード例 #1
0
ファイル: Macro.java プロジェクト: bramk/bnd
 private String doCommand(Object target, String method, String[] args) {
   if (target == null) ; // System.err.println("Huh? Target should never be null " +
   // domain);
   else {
     String cname = "_" + method.replaceAll("-", "_");
     try {
       Method m = target.getClass().getMethod(cname, new Class[] {String[].class});
       return (String) m.invoke(target, new Object[] {args});
     } catch (NoSuchMethodException e) {
       // Ignore
     } catch (InvocationTargetException e) {
       if (e.getCause() instanceof IllegalArgumentException) {
         domain.error(
             "%s, for cmd: %s, arguments; %s",
             e.getCause().getMessage(), method, Arrays.toString(args));
       } else {
         domain.warning("Exception in replace: %s", e.getCause());
         e.getCause().printStackTrace();
       }
     } catch (Exception e) {
       domain.warning("Exception in replace: " + e + " method=" + method);
       e.printStackTrace();
     }
   }
   return null;
 }
コード例 #2
0
 /** Start talking to the server */
 public void start() {
   String codehost = getCodeBase().getHost();
   if (socket == null) {
     try {
       // Open the socket to the server
       socket = new Socket(codehost, port);
       // Create output stream
       out = new ObjectOutputStream(socket.getOutputStream());
       out.flush();
       // Create input stream and start background
       // thread to read data from the server
       in = new ObjectInputStream(socket.getInputStream());
       new Thread(this).start();
     } catch (Exception e) {
       // Exceptions here are unexpected, but we can't
       // really do anything (so just write it to stdout
       // in case someone cares and then ignore it)
       System.out.println("Exception! " + e.toString());
       e.printStackTrace();
       setErrorStatus(STATUS_NOCONNECT);
       socket = null;
     }
   } else {
     // Already started
   }
   if (socket != null) {
     // Make sure the right buttons are enabled
     start_button.setEnabled(false);
     stop_button.setEnabled(true);
     setStatus(STATUS_ACTIVE);
   }
 }
コード例 #3
0
  /**
   * Method 'execute'
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward handle(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      // parse parameters
      // create the DAO class
      TelesalesCallSourceDao dao = TelesalesCallSourceDaoFactory.create();

      // execute the finder
      TelesalesCallSource dto[] = dao.findAll();

      // store the results
      request.setAttribute("result", dto);

      return mapping.findForward("success");
    } catch (Exception e) {
      ActionErrors _errors = new ActionErrors();
      _errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage()));
      saveErrors(request, _errors);
      return mapping.findForward("failure");
    }
  }
コード例 #4
0
ファイル: Download.java プロジェクト: saurabhd14/tinyos-1.x
  public void run() {

    // setup advertisement message
    advMsg.set_sourceAddr(TOS_UART_ADDR);

    if (reboot) {
      advMsg.set_summary_vNum(0x0);
      advMsg.set_runningVNum(0xffff);
    } else {
      advMsg.set_summary_vNum(0xffff);
      advMsg.set_runningVNum(0x0);
    }
    advMsg.set_summary_numPgsComplete((byte) numPgs);

    while (true) {
      try {
        // send an advertisement message every second
        if (printAllMsgs) System.out.print(advMsg);
        send(advMsg);
        Thread.currentThread().sleep(1000);
        if (reboot) {
          System.exit(0);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
コード例 #5
0
  public AttributeField attributeField() throws ParseException {
    try {
      AttributeField attributeField = new AttributeField();

      this.lexer.match('a');

      this.lexer.SPorHT();
      this.lexer.match('=');

      this.lexer.SPorHT();

      NameValue nameValue = new NameValue();

      int ptr = this.lexer.markInputPosition();
      try {
        String name = lexer.getNextToken(':');
        this.lexer.consume(1);
        String value = lexer.getRest();
        nameValue = new NameValue(name.trim(), value.trim());
      } catch (ParseException ex) {
        this.lexer.rewindInputPosition(ptr);
        String rest = this.lexer.getRest();
        if (rest == null) throw new ParseException(this.lexer.getBuffer(), this.lexer.getPtr());
        nameValue = new NameValue(rest.trim(), ""); // jvB: use empty string for flag values
      }
      attributeField.setAttribute(nameValue);

      this.lexer.SPorHT();

      return attributeField;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ParseException(e.getMessage(), 0);
    }
  }
コード例 #6
0
ファイル: CIManagerImpl.java プロジェクト: manoj-s/framework
 public List<CIBuild> getBuilds(CIJob job) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method CIManagerImpl.getCIBuilds(CIJob job)");
   }
   List<CIBuild> ciBuilds = null;
   try {
     if (debugEnabled) {
       S_LOGGER.debug("getCIBuilds()  JobName = " + job.getName());
     }
     JsonArray jsonArray = getBuildsArray(job);
     ciBuilds = new ArrayList<CIBuild>(jsonArray.size());
     Gson gson = new Gson();
     CIBuild ciBuild = null;
     for (int i = 0; i < jsonArray.size(); i++) {
       ciBuild = gson.fromJson(jsonArray.get(i), CIBuild.class);
       setBuildStatus(ciBuild, job);
       String buildUrl = ciBuild.getUrl();
       String jenkinUrl = job.getJenkinsUrl() + ":" + job.getJenkinsPort();
       buildUrl =
           buildUrl.replaceAll(
               "localhost:" + job.getJenkinsPort(),
               jenkinUrl); // when displaying url it should display setup machine ip
       ciBuild.setUrl(buildUrl);
       ciBuilds.add(ciBuild);
     }
   } catch (Exception e) {
     if (debugEnabled) {
       S_LOGGER.debug(
           "Entering Method CIManagerImpl.getCIBuilds(CIJob job) " + e.getLocalizedMessage());
     }
   }
   return ciBuilds;
 }
コード例 #7
0
ファイル: krypton_api.java プロジェクト: 0ldMaid/Krypton
  public String get_settings_array() {

    String jsontext = new String("");

    try {

      JSONObject obj = new JSONObject();

      for (int loop = 0; loop < network.settingsx.length; loop++) { // ******

        obj.put(loop, network.settingsx[loop]);
      } // *****************************************************************

      StringWriter out = new StringWriter();
      obj.writeJSONString(out);
      jsontext = out.toString();
      System.out.println(jsonText);

    } catch (Exception e) {
      e.printStackTrace();
      statex = "0";
      jsontext = "error";
    }

    return jsontext;
  } // ******************************
コード例 #8
0
 public void setSelectedItem(Object anItem) {
   if (anItem == null) {
     return;
   }
   if (anItem instanceof Date) {
     try {
       selectedDate = this.dateFormat.format((Date) anItem);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   } else {
     try {
       String strDate = anItem.toString().trim();
       if (strDate.length() != 10 && strDate.length() != 19) {
         return;
       }
       String pattern = dateFormat.toPattern();
       if (strDate.length() == 10 && pattern.length() == 19) {
         strDate = strDate + selectedDate.substring(10);
       }
       dateFormat.parse(strDate);
       selectedDate = strDate;
     } catch (Exception ex) {
       throw new UnsupportedOperationException(
           "Invalid datetime: string ["
               + anItem
               + "], format is ["
               + dateFormat.toPattern()
               + "]. ");
     }
   }
   fireContentsChanged(this, -1, -1);
 }
コード例 #9
0
ファイル: MiscUtilities.java プロジェクト: zukov/Jpicedt
  /**
   * @return the clipboard content as a String (DataFlavor.stringFlavor) Code snippet adapted from
   *     jEdit (Registers.java), http://www.jedit.org. Returns null if clipboard is empty.
   */
  public static String getClipboardStringContent(Clipboard clipboard) {
    // Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    try {
      String selection =
          (String) (clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor));
      if (selection == null) return null;

      boolean trailingEOL =
          (selection.endsWith("\n") || selection.endsWith(System.getProperty("line.separator")));

      // Some Java versions return the clipboard contents using the native line separator,
      // so have to convert it here , see jEdit's "registers.java"
      BufferedReader in = new BufferedReader(new StringReader(selection));
      StringBuffer buf = new StringBuffer();
      String line;
      while ((line = in.readLine()) != null) {
        buf.append(line);
        buf.append('\n');
      }
      // remove trailing \n
      if (!trailingEOL) buf.setLength(buf.length() - 1);
      return buf.toString();
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
コード例 #10
0
ファイル: MiscUtilities.java プロジェクト: zukov/Jpicedt
 /**
  * @return an instanciation of the given content-type class name, or null if class wasn't found
  */
 public static ContentType getContentTypeFromClassName(String contentTypeClassName) {
   if (contentTypeClassName == null)
     contentTypeClassName = getAvailableContentTypes()[DEFAULT_CONTENT_TYPE_INDEX];
   ContentType ct = null;
   try {
     Class clazz = Class.forName(contentTypeClassName);
     ct = (ContentType) clazz.newInstance();
   } catch (ClassNotFoundException cnfex) {
     if (jpicedt.Log.DEBUG) cnfex.printStackTrace();
     JPicEdt.getMDIManager()
         .showMessageDialog(
             "The pluggable content-type you asked for (class "
                 + cnfex.getLocalizedMessage()
                 + ") isn't currently installed, using default instead...",
             Localizer.currentLocalizer().get("msg.LoadingContentTypeClass"),
             JOptionPane.ERROR_MESSAGE);
   } catch (Exception ex) {
     if (jpicedt.Log.DEBUG) ex.printStackTrace();
     JPicEdt.getMDIManager()
         .showMessageDialog(
             ex.getLocalizedMessage(),
             Localizer.currentLocalizer().get("msg.LoadingContentTypeClass"),
             JOptionPane.ERROR_MESSAGE);
   }
   return ct;
 }
コード例 #11
0
 public void windowClosing(WindowEvent e) // write file on finish
     {
   FileOutputStream out = null;
   ObjectOutputStream data = null;
   try {
     // open file for output
     out = new FileOutputStream(DB);
     data = new ObjectOutputStream(out);
     // write Person objects to file using iterator class
     Iterator<Person> itr = persons.iterator();
     while (itr.hasNext()) {
       data.writeObject((Person) itr.next());
     }
     data.flush();
     data.close();
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         objUpdate.this,
         "Error processing output file" + "\n" + ex.toString(),
         "Output Error",
         JOptionPane.ERROR_MESSAGE);
   } finally {
     System.exit(0);
   }
 }
コード例 #12
0
 private void ListValueChanged(
     javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_ListValueChanged
   // TODO add your handling code here:
   // String part=partno.getText();
   try {
     String sql =
         "SELECT  TYPE,ITEM_NAME,QUANTITY,MRP FROM MOTORS WHERE ITEM_NAME='"
             + List.getSelectedValue()
             + "'";
     Class.forName("com.mysql.jdbc.Driver");
     Connection con =
         (Connection)
             DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
     while (rs.next()) {
       partno.setText(rs.getString("TYPE"));
       name.setText(rs.getString("ITEM_NAME"));
       qty.setText(rs.getString("QUANTITY"));
       rate.setText(rs.getString("MRP"));
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(null, e.toString());
   }
 } // GEN-LAST:event_ListValueChanged
コード例 #13
0
ファイル: CIManagerImpl.java プロジェクト: manoj-s/framework
  private void setSvnCredential(CIJob job) throws JDOMException, IOException {
    S_LOGGER.debug("Entering Method CIManagerImpl.setSvnCredential");
    try {
      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String credentialFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CREDENTIAL_XML;
      if (debugEnabled) {
        S_LOGGER.debug("credentialFilePath ... " + credentialFilePath);
      }
      File credentialFile = new File(credentialFilePath);

      SvnProcessor processor = new SvnProcessor(credentialFile);

      //			DataInputStream in = new DataInputStream(new FileInputStream(credentialFile));
      //			while (in.available() != 0) {
      //				System.out.println(in.readLine());
      //			}
      //			in.close();

      processor.changeNodeValue("credentials/entry//userName", job.getUserName());
      processor.changeNodeValue("credentials/entry//password", job.getPassword());
      processor.writeStream(new File(Utility.getJenkinsHome() + File.separator + job.getName()));

      // jenkins home location
      String jenkinsJobHome = System.getenv(JENKINS_HOME);
      StringBuilder builder = new StringBuilder(jenkinsJobHome);
      builder.append(File.separator);

      processor.writeStream(new File(builder.toString() + CI_CREDENTIAL_XML));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into the catch block of CIManagerImpl.setSvnCredential "
              + e.getLocalizedMessage());
    }
  }
コード例 #14
0
  public static void main(String[] args) {
    new ExampleProjects();

    try {

      File exsDir = new File("osb/showcase/neuroConstructShowcase");

      File mainFile = new File("docs/XML/xmlForHtml/samples/index.xml");

      logger.logComment("Going to create docs at: " + mainFile.getCanonicalPath(), true);

      generateMainPage(mainFile, exsDir);

      logger.logComment("Created doc at: " + mainFile.getCanonicalPath(), true);
      /*
      File modelsDir = new File("nCmodels");
      mainFile = new File("docs/XML/xmlForHtml/models/index.xml");


      generateMainPage(mainFile, modelsDir);

      logger.logComment("Created doc at: "+ mainFile.getCanonicalPath(), true);

       */
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #15
0
ファイル: Chart.java プロジェクト: feihugis/NetCDF
  public Chart(String filename) {
    try {
      // Get Stock Symbol
      this.stockSymbol = filename.substring(0, filename.indexOf('.'));

      // Create time series
      TimeSeries open = new TimeSeries("Open Price", Day.class);
      TimeSeries close = new TimeSeries("Close Price", Day.class);
      TimeSeries high = new TimeSeries("High", Day.class);
      TimeSeries low = new TimeSeries("Low", Day.class);
      TimeSeries volume = new TimeSeries("Volume", Day.class);

      BufferedReader br = new BufferedReader(new FileReader(filename));
      String key = br.readLine();
      String line = br.readLine();
      while (line != null && !line.startsWith("<!--")) {
        StringTokenizer st = new StringTokenizer(line, ",", false);
        Day day = getDay(st.nextToken());
        double openValue = Double.parseDouble(st.nextToken());
        double highValue = Double.parseDouble(st.nextToken());
        double lowValue = Double.parseDouble(st.nextToken());
        double closeValue = Double.parseDouble(st.nextToken());
        long volumeValue = Long.parseLong(st.nextToken());

        // Add this value to our series'
        open.add(day, openValue);
        close.add(day, closeValue);
        high.add(day, highValue);
        low.add(day, lowValue);

        // Read the next day
        line = br.readLine();
      }

      // Build the datasets
      dataset.addSeries(open);
      dataset.addSeries(close);
      dataset.addSeries(low);
      dataset.addSeries(high);
      datasetOpenClose.addSeries(open);
      datasetOpenClose.addSeries(close);
      datasetHighLow.addSeries(high);
      datasetHighLow.addSeries(low);

      JFreeChart summaryChart = buildChart(dataset, "Summary", true);
      JFreeChart openCloseChart = buildChart(datasetOpenClose, "Open/Close Data", false);
      JFreeChart highLowChart = buildChart(datasetHighLow, "High/Low Data", true);
      JFreeChart highLowDifChart =
          buildDifferenceChart(datasetHighLow, "High/Low Difference Chart");

      // Create this panel
      this.setLayout(new GridLayout(2, 2));
      this.add(new ChartPanel(summaryChart));
      this.add(new ChartPanel(openCloseChart));
      this.add(new ChartPanel(highLowChart));
      this.add(new ChartPanel(highLowDifChart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #16
0
ファイル: SalesExportPanel.java プロジェクト: cwi-swat/dokre
 public SalesExportPanel() {
   try {
     jbInit();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
コード例 #17
0
ファイル: Chart.java プロジェクト: feihugis/NetCDF
  public Chart(String title, String timeAxis, String valueAxis, TimeSeries data) {
    try {
      // Build the datasets
      dataset.addSeries(data);

      // Create the chart
      JFreeChart chart =
          ChartFactory.createTimeSeriesChart(
              title, timeAxis, valueAxis, dataset, true, true, false);

      // Setup the appearance of the chart
      chart.setBackgroundPaint(Color.white);
      XYPlot plot = chart.getXYPlot();
      plot.setBackgroundPaint(Color.lightGray);
      plot.setDomainGridlinePaint(Color.white);
      plot.setRangeGridlinePaint(Color.white);
      plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
      plot.setDomainCrosshairVisible(true);
      plot.setRangeCrosshairVisible(true);

      // Tell the chart how we would like dates to read
      DateAxis axis = (DateAxis) plot.getDomainAxis();
      axis.setDateFormatOverride(new SimpleDateFormat("EEE HH"));

      this.add(new ChartPanel(chart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #18
0
  public void processResponse(ResponseEvent responseReceivedEvent) {

    // Log.info("Registering response...." + sipCallId);

    Response response = (Response) responseReceivedEvent.getResponse();
    int statusCode = response.getStatusCode();
    String method = ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod();

    Log.debug("Got response " + response);

    if (statusCode == Response.OK) {
      isRegistered = true;

      Log.info(
          "Voice bridge successfully registered with "
              + registrar
              + " for "
              + proxyCredentials.getXmppUserName());
      PluginImpl.sipRegisterStatus = "Registered ok with " + proxyCredentials.getHost();

      sipServerCallback.removeSipListener(sipCallId);

    } else if (statusCode == Response.UNAUTHORIZED
        || statusCode == Response.PROXY_AUTHENTICATION_REQUIRED) {

      if (method.equals(Request.REGISTER)) {
        CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

        if (cseq.getSequenceNumber() < 2) {

          ClientTransaction regTrans =
              SipService.handleChallenge(
                  response, responseReceivedEvent.getClientTransaction(), proxyCredentials);

          if (regTrans != null) {
            try {
              regTrans.sendRequest();

            } catch (Exception e) {

              Log.info("Registration failed, cannot send transaction " + e);
              PluginImpl.sipRegisterStatus = "Registration error " + e.toString();
            }

          } else {
            Log.info("Registration failed, cannot create transaction");
            PluginImpl.sipRegisterStatus = "Registration cannot create transaction";
          }

        } else {
          Log.info("Registration failed " + responseReceivedEvent);
          PluginImpl.sipRegisterStatus = "Registration failed";
        }
      }

    } else {
      Log.info("Unrecognized response:  " + response);
    }
  }
コード例 #19
0
 static {
   try {
     SoundMixer mixer = SoundMixerEnumerator.getMixerByVendor("mm's computing");
     System.out.println("Mixer " + mixer.getMixerInfo() + " is available");
   } catch (Exception e) {
     System.out.println("9\b" + e.getMessage());
   }
 }
コード例 #20
0
ファイル: Macro.java プロジェクト: bramk/bnd
 public String _long2date(String args[]) {
   try {
     return new Date(Long.parseLong(args[1])).toString();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return "not a valid long";
 }
コード例 #21
0
 public static void main(String[] args) {
   // デフォルトデバッグ起動
   try {
     ACFrame.getInstance().setFrameEventProcesser(new QkanFrameEventProcesser());
     ACFrame.debugStart(new ACAffairInfo(QS001_13811_201504Design.class.getName()));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #22
0
  /** コンストラクタです。 */
  public QS001_13811_201504Design() {

    try {
      initialize();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #23
0
ファイル: QO005Design.java プロジェクト: orcacvsmirror/qkan
  /** コンストラクタです。 */
  public QO005Design() {

    try {
      initialize();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #24
0
ファイル: Recorder.java プロジェクト: G10DRAS/speech
 /**
  * Stop recording. This is not strictly necessary since the RandomAccessFile will keep most of the
  * information that has been logged.
  */
 public static void endRecord() {
   try {
     if (!recording) return;
     if (R != null) R.close();
     if (recording) recording = false;
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #25
0
ファイル: ACLMessageNode.java プロジェクト: LeviPorto/Jamder
 public void setTime(String theTime) {
   time = theTime;
   try {
     this.theDate = dateFormat.parse(time);
   } catch (Exception ex) {
     jade.util.Logger.getMyLogger(this.getClass().getName())
         .log(jade.util.Logger.WARNING, ex.getMessage());
   }
 }
コード例 #26
0
ファイル: DateTool.java プロジェクト: monzy613/time-algorithm
 public static Date stringToDate(String dateString) {
   try {
     MDebug.log("DATE: [|" + dateString + "|]");
     return formatter.parse(dateString);
   } catch (Exception ex) {
     ex.printStackTrace();
     return new Date();
   }
 }
コード例 #27
0
ファイル: SalesExportPanel.java プロジェクト: cwi-swat/dokre
  public SalesExportPanel(JFrame parent) {
    this.parent = parent;

    try {
      jbInit();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #28
0
ファイル: MersManager.java プロジェクト: won-woo/Helloworld
  public List<MersVO> mersData() {
    List<MersVO> list = new ArrayList<MersVO>();
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
    StringTokenizer st = new StringTokenizer(sdf.format(date), "-");
    int year = Integer.parseInt(st.nextToken());
    int month = Integer.parseInt(st.nextToken());
    int day = Integer.parseInt(st.nextToken());
    try {
      Document doc = Jsoup.connect("http://www.cdc.go.kr/CDC/cms/content/15/63315_view.html").get();
      // System.out.println(doc);
      Elements trs = doc.select("table tbody tr");
      // System.out.println(trs);
      String data = "";
      String[] temp = {"panel panel-primary", "panel panel-green", "panel panel-yellow"};
      int i = 0;
      for (Element tr : trs) {
        Iterator<Element> it = tr.getElementsByTag("td").iterator();

        // if(i==2) break;
        while (it.hasNext()) {

          MersVO vo = new MersVO();
          vo.setType(it.next().text());
          vo.setMers(it.next().text().replace("*", ""));
          /*vo.setYsum(it.next().text().replace(",", ""));
          vo.setPlus(it.next().text());
          vo.setMinus(it.next().text());*/

          if (data.equals("")) {
            data = it.next().text();
            vo.setIng(data);
          } else {
            vo.setIng(data);
          }
          vo.setNsum(it.next().text().replace(",", ""));
          vo.setHouse(it.next().text());
          vo.setOffice(it.next().text());
          vo.setDis(it.next().text().replace(",", ""));
          vo.setDiv1(temp[i]);
          vo.setYear(year);
          vo.setMonth(month);
          if (i == 2) {
            vo.setDay(day - 1);
          } else {
            vo.setDay(day);
          }
          list.add(vo);
          i++;
        }
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return list;
  }
コード例 #29
0
ファイル: move.java プロジェクト: EdvardPedersen/GeStore
 private static boolean unlock(String lock) {
   logger.info("Releasing lock " + lock);
   try {
     zkInstance.delete(lock, -1);
   } catch (Exception E) {
     logger.debug("Error releasing lock: " + E.toString());
     return true;
   }
   return true;
 }
コード例 #30
0
ファイル: MersManager.java プロジェクト: won-woo/Helloworld
  public List<MersHPVO> mersHPData() {
    List<MersHPVO> list = new ArrayList<MersHPVO>();
    try {
      Document doc = Jsoup.connect("http://www.cdc.go.kr/CDC/cms/content/16/63316_view.html").get();
      // System.out.println(doc);
      Elements trs = doc.select("table tbody tr");
      // System.out.println(trs);
      String data = "";

      for (Element tr : trs) {
        Iterator<Element> it = tr.getElementsByTag("td").iterator();
        int size = tr.getElementsByTag("td").size();
        MersHPVO vo = new MersHPVO();
        if (size == 5) {
          it.next().html();
          vo.setGugun(it.next().html());
          vo.setName(it.next().html());
          vo.setDuration(it.next().html());
          vo.setNum(it.next().html());
        } else {
          vo.setGugun(it.next().html());
          vo.setName(it.next().html());
          vo.setDuration(it.next().html());
          vo.setNum(it.next().html());
        }
        list.add(vo);
        // if(i==2) break;
        /*while(it.hasNext())
        {

         MersHPVO vo=new MersHPVO();
         String str=it.next().html();
         if(str.startsWith("<strong>"))
         {
          vo.setGugun(it.next().html());
          vo.setName(it.next().html());
          vo.setDuration(it.next().html());
          vo.setNum(it.next().html());
         }
         else
         {
          vo.setGugun(str);
          vo.setName(it.next().html());
          vo.setDuration(it.next().html());
          vo.setNum(it.next().html());
         }
         list.add(vo);
        }*/

      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return list;
  }