List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:com.ariesmcrae.mymemories.ui.story.CreateStoryFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w w w . j a va 2s. co m*/ mOpener = (OnOpenWindowInterface) activity; resolver = new MyMemoriesResolver(activity); } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnOpenWindowListener"); } }
From source file:com.buffalokiwi.aerodrome.jet.Utils.java
/** * Convert a json array to a list of Strings. * if arr is null, then an empty List<String> instance is returned. * // w ww . j av a 2 s . c o m * This is more safe than JsonArray.getValuesAs() as this method * has built-in type checking and will throw a ClassCastException if * the type is incorrect or null. * * @param arr array * @return a list * @throws ClassCastException if any element in arr is not an string */ public static List<String> jsonArrayToStringList(final JsonArray arr) { final List<String> out = new ArrayList<>(); if (arr == null) return out; for (int i = 0; i < arr.size(); i++) { final String s; try { s = arr.getString(i); } catch (ClassCastException e) { APILog.error(LOG, e, arr.get(i)); continue; } if (s == null) { throw new ClassCastException( "Element at position " + String.valueOf(i) + " is null - String required"); } out.add(s); } return out; }
From source file:com.achow101.bitcointalkforum.fragments.BoardTopicFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {//from w w w. ja va2s . co m mListener = (OnTopicListInteraction) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnTopicListInteraction"); } }
From source file:com.helpshift.kvstore.SharedPreferencesImpl.java
@Override public float getFloat(String key, float defValue) { String value = getValueByKey(key); if (value == null) { return defValue; } else {/*from w w w .j ava 2 s . co m*/ try { return Float.parseFloat(getValueByKey(key)); } catch (NumberFormatException e) { throw new ClassCastException("can not cast to Float"); } } }
From source file:com.ntsync.android.sync.activities.VerifyPaymentProgressDialog.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w w w.j av a 2 s. c o m*/ resultListener = (VerifyPaymentDialogListener) activity; } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception ClassCastException ex = new ClassCastException( activity.toString() + " must implement VerifyPaymentDialogListener"); ex.initCause(e); throw ex; } }
From source file:at.ac.tuwien.detlef.fragments.EpisodeListSortDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Verify that the host activity implements the callback interface try {/*w w w . j av a2 s. c o m*/ // Instantiate the NoticeDialogListener so we can send events to the // host mListener = (NoticeDialogListener) activity; } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception throw new ClassCastException(activity.toString() + " must implement NoticeDialogListener"); } }
From source file:com.project.framework.dao.BaseDao.java
/** * ?Query,./*from w w w .j a v a2s. c o m*/ */ protected Query setPageParameter(final Query q, final Page<T> page) { if (page.getStartIndex() > Integer.MAX_VALUE) throw new ClassCastException("Hibernate can not support startIndex Greater than Integer.Max"); //hibernatefirstResult??0 q.setFirstResult((int) page.getStartIndex()); q.setMaxResults(page.getPageSize()); return q; }
From source file:com.armtimes.drawer.CommonFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/* ww w .j av a2 s . c o m*/ mListener = (IFragmentListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement OnFragmentInteractionListener Interface"); } }
From source file:com.ericbarnhill.arrayMath.MathArrayDouble1D.java
protected MathArrayDouble1D divideC(Complex g) { throw new ClassCastException("Cannot add Complex number to double array"); }
From source file:com.androzic.Preferences.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception try {/*from w w w . jav a 2 s . c om*/ fragmentHolderCallback = (FragmentHolder) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement FragmentHolder"); } }