List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:org.ofbiz.shipment.thirdparty.usps.UspsServices.java
public static Map<String, Object> uspsUpdateShipmentRateInfo(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String shipmentId = (String) context.get("shipmentId"); String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId"); Locale locale = (Locale) context.get("locale"); Map<String, Object> shipmentGatewayConfig = ShipmentServices.getShipmentGatewayConfigFromShipment(delegator, shipmentId, locale);/*from w w w . j a v a 2 s .co m*/ String shipmentGatewayConfigId = (String) shipmentGatewayConfig.get("shipmentGatewayConfigId"); String resource = (String) shipmentGatewayConfig.get("configProps"); if (UtilValidate.isEmpty(shipmentGatewayConfigId) && UtilValidate.isEmpty(resource)) { return ServiceUtil.returnError( UtilProperties.getMessage(resourceError, "FacilityShipmentUspsGatewayNotAvailable", locale)); } try { GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment") .where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } // ensure the carrier is USPS if (!"USPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } // get the origin address GenericValue originAddress = shipmentRouteSegment.getRelatedOne("OriginPostalAddress", false); if (originAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(originAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String originZip = originAddress.getString("postalCode"); if (UtilValidate.isEmpty(originZip)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRouteSegmentOriginZipCodeMissing", UtilMisc.toMap("contactMechId", originAddress.getString("contactMechId")), locale)); } // get the destination address GenericValue destinationAddress = shipmentRouteSegment.getRelatedOne("DestPostalAddress", false); if (destinationAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentRouteSegmentDestPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(destinationAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String destinationZip = destinationAddress.getString("postalCode"); if (UtilValidate.isEmpty(destinationZip)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRouteSegmentDestinationZipCodeMissing", UtilMisc.toMap("contactMechId", destinationAddress.getString("contactMechId")), locale)); } // get the service type from the CarrierShipmentMethod String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId"); String partyId = shipmentRouteSegment.getString("carrierPartyId"); GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod") .where("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId) .queryOne(); if (carrierShipmentMethod == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsNoCarrierShipmentMethod", UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } String serviceType = carrierShipmentMethod.getString("carrierServiceCode"); if (UtilValidate.isEmpty(serviceType)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsNoCarrierServiceCodeFound", UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } // get the packages for this shipment route segment List<GenericValue> shipmentPackageRouteSegList = shipmentRouteSegment .getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId"), false); if (UtilValidate.isEmpty(shipmentPackageRouteSegList)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentPackageRouteSegsNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } BigDecimal actualTransportCost = BigDecimal.ZERO; String carrierDeliveryZone = null; String carrierRestrictionCodes = null; String carrierRestrictionDesc = null; // send a new request for each package for (Iterator<GenericValue> i = shipmentPackageRouteSegList.iterator(); i.hasNext();) { GenericValue shipmentPackageRouteSeg = i.next(); //String sprsKeyString = "[" + shipmentPackageRouteSeg.getString("shipmentId") + "," + // shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + "," + // shipmentPackageRouteSeg.getString("shipmentRouteSegmentId") + "]"; Document requestDocument = createUspsRequestDocument("RateRequest", true, delegator, shipmentGatewayConfigId, resource); Element packageElement = UtilXml.addChildElement(requestDocument.getDocumentElement(), "Package", requestDocument); packageElement.setAttribute("ID", "0"); UtilXml.addChildElementValue(packageElement, "Service", serviceType, requestDocument); UtilXml.addChildElementValue(packageElement, "ZipOrigination", originZip, requestDocument); UtilXml.addChildElementValue(packageElement, "ZipDestination", destinationZip, requestDocument); GenericValue shipmentPackage = null; shipmentPackage = shipmentPackageRouteSeg.getRelatedOne("ShipmentPackage", false); // weight elements - Pounds, Ounces String weightStr = shipmentPackage.getString("weight"); if (UtilValidate.isEmpty(weightStr)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsWeightNotFound", UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId")), locale)); } BigDecimal weight = BigDecimal.ZERO; try { weight = new BigDecimal(weightStr); } catch (NumberFormatException nfe) { nfe.printStackTrace(); // TODO: handle exception } String weightUomId = shipmentPackage.getString("weightUomId"); if (UtilValidate.isEmpty(weightUomId)) { weightUomId = "WT_lb"; // assume weight is in pounds } if (!"WT_lb".equals(weightUomId)) { // attempt a conversion to pounds Map<String, Object> result = FastMap.newInstance(); try { result = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", weightUomId, "uomIdTo", "WT_lb", "originalValue", weight)); } catch (GenericServiceException ex) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsWeightConversionError", UtilMisc.toMap("errorString", ex.getMessage()), locale)); } if (result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS) && result.get("convertedValue") != null) { weight = weight.multiply((BigDecimal) result.get("convertedValue")); } else { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsWeightUnsupported", UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "weightUom", "WT_lb"), locale)); } } BigDecimal weightPounds = weight.setScale(0, BigDecimal.ROUND_FLOOR); BigDecimal weightOunces = weight.multiply(new BigDecimal("16")).remainder(new BigDecimal("16")) .setScale(0, BigDecimal.ROUND_CEILING); DecimalFormat df = new DecimalFormat("#"); UtilXml.addChildElementValue(packageElement, "Pounds", df.format(weightPounds), requestDocument); UtilXml.addChildElementValue(packageElement, "Ounces", df.format(weightOunces), requestDocument); // Container element GenericValue carrierShipmentBoxType = null; List<GenericValue> carrierShipmentBoxTypes = null; carrierShipmentBoxTypes = shipmentPackage.getRelated("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "USPS"), null, false); if (carrierShipmentBoxTypes.size() > 0) { carrierShipmentBoxType = carrierShipmentBoxTypes.get(0); } if (carrierShipmentBoxType != null && UtilValidate.isNotEmpty(carrierShipmentBoxType.getString("packagingTypeCode"))) { UtilXml.addChildElementValue(packageElement, "Container", carrierShipmentBoxType.getString("packagingTypeCode"), requestDocument); } else { // default to "None", for customers using their own package UtilXml.addChildElementValue(packageElement, "Container", "None", requestDocument); } // Size element if (carrierShipmentBoxType != null && UtilValidate.isNotEmpty("oversizeCode")) { UtilXml.addChildElementValue(packageElement, "Size", carrierShipmentBoxType.getString("oversizeCode"), requestDocument); } else { // default to "Regular", length + girth measurement <= 84 inches UtilXml.addChildElementValue(packageElement, "Size", "Regular", requestDocument); } // Although only applicable for Parcel Post, this tag is required for all requests UtilXml.addChildElementValue(packageElement, "Machinable", "False", requestDocument); Document responseDocument = null; try { responseDocument = sendUspsRequest("Rate", requestDocument, delegator, shipmentGatewayConfigId, resource, locale); } catch (UspsRequestException e) { Debug.logInfo(e, module); return ServiceUtil.returnError( UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRateDomesticSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } Element respPackageElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "Package"); if (respPackageElement == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRateDomesticResponseIncompleteElementPackage", locale)); } Element respErrorElement = UtilXml.firstChildElement(respPackageElement, "Error"); if (respErrorElement != null) { return ServiceUtil .returnError(UtilProperties .getMessage(resourceError, "FacilityShipmentUspsRateDomesticResponseError", UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } // update the ShipmentPackageRouteSeg String postageString = UtilXml.childElementValue(respPackageElement, "Postage"); if (UtilValidate.isEmpty(postageString)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRateDomesticResponseIncompleteElementPostage", locale)); } BigDecimal postage = BigDecimal.ZERO; try { postage = new BigDecimal(postageString); } catch (NumberFormatException nfe) { nfe.printStackTrace(); // TODO: handle exception } actualTransportCost = actualTransportCost.add(postage); shipmentPackageRouteSeg.setString("packageTransportCost", postageString); shipmentPackageRouteSeg.store(); // if this is the last package, get the zone and APO/FPO restrictions for the ShipmentRouteSegment if (!i.hasNext()) { carrierDeliveryZone = UtilXml.childElementValue(respPackageElement, "Zone"); carrierRestrictionCodes = UtilXml.childElementValue(respPackageElement, "RestrictionCodes"); carrierRestrictionDesc = UtilXml.childElementValue(respPackageElement, "RestrictionDescription"); } } // update the ShipmentRouteSegment shipmentRouteSegment.set("carrierDeliveryZone", carrierDeliveryZone); shipmentRouteSegment.set("carrierRestrictionCodes", carrierRestrictionCodes); shipmentRouteSegment.set("carrierRestrictionDesc", carrierRestrictionDesc); shipmentRouteSegment.setString("actualTransportCost", String.valueOf(actualTransportCost)); shipmentRouteSegment.store(); } catch (GenericEntityException gee) { Debug.logInfo(gee, module); return ServiceUtil.returnError( UtilProperties.getMessage(resourceError, "FacilityShipmentUspsRateDomesticReadingError", UtilMisc.toMap("errorString", gee.getMessage()), locale)); } return ServiceUtil.returnSuccess(); }
From source file:de.uniwue.info6.webapp.admin.AdminEditScenario.java
/** * * * @param maxSizeInKB/*from w ww .jav a 2s . c om*/ * @return */ private boolean validSize(final int maxSizeInKB, final File file) { try { long fileSizeInKB = file.length() / 1024; if (fileSizeInKB < maxSizeInKB) return true; } catch (NumberFormatException e) { e.printStackTrace(); } return false; }
From source file:info.alni.comete.android.Comete.java
private AlertDialog createConnectDialog() { final View ll = getLayoutInflater().inflate(R.layout.connect_dialog, null); final EditText etIpAddress = (EditText) ll.findViewById(R.id.ipAddress); final EditText etPort = (EditText) ll.findViewById(R.id.port); final Spinner sSimType = (Spinner) ll.findViewById(R.id.sim_type); etIpAddress.setText(getConnectionPrefs().getString("ipAddress", "")); etPort.setText(getConnectionPrefs().getString("port", "")); return new AlertDialog.Builder(this).setTitle("Enter host IP and port ").setView(ll) .setPositiveButton("Connect", new DialogInterface.OnClickListener() { @Override/*from w w w . ja v a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { String ipAddress = etIpAddress.getText().toString(); String port = etPort.getText().toString(); int simType = sSimType.getSelectedItemPosition(); if (StringUtils.validateIPAddress(ipAddress) && StringUtils.validatePort(port)) { Editor editor = getConnectionPrefs().edit(); editor.putString("ipAddress", ipAddress); editor.putString("port", port); editor.putInt("simType", simType); editor.commit(); try { mConnectingDialog = ProgressDialog.show(Comete.this, "", "Connecting. Please wait...", true); // Comete.this.mIpAddress = ipAddress; // Comete.this.mPort = Integer.parseInt(port); Thread t = new Thread(new ConnectTask(ipAddress, Integer.parseInt(port), simType)); t.start(); } catch (NumberFormatException e) { showMsg(Comete.this, e.toString()); e.printStackTrace(); } } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:find.service.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { c = context;/*from w w w . j av a2 s . c om*/ Log.d(TAG, "received notification: " + intent.getAction()); setResultCode(Activity.RESULT_OK); this.intent = intent; // check if its alarm to start the service and enables it /* * if (intent.getAction().equals("startAlarm")) { Log.d(TAG, * "Handling alarm"); handleAlarm(); return; } */ // get data from push notification type = intent.getExtras().getString("type"); String mode = intent.getExtras().getString("mode"); Log.d(TAG, "Type:" + type); Log.d(TAG, "GCM - Mode:" + mode); // if received stop notification start the stopping service try { int tp = Integer.parseInt(type); if (tp == STOP) { Log.d(TAG, "Stopping service"); Notifications.generateNotification(c, "FIND Service", "Terminating the service", null); ScheduleService.cancelAlarm(c); Simulation.regSimulationContentProvider("", "", "", "", c); LOSTService.stop(c); return; } if (tp == CHANGE_MODE) { SharedPreferences prefs = c.getSharedPreferences(DemoActivity.class.getSimpleName(), Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(RequestServer.MODE, mode); editor.commit(); return; } } catch (NumberFormatException e) { Log.d(TAG, "Converted type is not a number"); } Log.d(TAG, "Checking received new notification"); // received new simulation notification, getting parameters name = intent.getExtras().getString("name"); date = intent.getExtras().getString("date"); long duration = Long.parseLong(intent.getExtras().getString("duration")); long durationInMillis = duration * 60 * 1000; // check if the simulation has already ended DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); try { Date dateFor = formatter.parse(date); Log.d(TAG, "date in milliseconds: " + dateFor.getTime()); if (System.currentTimeMillis() > dateFor.getTime() + durationInMillis) { Log.d(TAG, "The simulation has already ended"); return; } } catch (ParseException e) { e.printStackTrace(); } // bad code incoming: if (intent.getExtras().getString("latS") == null) return; latS = Double.parseDouble(intent.getExtras().getString("latS")); lonS = Double.parseDouble(intent.getExtras().getString("lonS")); latE = Double.parseDouble(intent.getExtras().getString("latE")); lonE = Double.parseDouble(intent.getExtras().getString("lonE")); Log.d(TAG, "date: " + date); // set timer for retriving location long timeleft = DateFunctions.timeToDate(date); locationTimer = timeleft / 2; locationTimeout = locationTimer / number_attempts; Log.d(TAG, "timeleft: " + timeleft); // retrieving last best location Location l = LocationFunctions.getBestLocation(context); if (l == null || LocationFunctions.oldLocation(l)) { Log.d(TAG, "old or null location"); // if old location then try to get new location for half the time // left until the starting date ls = new LocationSensor(c); ls.startSensor(); getLocation(); } else { Notifications.generateNotification(c, "Alert", "Location Found!", null); // prompt pop up window currentLoc = l; startPopUp(currentLoc); } }
From source file:com.kiandastream.musicplayer.MusicService.java
void processNextRequest() { if (mState == State.Starting) { if (song_playlist != null) { if ((Integer.parseInt(positionofsong) + 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) + 1; positionofsong = pos.toString(); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { String songurl = "http://api.kiandastream.globusapps.com/static/songs/" + song_playlist.get(Integer.parseInt(positionofsong)).getSong_id() + ".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }/*from w ww . j a v a2 s .c o m*/ } else relaxResources(true); } else relaxResources(true); } else if (mState == State.Playing) { if (song_playlist != null) { if ((Integer.parseInt(positionofsong) + 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) + 1; positionofsong = pos.toString(); if (listener != null) listener.stopUpdating(mPlayer); mPlayer.pause(); mPlayer.reset(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(positionofsong)).getSong_id()+".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } if (mState == State.Paused) { if (song_playlist != null) { if ((Integer.parseInt(positionofsong) + 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) + 1; positionofsong = pos.toString(); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(positionofsong)).getSong_id()+".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Last Song of Playlist", Toast.LENGTH_LONG).show(); relaxResources(true); } } } }
From source file:com.skilrock.lms.web.scratchService.gameMgmt.common.GameUploadAction.java
/** * This method is used to check for duplicate VIRN file * //from www .j a v a 2s .co m * @return void */ public void fileStatusCheckAjax() throws Exception { // System.out.println("gggggggggggggggggggggggg"); boolean virnFlag = true; PrintWriter out; out = getResponse().getWriter(); GameuploadHelper gameHelper = new GameuploadHelper(); StringBuilder vclist = new StringBuilder(""); System.out.println(getGameName()); System.out.println("function called readrank"); System.out.println("file path is " + getFilePath()); File file = new File(getFilePath()); FileReader fstream = null; try { System.out.println("11111111111111111111111"); fstream = new FileReader(file); BufferedReader br = new BufferedReader(fstream); System.out.println("6666666666666666666666"); String strLine = null; // String a = ""; // String b = ""; String c = ""; boolean flag = true; System.out.println("22222222222222==== gameName = " + gameName); String gameNameArr[] = getGameName().split("-"); int game_id = gameHelper.getGameId(gameNameArr[0], gameNameArr[1]); GameTicketFormatBean ticketFmtBean = gameHelper.getGameNbrDigitsByGameId(game_id); int gameNbrDigits = ticketFmtBean.getGameNbrDigits(); int maxRankDigits = ticketFmtBean.getMaxRankDigits(); if (gameNbrDigits == 0 || game_id == 0 || maxRankDigits == 0) { System.out.println("***************ERROR TYPE BLOCKER************"); } String virn_code = null; while ((strLine = br.readLine()) != null) { int lineLength = strLine.length(); // a = ""; // b = ""; c = ""; for (int i = 0; i < lineLength; i++) { // if (i < gameNbrDigits) // a = a + strLine.charAt(i); // if (i >= gameNbrDigits && i < // (gameNbrDigits+maxRankDigits)) // b = b + strLine.charAt(i); if (i >= gameNbrDigits + maxRankDigits && i < lineLength) { c = c + strLine.charAt(i); } } if (c != "") { virn_code = MD5Encoder.encode(c); if (flag) { vclist.append("'"); vclist.append(virn_code); vclist.append("'"); flag = false; } else { // vclist = vclist + ",'" + virn_code + "'"; vclist.append(",'"); vclist.append(virn_code); vclist.append("'"); } } } System.out.println("game id on action is" + game_id); System.out.println("game name is " + getGameName()); virnFlag = gameHelper.fileStatusCheck(vclist.toString(), game_id, gameNameArr[0]); System.out.println("flag is " + virnFlag); out.println(virnFlag); // return SUCCESS; } catch (NumberFormatException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // return SUCCESS; }
From source file:com.kiandastream.musicplayer.MusicService.java
void processPreviousRequest() { if (mState == State.Starting) { if (song_playlist != null) { if (Integer.parseInt(positionofsong) > 0) { if ((Integer.parseInt(positionofsong) - 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) - 1; positionofsong = pos.toString(); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(positionofsong)).getSong_id()+".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }//from ww w . ja v a 2 s . co m } else relaxResources(true); } } else relaxResources(true); } else if (mState == State.Playing) { if (song_playlist != null) { if (Integer.parseInt(positionofsong) > 0) { if ((Integer.parseInt(positionofsong) - 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) - 1; positionofsong = pos.toString(); if (listener != null) listener.stopUpdating(mPlayer); mPlayer.pause(); mPlayer.reset(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(positionofsong)).getSong_id()+".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } if (mState == State.Paused) { if (song_playlist != null) { if (Integer.parseInt(positionofsong) > 0) { if ((Integer.parseInt(positionofsong) - 1) < song_playlist.size()) { Integer pos = Integer.parseInt(positionofsong) - 1; positionofsong = pos.toString(); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(positionofsong)).getSong_id()+".mp3"; System.out.println("url of song playing is " + song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(positionofsong)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Last Song of Playlist", Toast.LENGTH_LONG).show(); relaxResources(true); } } } } }
From source file:com.appeligo.showfiles.ShowFlv.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("text/html"); PrintWriter out = response.getWriter(); /*//from ww w. ja v a 2s . c o m try { Velocity.init(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ init(getServletConfig()); VelocityContext context = new VelocityContext(); context.put("title", "Flip.TV Video Recall"); context.put("server", request.getServerName()); context.put("contextPath", request.getContextPath()); context.put("flvUrl", request.getPathInfo()); int start = 0; try { start = Integer.parseInt(request.getParameter("start")); } catch (NumberFormatException e) { } int duration = 0; try { duration = Integer.parseInt(request.getParameter("duration")); } catch (NumberFormatException e) { } context.put("start", new Integer(start)); // Note, there is a bug in FlowPlayer where you have to add the // start time TWICE to the duration to get the "workable" value // for the "end" parameter. if (duration > 0) { context.put("end", new Integer((start * 2) + duration)); } Template template = null; try { template = getTemplate("/FlowPlayer.vm"); } catch (ResourceNotFoundException rnfe) { // couldn't find the template rnfe.printStackTrace(); } catch (ParseErrorException pee) { // syntax error : problem parsing the template pee.printStackTrace(); } catch (MethodInvocationException mie) { // something invoked in the template // threw an exception mie.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } try { template.merge(context, out); // sw ); } catch (ResourceNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParseErrorException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MethodInvocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.kiandastream.musicplayer.MusicService.java
void processPlayRequest(String url) { if (song_playlist != null && song_playlist.size() > Integer.parseInt(url)) { System.out.println("i am in processPlayRequest before condition " + url); if (mState == State.Starting) { System.out.println("i am in processPlayRequest condition State.Starting"); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(url)).getSong_id()+".mp3"; System.out.println( "url of song playing is " + song_playlist.get(Integer.parseInt(url)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(url)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar /* setUpAsForeground(mSongTitle + " (loading)");*/ setNotification("Loading"); if (!mWifiLock.isHeld()) mWifiLock.acquire(); mPlayer.prepareAsync();/*from w ww .j ava2 s . co m*/ } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (mState == State.Stopped) { System.out.println("i am in processPlayRequest condition State.Complete"); createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(url)).getSong_id()+".mp3"; System.out.println( "url of song playing is " + song_playlist.get(Integer.parseInt(url)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(url)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar if (!mWifiLock.isHeld()) mWifiLock.acquire(); mPlayer.prepareAsync(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (mState == State.Paused) { System.out.println("i am in processPlayRequest condition .State.Paused"); if (mPlayer != null) { mPlayer.reset(); } else createMediaPlayerIfNeeded(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(url)).getSong_id()+".mp3"; System.out.println( "url of song playing is " + song_playlist.get(Integer.parseInt(url)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(url)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } configAndStartMediaPlayer(); } else if (mState == State.Playing) { System.out.println("i am in processPlayRequest condition .State.Playing"); if (listener != null) listener.stopUpdating(mPlayer); mPlayer.pause(); mPlayer.reset(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { //String songurl="http://api.kiandastream.globusapps.com/static/songs/"+song_playlist.get(Integer.parseInt(url)).getSong_id()+".mp3"; System.out.println( "url of song playing is " + song_playlist.get(Integer.parseInt(url)).getSongurl()); mPlayer.setDataSource(song_playlist.get(Integer.parseInt(url)).getSongurl()); setNotification("Loading"); mState = State.Preparing; //Setting title in notification bar mPlayer.prepareAsync(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } configAndStartMediaPlayer(); } } }
From source file:edu.usc.ir.geo.gazetteer.GeoNameResolver.java
/** * Index gazetteer's one line data by built-in Lucene Index functions * * @param indexWriter/* www.j a va2 s . c o m*/ * Lucene indexWriter to be loaded * @param line * a line from the gazetteer file * @throws IOException * @throws NumberFormatException */ private static void addDoc(IndexWriter indexWriter, final String line) { String[] tokens = line.split("\t"); int ID = Integer.parseInt(tokens[0]); String name = tokens[1]; String alternatenames = tokens[3]; Double latitude = -999999.0; try { latitude = Double.parseDouble(tokens[4]); } catch (NumberFormatException e) { latitude = OUT_OF_BOUNDS; } Double longitude = -999999.0; try { longitude = Double.parseDouble(tokens[5]); } catch (NumberFormatException e) { longitude = OUT_OF_BOUNDS; } int population = 0; try { population = Integer.parseInt(tokens[14]); } catch (NumberFormatException e) { population = 0;// Treat as population does not exists } // Additional fields to rank more known locations higher // All available codes can be viewed on www.geonames.org String featureCode = tokens[7];// more granular category String countryCode = tokens[8]; String admin1Code = tokens[10];// eg US State String admin2Code = tokens[11];// eg county Document doc = new Document(); doc.add(new IntField(FIELD_NAME_ID, ID, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_NAME, name, Field.Store.YES)); doc.add(new DoubleField(FIELD_NAME_LONGITUDE, longitude, Field.Store.YES)); doc.add(new DoubleField(FIELD_NAME_LATITUDE, latitude, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_ALTERNATE_NAMES, alternatenames, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_FEATURE_CODE, featureCode, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_COUNTRY_CODE, countryCode, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_ADMIN1_CODE, admin1Code, Field.Store.YES)); doc.add(new TextField(FIELD_NAME_ADMIN2_CODE, admin2Code, Field.Store.YES)); doc.add(new NumericDocValuesField(FIELD_NAME_POPULATION, population));//sort enabled field try { indexWriter.addDocument(doc); } catch (IOException e) { e.printStackTrace(); } }