List of usage examples for java.lang IndexOutOfBoundsException getMessage
public String getMessage()
From source file:org.restcomm.app.utillib.Reporters.ReportManager.java
/** * If MCC and MNC are known, returns them, and updates {@link ReportManager#lastknownMCCMNC}.<br> * If MCC and MNC are unknown and the phone is not roaming, returns {@link ReportManager#lastknownMCCMNC}.<br> * If MCC and MNC are unknown and the phone is roaming, returns <code>{0, 0}</code>. * @return int[] where element 0 is MCC, element 1 is MNC *//*w w w.ja v a2s . c o m*/ public int[] getMCCMNC() { TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); //MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "getMCCMNC", "mcc+mnc " + telephonyManager.getNetworkOperator()); try { if (telephonyManager.getNetworkOperator() == null || telephonyManager.getNetworkOperator().length() < 3) { //MMCLogger.logToFile(MMCLogger.Level.WTF, TAG, "getMCCMNC", "no mnc, just " + telephonyManager.getNetworkOperator()); return lastknownMCCMNC; } String mcc = telephonyManager.getNetworkOperator().substring(0, 3); String mnc = "0"; // if (telephonyManager.getNetworkOperator().length() > 3) mnc = telephonyManager.getNetworkOperator().substring(3); int MCC = Integer.parseInt(mcc); mnc = DeviceInfo.fixMNC(mnc); int MNC = Integer.parseInt(mnc); lastknownMCCMNC[0] = MCC; lastknownMCCMNC[1] = MNC; return lastknownMCCMNC; } catch (IndexOutOfBoundsException e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "IndexOutOfBoundsException parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } catch (NumberFormatException e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "NumberFormatException parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } catch (Exception e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "Exception parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } if (telephonyManager.isNetworkRoaming()) { return new int[] { 0, 0 }; } else { return lastknownMCCMNC; } }
From source file:dentex.youtube.downloader.DashboardActivity.java
private static void buildList() { for (int i = 0; i < idEntries.size(); i++) { String thisSize;/* www . j av a 2s . c om*/ try { String thisStatus = statusEntries.get(i); if (thisStatus.equals(YTD.JSON_DATA_STATUS_IN_PROGRESS) && speedEntries.get(i) != 0) { thisSize = partSizeEntries.get(i); } else { thisSize = sizeEntries.get(i); } itemsList.add(new DashboardListItem(idEntries.get(i), typeEntries.get(i), linkEntries.get(i), posEntries.get(i), thisStatus .replace(YTD.JSON_DATA_STATUS_COMPLETED, sDashboard.getString(R.string.json_status_completed)) .replace(YTD.JSON_DATA_STATUS_IN_PROGRESS, sDashboard.getString(R.string.json_status_in_progress)) .replace(YTD.JSON_DATA_STATUS_FAILED, sDashboard.getString(R.string.json_status_failed)) .replace(YTD.JSON_DATA_STATUS_IMPORTED, sDashboard.getString(R.string.json_status_imported)) .replace(YTD.JSON_DATA_STATUS_PAUSED, sDashboard.getString(R.string.json_status_paused)), pathEntries.get(i), filenameEntries.get(i), basenameEntries.get(i), audioExtEntries.get(i), thisSize, progressEntries.get(i), speedEntries.get(i))); } catch (IndexOutOfBoundsException e) { Utils.logger("w", "buildList: " + e.getMessage(), DEBUG_TAG); } } }
From source file:com.mahali.gpslogger.MainActivity.java
public void startSession(View v) throws IOException { // Throws IOException when something goes wrong // Probe for devices final List<UsbSerialDriver> drivers = UsbSerialProber.getDefaultProber().findAllDrivers(mUsbManager); // Get the first port of the first driver // TODO: probably shouldn't be hard-coded, but multiple cables are unlikely try {/*from ww w.j av a 2 s . c om*/ sPort = drivers.get(0).getPorts().get(0); } catch (IndexOutOfBoundsException e) { Log.e(TAG, "Serial port not available"); throw new IOException("Serial port not available"); } // Open a connection UsbDeviceConnection connection = mUsbManager.openDevice(sPort.getDriver().getDevice()); if (connection == null) { Log.e(TAG, "Error opening USB device"); throw new IOException("Error opening USB device"); } try { sPort.open(connection); // TODO: port configuration should almost certainly be configuration sPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE); } catch (IOException e) { Log.e(TAG, "Error setting up device: " + e.getMessage(), e); try { sPort.close(); } catch (IOException e2) { // Ignore. } sPort = null; throw new IOException("Error configuring USB device:" + e.getMessage()); } Log.i(TAG, "startSession: creating new GPS session"); mCurrentSession = new GPSSession(); sessFile = new File(dirFile.getPath(), mCurrentSession.getFileName()); if (sessFile.exists()) { Log.e(TAG, "Session file already exists!"); throw new IOException("Session file already exists: " + mCurrentSession.getFileName()); } // Create file try { boolean fileCreated = sessFile.createNewFile(); Log.i(TAG, "fileCreated: " + fileCreated); } catch (IOException e) { Log.e(TAG, "Failed to create new file: " + e.getMessage()); throw new IOException("Failed to create new file: " + e.getMessage()); } // Create output buffer try { bufOS = new BufferedOutputStream(new FileOutputStream(sessFile)); } catch (FileNotFoundException e) { Log.e(TAG, "File not found exception: " + e.getMessage()); throw new IOException("File not found exception during buffer creation"); } // Start the IO manager thread startIoManager(); }
From source file:ch.cyberduck.core.ftp.FTPPath.java
@Override public AttributedList<Path> list(final AttributedList<Path> children) { try {//from ww w .j a v a 2s . c o m this.getSession().check(); this.getSession().message(MessageFormat .format(Locale.localizedString("Listing directory {0}", "Status"), this.getName())); // Cached file parser determined from SYST response with the timezone set from the bookmark final FTPFileEntryParser parser = this.getSession().getFileParser(); boolean success = false; try { if (this.getSession().isStatListSupportedEnabled()) { int response = this.getSession().getClient().stat(this.getAbsolute()); if (FTPReply.isPositiveCompletion(response)) { String[] reply = this.getSession().getClient().getReplyStrings(); final List<String> result = new ArrayList<String>(reply.length); for (final String line : reply) { //Some servers include the status code for every line. if (line.startsWith(String.valueOf(response))) { try { result.add(line.substring(line.indexOf(response) + line.length() + 1).trim()); } catch (IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.stripStart(line, null)); } } success = this.parseListResponse(children, parser, result); } else { this.getSession().setStatListSupportedEnabled(false); } } } catch (IOException e) { log.warn("Command STAT failed with I/O error:" + e.getMessage()); this.getSession().interrupt(); this.getSession().check(); } if (!success || children.isEmpty()) { success = this.data(new DataConnectionAction() { @Override public boolean run() throws IOException { if (!getSession().getClient().changeWorkingDirectory(getAbsolute())) { throw new FTPException(getSession().getClient().getReplyString()); } if (!getSession().getClient().setFileType(FTPClient.ASCII_FILE_TYPE)) { // Set transfer type for traditional data socket file listings. The data transfer is over the // data connection in type ASCII or type EBCDIC. throw new FTPException(getSession().getClient().getReplyString()); } boolean success = false; // STAT listing failed or empty if (getSession().isMlsdListSupportedEnabled() // Note that there is no distinct FEAT output for MLSD. // The presence of the MLST feature indicates that both MLST and MLSD are supported. && getSession().getClient().isFeatureSupported(FTPCommand.MLST)) { success = parseMlsdResponse(children, getSession().getClient().list(FTPCommand.MLSD)); if (!success) { getSession().setMlsdListSupportedEnabled(false); } } if (!success) { // MLSD listing failed or not enabled if (getSession().isExtendedListEnabled()) { try { success = parseListResponse(children, parser, getSession().getClient().list(FTPCommand.LIST, "-a")); } catch (FTPException e) { getSession().setExtendedListEnabled(false); } } if (!success) { // LIST -a listing failed or not enabled success = parseListResponse(children, parser, getSession().getClient().list(FTPCommand.LIST)); } } return success; } }); } for (Path child : children) { if (child.attributes().isSymbolicLink()) { if (this.getSession().getClient().changeWorkingDirectory(child.getAbsolute())) { child.attributes().setType(SYMBOLIC_LINK_TYPE | DIRECTORY_TYPE); } else { // Try if CWD to symbolic link target succeeds if (this.getSession().getClient() .changeWorkingDirectory(child.getSymlinkTarget().getAbsolute())) { // Workdir change succeeded child.attributes().setType(SYMBOLIC_LINK_TYPE | DIRECTORY_TYPE); } else { child.attributes().setType(SYMBOLIC_LINK_TYPE | FILE_TYPE); } } } } if (!success) { // LIST listing failed log.error("No compatible file listing method found"); } } catch (IOException e) { log.warn("Listing directory failed:" + e.getMessage()); children.attributes().setReadable(false); if (!session.cache().containsKey(this.getReference())) { this.error(e.getMessage(), e); } } return children; }
From source file:org.vpac.ndg.cli.Client.java
private void deleteBand(List<String> remainingArgs) throws IOException { log.info("Deleting a band."); String id;/*from w w w.j ava 2 s . c o m*/ try { id = remainingArgs.get(0); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Band ID not specified."); } BandConnector bc = sm.getBandConnector(); try { log.debug("deleting band"); bc.delete(id); } catch (IOException e) { log.error("Could not delete band: {}", e.getMessage()); throw e; } System.out.println(String.format("Band: %s has been deleted.", id)); }
From source file:org.vpac.ndg.cli.Client.java
/** * Delete dataset from database and all dataset tiles from storagepool. * @param remainingArgs dataset ID./*from w w w .j a va2 s. c o m*/ * @throws IOException Error when deleting dataset. */ public void deleteDataset(List<String> remainingArgs) throws IOException { log.info("Deleting a dataset."); String id; try { id = remainingArgs.get(0); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Dataset ID not specified."); } DatasetConnector dsc = sm.getDatasetConnector(); log.debug("deleting dataset"); try { dsc.delete(id); } catch (IOException e) { log.error("Could not delete dataset: {}", e.getMessage()); throw e; } System.out.println(String.format("Dataset: %s has been deleted.", id)); }
From source file:org.dcm4chee.proxy.forward.ForwardFiles.java
private FileFilter fileFilter(final ProxyAEExtension proxyAEE, final String calledAET) { final long now = System.currentTimeMillis(); return new FileFilter() { @Override//from w ww . j a v a 2 s .c om public boolean accept(File file) { String path = file.getPath(); int interval = proxyAEE.getApplicationEntity().getDevice() .getDeviceExtension(ProxyDeviceExtension.class).getSchedulerInterval(); if (path.endsWith(".dcm") || path.endsWith(".nevent")) { if (now > (file.lastModified() + interval)) return true; else return false; } if (path.endsWith(".part") || path.endsWith(".snd") || path.endsWith(".info") || path.endsWith(".naction")) return false; try { LOG.debug("Get matching retry for file " + file.getPath()); String suffix = path.substring(path.lastIndexOf('.')); Retry matchingRetry = getMatchingRetry(proxyAEE, suffix); if (matchingRetry == null) if (proxyAEE.isDeleteFailedDataWithoutRetryConfiguration()) deleteFailedFile(proxyAEE, calledAET, file, ": delete files without retry configuration is ENABLED", 0); else moveToNoRetryPath(proxyAEE, calledAET, file, ": delete files without retry configuration is DISABLED"); else if (checkNumberOfRetries(proxyAEE, matchingRetry, suffix, file, calledAET) && checkSendFileDelay(now, file, matchingRetry)) return true; } catch (IndexOutOfBoundsException e) { LOG.error("Error parsing suffix of " + path); try { moveToNoRetryPath(proxyAEE, calledAET, file, "(error parsing suffix)"); } catch (IOException e1) { LOG.error("Error moving file {} to no retry directory: {}", new Object[] { file.getName(), e.getMessage() }); if (LOG.isDebugEnabled()) e1.printStackTrace(); } } catch (IOException e) { LOG.error("Error reading from directory: {}", e.getMessage()); if (LOG.isDebugEnabled()) e.printStackTrace(); } return false; } private boolean checkSendFileDelay(final long now, File file, Retry matchingRetry) { boolean sendNow = now > (file.lastModified() + (matchingRetry.delay * 1000)); if (sendNow) LOG.debug(">> ready to send now"); else LOG.debug(">> wait until last send delay > {}sec", matchingRetry.delay); return sendNow; } }; }
From source file:edu.ku.brc.af.ui.forms.ViewFactory.java
/** * Processes the rows in a definition./*from w w w.j av a 2s .co m*/ * @param tableInfo table info for current form (may be null) * @param parent MultiView parent * @param viewDef the FormViewDef (Viewdef) * @param validator optional validator * @param viewBldObj the FormViewObj this row belongs to * @param mode the creation mode * @param builder the current JGoodies builder * @param labelsForHash the has table for label * @param cc CellConstraints * @param currDataObj the current data object * @param formRows the list of rows to be processed */ protected void processRows(final DBTableInfo tableInfo, final MultiView parent, final ViewDefIFace viewDef, final FormValidator validator, final ViewBuilderIFace viewBldObj, final AltViewIFace.CreationMode mode, final HashMap<String, JLabel> labelsForHash, final Object currDataObj, final List<FormRowIFace> formRows) { BuildInfoStruct bi = new BuildInfoStruct(); bi.curMaxRow = 1; int rowInx = 1; boolean hasRequiredOrDerivedField = false; for (FormRowIFace row : formRows) { bi.colInx = 1; for (FormCellIFace cell : row.getCells()) { DBTableChildIFace childInfo = null; String cellName = cell.getName(); if (tableInfo != null && StringUtils.isNotEmpty(cellName)) { childInfo = tableInfo.getItemByName(cellName); } boolean isEditOnCreateOnly = false; //XXX bug #9497: if (mode == AltViewIFace.CreationMode.EDIT) if (mode == AltViewIFace.CreationMode.EDIT && cell.getType() == FormCellIFace.CellType.field) { // XXX bug #9497: if (cell.getType() == FormCellIFace.CellType.field) { isEditOnCreateOnly = ((FormCellField) cell).getPropertyAsBoolean("editoncreate", false); ((FormCellField) cell).setEditOnCreate(true); /* XXX bug #9497:} else if (childInfo instanceof DBRelationshipInfo) { if (AppContextMgr.isSecurityOn()) { DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance().getByShortClassName(childInfo.getDataClass().getSimpleName()) : null; if (tblInfo != null) { PermissionSettings perm = tblInfo.getPermissions(); if (perm != null) { //XXX whoa. What about view perms??? //if (perm.isViewOnly() || !perm.canView()) { if (perm.canAdd() && !perm.canModify()) { isEditOnCreateOnly = true; } } } } }*/ } if (!createItem(tableInfo, childInfo, parent, viewDef, validator, viewBldObj, mode, labelsForHash, currDataObj, cell, isEditOnCreateOnly, rowInx, bi)) { return; } //log.debug(cell.getType()+" "+cell.getName()+" col: "+bi.colInx); if (bi.compToAdd != null) { try { addControl(validator, viewBldObj, rowInx, cell, bi); } catch (java.lang.IndexOutOfBoundsException ex) { String msg = "Error adding control type: `" + cell.getType() + "` id: `" + cell.getIdent() + "` name: `" + cell.getName() + "` on row: " + rowInx + " column: " + bi.colInx + "\n" + ex.getMessage(); UIRegistry.showError(msg); return; } } //XXX bug #9497: if (isEditOnCreateOnly && cell.getType() == FormCellIFace.CellType.field) if (isEditOnCreateOnly && cell.getType() == FormCellIFace.CellType.field) { EditViewCompSwitcherPanel evcsp = (EditViewCompSwitcherPanel) bi.compToReg; evcsp.setParentValidator(validator); BuildInfoStruct bi2 = new BuildInfoStruct(); bi2.curMaxRow = 1; bi2.colInx = 1; createItem(tableInfo, childInfo, parent, viewDef, evcsp.getValidator(), viewBldObj, AltViewIFace.CreationMode.EDIT, labelsForHash, currDataObj, cell, false, rowInx, bi2); Component editCompReg = bi2.compToReg; Component editCompAdd = bi2.compToAdd; createItem(tableInfo, childInfo, parent, viewDef, null, viewBldObj, AltViewIFace.CreationMode.VIEW, labelsForHash, currDataObj, cell, false, rowInx, bi2); Component viewCompReg = bi2.compToReg; Component viewCompAdd = bi2.compToAdd; evcsp.set(editCompReg, editCompAdd, viewCompReg, viewCompAdd); } if (!bi.isRequired && ((childInfo != null && childInfo.isRequired()) || (cell instanceof FormCellFieldIFace && ((FormCellFieldIFace) cell).isRequired()))) { bi.isRequired = true; ((FormCellFieldIFace) cell).setRequired(true); } } if (bi.isRequired || bi.isDerivedLabel) { hasRequiredOrDerivedField = true; } rowInx += 2; } if (bi.collapseSepHash != null && bi.collapseSepHash.size() > 0) { for (CollapsableSeparator collapseSep : bi.collapseSepHash.keySet()) { Component comp = viewBldObj.getControlByName(bi.collapseSepHash.get(collapseSep)); if (comp != null) { collapseSep.setInnerComp(comp); } } } viewBldObj.doneBuilding(); // Check to see if there is at least one required field. // The call to 'viewBldObj.hasRequiredFields is because it may have had an embedded panel // that had required fields. if (doFixLabels && (hasRequiredOrDerivedField || viewBldObj.hasRequiredFields())) { viewBldObj.fixUpRequiredDerivedLabels(); } }
From source file:de.main.sessioncreator.DesktopApplication1View.java
private void btnWizardBack(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWizardBack int selTab = wizardtabp.getSelectedIndex(); try {/*from w w w. j av a 2 s . co m*/ if (wizardbtnNext.isVisible() == false | wizardbtnStart.isVisible() == true) { wizardbtnNext.setVisible(true); wizardbtntopNext.setEnabled(true); wizardbtnStart.setVisible(false); wizardbtntopStart.setEnabled(false); wizardbtnStop.setVisible(false); wizardbtntopStop.setEnabled(false); } wizardbtnNext.setText("Next >"); wizardbtnNext.setEnabled(true); wizardbtntopNext.setEnabled(true); if (wizardtabp.getSelectedIndex() != 0) { wizardtabp.setSelectedIndex(selTab - 1); swingHelper.setTab1EnableAt(wizardtabp, selTab - 1); } statusMessageLabel.setText(""); if (wizardtabp.getSelectedIndex() == 0) { wizardbtnBack.setEnabled(false); wizardbtntopBack.setEnabled(false); } } catch (IndexOutOfBoundsException ex) { statusMessageLabel.setText(ex.getMessage()); } }
From source file:org.vpac.ndg.cli.Client.java
/** * Upload files, then run the import tool. * //from w ww . j a v a 2 s . c om * @param remainingArgs * The files to import. The first file is the primary file; the * others are supporting files (optional). * @throws TaskException * @throws TaskInitialisationException */ public void importData(List<String> remainingArgs) throws TaskInitialisationException, TaskException { log.info("Importing data."); validateAsync(); String srcnodata = null; String timeSliceId; String bandId; List<String> files; try { timeSliceId = remainingArgs.get(0); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Timeslice ID not specified."); } try { bandId = remainingArgs.get(1); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Band not specified."); } if (timeSliceId.trim().isEmpty()) { // Capture if timeslice ID not specified throw new IllegalArgumentException("Timeslice ID not specified."); } if (bandId.trim().isEmpty()) { // Capture if band ID not specified throw new IllegalArgumentException("Band ID not specified."); } if (cmd.hasOption("srcnodata")) { srcnodata = cmd.getOptionValue("srcnodata"); } Boolean bilinear = getUseBilinear(); files = remainingArgs.subList(2, remainingArgs.size()); // First, upload to the staging area. DataUpload uploader = sm.getDataUploader(); uploader.setTimeSlice(timeSliceId); for (String f : files) { if (f.trim().isEmpty()) continue; Path path = Paths.get(f); path = workingDirectory.resolve(path); uploader.addInput(path); } String uploadId; try { log.debug("uploading"); uploadId = uploader.upload(); } catch (IOException | IllegalArgumentException e) { log.error("Could not upload data: {}", e.getMessage()); exit(1); return; } // Now run the import. DataImport importer = sm.getDataImporter(); importer.setUploadId(uploadId); importer.setBand(bandId); importer.setUseBilinearInterpolation(bilinear); if (srcnodata != null && !srcnodata.isEmpty()) { importer.setSrcnodata(srcnodata); } importer.setRemainingArgs(remainingArgs); log.debug("importing"); String taskId = importer.start(); if (cmd.hasOption("async")) { printTask(taskId); } else { printTaskInline(taskId); } }