List of usage examples for java.lang RuntimeException toString
public String toString()
From source file:org.ireland.jnetty.webapp.WebApp.java
/** * Returns a dispatcher for the named servlet. * //from ww w.j a v a 2 s . c o m */ @Override public RequestDispatcherImpl getRequestDispatcher(String rawContextURI) { if (rawContextURI == null) throw new IllegalArgumentException("request dispatcher url can't be null."); else if (!rawContextURI.startsWith("/")) throw new IllegalArgumentException("request dispatcher url '" + rawContextURI + "' must be absolute"); // ??RequestDispatcher RequestDispatcherImpl disp = getRequestDispatcherCache().get(rawContextURI); if (disp != null) return disp; try { // InvocationRequestDispatcherdispatchforward?(??DispatcherType) disp = new RequestDispatcherImpl(this, rawContextURI); // RequestDispatcher getRequestDispatcherCache().put(rawContextURI, disp); return disp; } catch (RuntimeException e) { throw e; } catch (Exception e) { log.debug(e.toString(), e); return null; } }
From source file:gov.anl.aps.cdb.portal.controllers.CdbEntityController.java
/** * Search all entities for a given string. * * @param searchString search string//from ww w . j a va2 s. c o m * @param caseInsensitive use case insensitive search */ public void performEntitySearch(String searchString, boolean caseInsensitive) { if (searchString == null || searchString.isEmpty()) { searchResultList = new LinkedList<>(); return; } if (searchString.equals(this.searchString) && caseInsensitive == this.caseInsensitive) { // Return old results return; } // Start new search this.searchString = searchString; this.caseInsensitive = caseInsensitive; searchResultList = new LinkedList<>(); Pattern searchPattern; if (caseInsensitive) { searchPattern = Pattern.compile(Pattern.quote(searchString), Pattern.CASE_INSENSITIVE); } else { searchPattern = Pattern.compile(Pattern.quote(searchString)); } DataModel<EntityType> dataModel = getListDataModel(); Iterator<EntityType> iterator = dataModel.iterator(); while (iterator.hasNext()) { EntityType entity = iterator.next(); try { SearchResult searchResult = entity.search(searchPattern); if (!searchResult.isEmpty()) { searchResultList.add(searchResult); } } catch (RuntimeException ex) { logger.warn("Could not search entity " + entity.toString() + " (Error: " + ex.toString() + ")"); } } }
From source file:org.lockss.protocol.BlockingStreamComm.java
private void runHandlers(PeerMessage msg) throws ProtocolException { try {/* w w w .j ava 2 s. co m*/ int proto = msg.getProtocol(); MessageHandler handler; if (proto >= 0 && proto < messageHandlers.size() && (handler = (MessageHandler) messageHandlers.get(proto)) != null) { runHandler(handler, msg); } else { log.warning("Received message with unregistered protocol: " + proto); } } catch (RuntimeException e) { log.warning("Unexpected error in runHandlers", e); throw new ProtocolException(e.toString()); } }
From source file:com.lambdaworks.redis.RedisClient.java
private <K, V> StatefulRedisSentinelConnection<K, V> connectSentinel(RedisCodec<K, V> codec, RedisURI redisURI, Timeout timeout) {/*ww w . jav a2 s .c om*/ assertNotNull(codec); checkValidRedisURI(redisURI); Queue<RedisCommand<K, V, ?>> queue = LettuceFactories.newConcurrentQueue(); ConnectionBuilder connectionBuilder = ConnectionBuilder.connectionBuilder(); connectionBuilder.clientOptions(ClientOptions.copyOf(getOptions())); connectionBuilder.clientResources(clientResources); final CommandHandler<K, V> commandHandler = new CommandHandler<>(clientOptions, clientResources, queue); StatefulRedisSentinelConnectionImpl<K, V> connection = newStatefulRedisSentinelConnection(commandHandler, codec, timeout.timeout, timeout.timeUnit); logger.debug("Trying to get a Redis Sentinel connection for one of: " + redisURI.getSentinels()); connectionBuilder(commandHandler, connection, getSocketAddressSupplier(redisURI), connectionBuilder, redisURI); if (clientOptions.isPingBeforeActivateConnection()) { connectionBuilder.enablePingBeforeConnect(); } if (redisURI.getSentinels().isEmpty() && (isNotEmpty(redisURI.getHost()) || !isEmpty(redisURI.getSocket()))) { channelType(connectionBuilder, redisURI); try { initializeChannel(connectionBuilder); } catch (RuntimeException e) { connection.close(); throw e; } } else { boolean connected = false; boolean first = true; Exception causingException = null; validateUrisAreOfSameConnectionType(redisURI.getSentinels()); for (RedisURI uri : redisURI.getSentinels()) { if (first) { channelType(connectionBuilder, uri); first = false; } connectionBuilder.socketAddressSupplier(getSocketAddressSupplier(uri)); if (logger.isDebugEnabled()) { SocketAddress socketAddress = SocketAddressResolver.resolve(redisURI, clientResources.dnsResolver()); logger.debug("Connecting to Redis Sentinel, address: " + socketAddress); } try { initializeChannel(connectionBuilder); connected = true; break; } catch (Exception e) { logger.warn("Cannot connect Redis Sentinel at " + uri + ": " + e.toString()); causingException = e; } } if (!connected) { connection.close(); throw new RedisConnectionException("Cannot connect to a Redis Sentinel: " + redisURI.getSentinels(), causingException); } } if (LettuceStrings.isNotEmpty(redisURI.getClientName())) { connection.setClientName(redisURI.getClientName()); } return connection; }
From source file:com.aliyun.homeshell.Folder.java
public void hideSoftInputMethod(Activity activity) { View v;/*from w w w. ja v a 2 s.c o m*/ if (activity == null || activity.getWindow() == null) { v = mFolderName; } else { v = activity.getWindow().peekDecorView(); } // YUNOS END try { if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); boolean result = imm.hideSoftInputFromWindow(v.getWindowToken(), 0); Log.d(TAG, "hideSoftInputMethod, ret:" + result); } } catch (RuntimeException e) { // add try catch block due to InputMethod throws // RuntimeException; // BugID:101639 Log.e(TAG, e.toString(), e); } }
From source file:net.minecraftforge.fml.common.Loader.java
/** * Sort the mods into a sorted list, using dependency information from the * containers. The sorting is performed using a {@link TopologicalSort} * based on the pre- and post- dependency information provided by the mods. *///from w w w . jav a2 s. c o m private void sortModList() { FMLLog.finer("Verifying mod requirements are satisfied"); try { BiMap<String, ArtifactVersion> modVersions = HashBiMap.create(); for (ModContainer mod : Iterables.concat(getActiveModList(), ModAPIManager.INSTANCE.getAPIList())) { modVersions.put(mod.getModId(), mod.getProcessedVersion()); } ArrayListMultimap<String, String> reqList = ArrayListMultimap.create(); for (ModContainer mod : getActiveModList()) { if (!mod.acceptableMinecraftVersionRange().containsVersion(minecraft.getProcessedVersion())) { FMLLog.severe( "The mod %s does not wish to run in Minecraft version %s. You will have to remove it to play.", mod.getModId(), getMCVersionString()); RuntimeException ret = new WrongMinecraftVersionException(mod, getMCVersionString()); FMLLog.severe(ret.getMessage()); throw ret; } Map<String, ArtifactVersion> names = Maps.uniqueIndex(mod.getRequirements(), new ArtifactVersionNameFunction()); Set<ArtifactVersion> versionMissingMods = Sets.newHashSet(); Set<String> missingMods = Sets.difference(names.keySet(), modVersions.keySet()); if (!missingMods.isEmpty()) { FMLLog.severe("The mod %s (%s) requires mods %s to be available", mod.getModId(), mod.getName(), missingMods); for (String modid : missingMods) { versionMissingMods.add(names.get(modid)); } RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName()); FMLLog.severe(ret.getMessage()); throw ret; } reqList.putAll(mod.getModId(), names.keySet()); ImmutableList<ArtifactVersion> allDeps = ImmutableList.<ArtifactVersion>builder() .addAll(mod.getDependants()).addAll(mod.getDependencies()).build(); for (ArtifactVersion v : allDeps) { if (modVersions.containsKey(v.getLabel())) { if (!v.containsVersion(modVersions.get(v.getLabel()))) { versionMissingMods.add(v); } } } if (!versionMissingMods.isEmpty()) { FMLLog.severe("The mod %s (%s) requires mod versions %s to be available", mod.getModId(), mod.getName(), versionMissingMods); RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName()); FMLLog.severe(ret.toString()); throw ret; } } FMLLog.finer("All mod requirements are satisfied"); reverseDependencies = Multimaps.invertFrom(reqList, ArrayListMultimap.<String, String>create()); ModSorter sorter = new ModSorter(getActiveModList(), namedMods); try { FMLLog.finer("Sorting mods into an ordered list"); List<ModContainer> sortedMods = sorter.sort(); // Reset active list to the sorted list modController.getActiveModList().clear(); modController.getActiveModList().addAll(sortedMods); // And inject the sorted list into the overall list mods.removeAll(sortedMods); sortedMods.addAll(mods); mods = sortedMods; FMLLog.finer("Mod sorting completed successfully"); } catch (ModSortingException sortException) { FMLLog.severe( "A dependency cycle was detected in the input mod set so an ordering cannot be determined"); SortingExceptionData<ModContainer> exceptionData = sortException.getExceptionData(); FMLLog.severe("The first mod in the cycle is %s", exceptionData.getFirstBadNode()); FMLLog.severe("The mod cycle involves"); for (ModContainer mc : exceptionData.getVisitedNodes()) { FMLLog.severe("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()); } FMLLog.log(Level.ERROR, sortException, "The full error"); throw sortException; } } finally { FMLLog.fine("Mod sorting data"); int unprintedMods = mods.size(); for (ModContainer mod : getActiveModList()) { if (!mod.isImmutable()) { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), mod.getSortingRules()); unprintedMods--; } } if (unprintedMods == mods.size()) { FMLLog.fine("No user mods found to sort"); } } }
From source file:be.ibridge.kettle.trans.step.exceloutput.ExcelOutput.java
/** * Write a value to Excel, increasing data.positionX with one afterwards. * @param v The value to write/* w w w .j av a 2 s .c o m*/ * @param excelField the field information (if any, otherwise : null) * @param column the excel column for getting the template format * @param isHeader true if this is part of the header/footer * @return */ private boolean writeField(Value v, ExcelField excelField, int column, boolean isHeader) { try { String hashName = v.getName(); if (isHeader) hashName = "____header_field____"; // all strings, can map to the same format. WritableCellFormat cellFormat = (WritableCellFormat) data.formats.get(hashName); // when template is used, take over the column format if (cellFormat == null && meta.isTemplateEnabled() && !isHeader) { try { if (column < data.templateColumns) { cellFormat = new WritableCellFormat(data.sheet.getColumnView(column).getFormat()); data.formats.put(hashName, cellFormat); // save for next time around... } } catch (RuntimeException e) { //ignore if the column is not found, format as usual } } switch (v.getType()) { case Value.VALUE_TYPE_DATE: { if (!v.isNull() && v.getDate() != null) { if (cellFormat == null) { if (excelField != null && excelField.getFormat() != null) { DateFormat dateFormat = new DateFormat(excelField.getFormat()); cellFormat = new WritableCellFormat(dateFormat); } else { cellFormat = new WritableCellFormat(DateFormats.FORMAT9); } data.formats.put(hashName, cellFormat); // save for next time around... } DateTime dateTime = new DateTime(data.positionX, data.positionY, v.getDate(), cellFormat); data.sheet.addCell(dateTime); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; case Value.VALUE_TYPE_STRING: case Value.VALUE_TYPE_BOOLEAN: case Value.VALUE_TYPE_BINARY: { if (!v.isNull()) { if (cellFormat == null) { cellFormat = new WritableCellFormat(data.writableFont); data.formats.put(hashName, cellFormat); } Label label = new Label(data.positionX, data.positionY, v.getString(), cellFormat); data.sheet.addCell(label); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; case Value.VALUE_TYPE_NUMBER: case Value.VALUE_TYPE_BIGNUMBER: case Value.VALUE_TYPE_INTEGER: { if (!v.isNull()) { if (cellFormat == null) { String format; if (excelField != null && excelField.getFormat() != null) { format = excelField.getFormat(); } else { format = "###,###.00"; } NumberFormat numberFormat = new NumberFormat(format); cellFormat = new WritableCellFormat(numberFormat); data.formats.put(v.getName(), cellFormat); // save for next time around... } jxl.write.Number number = new jxl.write.Number(data.positionX, data.positionY, v.getNumber(), cellFormat); data.sheet.addCell(number); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; default: break; } } catch (Exception e) { logError("Error writing field (" + data.positionX + "," + data.positionY + ") : " + e.toString()); logError(Const.getStackTracker(e)); return false; } finally { data.positionX++; // always advance :-) } return true; }
From source file:com.panet.imeta.trans.steps.exceloutput.ExcelOutput.java
/** * Write a value to Excel, increasing data.positionX with one afterwards. * @param v The value to write// w ww .j ava2 s . com * @param vMeta The valueMeta to write * @param excelField the field information (if any, otherwise : null) * @param column the excel column for getting the template format * @param isHeader true if this is part of the header/footer * @return */ private boolean writeField(Object v, ValueMetaInterface vMeta, ExcelField excelField, int column, boolean isHeader) { WritableFont writableFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD); try { String hashName = vMeta.getName(); if (isHeader) hashName = "____header_field____"; // all strings, can map to the same format. WritableCellFormat cellFormat = (WritableCellFormat) data.formats.get(hashName); // when template is used, take over the column format if (cellFormat == null && meta.isTemplateEnabled() && !isHeader) { try { if (column < data.templateColumns) { cellFormat = new WritableCellFormat(data.sheet.getColumnView(column).getFormat()); data.formats.put(hashName, cellFormat); // save for next time around... } } catch (RuntimeException e) { //ignore if the column is not found, format as usual } } if (meta.isAutoSizeColums()) { // prepare auto size colums int vlen = vMeta.getName().length(); if (!isHeader && v != null) vlen = v.toString().trim().length(); if (vlen > 0 && vlen > data.fieldsWidth[column]) data.fieldsWidth[column] = vlen + 1; } switch (vMeta.getType()) { case ValueMetaInterface.TYPE_DATE: { if (v != null && vMeta.getDate(v) != null) { if (cellFormat == null) { if (excelField != null && excelField.getFormat() != null) { DateFormat dateFormat = new DateFormat(excelField.getFormat()); cellFormat = new WritableCellFormat(dateFormat); } else { cellFormat = new WritableCellFormat(DateFormats.FORMAT9); } data.formats.put(hashName, cellFormat); // save for next time around... } DateTime dateTime = new DateTime(data.positionX, data.positionY, vMeta.getDate(v), cellFormat); data.sheet.addCell(dateTime); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; case ValueMetaInterface.TYPE_STRING: case ValueMetaInterface.TYPE_BOOLEAN: case ValueMetaInterface.TYPE_BINARY: { if (v != null) { if (cellFormat == null) { cellFormat = new WritableCellFormat(writableFont); data.formats.put(hashName, cellFormat); } Label label = new Label(data.positionX, data.positionY, vMeta.getString(v), cellFormat); data.sheet.addCell(label); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: case ValueMetaInterface.TYPE_INTEGER: { if (v != null) { if (cellFormat == null) { String format; if (excelField != null && excelField.getFormat() != null) { format = excelField.getFormat(); } else { format = "###,###.00"; } NumberFormat numberFormat = new NumberFormat(format); cellFormat = new WritableCellFormat(numberFormat); data.formats.put(vMeta.getName(), cellFormat); // save for next time around... } jxl.write.Number number = new jxl.write.Number(data.positionX, data.positionY, vMeta.getNumber(v), cellFormat); data.sheet.addCell(number); } else { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } } break; default: break; } } catch (Exception e) { logError("Error writing field (" + data.positionX + "," + data.positionY + ") : " + e.toString()); logError(Const.getStackTracker(e)); return false; } finally { data.positionX++; // always advance :-) } return true; }
From source file:org.pentaho.di.trans.steps.exceloutput.ExcelOutput.java
/** * Write a value to Excel, increasing data.positionX with one afterwards. * * @param v//from w w w . j a va 2 s .c o m * The value to write * @param vMeta * The valueMeta to write * @param excelField * the field information (if any, otherwise : null) * @param column * the excel column for getting the template format * @param isHeader * true if this is part of the header/footer * @return <code>true</code> if write succeeded */ private boolean writeField(Object v, ValueMetaInterface vMeta, ExcelField excelField, int column, boolean isHeader) { try { String hashName = vMeta.getName(); if (isHeader) { hashName = "____header_field____"; // all strings, can map to the same format. } WritableCellFormat cellFormat = data.formats.get(hashName); // when template is used, take over the column format if (cellFormat == null && meta.isTemplateEnabled() && !isHeader) { try { if (column < data.templateColumns) { CellFormat format = data.sheet.getColumnView(column).getFormat(); if (format != null) { cellFormat = new WritableCellFormat(format); data.formats.put(hashName, cellFormat); // save for next time around... } } } catch (RuntimeException e) { // ignore if the column is not found, format as usual } } if (meta.isAutoSizeColums()) { // prepare auto size colums int vlen = vMeta.getName().length(); if (!isHeader && v != null) { vlen = v.toString().trim().length(); } if (vlen > 0 && vlen > data.fieldsWidth[column]) { data.fieldsWidth[column] = vlen + 1; } } // Do we need to use a specific format to header? if (isHeader) { // Set font for header and footer+ data.sheet .addCell(new Label(data.positionX, data.positionY, vMeta.getName(), data.headerCellFormat)); if (cellFormat == null) { data.formats.put(hashName, data.headerCellFormat); // save for next time around... } } else { switch (vMeta.getType()) { case ValueMetaInterface.TYPE_DATE: { if (v != null && vMeta.getDate(v) != null) { if (cellFormat == null) { if (excelField != null && excelField.getFormat() != null) { DateFormat dateFormat = new DateFormat(excelField.getFormat()); if (data.writableFont != null) { cellFormat = new WritableCellFormat(data.writableFont, dateFormat); if (data.rowFontBackgoundColour != null) { cellFormat.setBackground(data.rowFontBackgoundColour); } } else { cellFormat = new WritableCellFormat(dateFormat); } } else { if (data.writableFont != null) { cellFormat = new WritableCellFormat(data.writableFont, DateFormats.FORMAT9); if (data.rowFontBackgoundColour != null) { cellFormat.setBackground(data.rowFontBackgoundColour); } } else { cellFormat = new WritableCellFormat(DateFormats.FORMAT9); } } data.formats.put(hashName, cellFormat); // save for next time around... } DateTime dateTime = new DateTime(data.positionX, data.positionY, vMeta.getDate(v), cellFormat); data.sheet.addCell(dateTime); } else if (!meta.isNullBlank()) { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } break; } case ValueMetaInterface.TYPE_STRING: case ValueMetaInterface.TYPE_BOOLEAN: case ValueMetaInterface.TYPE_BINARY: { if (cellFormat == null) { cellFormat = new WritableCellFormat(data.writableFont); if (data.rowFontBackgoundColour != null) { cellFormat.setBackground(data.rowFontBackgoundColour); } data.formats.put(hashName, cellFormat); } if (v != null) { Label label = new Label(data.positionX, data.positionY, vMeta.getString(v), cellFormat); data.sheet.addCell(label); } else if (!meta.isNullBlank()) { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } break; } case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: case ValueMetaInterface.TYPE_INTEGER: { if (v != null) { if (cellFormat == null) { String format; if (excelField != null && excelField.getFormat() != null) { format = excelField.getFormat(); } else { format = "###,###.00"; } NumberFormat numberFormat = new NumberFormat(format); if (data.writableFont != null) { cellFormat = new WritableCellFormat(data.writableFont, numberFormat); if (data.rowFontBackgoundColour != null) { cellFormat.setBackground(data.rowFontBackgoundColour); } } else { cellFormat = new WritableCellFormat(numberFormat); } data.formats.put(vMeta.getName(), cellFormat); // save for next time around... } jxl.write.Number number = new jxl.write.Number(data.positionX, data.positionY, vMeta.getNumber(v), cellFormat); data.sheet.addCell(number); } else if (!meta.isNullBlank()) { data.sheet.addCell(new Label(data.positionX, data.positionY, "")); } break; } default: { break; } } } } catch (Exception e) { logError("Error writing field (" + data.positionX + "," + data.positionY + ") : " + e.toString()); logError(Const.getStackTracker(e)); return false; } finally { data.positionX++; // always advance :-) } return true; }