Example #1
0
  /** Splits a mod:item:meta or mod:item into a itemstack - I hope */
  public static ItemStack getItemStackFromName(String name) {

    if (name == null) return null;

    String[] parts = name.split(":");
    if (parts.length != 2 && parts.length != 3) return null;

    String itemName = String.format("%s:%s", parts[0], parts[1]);
    Item item = Item.getByNameOrId(itemName);

    if (item == null) return null;

    int meta = 0;
    if (parts.length == 3) {
      try {
        meta = Integer.parseInt(parts[2]);
      } catch (NumberFormatException e) {
        e.printStackTrace();
        return null;
      }
      if (meta < 0 || meta > OreDictionary.WILDCARD_VALUE) return null;
    }

    return new ItemStack(item, 1, meta);
  }
Example #2
0
  public Ending(Paradigm paradigm, Node node) {
    super(node);
    this.paradigm = paradigm;

    if (!node.getNodeName().equalsIgnoreCase("Ending"))
      throw new Error("Node '" + node.getNodeName() + "' but Ending expected.");

    Node n = node.getAttributes().getNamedItem("ID");
    if (n != null) this.setID(Integer.parseInt(n.getTextContent()));

    n = node.getAttributes().getNamedItem("StemChange");
    if (n != null) this.setMija(Integer.parseInt(n.getTextContent()));

    n = node.getAttributes().getNamedItem("Ending");
    if (n != null) this.setEnding(n.getTextContent());

    n = node.getAttributes().getNamedItem("StemID");
    if (n != null) this.stemID = Integer.parseInt(n.getTextContent());

    n = node.getAttributes().getNamedItem("LemmaEnding");
    if (n != null)
      try {
        setLemmaEnding(Integer.parseInt(n.getTextContent()));
        // FIXME - nestrādās, ja pamatformas galotne tiks ielasīta pēc šīs galotnes, nevis pirms..
      } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (DOMException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (Exception e) {
        throw new Error(e.getMessage());
      }
  }
Example #3
0
	/*
			//	this.signature.creation_date = Util.getCalendar(creationTime);
			 try {
				this.signature.setEditable();
				this.signature.storeVerified();
			} catch (P2PDDSQLException e) {
				e.printStackTrace();
			}
	 */
	public void setChoiceOldJustification(/*String creationTime*/){
		if(DEBUG) System.out.println("VoteEditor: setChoiceOldJustification start");
		JustGIDItem selected = (JustGIDItem) just_old_just_field.getSelectedItem();
		String id = null, gid=null;
		try {
			if(selected == null){
				if(DEBUG) System.out.println("VoteEditor: setChoiceOldJustification no selection null");
				id = null;
			}else{
				if(DEBUG) out.println("VoteEditor:handleFieldEvent: selected old just ="+selected.toStringDump());
				if(selected.id == null){
					if(DEBUG) out.println("VoteEditor:handleFieldEvent: selected id=null");
					id = null;
				}
				else{
					id = ""+(new Integer(selected.id).longValue());
					gid = selected.gid;
				}
			}

			signature.justification_ID = id;
			signature.global_justification_ID = gid;
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}	
	}
Example #4
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));
    }
  }
Example #5
0
  public static void main(String[] args) {
    try {
      int port = DEFAULT_SERVER_PORT;
      File systemDir = null;
      if (args.length > 0) {
        try {
          port = Integer.parseInt(args[0]);
        } catch (NumberFormatException e) {
          System.err.println("Error parsing port: " + e.getMessage());
          System.exit(-1);
        }

        systemDir = new File(args[1]);
      }

      final Server server =
          new Server(
              systemDir, System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null);

      initLoggers();
      server.start(port);

      System.out.println("Server classpath: " + System.getProperty("java.class.path"));
      System.err.println(SERVER_SUCCESS_START_MESSAGE + port);
    } catch (Throwable e) {
      System.err.println(SERVER_ERROR_START_MESSAGE + e.getMessage());
      e.printStackTrace(System.err);
      System.exit(-1);
    }
  }
