List of usage examples for java.lang ClassCastException getMessage
public String getMessage()
From source file:org.ymkm.lib.controller.support.ControlledFragment.java
/** * Instantiates a new {@linkplain ControllableFragment} of specified * {@code Class}, whose handler will run in the specified Looper * //w w w . j av a 2 s . com * @param f * the subclass of {@linkplain ControlledFragment} to instantiate * @param runsInOwnThread * {@code true} if a new thread should be created for this * fragment, {@code false} to let it run in the current thread * @return A new instance of {@linkplain ControllableFragment} * @throws ControllableFragmentException * if instantiation failed */ public static ControllableFragment createFragment(Class<? extends ControllableFragment> f, boolean runsInOwnThread, Bundle args) throws ControllableFragmentException { assert (null != args); try { ControlledFragment fragment = (ControlledFragment) f.newInstance(); args.putBoolean("__new_thread__", runsInOwnThread); fragment.setArguments(args); return fragment; } catch (ClassCastException e) { e.printStackTrace(); throw new ControllableFragmentException(e.getMessage()); } catch (java.lang.InstantiationException e) { e.printStackTrace(); throw new ControllableFragmentException(e.getMessage()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new ControllableFragmentException(e.getMessage()); } }
From source file:org.filteredpush.qc.sciname.services.GBIFService.java
public static List<NameUsage> parseAllNameUsagesFromJSON(String json) { boolean gotAll = true; ArrayList<NameUsage> result = new ArrayList<NameUsage>(); JSONParser parser = new JSONParser(); try {/*from w w w . j a va 2 s .c o m*/ JSONArray array = new JSONArray(); try { JSONObject o = (JSONObject) parser.parse(json); array = (JSONArray) o.get("results"); //System.out.println(o.get("offset")); //System.out.println(o.get("limit")); //System.out.println(o.get("endOfRecords")); //System.out.println(o.get("count")); if (o.get("endOfRecords").equals("false")) { gotAll = false; } } catch (ClassCastException e) { array = (JSONArray) parser.parse(json); } Iterator i = array.iterator(); while (i.hasNext()) { JSONObject obj = (JSONObject) i.next(); NameUsage name = new NameUsage(obj); result.add(name); } } catch (ParseException e) { logger.error(e.getMessage()); } // TODO: Report not getting all records. if (!gotAll) { logger.error("Incomplete Harvest"); System.out.println("Incomplete Harvest"); } return result; }
From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java
/** * Read a Kubernetes resource fragment and add meta information extracted from the filename * to the resource descriptor. I.e. the following elements are added if not provided in the fragment: * * <ul>//ww w. j a va 2 s . c o m * <li>name - Name of the resource added to metadata</li> * <li>kind - Resource's kind</li> * <li>apiVersion - API version (given as parameter to this method)</li> * </ul> * * * @param apiVersions the API versions to add if not given. * @param file file to read, whose name must match {@link #FILENAME_PATTERN}. @return map holding the fragment * @param appName resource name specifying resources belonging to this application */ public static HasMetadata getResource(ResourceVersioning apiVersions, File file, String appName) throws IOException { Map<String, Object> fragment = readAndEnrichFragment(apiVersions, file, appName); ObjectMapper mapper = new ObjectMapper(); try { return mapper.convertValue(fragment, HasMetadata.class); } catch (ClassCastException exp) { throw new IllegalArgumentException(String.format("Resource fragment %s has an invalid syntax (%s)", file.getPath(), exp.getMessage())); } }
From source file:edu.harvard.mcz.imagecapture.ui.ProgressBarRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { log.debug(value);/*from ww w.java2 s.c o m*/ if (value != null) { try { progressBar.setValue((int) value); } catch (ClassCastException e) { log.error(e.getMessage()); } } log.debug(progressBar.getValue()); return progressBar; }
From source file:co.ldln.android.FragmentId.java
public Fragment getFragment() { try {// w w w . ja va2s. c o m if (this.clazz != null) { return (Fragment) this.clazz.newInstance(); } } catch (ClassCastException e) { Log.e("LDLN", e.getMessage()); } catch (InstantiationException e) { Log.e("LDLN", e.getMessage()); } catch (IllegalAccessException e) { Log.e("LDLN", e.getMessage()); } return null; }
From source file:org.opens.urlmanager.rest.operation.command.service.entity.tag.TagDSOGetTagFromLabel.java
@Override public Object process(GenericDataService<Tag, Long> genericDataService, Tag entity) { try {//from w w w .j a v a2 s. c o m return ((TagDataService) genericDataService).getTagFromLabel(entity.getLabel()); } catch (ClassCastException e) { LogFactory.getLog(TagDSOGetTagFromLabel.class).debug("Invalid parameter : " + e.getMessage()); throw new InternalErrorException("Internal error", e); } }
From source file:org.tonguetied.utils.pagination.PaginatedList.java
/** * Performs a deep copy of this list.//from ww w . j a v a 2s .co m * * @throws CloneNotSupportedException if the list is not a list of * {@link DeepCloneable} objects */ public PaginatedList<T> deepClone() throws CloneNotSupportedException { //// if (!this.getClass().isInstance(Cloneable.class)) //// throw new CloneNotSupportedException(); // ArrayList<T> items = new ArrayList<T>(); try { for (DeepCloneable<T> item : (List<DeepCloneable<T>>) this) { items.add(item.deepClone()); } } catch (ClassCastException cce) { throw new CloneNotSupportedException(cce.getMessage()); } return new PaginatedList<T>(items, maxListSize); }
From source file:org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void invokeCustomizer(WebServerFactoryCustomizer customizer, WebServerFactory webServerFactory) { try {//from w w w. j av a 2s .com customizer.customize(webServerFactory); } catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || msg.startsWith(webServerFactory.getClass().getName())) { // Possibly a lambda-defined listener which we could not resolve the // generic event type for logLambdaDebug(customizer, ex); } else { throw ex; } } }
From source file:org.apache.zeppelin.notebook.scheduler.CronJob.java
@Override public void execute(JobExecutionContext context) { JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); Notebook notebook = (Notebook) jobDataMap.get("notebook"); String noteId = jobDataMap.getString("noteId"); Note note = notebook.getNote(noteId); if (note.haveRunningOrPendingParagraphs()) { logger.warn("execution of the cron job is skipped because there is a running or pending " + "paragraph (note id: {})", noteId); return;/*from ww w . ja va 2 s .co m*/ } if (!note.isCronSupported(notebook.getConf())) { logger.warn("execution of the cron job is skipped cron is not enabled from Zeppelin server"); return; } runAll(note); boolean releaseResource = false; String cronExecutingUser = null; try { Map<String, Object> config = note.getConfig(); if (config != null) { if (config.containsKey("releaseresource")) { releaseResource = (boolean) config.get("releaseresource"); } cronExecutingUser = (String) config.get("cronExecutingUser"); } } catch (ClassCastException e) { logger.error(e.getMessage(), e); } if (releaseResource) { for (InterpreterSetting setting : notebook.getInterpreterSettingManager() .getInterpreterSettings(note.getId())) { try { notebook.getInterpreterSettingManager().restart(setting.getId(), noteId, cronExecutingUser != null ? cronExecutingUser : "anonymous"); } catch (InterpreterException e) { logger.error("Fail to restart interpreter: " + setting.getId(), e); } } } }
From source file:com.orange.mmp.api.ws.jsonrpc.SimpleMapSerializer.java
@SuppressWarnings("unchecked") @Override/*from ww w. ja v a2s . c om*/ public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { Map map = null; try { try { try { if (clazz.isInterface()) { map = new java.util.HashMap(); } else map = (Map) clazz.newInstance(); } catch (ClassCastException cce) { throw new UnmarshallException("invalid unmarshalling Class " + cce.getMessage()); } } catch (IllegalAccessException iae) { throw new UnmarshallException("no access unmarshalling object " + iae.getMessage()); } } catch (InstantiationException ie) { throw new UnmarshallException("unable to instantiate unmarshalling object " + ie.getMessage()); } JSONObject jso = (JSONObject) o; Iterator keys = jso.keys(); state.setSerialized(o, map); try { while (keys.hasNext()) { String key = (String) keys.next(); map.put(key, ser.unmarshall(state, null, jso.get(key))); } } catch (JSONException je) { throw new UnmarshallException("Could not read map: " + je.getMessage()); } return map; }