List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.sisrni.converter.OrganismoConverter.java
@Override public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { value = String.valueOf(value); if (JsfUtil.isDummySelectItem(component, value)) { return null; }/*from w w w . jav a 2 s .c o m*/ if (value != null && value.trim().length() > 0 && !value.equalsIgnoreCase("null")) { try { if (isNumeric(value)) { if (value != null) { Integer key = getKey(value); Organismo findById = this.organismoService.findById(key); return findById; } } } catch (NumberFormatException e) { e.printStackTrace(); throw new ConverterException( new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme.")); } } else { return null; } return null; }
From source file:com.sisrni.converter.TipoProyectoConverter.java
@Override public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { value = String.valueOf(value); if (JsfUtil.isDummySelectItem(component, value)) { return null; }// w w w. ja va 2 s. c o m if (isNumeric(value)) { if (value != null && value.trim().length() > 0 && !value.equalsIgnoreCase("null")) { try { Integer key = getKey(value); TipoProyecto findById = tipoProyectoService.findById(key); return findById; } catch (NumberFormatException e) { e.printStackTrace(); throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme.")); } } } else { return new TipoProyecto(); } return null; }
From source file:com.sisrni.converter.ProgramaMovilidadConverter.java
@Override public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { value = String.valueOf(value); if (JsfUtil.isDummySelectItem(component, value)) { return null; }/*from w w w. jav a2 s . c o m*/ if (isNumeric(value)) { if (value != null && value.trim().length() > 0 && !value.equalsIgnoreCase("null")) { try { Integer key = getKey(value); ProgramaMovilidad findById = this.programaMovilidadService.getByID(key); return findById; } catch (NumberFormatException e) { e.printStackTrace(); throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "programaMovilidadConverter Error", "Not a valid theme.")); } } } else { return null; } return null; }
From source file:com.sisrni.converter.EtapaMovilidadConverter.java
@Override public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { value = String.valueOf(value); if (JsfUtil.isDummySelectItem(component, value)) { return null; }//www . j a va2 s. c o m if (isNumeric(value)) { if (value != null && value.trim().length() > 0 && !value.equalsIgnoreCase("null")) { try { Integer key = getKey(value); EtapaMovilidad findById = this.etapaMovilidadService.getByID(key); return findById; } catch (NumberFormatException e) { e.printStackTrace(); throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme.")); } } } else { return null; } return null; }
From source file:br.com.pi.converter.EntityConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String texto) { T object = null;//from ww w. j a v a 2 s . c o m if (texto.equals("")) { return null; } try { object = targetClass.newInstance(); BeanUtils.setProperty(object, "id", Integer.parseInt(texto)); return object; } catch (NumberFormatException e) { return null; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.sonews.daemon.command.StatCommand.java
@Override public void processLine(NNTPConnection conn, final String line, byte[] raw) throws IOException, StorageBackendException { final String[] command = line.split(" "); Article article = null;//from w w w. java 2 s . c o m if (command.length == 1) { article = conn.getCurrentArticle(); if (article == null) { conn.println("420 no current article has been selected"); return; } } else if (command[1].matches(SynchronousNNTPConnection.MESSAGE_ID_PATTERN)) { // Message-ID article = Article.getByMessageID(command[1]); if (article == null) { conn.println("430 no such article found"); return; } } else { // Message Number try { long aid = Long.parseLong(command[1]); article = conn.getCurrentGroup().getArticle(aid); } catch (NumberFormatException ex) { ex.printStackTrace(); } catch (StorageBackendException ex) { ex.printStackTrace(); } if (article == null) { conn.println("423 no such article number in this group"); return; } conn.setCurrentArticle(article); } conn.println("223 " + conn.getCurrentGroup().getIndexOf(article) + " " + article.getMessageID() + " article retrieved - request text separately"); }
From source file:org.wikipedia.vlsergey.secretary.jwpf.actions.PostLogin.java
@Override protected void parseAPI(org.w3c.dom.Element root) throws ProcessException, ParseException { Element login = (Element) root.getElementsByTagName("login").item(0); String result = login.getAttribute("result"); if (result.equalsIgnoreCase(success)) { try {/*from www.java2 s . com*/ this.login = new LoginData(Integer.parseInt(login.getAttribute("lguserid")), login.getAttribute("lgusername"), login.getAttribute("lgtoken")); } catch (NumberFormatException e) { e.printStackTrace(); } } else if (result.equalsIgnoreCase(needToken)) { this.ticketData = new TicketData(login.getAttribute("token"), login.getAttribute("sessionid")); } else if (result.equalsIgnoreCase(wrongPass)) { exceptionText = "Wrong Password"; } else if (result.equalsIgnoreCase(notExists)) { exceptionText = "No sutch User"; } }
From source file:org.fao.geonet.services.thumbnail.Generate.java
public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception { String id = Util.getParam(params, Params.ID); String version = Util.getParam(params, Params.VERSION); String file = Util.getParam(params, Params.NAME, "thumbnail.png"); String jsonConfig = Util.getParam(params, "config"); String rotation = Util.getParam(params, "rotation", null); Integer rotationAngle = null; try {/*from w w w . ja va 2 s .c om*/ rotationAngle = Integer.valueOf(rotation); } catch (NumberFormatException e) { e.printStackTrace(); } Lib.resource.checkEditPrivilege(context, id); GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); DataManager dataMan = gc.getBean(DataManager.class); ThumbnailMaker thumbnailMaker = gc.getBean(ThumbnailMaker.class); //--- check if the metadata has been modified from last time if (version != null && !dataMan.getVersion(id).equals(version)) { throw new ConcurrentUpdateEx(id); } File thumbnailFile = thumbnailMaker.generateThumbnail(jsonConfig, rotationAngle); //--- create destination directory String dataDir = Lib.resource.getDir(context, Params.Access.PUBLIC, id); IO.mkdirs(new File(dataDir), "Metadata data directory"); File outFile = new File(dataDir, file); if (outFile.exists() && !outFile.delete()) { throw new Exception("Unable to overwrite existing file: " + outFile); } try { FileUtils.moveFile(thumbnailFile, outFile); } catch (Exception e) { IO.delete(thumbnailFile, false, context); throw new Exception( "Unable to move uploaded thumbnail to destination: " + outFile + ". Error: " + e.getMessage()); } dataMan.setThumbnail(context, id, false, file, false); dataMan.indexMetadata(id, false); Element response = new Element("a"); response.addContent(new Element("id").setText(id)); response.addContent(new Element("version").setText(dataMan.getNewVersion(id))); return response; }
From source file:opennlp.tools.parse_thicket.opinion_processor.YouTubeMiner.java
public YouTubeMinerResult getData(String url) { YouTubeMinerResult result = new YouTubeMinerResult(); String content = fetcher.fetchOrigHTML(url); try {//from www . j a v a 2 s . com FileUtils.writeStringToFile(new File(url.replace(':', '_').replace('/', '_')), content); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (url.indexOf("channel") > -1) { try { // subscriber-count" title="30" String subscribersStr = StringUtils.substringBetween(content, "subscriber-count", "tabindex"); String dirtyNumber = StringUtils.substringBetween(subscribersStr, "title=\"", "\""); String cleanNumber = dirtyNumber.replaceAll("[^\\x00-\\x7F]", ""); if (cleanNumber != null) { int subscribers = Integer.parseInt(cleanNumber); result.subscribers = subscribers; } else { System.err.println("Not found data for 'subscriber-count', 'tabindex'"); } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { String subscribersStr = StringUtils.substringBetween(content, "subscriber-count", "tabindex"); String dirtyNumber = StringUtils.substringBetween(subscribersStr, "title=\"", "\"").replace(" ", ""); if (dirtyNumber != null) { int subscribers = Integer.parseInt(dirtyNumber); result.subscribers = subscribers; } else { System.err.println("Not found data for 'subscriber-count', 'tabindex'"); } String viewsStrDirty = StringUtils.substringBetween(content, // "div class=\"watch-view-count\">"," views</div>"); // view-count">12 ?</div> "view-count", "<div>"); String viewsStr = StringUtils.substringBetween(viewsStrDirty, ">", " "); if (viewsStr != null) { int views = Integer.parseInt(viewsStr); result.views = views; } else { System.err.println("Not found data for 'view-count','<div>'"); } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return result; }
From source file:my.jabbr.app.ftpclient.controller.ConfigManager.java
public void copyABEKeys(String defaultScheme, String sourcePKFile, String sourceASKFile, char[] password) throws IOException, EncryptionAlgorithmMismatchException, InvalidABEFileFormatException { AppConfiguration appConfig = client.getAppConfig(); try {//from ww w . jav a 2 s . c om ABEPublicKey pk = JabbrKeyStoreUtils.readPublicKeyFromFile(defaultScheme, sourcePKFile); JabbrKeyStoreUtils.writeToFile(pk, appConfig.getPublicEncryptionKeyFile(), defaultScheme); byte[] plaintextSecretKeyBytes = FileUtils.readFileToByteArray(new File(sourceASKFile)); JabbrKeyStoreUtils.pbeEncryptBytes(plaintextSecretKeyBytes, password, appConfig.getUserSecretEncryptionKeyFile()); //ABEUserAttributeSet userAttributes = ABEObjectFactory.createUserAttributeSetObj(); //ABESecretKey userKey = JabbrKeyStoreUtils.readUserKeyFromFile(defaultScheme, userAttributes, pk, sourceASKFile); //JabbrKeyStoreUtils.writeToFile(userKey, appConfig.getUserSecretEncryptionKeyFile(), defaultScheme, userAttributes); } catch (NumberFormatException e) { e.printStackTrace(); } }