List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:com.achow101.bitcointalkforum.fragments.UnreadPostListsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w w w . j a v a2 s . c om*/ mListener = (OnUnreadListInteraction) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnUnreadListInteraction"); } }
From source file:com.cuddlesoft.nori.fragment.EditAPISettingDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Ensure the parent activity implements the proper listener interface. try {/* ww w.j a v a 2 s. c o m*/ listener = (Listener) getActivity(); } catch (ClassCastException e) { throw new ClassCastException( getActivity().toString() + " must implement EditAPISettingDialogFragment.Listener"); } }
From source file:com.github.haixing_hu.bean.DefaultProperty.java
/** * Checks the type of a value./*w ww . j a va 2s .c om*/ * * @param value * the value to be checked, which could be {@code null}, depending on * the implementation. * @throws ClassCastException * if the value is not an instance of the type of this property. */ protected void checkType(@Nullable final Object value) { if (value == null) { return; } final Class<?> type = descriptor.getType(); if (!type.isAssignableFrom(value.getClass())) { throw new ClassCastException("Cannot cast the value of type " + value.getClass().getName() + " to the value of type " + type.getName()); } }
From source file:butter.droid.fragments.NavigationDrawerFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {// w w w. j av a2 s . co m mCallbacks = (Callbacks) activity; } catch (ClassCastException e) { throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); } }
From source file:com.cerema.cloud2.ui.dialog.SamlWebViewDialog.java
@Override public void onAttach(Activity activity) { Log_OC.v(TAG, "onAttach"); super.onAttach(activity); try {/*from ww w . j av a 2 s . c o m*/ mSsoWebViewClientListener = (SsoWebViewClientListener) activity; mHandler = new Handler(); mWebViewClient = new SsoWebViewClient(activity, mHandler, mSsoWebViewClientListener); } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement " + SsoWebViewClientListener.class.getSimpleName()); } }
From source file:com.codinguser.android.contactpicker.ContactDetailsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/* w ww. ja v a 2 s.c o m*/ mContactsListener = (OnContactSelectedListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnContactSelectedListener"); } }
From source file:am.roadpolice.roadpolice.dialogs.DialogConfirmation.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {//www. java2s. c om this.mListener = (IDialogConfirmationListener) activity; } catch (final ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement IDialogConfirmationListener"); } }
From source file:com.achow101.bitcointalkforum.fragments.HomeFragment.java
public void onAttach(Activity activity) { super.onAttach(activity); try {//from w ww . j a v a2s. com mBoardCallback = (GoToBoard) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement GoToBoard"); } }
From source file:dbs_project.util.SimpleColumn.java
@Override public double getDouble(int index) throws IndexOutOfBoundsException, ClassCastException { if (isNull(index)) { return Type.NULL_VALUE_DOUBLE; } else {/*from w ww.j a va 2 s. c o m*/ Object value = data.get(index); if (value instanceof Double) { return (Double) value; } else if (value instanceof Integer) { return (Integer) value; } else { throw new ClassCastException(String.valueOf(value)); } } }
From source file:ConversionUtil.java
/** * Attempts to convert an object to Comparable instance. *///from ww w . j a v a 2 s . c om public static Comparable toComparable(Object object) { if (object == null) { return null; } else if (object instanceof Comparable) { return (Comparable) object; } else if (object instanceof StringBuffer) { return object.toString(); } else if (object instanceof char[]) { return new String((char[]) object); } else { throw new ClassCastException("Invalid Comparable class:" + object.getClass().getName()); } }