List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:org.jasig.cas.support.oauth.token.registry.JpaTokenRegistry.java
@Override public <T extends Token> T getToken(final String tokenId, final Class<T> clazz) throws ClassCastException { Assert.notNull(clazz, "clazz cannot be null"); final T token = entityManager.find(getClassImplementation(clazz), tokenId); if (token == null) { return null; }/*from ww w .ja va2 s. c o m*/ if (!clazz.isAssignableFrom(token.getClass())) { throw new ClassCastException("Token [" + token.getId() + "] is of type " + token.getClass() + " when we were expecting " + clazz); } return token; }
From source file:cat.wuyingren.rorhelper.fragments.dialogs.NewGameDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Verify that the host activity implements the callback interface try {// w w w . j a v a2s.c om // Instantiate the NoticeDialogListener so we can send events to the host mListener = (NewGameDialogListener) activity; } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception throw new ClassCastException(activity.toString() + " must implement NewGameDialogListener"); } }
From source file:dbs_project.util.SimpleColumn.java
@Override public int getInteger(int index) throws IndexOutOfBoundsException, ClassCastException { if (isNull(index)) { return Type.NULL_VALUE_INTEGER; } else {/*from w w w . jav a 2 s .c om*/ Object value = data.get(index); if (value instanceof Integer) { return (Integer) value; } else if (value instanceof Double) { return ((Double) value).intValue(); } else { throw new ClassCastException(String.valueOf(value)); } } }
From source file:com.devspacenine.poolpal.fragment.DatePickerDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Make sure the calling fragment or activity implements OnDecisionMadeListener if (getArguments().containsKey(FRAGMENT_TAG)) { Fragment frag = ((FragmentActivity) activity).getSupportFragmentManager() .findFragmentByTag(getArguments().getString(FRAGMENT_TAG)); try {//from ww w .j av a 2s. c om mOnDateSetListener = (OnDateSetListener) frag; } catch (ClassCastException e) { throw new ClassCastException(frag + " must implement the OnDecisionMadeListener interface."); } } else { try { mOnDateSetListener = (OnDateSetListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity + " must implement the OnDecisionMadeListener interface."); } } }
From source file:com.androzic.track.TrackDetails.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 ww w .j a v a 2 s . c om fragmentHolderCallback = (FragmentHolder) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement FragmentHolder"); } try { trackActionsCallback = (OnTrackActionListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnTrackActionListener"); } }
From source file:com.learnit.LearnIt.async_tasks.GetHelpWordsGoogleTask.java
@Override protected void onPostExecute(List<String> words) { super.onPostExecute(words); if (words == null) { _taskActionCallback.onFail();/* ww w.j ava2s .c om*/ return; } if (_taskActionCallback instanceof IWorkerEventListenerHelpWords) { ((IWorkerEventListenerHelpWords) _taskActionCallback).onSuccessWords(words); } else { throw new ClassCastException(_taskActionCallback.getClass().getSimpleName() + " must implement " + IWorkerEventListenerHelpWords.class.getSimpleName()); } }
From source file:augsburg.se.alltagsguide.page.PageOverviewFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); try {/* w ww . ja va2s .c om*/ mListener = (OnPageFragmentInteractionListener) context; } catch (ClassCastException e) { throw new ClassCastException(context.toString() + " must implement OnPageFragmentInteractionListener"); } }
From source file:augsburg.se.alltagsguide.event.EventOverviewFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); try {/*from ww w . ja va2 s . com*/ mListener = (OnEventPageFragmentInteractionListener) context; } catch (ClassCastException e) { throw new ClassCastException( context.toString() + " must implement OnEventPageFragmentInteractionListener"); } }
From source file:at.ac.tuwien.detlef.fragments.PodListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {// w w w . j a v a 2s . co m listener = (OnPodcastSelectedListener) activity; } catch (ClassCastException e) { throw new ClassCastException(String.format("%s must implement %s", activity.toString(), OnPodcastSelectedListener.class.getName())); } }
From source file:ca.ualberta.slevinsk.gameshow.NumberPickerFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {// ww w.j a v a 2 s .c o m onPlayerCountChangeListener = (NumberPicker.OnValueChangeListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnValueChangListener"); } }