Ejemplo n.º 1
0
  /** Las a resources */
  private void loadResource(Attributes atts) {
    final HumanResource hr;

    try {
      String id = atts.getValue("id");
      if (id == null) {
        hr = getResourceManager().newHumanResource();
        hr.setName(atts.getValue("name"));
        getResourceManager().add(hr);
      } else {
        hr = getResourceManager().create(atts.getValue("name"), Integer.parseInt(id));
      }
      myCurrentResource = hr;
    } catch (NumberFormatException e) {
      System.out.println("ERROR in parsing XML File id is not numeric: " + e.toString());
      return;
    }

    hr.setMail(atts.getValue("contacts"));
    hr.setPhone(atts.getValue("phone"));
    try {
      String roleID = atts.getValue("function");
      myLateResource2roleBinding.put(hr, roleID);
      // hr.setFunction(Integer.parseInt());
    } catch (NumberFormatException e) {
      System.out.println("ERROR in parsing XML File function id is not numeric: " + e.toString());
    }
  }
Ejemplo n.º 2
0
  // Called when UI activities all pause, terminates the service
  // unless canceled.
  //
  public void startBackgroundTimeout() {

    // Cancel any pre-existing timeout.
    cancelBackgroundTimeout();

    Runnable task =
        new Runnable() {
          public void run() {
            mLogger.info("background timeout");
            mApp.doExit();
          }
        };

    String delaystr = mPrefs.getString(SettingsActivity.KEY_BACKGROUND_TIMEOUT, "600");
    long delay;
    try {
      delay = Long.parseLong(delaystr);
    } catch (NumberFormatException ex) {
      throw new RuntimeException(ex.toString()); // Shouldn't happen.
    }

    if (delay != -1) {
      mBackgroundTimeout = mTimeoutWorker.schedule(task, delay, TimeUnit.SECONDS);

      mLogger.info(String.format("background timeout scheduled in %d seconds", delay));
    }
  }
  private void setParamFromField() {
    String value = widget.getText();

    if (D) System.out.println("New Value = " + value);
    try {
      Long val;
      if (value.equals("")) val = null;
      else val = Long.parseLong(value);
      setValue(val);
      refreshParamEditor();
      widget.validate();
      widget.repaint();
    } catch (NumberFormatException ee) {
      if (D) System.out.println("Error = " + ee.toString());

      Long obj = getValue();
      if (obj == null) widget.setText("");
      else widget.setText(obj.toString());

      this.unableToSetValue(value);
    } catch (ConstraintException ee) {
      if (D) System.out.println("Error = " + ee.toString());

      Long obj = getValue();
      if (obj == null) widget.setText("");
      else widget.setText(obj.toString());

      this.unableToSetValue(value);
    } catch (WarningException ee) {
      refreshParamEditor();
      widget.validate();
      widget.repaint();
    }
  }
  private boolean einlesen() {
    int eingabefaktor;

    // Faktor
    try {
      eingabefaktor = Integer.parseInt(feldFaktor.getText());
      if (eingabefaktor < 0) {
        System.out.println("Faktor < 0");
        feldFaktor.selectAll();
        return false;
      }
    } catch (NumberFormatException e) {
      System.out.println(e.toString());
      feldFaktor.selectAll();
      return false;
    }

    faktor = eingabefaktor;

    // Ist die Checkbox angekreuzt?
    NUREINSCHRITT = checkbox_nureinSchritt.isSelected();
    AUCHSTRAGEGIE2 = checkbox_auchStrategie2.isSelected();

    return true;
  }
  @RequestMapping(value = "add", method = RequestMethod.POST)
  public String addPerson(
      @RequestParam("id") String id,
      @RequestParam("name") String name,
      @RequestParam("phone") String phone,
      @RequestParam("birthday") String birthday,
      Model model) {

    logger.info("Running to add By POST");

    boolean sucessful = true;

    try {
      Date date = sdf.parse(birthday);
      Person p = Person.createPerson();
      p.setId(Integer.parseInt(id));
      p.setName(name);
      p.setPhone(phone);
      p.setBirthday(date);
      this.addPersonIntoDBMemory(p);

    } catch (ParseException e) {
      addErrorMessage("Formato de fecha invalido o campo vacio ");
      addErrorMessage("Formato: DD/MM/YYYY");
      model.addAttribute("error", this.errorList);
      sucessful = false;

    } catch (NumberFormatException nfe) {
      addErrorMessage(nfe.getMessage());
      addErrorMessage(nfe.toString());
      model.addAttribute("error", this.errorList);
      sucessful = false;
    }
    return getURLReturn(sucessful);
  }