Example #6
0
  private boolean readAndPopulateData() {
    BufferedReader reader = null;
    boolean isSuccess = false;
    try {
      InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(inputFile);
      reader = new BufferedReader(new FileReader(new File(inputFile)));

      String line;
      while ((line = reader.readLine()) != null) {
        String[] arr = line.split(":");
        String countryName = arr[0];
        Integer score = Integer.parseInt(arr[1]);
        countrySet.add(countryName);
        populateScoreCard(countryName, score);
        isSuccess = true;
      }
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (reader != null) reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return isSuccess;
  }
Example #7
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
  public int getPageForFacet(String facetName) {
    if (facetName == null) {
      throw new NullPointerException();
    }

    int newPage = 1;
    int pageCount = getPageCount();

    if (FIRST_FACET_NAME.equals(facetName)) {
      newPage = 1;
    } else if (LAST_FACET_NAME.equals(facetName)) {
      newPage = pageCount > 0 ? pageCount : 1;
    } else if (PREVIOUS_FACET_NAME.equals(facetName)) {
      newPage = getPage() - 1;
    } else if (NEXT_FACET_NAME.equals(facetName)) {
      newPage = getPage() + 1;
    } else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
      newPage = getPage() + getFastStepOrDefault();
    } else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
      newPage = getPage() - getFastStepOrDefault();
    } else {
      try {
        newPage = Integer.parseInt(facetName.toString());
      } catch (NumberFormatException e) {
        throw new FacesException(e.getLocalizedMessage(), e);
      }
    }

    if (newPage >= 1 && newPage <= pageCount) {
      return newPage;
    } else {
      return 0;
    }
  }
 /**
  * 获取状态栏高度
  *
  * @param activity
  * @return
  */
 public int getStatusHeight(Activity activity) {
   int statusHeight = 0;
   Rect localRect = new Rect();
   activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
   statusHeight = localRect.top;
   if (0 == statusHeight) {
     Class<?> localClass;
     try {
       localClass = Class.forName("com.android.internal.R$dimen");
       Object localObject = localClass.newInstance();
       int i5 =
           Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());
       statusHeight = activity.getResources().getDimensionPixelSize(i5);
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     } catch (InstantiationException e) {
       e.printStackTrace();
     } catch (NumberFormatException e) {
       e.printStackTrace();
     } catch (IllegalArgumentException e) {
       e.printStackTrace();
     } catch (SecurityException e) {
       e.printStackTrace();
     } catch (NoSuchFieldException e) {
       e.printStackTrace();
     }
   }
   return statusHeight;
 }
  /**
   * Get multiple bonuses
   *
   * @param ssn
   * @param multiplier
   * @return
   */
  private MultipleBonus[] getBonuses(String[] ssn, String[] multiplierStr) {

    // 2 input arrays do not have the same length
    MultipleBonus[] multipleBonus = new MultipleBonus[multiplierStr.length];
    for (int i = 0; i < multiplierStr.length; i++) {

      MultipleBonus b = new MultipleBonus();
      int iSsn = (int) i / 3;
      log.info("(i, iSsn) = (" + i + ", " + iSsn + ")");
      try {
        Ssn _ssn = new Ssn();
        _ssn.setSsn(ssn[iSsn]);
        b.setSsn(new Ssn());
        double m = Double.valueOf(multiplierStr[i]);
        b.setBonus(m);

      } catch (NumberFormatException e) {
        log.error(e.getStackTrace());
        b.setBonus(-1); // if multiplier is not filled correctly

      } finally {
        String msg = String.format("bonus[%d]=%s", i, b.toString());
        log.info(msg);
        multipleBonus[i] = b;
      }
    }
    return multipleBonus;
  }
  private String formatResult(String code, String value, Date date, String datePattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
    String res = "";

    if (code != null && code.length() > 0) res = code;

    if (value != null && value.length() > 0) {
      if (res.length() > 0) res = res.concat(",").concat(value);
      else res = value;
    }

    Integer markingSize;
    try {
      markingSize =
          Integer.parseInt(
              getFacadeContainer()
                  .getGlobalParameterAPI()
                  .findByCode("service.operation.marking.lenght"));
    } catch (NumberFormatException e) {
      e.printStackTrace();
      markingSize = 35;
    } catch (GenericFacadeException e) {
      e.printStackTrace();
      markingSize = 35;
    }

    if (res.length() > (markingSize - datePattern.length()))
      res = res.substring(0, (markingSize - datePattern.length()) - 1);

    if (res.length() > 0) res = res.concat(",");

    res = res.concat(sdf.format(date));
    return res;
  }
