List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException()
ClassCastException
with no detail message. From source file:Main.java
public static long toLong(Object o) { if (o instanceof Byte) { return ((Byte) o).byteValue(); } else if (o instanceof Short) { return ((Short) o).shortValue(); } else if (o instanceof Integer) { return ((Integer) o).intValue(); } else if (o instanceof Long) { return ((Long) o).longValue(); } else if (o instanceof Character) { return ((Character) o).charValue(); } else {// w ww . j a v a 2 s. c o m throw new ClassCastException(); } }
From source file:org.intermine.app.net.ResponseHelper.java
public static void handleSpiceException(SpiceException ex, BaseActivity atv, String mineName, int dialogCode) { if (ex instanceof RequestCancelledException) { return;/*from w ww. j a va2 s . com*/ } if (ex instanceof NoNetworkException) { atv.showStandardAlert(R.string.no_network_error_message, DIALOG_CODE_NETWORK); return; } HttpNetworkException networkException; try { networkException = (HttpNetworkException) ex.getCause(); if (null == networkException) { throw new ClassCastException(); } } catch (ClassCastException e) { atv.showStandardAlert(R.string.unknown_error_message, dialogCode); return; } HttpStatus code = networkException.getStatusCode(); String message = networkException.getErrorMessage(); // Handle unauthorized if (UNAUTHORIZED == code) { Storage storage = atv.getStorage(); storage.setUserToken(mineName, null); atv.showStandardAlert(R.string.unauthorized_error_message, BaseActivity.UNAUTHORIZED_CODE); return; } if (Strs.isNullOrEmpty(message)) { atv.showStandardAlert(R.string.unknown_error_message, dialogCode); } else { atv.showStandardAlert(message, dialogCode); } Log.e(TAG, ex.toString()); }
From source file:Employee.java
public int compareTo(Object o) { if (!(o instanceof Employee)) throw new ClassCastException(); Employee e = (Employee) o;/*w ww. j a v a 2s . c o m*/ return name.compareTo(e.getName()); }
From source file:com.github.pjungermann.config.specification.FailedToLoadSpecificationErrorTest.java
@Before public void setUp() { error = new FailedToLoadSpecificationError(new File("fake"), new ClassCastException()); }
From source file:com.github.pjungermann.config.specification.types.TypeConversionFailedErrorTest.java
@Test public void toString_valueNotNull_provideToStringWithFields() { TypeConversionFailedError error = new TypeConversionFailedError("fake-key", "fake-value", Long.class, new ClassCastException()); assertEquals(//from www .ja va 2 s .co m "TypeConversionFailedError(key=fake-key, value=fake-value, value.class=class java.lang.String, type=class java.lang.Long)", error.toString()); }
From source file:edu.usc.goffish.gofs.formats.gml.KeyValuePair.java
public Iterable<KeyValuePair> ValueAsList() { throw new ClassCastException(); }
From source file:edu.usc.goffish.gofs.formats.gml.KeyValuePair.java
public long ValueAsLong() { throw new ClassCastException(); }
From source file:edu.usc.goffish.gofs.formats.gml.KeyValuePair.java
public double ValueAsDouble() { throw new ClassCastException(); }
From source file:com.github.pjungermann.config.specification.types.TypeConversionFailedErrorTest.java
@Test public void toString_valueNull_provideToStringWithFields() { TypeConversionFailedError error = new TypeConversionFailedError("fake-key", null, Long.class, new ClassCastException()); assertEquals(/*from w w w . ja va2s. c om*/ "TypeConversionFailedError(key=fake-key, value=null, value.class=null, type=class java.lang.Long)", error.toString()); }
From source file:edu.usc.goffish.gofs.formats.gml.GMLWriter.java
public static String classTypeToGMLType(Class<? extends Object> type) { if (type == String.class) { return GMLParser.STRING_TYPE; } else if (type == Integer.class) { return GMLParser.INTEGER_TYPE; } else if (type == Long.class) { return GMLParser.LONG_TYPE; } else if (type == Float.class) { return GMLParser.FLOAT_TYPE; } else if (type == Double.class) { return GMLParser.DOUBLE_TYPE; } else if (type == Boolean.class) { return GMLParser.BOOLEAN_TYPE; } else if (type == List.class) { return GMLParser.LIST_TYPE; }/*from w w w .j ava2s . c o m*/ // type was not recognized throw new ClassCastException(); }