Ejemplo n.º 6
0
 public static void main(String[] args) {
   int n = 0;
   int m = 0;
   while (true) {
     try {
       BufferedReader sisse = new BufferedReader(new InputStreamReader(System.in));
       System.out.println("V2ljumiseks vajutage ctrl-C");
       System.out.print("Laste arv: ");
       String s = sisse.readLine();
       n = Integer.parseInt(s);
       if (n < 0) throw new IllegalArgumentException(String.valueOf(n));
       System.out.print("6unte arv: ");
       s = sisse.readLine();
       m = Integer.parseInt(s);
       if (m < 0) throw new IllegalArgumentException(String.valueOf(m));
       System.out.println(
           "Igale lapsele "
               + String.valueOf(m / n)
               + " 6una ja "
               + String.valueOf(m % n)
               + " j22b yle");
     } catch (NumberFormatException e) {
       System.out.println("Ei ole arv: " + e.toString());
     } catch (ArithmeticException e) {
       System.out.println("Aritmeetikakatkestus: " + e.toString());
     } catch (Exception muu) {
       System.out.println("Probleem: " + muu.toString());
     } finally {
       System.out.println("n = " + n + "  m = " + m);
     }
   }
 } // main
  /**
   * 数据解包,解包顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpLECRecommendation>历史记账凭证主表信息</A>表字段
   *
   * @param: strMessage String 包含一条纪录数据的字符串
   * @return: boolean
   */
  public boolean decode(String strMessage) {
    try {
      recommend = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 1, SysConst.PACKAGESPILTER);
      recommended = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 2, SysConst.PACKAGESPILTER);
      sendtimes =
          new Integer(ChgData.chgNumericStr(StrTool.getStr(strMessage, 3, SysConst.PACKAGESPILTER)))
              .intValue();
      success = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 4, SysConst.PACKAGESPILTER);
      registered = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 5, SysConst.PACKAGESPILTER);
      field1 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 6, SysConst.PACKAGESPILTER);
      field2 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 7, SysConst.PACKAGESPILTER);
      field3 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 8, SysConst.PACKAGESPILTER);
      makedate = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 9, SysConst.PACKAGESPILTER);
      maketime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 10, SysConst.PACKAGESPILTER);
      modifydate = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 11, SysConst.PACKAGESPILTER);
      modifytime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 12, SysConst.PACKAGESPILTER);
    } catch (NumberFormatException ex) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "LECRecommendationSchema";
      tError.functionName = "decode";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      return false;
    }
    return true;
  }
Ejemplo n.º 8
0
 protected void initTransportListener(HttpServletRequest httpServletRequest) {
   // httpServletRequest.getLocalPort() , giving me a build error so I had to use the followin
   String filePart;
   try {
     filePart = httpServletRequest.getRequestURL().toString();
   } catch (Throwable t) {
     log.info("Old Servlet API (fallback to HttpServletRequest.getRequestURI) :" + t);
     filePart = httpServletRequest.getRequestURI();
   }
   int ipindex = filePart.indexOf("//");
   String ip;
   if (ipindex >= 0) {
     ip = filePart.substring(ipindex + 2, filePart.length());
     int seperatorIndex = ip.indexOf(":");
     int slashIndex = ip.indexOf("/");
     String portstr;
     if (seperatorIndex >= 0) {
       portstr = ip.substring(seperatorIndex + 1, slashIndex);
     } else {
       portstr = "80";
     }
     try {
       addTransportListener(httpServletRequest.getScheme(), Integer.parseInt(portstr));
     } catch (NumberFormatException e) {
       log.debug(e.toString(), e);
     }
   }
 }
