List of usage examples for java.lang ClassCastException getMessage
public String getMessage()
From source file:org.gnucash.android.ui.accounts.AccountsActivity.java
/** * Creates the default accounts which have the selected by the user. * The indices of the default accounts is stored in {@link #mSelectedDefaultAccounts} *//*from w ww . ja v a2s . c om*/ private void createDefaultAccounts() { AlertDialog.Builder builder = new AlertDialog.Builder(this); boolean[] checkedDefaults = new boolean[] { true, true, false, false, false }; //add the checked defaults, the rest will be added by user action mSelectedDefaultAccounts.add(0); mSelectedDefaultAccounts.add(1); builder.setTitle(R.string.title_default_accounts); builder.setMultiChoiceItems(R.array.default_accounts, checkedDefaults, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { mSelectedDefaultAccounts.add(which); } else { mSelectedDefaultAccounts.remove(Integer.valueOf(which)); } } }); builder.setPositiveButton(R.string.btn_create_accounts, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AccountsDbAdapter dbAdapter = new AccountsDbAdapter(getApplicationContext()); String[] defaultAccounts = getResources().getStringArray(R.array.default_accounts); for (int index : mSelectedDefaultAccounts) { String name = defaultAccounts[index]; dbAdapter.addAccount(new Account(name)); } dbAdapter.close(); removeFirstRunFlag(); Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_ACCOUNTS_LIST); if (fragment != null) { try { ((AccountsListFragment) fragment).refreshList(); } catch (ClassCastException e) { Log.e(TAG, e.getMessage()); } } } }); builder.setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mDefaultAccountsDialog.dismiss(); removeFirstRunFlag(); } }); mDefaultAccountsDialog = builder.create(); mDefaultAccountsDialog.show(); }
From source file:com.microsoft.rightsmanagement.ui.UserPolicyViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Logger.ms(TAG, "onCreate"); super.onCreate(savedInstanceState); int layoutId = R.layout.user_policy_viewer_activity_layout; setContentView(layoutId);/*from w w w .j av a2s .com*/ Intent intent = getIntent(); mRequestCallbackId = intent.getIntExtra(REQUEST_CALLBACK_ID, 0); mUserPolicyViewerActivityRequestOption = intent.getIntExtra(REQUEST_RESULT_POLICY_VIEWER_OPTIONS, UserPolicyViewerActivityRequestOption.NONE); Parcelable possbileUserPolicyModelInstance = intent.getParcelableExtra(REQUEST_RESULT_USER_POLICY_MODEL); try { mUserPolicyModel = (UserPolicyModel) possbileUserPolicyModelInstance; } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); } addUserPolicyViewerFragment(); addTransparentPartDismissListener(R.id.user_policy_viewer_transparent_part); // create fader animators createBgAnimators(R.id.user_policy_viewer_base_container, savedInstanceState); Logger.me(TAG, "onCreate"); }
From source file:de.hybris.platform.test.MailUtilsTest.java
@Test public void testConvertCache() { final int defaultSMTPPort = -1; //this will put integer into cache final int intSMTPPort = Config.getInt(Config.Params.MAIL_SMTP_PORT, defaultSMTPPort); //this will try to get Integer as string from cache - shouldn't result in clasCastException String stringSMTPPort = null; try {/* w ww .ja v a 2s .c o m*/ stringSMTPPort = Config.getString(Config.Params.MAIL_SMTP_PORT, String.valueOf(defaultSMTPPort)); } catch (final ClassCastException cce) { fail("Cache is not resistful for subsequent calls of getters (of different returned type) for same parameter:" + cce.getMessage()); } assertEquals("Should be equal", String.valueOf(intSMTPPort), stringSMTPPort); }
From source file:org.apache.ambari.server.controller.internal.HttpProxyPropertyProvider.java
private Object getPropertyValueToSet(Map<String, Object> propertyValueFromJson, Object componentName) throws SystemException { Object result = propertyValueFromJson; //TODO need refactoring for universalization try {/* w w w .java 2 s. c o m*/ if (PROPERTIES_TO_FILTER.get(componentName) != null) { for (String key : PROPERTIES_TO_FILTER.get(componentName).split("/")) { result = ((Map) result).get(key); } } } catch (ClassCastException e) { LOG.error(String.format("Error getting property value for %s. %s", PROPERTIES_TO_FILTER.get(componentName), e.getMessage())); throw new SystemException( String.format("Error getting property value for %s.", PROPERTIES_TO_FILTER.get(componentName)), e); } return result; }
From source file:eu.learnpad.simulator.mon.impl.ComplexEventProcessorImpl.java
@Override public void onMessage(Message arg0) { ObjectMessage msg = (ObjectMessage) arg0; try {/*ww w . j av a 2s. co m*/ GlimpseBaseEvent<?> receivedEvent = (GlimpseBaseEvent<?>) msg.getObject(); if (eventStream != null && receivedEvent != null) { try { eventStream.insert(receivedEvent); if (receivedEvent instanceof GlimpseBaseEventBPMN<?>) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: " + receivedEvent.getEventName() + "\n" + "timestamp: " + receivedEvent.getTimeStamp() + "\n" + "event: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getEvent()); } else { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: " + receivedEvent.getEventName() + "\n" + "timestamp: " + receivedEvent.getTimeStamp()); } DebugMessages.line(); } catch (org.drools.RuntimeDroolsException droolsCrashException) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), droolsCrashException.getMessage()); new UnknownMethodCallRuleException(); } } } catch (JMSException e) { e.printStackTrace(); } catch (ClassCastException ex) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), ex.getMessage()); } }
From source file:com.otiliouine.configurablefactory.ConfigurableFactory.java
/** * Creates an instance of the implementation class mapped to <b>interfazz</b> * //from ww w. j ava2 s . c o m * @param interfazz the Interface or class which represents the abstraction of instance types * @param args the arguments to use when creating the new instance * @return a new instance of the implementation class mapped to <b>interfazz</b> */ public <T> T createInstance(Class<T> interfazz, Object... args) { Class<T> clazz = (Class<T>) mapping.get(interfazz); if (clazz == null) { throw new NoFactoryDefinitionException( "No factory is defined for class " + interfazz.getCanonicalName()); } try { T instance = (T) ConstructorUtils.invokeConstructor(clazz, args); return interfazz.cast(instance); } catch (ClassCastException e) { throw new InvalidMappingValuesException( "invalid factory configuration, class " + clazz.getCanonicalName(), e); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.yes.cart.domain.message.consumer.StandardMessageListener.java
/** * {@inheritDoc}/*from w ww. j av a 2 s . c o m*/ */ public void run() { final Map<String, Object> map = (Map<String, Object>) objectMessage; try { try { if (map.get(SHOP) == null) { enrichMapWithShop(map); } if (map.get(CUSTOMER) == null) { enrichMapWithCustomer(map); } if (map.get(ROOT) instanceof CustomerOrder) { enrichMapWithProducts(map); } final Mail mail = mailService.getGenericDao().getEntityFactory().getByIface(Mail.class); final String attrVal = ((Shop) map.get(SHOP)) .getAttributeValueByCode(AttributeNamesKeys.Shop.SHOP_ADMIN_EMAIL); String fromEmail = null; if (StringUtils.isNotBlank(attrVal)) { fromEmail = attrVal; } mailComposer.composeMessage(mail, (String) map.get(SHOP_CODE), (String) map.get(LOCALE), (List<String>) map.get(TEMPLATE_FOLDER), (String) map.get(TEMPLATE_NAME), fromEmail, (String) map.get(CUSTOMER_EMAIL), //email recipient - to null, null, map); mailService.create(mail); } catch (Exception e) { LOG.error(Markers.alert(), MessageFormat.format( "Cannot compose or send email template {0} with locale {1} theme {2} to {3}, cause: {4}", map.get(TEMPLATE_NAME), map.get(LOCALE), map.get(TEMPLATE_FOLDER), map.get(CUSTOMER_EMAIL), e.getMessage()), e); } } catch (ClassCastException cce) { LOG.error("Class cast exception " + cce.getMessage(), cce); } }
From source file:com.comcast.cats.provider.VideoRecorderRESTProviderImpl.java
private boolean execute(String recordingGroupNameAlias, String requestURI) throws VideoRecorderException { boolean retVal = false; VideoRecorderResponse response = null; if (videoHostIp != null && !videoHostIp.isEmpty() && videoPort >= 0 && requestURI != null && !requestURI.isEmpty() && macID != null && !macID.isEmpty() && serverHost != null && !serverHost.isEmpty()) { try {/*from ww w . j a va2 s.c o m*/ response = (VideoRecorderResponse) HttpClientUtil.postForObject(getRequestUri(requestURI), getParamMap(macID, videoHostIp, videoPort, recordingGroupNameAlias)); logger.debug("webServiceReturn " + response); } catch (ClassCastException e) { logger.debug("RecorderServer not a valid one. " + " hostServer " + serverHost + " error : " + e.getMessage()); } if (response == null || response.getResult() == WebServiceReturnEnum.FAILURE || (response.getRecording() != null && response.getRecording().getRecordingStatus() != null && (response.getRecording().getRecordingStatus().getState() .equalsIgnoreCase(VideoRecorderState.ERROR.name()) || response.getRecording().getRecordingStatus().getState() .equalsIgnoreCase(VideoRecorderState.FORCE_CLOSE.name())))) { retVal = false; } else { retVal = true; } } else { throw new VideoRecorderException("Provider not instantiated properly"); } logger.trace("execute: videoHostIp " + videoHostIp + " videoPort " + videoPort + " requestURI " + requestURI + " response " + response); return retVal; }
From source file:com.vinted.ab.security.Hex.java
/** * Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those * same values. The returned array will be half the length of the passed String or array, as it takes two characters * to represent any given byte. An exception is thrown if the passed char array has an odd number of elements. * * @param object/*from w w w . j av a 2 s. c o m*/ * A String or, an array of character bytes containing hexadecimal digits * @return A byte array containing binary data decoded from the supplied byte array (representing characters). * @throws DecoderException * Thrown if an odd number of characters is supplied to this function or the object is not a String or * char[] * @see #decodeHex(char[]) */ @Override public Object decode(Object object) throws DecoderException { try { char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; return decodeHex(charArray); } catch (ClassCastException e) { throw new DecoderException(e.getMessage(), e); } }
From source file:com.vinted.ab.security.Hex.java
/** * Converts a String or an array of bytes into an array of characters representing the hexadecimal values of each * byte in order. The returned array will be double the length of the passed String or array, as it takes two * characters to represent any given byte. * <p>/*from w ww . j a v a 2 s . com*/ * The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by * {@link #getCharset()}. * </p> * * @param object * a String, or byte[] to convert to Hex characters * @return A char[] containing hexadecimal characters * @throws EncoderException * Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) */ @Override public Object encode(Object object) throws EncoderException { try { byte[] byteArray = object instanceof String ? ((String) object).getBytes(this.getCharset()) : (byte[]) object; return encodeHex(byteArray); } catch (ClassCastException e) { throw new EncoderException(e.getMessage(), e); } }