List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:com.ericbarnhill.arrayMath.MathArrayFloat1D.java
protected MathArrayFloat1D multiplyC(Complex g) { throw new ClassCastException("Cannot multiply Complex number to double array"); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w w w.ja v a 2 s . co m*/ mCallbacks = (FragmentCallbacks) activity; } catch (ClassCastException e) { throw new ClassCastException("Activity must implement Fragment One."); } }
From source file:com.ericbarnhill.arrayMath.MathArrayFloat2D.java
protected MathArrayFloat2D multiplyC(Complex g) { throw new ClassCastException("Cannot multiply Complex number to double array"); }
From source file:com.ericbarnhill.arrayMath.MathArrayFloat3D.java
protected MathArrayFloat3D multiplyC(Complex g) { throw new ClassCastException("Cannot multiply Complex number to double array"); }
From source file:bdi4jade.core.Capability.java
/** * Adds by reflection capability components, such as beliefs and plans, * according to annotated fields. This method is invoked by for capability * class, and all parent classes.// ww w . j a va 2 s . c o m * * @param capabilityClass * the capability class of which fields should me added to this * capability. */ protected void addAnnotatedFields(Class<? extends Capability> capabilityClass) { for (Field field : capabilityClass.getDeclaredFields()) { boolean b = field.isAccessible(); field.setAccessible(true); try { if (field.isAnnotationPresent(bdi4jade.annotation.Belief.class)) { if (Belief.class.isAssignableFrom(field.getType())) { Belief<?, ?> belief = (Belief<?, ?>) field.get(this); this.getBeliefBase().addBelief(belief); } else { throw new ClassCastException("Field " + field.getName() + " should be a Belief"); } } else if (field.isAnnotationPresent(bdi4jade.annotation.TransientBelief.class)) { bdi4jade.annotation.TransientBelief annotation = field .getAnnotation(bdi4jade.annotation.TransientBelief.class); String name = "".equals(annotation.name()) ? field.getName() : annotation.name(); Object value = field.get(this); this.getBeliefBase().addBelief(new TransientBelief(name, value)); } else if (field.isAnnotationPresent(bdi4jade.annotation.TransientBeliefSet.class)) { bdi4jade.annotation.TransientBeliefSet annotation = field .getAnnotation(bdi4jade.annotation.TransientBeliefSet.class); String name = "".equals(annotation.name()) ? field.getName() : annotation.name(); Object value = field.get(this); if (Set.class.isAssignableFrom(field.getType())) { this.getBeliefBase().addBelief(new TransientBeliefSet(name, (Set) value)); } } else if (field.isAnnotationPresent(bdi4jade.annotation.Plan.class)) { if (Plan.class.isAssignableFrom(field.getType())) { Plan plan = (Plan) field.get(this); this.getPlanLibrary().addPlan(plan); } else { throw new ClassCastException("Field " + field.getName() + " should be a Plan"); } } else if (field.isAnnotationPresent(bdi4jade.annotation.AssociatedCapability.class)) { if (Capability.class.isAssignableFrom(field.getType())) { Capability capability = (Capability) field.get(this); this.addAssociatedCapability(capability); } else { throw new ClassCastException("Field " + field.getName() + " should be a Capability"); } } else if (field.isAnnotationPresent(bdi4jade.annotation.PartCapability.class)) { if (Capability.class.isAssignableFrom(field.getType())) { Capability capability = (Capability) field.get(this); this.addPartCapability(capability); } else { throw new ClassCastException("Field " + field.getName() + " should be a Capability"); } } } catch (Exception exc) { log.warn(exc); exc.printStackTrace(); } field.setAccessible(b); } }
From source file:org.apache.syncope.core.persistence.beans.user.SyncopeUser.java
@Override public <T extends AbstractAttr> boolean addAttribute(final T attribute) { if (!(attribute instanceof UAttr)) { throw new ClassCastException( "attribute is expected to be typed UAttr: " + attribute.getClass().getName()); }/*from w w w .jav a2s .c om*/ return attributes.add((UAttr) attribute); }
From source file:com.ebaotech.salesplatform.commons.helper.SimpleSharedPreferences.java
@Override public int getInt(String key, int defValue) throws ClassCastException { initiateSharedPreferences();/* w w w .j ava2 s . com*/ try { return mSharedPreferences.getInt(key, defValue); } catch (final ClassCastException e) { final String returnType = new Object() { }.getClass().getEnclosingMethod().getReturnType().toString(); throw new ClassCastException("\n ======================================== \nClassCastException : " + key + "'s value is not an " + returnType + " \n ======================================== \n"); } }
From source file:com.citrus.sample.UserManagementFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w ww .j a v a 2 s .c o m*/ mListener = (UserManagementInteractionListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement UserManagementInteractionListener"); } }
From source file:com.ericbarnhill.arrayMath.MathArrayDouble1D.java
protected MathArrayDouble1D subtract(Complex g) { throw new ClassCastException("Cannot add Complex number to double array"); }
From source file:com.randerson.cloudantdroid.CouchSession.java
private CouchSessionInterface getActivityInterface() { // create a null instance of the interface object CouchSessionInterface sessionInterface = null; // verify that the context is implementing the interface if (CONTEXT instanceof CouchSessionInterface) { sessionInterface = (CouchSessionInterface) CONTEXT; } else {/*from w w w. jav a 2s . c o m*/ // throw exception throw new ClassCastException(CONTEXT.toString() + " must implement required methods"); } return sessionInterface; }