Ejemplo n.º 9
0
  @Transactional
  public void insertSerial(String id, String wh) {
    String guid;
    LogItem logItem = new LogItem();
    SerialType type = null;
    try {
      type = this.serialDao.getTypeById(id);
      Serial serial = new Serial();

      serial.setSerial(wh);
      serial.setSerialType(type);

      if ("0".equalsIgnoreCase(type.getType())) {
        type.setCurrentSerialNo(type.getCurrentSerialNo() + 1D);
      } else {
        String update_bz = "";
        update_bz =
            (String)
                Db.getJtN()
                    .queryForObject(
                        "select update_bz from t_form_customserial where id=?",
                        new Object[] {id},
                        String.class);

        if ((this.serialDao.getSerialCount(type.getId(), type.getType()) == 0)
            && (update_bz.equals("0"))) type.setCurrentSerialNo(2.0D);
        else type.setCurrentSerialNo(type.getCurrentSerialNo() + 1D);
      }

      type.setCurrentSerialNo(type.getCurrentSerialNo() + 1D);
      this.serialDao.updateSerialType(type);

      this.serialDao.insertSerial(serial);

      logItem.setMethod("insertSerial");
      logItem.setLogid(Guid.get());
      logItem.setLevel("error");
      logItem.setDesc("文号添加成功");
      Log.write(logItem);
    } catch (NumberFormatException e) {
      guid = Guid.get();
      logItem.setMethod("insertSerial");
      logItem.setLogid(guid);
      logItem.setLevel("error");
      logItem.setDesc("文号处理时出现异常");
      logItem.setContent(e.toString());
      Log.write(logItem);
      throw new ServiceException("文号处理时出现异常");
    } catch (Exception e) {
      guid = Guid.get();
      logItem.setMethod("insertSerial");
      logItem.setLogid(guid);
      logItem.setLevel("error");
      logItem.setDesc("文号处理时出现异常");
      logItem.setContent(e.toString());
      Log.write(logItem);
      throw new ServiceException("文号处理时出现异常");
    }
  }
Ejemplo n.º 10
0
 private static int getIntSystemProperty(final int defaultValue, final String key) {
   try {
     return Integer.parseInt(System.getProperty(key, "" + defaultValue));
   } catch (NumberFormatException e) {
     LOG.error(BUNDLE_MARKER, e.toString(), e);
   }
   return defaultValue;
 }
Ejemplo n.º 11
0
 // @RubyLevelMethod(name="to_f")
 public RubyFloat toRubyFloat() {
   double d;
   try {
     d = this.toFloat();
   } catch (NumberFormatException e) {
     throw new RubyException(RubyRuntime.ArgumentErrorClass, e.toString());
   }
   return ObjectFactory.createFloat(d);
 }