Example #12
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String strCallResult = "";
    resp.setContentType("text/plain");

    String strId = req.getParameter("id");
    String strCount = req.getParameter("count");
    int id = -1;
    int count = -1;
    try {
      id = Integer.valueOf(strId);
      count = Integer.valueOf(strCount);
    } catch (NumberFormatException e) {
      e.printStackTrace();
    }

    try {

      TopsCalculator.getTopUrlsForDay();
      TopsCalculator.getTopUrlsForMonth();
      TopsCalculator.getTopUrlsForYear();
      TopsCalculator.getTopHostsForDay();
      TopsCalculator.getTopHostsForMonth();
      TopsCalculator.getTopHostsForYear();

      if (id == 0) {
        DbHelper.setStartTime(System.currentTimeMillis());
      } else if (id == count - 1) {
        DbHelper.setRunTime(System.currentTimeMillis() - DbHelper.getStartTime());
      }

    } catch (Exception ex) {
      strCallResult = "FAIL: Fetching top lists";
      System.out.println(strCallResult);
    }
  }
  private void writeFrequency() {
    // get the text entered in edit box
    String text = mUserText.getText().toString();
    try {
      int iFreq = Integer.parseInt(text);
      Float validFreq = UpdateFrequency(iFreq);
      if (validFreq != 0) {
        // reset the text in edit box for the next entry
        mUserText.setText(null);

        Bundle bundle = new Bundle();
        bundle.putFloat(FREQ_VALUE, validFreq);
        Intent result = new Intent();
        result.putExtras(bundle);
        setResult(RESULT_OK, result);
        finish();

      } else {
        new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setMessage("Enter valid frequency!!")
            .setNegativeButton(android.R.string.ok, null)
            .show();
        mUserText.setText(null);
      }
    } catch (NumberFormatException nfe) {
      if (DBG) Log.d(TAG, "NumberFormatException:" + nfe.getMessage());
      new AlertDialog.Builder(this)
          .setIcon(android.R.drawable.ic_dialog_alert)
          .setMessage("Enter valid number!!")
          .setNegativeButton(android.R.string.ok, null)
          .show();
      mUserText.setText(null);
    }
  }
  protected void execute(String[] command, long timestamp)
      throws ValidationException, DatastoreException {
    Validator.validateNotNullOrEmpty("metricName", command[1]);

    String metricName = command[1];

    DataPoint dp;
    try {
      if (command[3].contains("."))
        dp = m_doubleFactory.createDataPoint(timestamp, Double.parseDouble(command[3]));
      else dp = m_longFactory.createDataPoint(timestamp, Util.parseLong(command[3]));
    } catch (NumberFormatException e) {
      throw new ValidationException(e.getMessage());
    }

    ImmutableSortedMap.Builder<String, String> tags = Tags.create();

    int tagCount = 0;
    for (int i = 4; i < command.length; i++) {
      String[] tag = command[i].split("=");
      validateTag(tagCount, tag);

      tags.put(tag[0], tag[1]);
      tagCount++;
    }

    if (tagCount == 0) tags.put("add", "tag");

    m_counter.incrementAndGet();
    m_datastore.putDataPoint(metricName, tags.build(), dp);
  }
 @FXML
 public void handleVideoSound(ActionEvent e) {
   if (videoSound_frequency.getText().isEmpty()
       || videoSound_duration.getText().isEmpty()
       || videoSound_numberOfCycles.getText().isEmpty()
       || videoSound_interSoundWait.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .videoSound(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   videoSound_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(videoSound_frequency.getText()),
               Integer.parseInt(videoSound_duration.getText()),
               Integer.parseInt(videoSound_numberOfCycles.getText()),
               Integer.parseInt(videoSound_interSoundWait.getText()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
  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();
    }
  }
Example #17
0
 public static Vector<Section> makeShvellerList(List<String> data) {
   Vector<Section> corners = new Vector<>();
   for (int i = 2; i < data.size(); i++) {
     String[] tmp = data.get(i).trim().split("\t");
     try {
       System.out.println(Arrays.toString(tmp));
       corners.add(
           new Shveller(
               tmp[0], // имя профиля
               Float.parseFloat(tmp[1]), // стенка в мм
               Float.parseFloat(tmp[2]), // полка в мм
               Float.parseFloat(tmp[3]), // толщина стенки в мм
               Float.parseFloat(tmp[4]), // толщина полки в мм
               Float.parseFloat(tmp[5]), // радиус большой в мм
               Float.parseFloat(tmp[6]), // радиус малый в мм
               Float.parseFloat(tmp[7]), // площадь в см2
               Float.parseFloat(tmp[8]), // масса в кг/м.п.
               Float.parseFloat(tmp[9]), // момент инерции вокруг оси х в см3
               Float.parseFloat(tmp[10]), // момент сопротивления вокруг оси х в см3
               Float.parseFloat(tmp[11]), // радиус инерции вокруг оси х в см
               Float.parseFloat(tmp[12]), // статический момент оси х в см
               Float.parseFloat(tmp[13]), // момент инерции вокруг оси y в см4
               Float.parseFloat(tmp[14]), // момент сопротивления вокруг оси y в см3
               Float.parseFloat(tmp[15]), // радиус инерции вокруг оси y в см
               Float.parseFloat(tmp[16]))); // tg(alpha) - тангенс угла наклона оси u
     } catch (NumberFormatException e) {
       // System.out.println("NumberFormatException " + i);
       JOptionPane.showMessageDialog(
           null, i + ": " + e.getMessage(), "Швеллеры с уклоном полок", JOptionPane.ERROR_MESSAGE);
       break;
     }
   } // for
   return corners;
 }
Example #18
0
  private long[] readSecrets(String fileName) {
    long[] secrets = null;

    try {
      BufferedReader br = new BufferedReader(new FileReader(fileName));
      int len = Integer.parseInt(br.readLine());
      secrets = new long[len];

      for (int i = 0; i < len; i++) {
        secrets[i] = Long.parseLong(br.readLine());
      }

      br.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      return null;
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    } catch (NumberFormatException e) {
      e.printStackTrace();
      return null;
    }

    return secrets;
  }
  public static Map<String, Double> get(String fileNameProbModel) {
    java.io.BufferedReader br = null;
    try {
      br = new java.io.BufferedReader(new FileReader(fileNameProbModel));
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    String line;
    Map<String, Double> probModel = new HashMap<String, Double>();
    try {
      while ((line = br.readLine()) != null) {
        String[] lines = line.split(",");
        probModel.put(lines[0], Double.parseDouble(lines[1]));
      }
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return probModel;
  }
Example #20
0
 @Override
 public void run() {
   if (isr != null && osw != null) {
     String body;
     try {
       body = readJson();
       System.out.println(body);
       JSONRPC2Request request = JSONRPC2Request.parse(body);
       JSONRPC2Response response = dispatcher.process(request, null);
       String res = response.toJSONString();
       System.out.println(res);
       sendResponse(res);
     } catch (NumberFormatException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (JSONRPC2ParseException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     } finally {
       try {
         isr.close();
         osw.close();
         socket.close();
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
 }
Example #21
0
  public void setDefaultPlotPrice(String plotPrice) {
    if (localSender.isConsole()) {
      localSender.notifyConsoleNotSupported();
      return;
    }

    if (!localSender.hasMayoralPermissions()) {
      localSender.notifyInsufPermissions();
      return;
    }

    Town t = localSender.getActiveTown();

    if (t == null) {
      localSender.notifyActiveTownNotSet();
      return;
    }

    BigDecimal price;

    try {
      price = new BigDecimal(plotPrice);
    } catch (NumberFormatException nfe) {
      localSender.sendMessage(ERR + "Error parsing plot price: " + nfe.getMessage());
      return;
    }

    t.setDefaultPlotPrice(price);
    localSender.sendMessage(
        SUCC + "The default price of plots in " + t.getTownName() + " has been set to " + price);
  }
 @FXML
 public void handleControlClock(ActionEvent e) {
   if (controlClock_hour.getText().isEmpty()
       || controlClock_min.getText().isEmpty()
       || controlClock_sec.getText().isEmpty()
       || controlClock_row.getText().isEmpty()
       || controlClock_column.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .controlClock(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_units.getSelectionModel().getSelectedItem()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_function.getSelectionModel().getSelectedItem()),
               controlClock_clockID.getSelectionModel().getSelectedItem(),
               Integer.parseInt(controlClock_hour.getText()),
               Integer.parseInt(controlClock_min.getText()),
               Integer.parseInt(controlClock_sec.getText()),
               Integer.parseInt(controlClock_row.getText()),
               Integer.parseInt(controlClock_column.getText()),
               Integer.parseInt(controlClock_attribute.getText()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_mode.getSelectionModel().getSelectedItem()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
  public String removerCategoria() {

    HttpServletRequest request =
        (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    try {
      long idCategoria = Long.parseLong(request.getParameter("idCategoria"));

      CategoriaDAO categoriaDao = new CategoriaJPADAO();
      Categoria categoria = categoriaDao.find(idCategoria);

      categoriaDao.delete(categoria);

    } catch (NumberFormatException ex) {
      ex.printStackTrace();
      FacesContext.getCurrentInstance()
          .addMessage(
              "Aviso", new FacesMessage(FacesMessage.SEVERITY_WARN, "Categoria inexistente!", ""));

    } catch (PersistenceException e) {
      e.printStackTrace();
      new CategoriaJPADAO().rollback();
      FacesContext.getCurrentInstance()
          .addMessage(
              "Aviso",
              new FacesMessage(
                  FacesMessage.SEVERITY_WARN, "Já existem atividades nesta categoria!", ""));
    }

    return "?faces-redirect=true";
  }
 @FXML
 public void handleDrawBox(ActionEvent e) {
   if (drawBox_row.getText().isEmpty()
       || drawBox_column.getText().isEmpty()
       || drawBox_height.getText().isEmpty()
       || drawBox_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .drawBox(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   drawBox_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(drawBox_row.getText()),
               Integer.parseInt(drawBox_column.getText()),
               Integer.parseInt(drawBox_height.getText()),
               Integer.parseInt(drawBox_width.getText()),
               Integer.parseInt(drawBox_attribute.getText()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   drawBox_borderType.getSelectionModel().getSelectedItem()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 /**
  * Sets the property value by parsing a given String. May raise java.lang.IllegalArgumentException
  * if the String is badly formatted.
  *
  * @param text The string to be parsed.
  */
 public void setAsText(String text) throws java.lang.IllegalArgumentException {
   try {
     setValue(new Double(text));
   } catch (NumberFormatException x) {
     throw new IllegalArgumentException(x.getMessage());
   }
 }
 @FXML
 public void handleSaveVideoRegion(ActionEvent e) {
   if (saveVideoRegion_row.getText().isEmpty()
       || saveVideoRegion_column.getText().isEmpty()
       || saveVideoRegion_height.getText().isEmpty()
       || saveVideoRegion_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .saveVideoRegion(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   saveVideoRegion_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(saveVideoRegion_row.getText()),
               Integer.parseInt(saveVideoRegion_column.getText()),
               Integer.parseInt(saveVideoRegion_height.getText()),
               Integer.parseInt(saveVideoRegion_height.getText()),
               saveVideoRegion_bufferID.getSelectionModel().getSelectedItem());
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 public static WriterParameters parseWriterParameters(final UriInfo info) {
   WriterParameters.WriterParametersBuilder wpBuilder =
       new WriterParameters.WriterParametersBuilder();
   String param = info.getQueryParameters(false).getFirst(UriParameters.DEPTH.toString());
   if (!Strings.isNullOrEmpty(param) && !"unbounded".equals(param)) {
     try {
       final int depth = Integer.valueOf(param);
       if (depth < 1) {
         throw new RestconfDocumentedException(
             new RestconfError(
                 RestconfError.ErrorType.PROTOCOL,
                 RestconfError.ErrorTag.INVALID_VALUE,
                 "Invalid depth parameter: " + depth,
                 null,
                 "The depth parameter must be an integer > 1 or \"unbounded\""));
       }
       wpBuilder.setDepth(depth);
     } catch (final NumberFormatException e) {
       throw new RestconfDocumentedException(
           new RestconfError(
               RestconfError.ErrorType.PROTOCOL,
               RestconfError.ErrorTag.INVALID_VALUE,
               "Invalid depth parameter: " + e.getMessage(),
               null,
               "The depth parameter must be an integer > 1 or \"unbounded\""));
     }
   }
   param = info.getQueryParameters(false).getFirst(UriParameters.PRETTY_PRINT.toString());
   wpBuilder.setPrettyPrint("true".equals(param));
   return wpBuilder.build();
 }
 @FXML
 public void handleUpdateVideoRegionAttribute(ActionEvent e) {
   if (updateVideoRegionAttribute_row.getText().isEmpty()
       || updateVideoRegionAttribute_col.getText().isEmpty()
       || updateVideoRegionAttribute_height.getText().isEmpty()
       || updateVideoRegionAttribute_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .updateVideoRegionAttribute(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   updateVideoRegionAttribute_units.getSelectionModel().getSelectedItem()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   updateVideoRegionAttribute_function.getSelectionModel().getSelectedItem()),
               Integer.parseInt(updateVideoRegionAttribute_row.getText()),
               Integer.parseInt(updateVideoRegionAttribute_col.getText()),
               Integer.parseInt(updateVideoRegionAttribute_height.getText()),
               Integer.parseInt(updateVideoRegionAttribute_width.getText()),
               Integer.parseInt(updateVideoRegionAttribute_attribute.getText()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
Example #29
0
	public void setChoice(){
		if(DEBUG) System.out.println("VoteEditor: setChoice start");
		D_MotionChoice selected = (D_MotionChoice) this.vote_choice_field.getSelectedItem();
		String name = null, short_name=null;
		try {
			if(selected == null){
				if(DEBUG) System.out.println("VoteEditor: setChoiceOldJustification no selection null");
				short_name = null;
			}else{
				if(DEBUG) out.println("VoteEditor:handleFieldEvent: selected old just ="+selected.toStringDump());
				if(selected.short_name == null){
					if(DEBUG) out.println("VoteEditor:handleFieldEvent: selected choice = null");
					short_name = null;
				}
				else {
					short_name = selected.short_name;
					name = selected.name;
				}
			}

			signature.choice = short_name;
			if(DEBUG) out.println("VoteEditor:handleFieldEvent: selected choice = "+name);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}		
	}
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    double precioBase;
    double peso;
    String descripcion;
    String color;
    String consumo;
    double carga;

    descripcion = request.getParameter("descripcion");
    color = request.getParameter("color");
    consumo = request.getParameter("consumo");

    try {
      precioBase = Double.parseDouble(request.getParameter("precioBase"));
      peso = Double.parseDouble(request.getParameter("peso"));
      carga = Double.parseDouble(request.getParameter("carga"));

      Electrodomestico e =
          ce.crearElectrodomestico(precioBase, peso, descripcion, color, consumo, carga);
      ce.addElectrodomestico(e);
    } catch (NumberFormatException e) {
      e.printStackTrace();
      // hacer algo copado con los errores
      // tener en cuenta que el usuario es experto, asi que no hay errores
    }

    response.sendRedirect("alta.html");
  }