List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:app.com.vaipo.ContactsFragment.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 ww. j a v a 2 s . c o m mCallback = (ContactsListenerAction) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement LogoutUser"); } }
From source file:com.dena.app.usage.watcher.fragment.NavigationDrawerFragment.java
public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w ww . ja va 2s. c o m*/ mCallbacks = (NavigationDrawerCallbacks) activity; } catch (ClassCastException e) { throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); } }
From source file:com.acbelter.directionalcarousel.CarouselViewPager.java
@Override public void setAdapter(PagerAdapter adapter) { super.setAdapter(adapter); if (adapter == null) { return;/*from w w w . j av a2 s . com*/ } if (adapter.getClass() != CarouselPagerAdapter.class) { throw new ClassCastException("Adapter must be instance of CarouselPagerAdapter class."); } setOnPageChangeListener((OnPageChangeListener) adapter); setCurrentItem(((CarouselPagerAdapter) adapter).getFirstPosition()); }
From source file:bdi4jade.util.ReflectionUtils.java
/** * Sets plan body fields annotated with {@link bdi4jade.annotation.Belief}. * //from w ww .ja va2s .c o m * @param planBody * the plan body to be setup with beliefs. */ public static void setupBeliefs(PlanBody planBody) { Capability capability = planBody.getPlan().getPlanLibrary().getCapability(); Class<?> currentClass = planBody.getClass(); while (PlanBody.class.isAssignableFrom(currentClass)) { for (Field field : currentClass.getDeclaredFields()) { boolean b = field.isAccessible(); field.setAccessible(true); try { if (field.isAnnotationPresent(bdi4jade.annotation.Belief.class)) { if (Belief.class.isAssignableFrom(field.getType())) { bdi4jade.annotation.Belief beliefAnnotation = field .getAnnotation(bdi4jade.annotation.Belief.class); String beliefName = beliefAnnotation.name(); if (beliefName == null || "".equals(beliefName)) { beliefName = field.getName(); } Belief<?, ?> belief = capability.getBeliefBase().getBelief(beliefName); field.set(planBody, belief); } else { throw new ClassCastException("Field " + field.getName() + " should be a Belief"); } } } catch (Exception exc) { log.warn(exc); } field.setAccessible(b); } currentClass = currentClass.getSuperclass(); } }
From source file:ca.ualberta.cmput301.t03.trading.TradeOfferHistoryFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {//from ww w . j a v a 2 s. c o m // mListener = (OnFragmentInteractionListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnFragmentInteractionListener"); } }
From source file:ca.shoaib.ping.PingListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {//from w w w .j ava 2 s . c o m mPingListCallback = (PingListCallback) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement PingListCallback"); } }
From source file:com.crcrch.chromatictuner.app.NotePickerFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); try {//from w w w .j av a2s . com listener = (OnFrequencySelectedListener) context; } catch (ClassCastException e) { throw new ClassCastException(context + " must implement OnFrequencySelectedListener"); } }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.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 {// ww w .jav a2 s. c o m mCallback = (OnHeadlineSelectedListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnHeadlineSelectedListener"); } }
From source file:com.ericbarnhill.arrayMath.MathArrayFloat1D.java
protected MathArrayFloat1D divideC(Complex g) { throw new ClassCastException("Cannot divide Complex number to double array"); }
From source file:com.ericbarnhill.arrayMath.MathArrayFloat2D.java
protected MathArrayFloat2D divideC(Complex g) { throw new ClassCastException("Cannot divide Complex number to double array"); }