Ejemplo n.º 12
0
 /**
  * @param v
  * @exception DicomException
  */
 public void addValue(String v) throws DicomException {
   short shortValue = 0;
   try {
     shortValue = (short) Integer.parseInt(v);
   } catch (NumberFormatException e) {
     throw new DicomException(e.toString());
   }
   addValue(shortValue);
 }
  private final int pullVcardEntry(
      byte[] appParam,
      AppParamValue appParamValue,
      Operation op,
      final String name,
      final String current_path) {
    if (name == null || name.length() < VCARD_NAME_SUFFIX_LENGTH) {
      if (D) Log.d(TAG, "Name is Null, or the length of name < 5 !");
      return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
    }
    String strIndex = name.substring(0, name.length() - VCARD_NAME_SUFFIX_LENGTH + 1);
    int intIndex = 0;
    if (strIndex.trim().length() != 0) {
      try {
        intIndex = Integer.parseInt(strIndex);
      } catch (NumberFormatException e) {
        Log.e(TAG, "catch number format exception " + e.toString());
        return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
      }
    }

    int size = mVcardManager.getPhonebookSize(appParamValue.needTag);
    if (size == 0) {
      if (V) Log.v(TAG, "PhonebookSize is 0, return.");
      return ResponseCodes.OBEX_HTTP_OK;
    }

    boolean vcard21 = appParamValue.vcard21;
    if (appParamValue.needTag == 0) {
      Log.w(TAG, "wrong path!");
      return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
    } else if (appParamValue.needTag == ContentType.PHONEBOOK) {
      if (intIndex < 0 || intIndex >= size) {
        Log.w(TAG, "The requested vcard is not acceptable! name= " + name);
        return ResponseCodes.OBEX_HTTP_OK;
      } else if (intIndex == 0) {
        // For PB_PATH, 0.vcf is the phone number of this phone.
        String ownerVcard = mVcardManager.getOwnerPhoneNumberVcard(vcard21);
        return pushBytes(op, ownerVcard);
      } else {
        return mVcardManager.composeAndSendPhonebookOneVcard(op, intIndex, vcard21, null, mOrderBy);
      }
    } else {
      if (intIndex <= 0 || intIndex > size) {
        Log.w(TAG, "The requested vcard is not acceptable! name= " + name);
        return ResponseCodes.OBEX_HTTP_OK;
      }
      // For others (ich/och/cch/mch), 0.vcf is meaningless, and must
      // begin from 1.vcf
      if (intIndex >= 1) {
        return mVcardManager.composeAndSendCallLogVcards(
            appParamValue.needTag, op, intIndex, intIndex, vcard21);
      }
    }
    return ResponseCodes.OBEX_HTTP_OK;
  }
Ejemplo n.º 14
0
 /**
  * @param v
  * @exception DicomException
  */
 public void addValue(String v) throws DicomException {
   flushCachedCopies();
   double doubleValue = 0;
   try {
     doubleValue = Double.parseDouble(v);
   } catch (NumberFormatException e) {
     throw new DicomException(e.toString());
   }
   addValue(doubleValue);
 }
Ejemplo n.º 15
0
 /** @return the pot */
 public static int getPort() {
   int port = 0;
   try {
     port = Integer.parseInt(pot.getText());
   } catch (NumberFormatException f) {
     f.printStackTrace();
     new WhatIDo("Entrer un port valide", f.toString());
   }
   return port;
 }
Ejemplo n.º 16
0
 /**
  * Constructs a <CODE>PdfNumber</CODE>-object.
  *
  * @param content value of the new <CODE>PdfNumber</CODE>-object
  */
 public PdfNumber(String content) {
   super(NUMBER);
   try {
     value = Double.parseDouble(content.trim());
     setContent(content);
   } catch (NumberFormatException nfe) {
     throw new RuntimeException(
         MessageLocalization.getComposedMessage(
             "1.is.not.a.valid.number.2", content, nfe.toString()));
   }
 }
  @Override
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    ModelAndView returnValue = new ModelAndView("modify");

    String id = null;
    String message = null;
    try {
      id = request.getParameter("id");
      message = "Edited Employee's Position";
      String hqlQuery;

      Map<String, Object> namedParameter = new HashMap<String, Object>();
      String fieldValue = request.getParameter("positionId");

      namedParameter.put(":positionId", Integer.valueOf(fieldValue));
      namedParameter.put(":id", Integer.valueOf(id));

      hqlQuery = queryManager.getQuery("UPDATE_positionId");

      employeeDAO.modifyEmployeeData(hqlQuery, namedParameter);

      String condition = " WHERE E.id = " + id;
      hqlQuery = queryManager.getQuery("SELECT_ALL_JOIN_ALL") + condition;

      List<Object[]> employeeData = employeeDAO.getEmployeeData(hqlQuery, 0, 1);

      String[] labels = (String[]) employeeData.remove(employeeData.size() - 1);
      employeeData.add(0, labels);

      hqlQuery = queryManager.getQuery("S_ALL_Positions_ORDER_Position");

      List<Object[]> positionData = employeeDAO.getEmployeeData(hqlQuery, 0, 0);

      if (positionData.size() == 1) {
        return new ModelAndView("modifyPage", "message", "Position List is Empty.");
      }
      positionData.remove(positionData.size() - 1);

      returnValue.addObject("employeeData", employeeData);
      returnValue.addObject("positionData", positionData);
    } catch (NumberFormatException e) {
      e.printStackTrace();
      message = e.toString();
    } catch (HibernateException e) {
      e.printStackTrace();
      message = "Editing Position Failed.";
    }

    returnValue.addObject("id", id);
    returnValue.addObject("message", message);

    return returnValue;
  }
Ejemplo n.º 18
0
 private static Long textToLong(String filename, String text, String name) throws Exception {
   if (text == null || text.length() == 0) {
     throw new Exception("Bad long. Filename= " + filename + ", name= " + name);
   }
   Long intValue = null;
   try {
     intValue = Long.valueOf(text);
   } catch (NumberFormatException e) {
     throw new Exception("Bad long. Filename= " + filename + ", exception= " + e.toString());
   }
   return intValue;
 }
 /**
  * Parse {@link Long}.
  *
  * @param value value a {@link String}
  * @param defValue default value
  * @return parsed {@link Long}
  */
 public long parseLong(final String value, final long defValue) {
   long ret = defValue;
   if (value == null || value.length() == 0) {
     return ret;
   }
   try {
     ret = Long.parseLong(value);
   } catch (NumberFormatException e) {
     Log.e(TAG, "parseLong(" + value + ") failed: " + e.toString());
   }
   return ret;
 }
 @Override
 public void actionPerformed(ActionEvent arg0) {
   // TODO Auto-generated method stub
   try {
     int aux = Integer.parseInt(spf.getTextField().getText());
     sp.setNumberOfPlayers(aux);
     spf.getLabel().setText("Recibido numero  " + aux);
   } catch (NumberFormatException e) {
     // TODO: handle exception
     JOptionPane.showMessageDialog(spf, "Must in numbers " + e.toString());
   }
 }
Ejemplo n.º 21
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == cancel) dispose();
   else
     try {
       long wohin = Long.parseLong(postf.getText(), 16);
       long wieweit = Long.parseLong(sizetf.getText(), 16);
       if (parent.hv.goTo(wohin, wieweit)) dispose();
     } catch (NumberFormatException ex) {
       postf.setText(ex.toString());
       return;
     }
 }
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    CharSequence pathInfo = request.getPathInfo();
    if (pathInfo == null) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
      return;
    }
    Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
    long toItemID;
    List<Long> itemIDsList = Lists.newArrayList();
    try {
      toItemID = Long.parseLong(pathComponents.next());
      while (pathComponents.hasNext()) {
        itemIDsList.add(Long.parseLong(pathComponents.next()));
      }
    } catch (NoSuchElementException nsee) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
      return;
    } catch (NumberFormatException nfe) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString());
      return;
    }
    if (itemIDsList.isEmpty()) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items");
      return;
    }
    long[] itemIDs = new long[itemIDsList.size()];
    for (int i = 0; i < itemIDs.length; i++) {
      itemIDs[i] = itemIDsList.get(i);
    }

    MyrrixRecommender recommender = getRecommender();
    try {
      float[] similarities = recommender.similarityToItem(toItemID, itemIDs);
      Writer out = response.getWriter();
      for (float similarity : similarities) {
        out.write(Float.toString(similarity));
        out.write('\n');
      }
    } catch (NoSuchItemException nsie) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString());
    } catch (NotReadyException nre) {
      response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
    } catch (TasteException te) {
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
      getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
    }
  }
Ejemplo n.º 23
0
 @Override
 public TVLong getCellEditorValue() {
   try {
     return new TVLong(
         tvLong.getFormat().parse(super.getCellEditorValue().toString().trim()));
   } catch (NumberFormatException numberFormatException) {
     JOptionPane.showMessageDialog(
         getComponent(),
         numberFormatException.toString(),
         "Invalid Input",
         JOptionPane.ERROR_MESSAGE);
   }
   return tvLong;
 }
Ejemplo n.º 24
0
  /**
   * Reads typed parameters from xml element and returns them in a Map where the key is the
   * parameter's String name and the value is the value of the parameter. Finds all tags named
   * "param". Those tags should have two attributes, name and type. Valid parameters types are
   * "int", "double", "boolean", and "string". If the value is not compatible with the specified
   * type then value will be null, except in the case of a Boolean with an incompatible value, in
   * which case the value will be False. If a parameter's value is not specified or empty then the
   * value will be null.
   *
   * @param moduleElement Dom {@link Element}
   * @return parameters indexed by name.
   */
  public static Map<String, Object> getTypedParams(Element moduleElement) {
    Map<String, Object> prop = new HashMap<String, Object>();
    List<Element> nl = getChildren(moduleElement, "param");
    if (nl != null) {
      for (Element param : nl) {
        String name = param.getAttribute("name");
        String type = param.getAttribute("type");
        String sValue = getValue(param);
        Object value = sValue;
        if (sValue != null) {

          if (type == null || "string".equalsIgnoreCase(type)) {
            value = sValue;
          } else if ("int".equalsIgnoreCase(type)) {
            try {
              value = Integer.parseInt(sValue);
            } catch (NumberFormatException e) {
              value = null;
              logger.log(Level.FINE, e.toString(), TaskManager.getCurrentTick());
            }
          } else if ("double".equalsIgnoreCase(type)) {
            try {
              value = Double.parseDouble(sValue);
            } catch (NumberFormatException e) {
              value = null;
              logger.log(Level.FINE, e.toString(), TaskManager.getCurrentTick());
            }
          } else if ("boolean".equalsIgnoreCase(type)) {
            value = Boolean.parseBoolean(sValue);
          }
        }
        prop.put(name, value);
      }
    }
    return prop;
  }
 private void feldFaktorActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_feldFaktorActionPerformed
   try {
     int eingabefaktor = Integer.parseInt(feldFaktor.getText());
     if (eingabefaktor < 0) {
       System.out.println("Faktor < 0");
       feldFaktor.setSelectionStart(0);
       feldFaktor.setSelectionEnd(feldFaktor.getText().length());
     }
   } catch (NumberFormatException e) {
     System.out.println(e.toString());
     feldFaktor.setSelectionStart(0);
     feldFaktor.setSelectionEnd(feldFaktor.getText().length());
   }
 } // GEN-LAST:event_feldFaktorActionPerformed
Ejemplo n.º 26
0
 public void message(String s) {
   if (firstLine == null) firstLine = s;
   else {
     StringTokenizer st = new StringTokenizer(s, " ");
     try {
       st.nextToken();
       st.nextToken();
       st.nextToken();
       size = (new Integer(st.nextToken().trim())).longValue();
     } catch (NoSuchElementException e) {
       exception = new RunnerException(e.toString());
     } catch (NumberFormatException e) {
       exception = new RunnerException(e.toString());
     }
   }
 }
Ejemplo n.º 27
0
  private IntervalXYDataset getDataset() {
    HistogramDataset histogramDataset = new HistogramDataset();

    List<Double> values = new ArrayList<Double>();
    if (valueIndex.mask) {
      for (Site s : sitesMask) {
        values.add(s.respValues.get(valueIndex.idx).doubleValue());
      }
    } else {
      for (Site s : sites) {
        values.add(s.respValues.get(valueIndex.idx).doubleValue());
      }
    }
    double max = paint.max;
    double min = paint.min;

    int bins = 0;
    try {
      // Freedman-Diaconis rule
      double IQR = InterQuartileRange(values);
      double binSize = (2 * IQR * Math.pow(values.size(), -1 / 3));
      bins = (int) Math.ceil((max - min) / binSize);
    } catch (Exception e) {
      e.printStackTrace();
    }

    String s =
        (String)
            JOptionPane.showInputDialog(
                "Please, Enter Number of Bins. Freedman-Diaconis Rule recommends "
                    + String.valueOf(bins));
    int ubins = 1;
    try {
      ubins = Integer.parseInt(s);
      bins = ubins;
    } catch (NumberFormatException e) {
      System.out.println(e.toString());
    }

    double[] histValues = new double[values.size()];
    for (int i = 0; i < values.size(); i++) histValues[i] = values.get(i).doubleValue();

    histogramDataset.addSeries("On Screen Values", histValues, bins);

    return histogramDataset;
  }
  /**
   * 数据解包,解包顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpSearchRecord>历史记账凭证主表信息</A>表字段
   *
   * @param: strMessage String 包含一条纪录数据的字符串
   * @return: boolean
   */
  public boolean decode(String strMessage) {
    try {
      tradeNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 1, SysConst.PACKAGESPILTER);
      contNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 2, SysConst.PACKAGESPILTER);
      userCode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 3, SysConst.PACKAGESPILTER);
      name = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 4, SysConst.PACKAGESPILTER);
      gender = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 5, SysConst.PACKAGESPILTER);
      birthday =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 6, SysConst.PACKAGESPILTER));
      province = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 7, SysConst.PACKAGESPILTER);
      city = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 8, SysConst.PACKAGESPILTER);
      mobile = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 9, SysConst.PACKAGESPILTER);
      userIDType = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 10, SysConst.PACKAGESPILTER);
      userIDNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 11, SysConst.PACKAGESPILTER);
      riskname = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 12, SysConst.PACKAGESPILTER);
      riskcode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 13, SysConst.PACKAGESPILTER);
      userState = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 14, SysConst.PACKAGESPILTER);
      userSource = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 15, SysConst.PACKAGESPILTER);
      field1 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 16, SysConst.PACKAGESPILTER);
      field2 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 17, SysConst.PACKAGESPILTER);
      field3 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 18, SysConst.PACKAGESPILTER);
      field4 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 19, SysConst.PACKAGESPILTER);
      field5 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 20, SysConst.PACKAGESPILTER);
      field6 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 21, SysConst.PACKAGESPILTER);
      searchDate =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 22, SysConst.PACKAGESPILTER));
      searchTime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 23, SysConst.PACKAGESPILTER);
      makedate =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 24, SysConst.PACKAGESPILTER));
      maketime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 25, SysConst.PACKAGESPILTER);
    } catch (NumberFormatException ex) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "SearchRecordSchema";
      tError.functionName = "decode";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      return false;
    }
    return true;
  }
    @Override
    protected Void doInBackground(Void... arg0) {

      try {
        Integer.parseInt(dstPort);

      } catch (NumberFormatException e) {
        error_msg = "NumberFormatException:" + e.toString();
        return null;
      }
      ServerConnection connection = ServerConnection.getInstance();
      connection.initialize(dstAddress, Integer.parseInt(dstPort));
      // connection.run();
      connection.connect();
      error_msg = connection.getErro_msg();

      return null;
    }
  /**
   * 数据解包,解包顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpLEPRiskDuty>历史记账凭证主表信息</A>表字段
   *
   * @param: strMessage String 包含一条纪录数据的字符串
   * @return: boolean
   */
  public boolean decode(String strMessage) {
    try {
      riskCode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 1, SysConst.PACKAGESPILTER);
      riskVer = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 2, SysConst.PACKAGESPILTER);
      dutyCode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 3, SysConst.PACKAGESPILTER);
      choFlag = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 4, SysConst.PACKAGESPILTER);
      specFlag = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 5, SysConst.PACKAGESPILTER);
    } catch (NumberFormatException ex) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "LEPRiskDutySchema";
      tError.functionName = "decode";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      return false;
    }
    return true;
  }