List of usage examples for java.lang ClassCastException getMessage
public String getMessage()
From source file:org.wso2.carbon.la.core.impl.LogsController.java
private Map<String, String> getStringStringMap(Map<String, Object> rawEvent) throws LogsControllerException { Map<String, String> filteredEvent = new HashMap<>(); for (Map.Entry<String, Object> entry : rawEvent.entrySet()) { try {//from w w w.ja v a 2 s . co m filteredEvent.put(entry.getKey(), entry.getValue().toString()); } catch (ClassCastException e) { throw new LogsControllerException("Unsupported datatype present in the log event" + e.getMessage(), e); } } return filteredEvent; }
From source file:com.ariesmcrae.mymemories.ui.story.StoryListFragment.java
/** * @see android.support.v4.app.Fragment#onAttach(android.app.Activity) *///www . j a va 2s . c o m @Override public void onAttach(Activity activity) { Log.d(LOG_TAG, "onAttach start"); super.onAttach(activity); try { mOpener = (OnOpenWindowInterface) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement OnOpenWindowListener" + e.getMessage()); } Log.d(LOG_TAG, "onAttach end"); }
From source file:it.cnr.isti.labsedc.glimpse.impl.ComplexEventProcessorImpl.java
@Override public void onMessage(Message arg0) { ObjectMessage msg = (ObjectMessage) arg0; try {/*w w w. ja va 2s . c om*/ GlimpseBaseEvent<?> receivedEvent = (GlimpseBaseEvent<?>) msg.getObject(); if (eventStream != null && receivedEvent != null) { try { eventStream.insert(receivedEvent); if (receivedEvent instanceof GlimpseBaseEventChoreos<?>) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: " + receivedEvent.getEventName() + "\n" + "timestamp: " + receivedEvent.getTimeStamp() + "\n" + "machineIP: " + ((GlimpseBaseEventChoreos<?>) receivedEvent).getMachineIP() + "\n" + "choreographySource: " + ((GlimpseBaseEventChoreos<?>) receivedEvent).getChoreographySource()); } else if (receivedEvent instanceof GlimpseBaseEventBPMN<?>) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: " + receivedEvent.getEventName() + "\n" + "timestamp: " + receivedEvent.getTimeStamp() + "\n" + "sessionID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getSessionID() + "\n" + "assigneeID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getAssigneeID() + "\n" + "roleID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getRoleID() + "\n" + "taskID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getTaskID() + "\n" + "subProcessID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getSubProcessID() + "\n" + "desideredCompletionTime: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getDesideredCompletionTime()); } else { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: " + receivedEvent.getEventName() + "\n" + "timestamp: " + receivedEvent.getTimeStamp()); } DebugMessages.line(); } catch (org.drools.RuntimeDroolsException droolsCrashException) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), droolsCrashException.getMessage()); new UnknownMethodCallRuleException(); } } } catch (JMSException e) { e.printStackTrace(); } catch (ClassCastException ex) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), ex.getMessage()); } }
From source file:com.comcast.cats.provider.VideoRecorderRESTProviderImpl.java
@Override public String getRecordingInfo() throws VideoRecorderException { String retVal = "Status could not be retrieved"; VideoRecorderResponse response = null; if (videoHostIp != null && !videoHostIp.isEmpty() && videoPort >= 0 && macID != null && !macID.isEmpty() && serverHost != null && !serverHost.isEmpty()) { try {// w ww . j a v a 2 s . co m response = (VideoRecorderResponse) HttpClientUtil.getForObject( getRequestUri(VideoRecorderServiceConstants.REST_REQUEST_STATUS), getParamMap(macID, videoHostIp, videoPort)); } catch (ClassCastException e) { logger.debug("RecorderServer not a valid one. " + " hostServer " + serverHost + " error : " + e.getMessage()); } if (response == null || response.getResult() == WebServiceReturnEnum.FAILURE) { String message = (response == null) ? "Error Recording: Cause Unknown" : response.getMessage(); throw new VideoRecorderException(message); } else { StringBuilder stringBuilder = new StringBuilder(); if (response.getRecording() != null) { stringBuilder.append("\n"); stringBuilder.append("MAC Address : " + response.getRecording().getStbMacAddress()); stringBuilder.append("\n"); stringBuilder.append("Created Time : " + response.getRecording().getCreatedTime()); stringBuilder.append("\n"); stringBuilder.append("VideoServerIP : " + response.getRecording().getVideoServerIp()); stringBuilder.append("\n"); stringBuilder.append("VideoServer Camera : " + response.getRecording().getVideoServerPort()); stringBuilder.append("\n"); if (response.getRecording().getRecordingStatus() != null) { stringBuilder.append("Recording State : " + response.getRecording().getRecordingStatus().getState()); stringBuilder.append("\n"); stringBuilder.append("Status Message : " + response.getRecording().getRecordingStatus().getMessage()); stringBuilder.append("\n"); } if (response.getRecording().getMediaInfoEntityList() != null && response.getRecording().getMediaInfoEntityList().size() > 0) { String filePath = substituteFilePath( response.getRecording().getMediaInfoEntityList().get(0).getHttpPath()); stringBuilder.append("Http Path : " + filePath); stringBuilder.append("\n"); } } retVal = stringBuilder.toString(); } } else { throw new VideoRecorderException("Provider not instantiated properly"); } return retVal; }
From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.reader.FeatureCollectionMessageBodyReaderWfs20.java
@SuppressWarnings("unchecked") @Override//www . j a v a 2 s . co m public Wfs20FeatureCollection readFrom(Class<Wfs20FeatureCollection> clazz, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> headers, InputStream inStream) throws IOException, WebApplicationException { // Save original input stream for any exception message that might need to be // created and additional attributes String originalInputStream = IOUtils.toString(inStream, "UTF-8"); LOGGER.debug("{}", originalInputStream); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread() .setContextClassLoader(FeatureCollectionMessageBodyReaderWfs20.class.getClassLoader()); //Fetch FeatureCollection attributes Unmarshaller unmarshaller = null; JAXBElement<FeatureCollectionType> wfsFeatureCollectionType = null; try { unmarshaller = JAXB_CONTEXT.createUnmarshaller(); Reader reader = new StringReader(originalInputStream); wfsFeatureCollectionType = (JAXBElement<FeatureCollectionType>) unmarshaller.unmarshal(reader); } catch (ClassCastException e1) { LOGGER.warn("Exception unmarshalling {}, could be an OWS Exception Report from server.", e1.getMessage()); // If an ExceptionReport is sent from the remote WFS site it will be sent with an // JAX-RS "OK" status, hence the ErrorResponse exception mapper will not fire. // Instead the ServiceExceptionReport will come here and be treated like a GetFeature // response, resulting in an XStreamException since ExceptionReport cannot be // unmarshalled. So this catch clause is responsible for catching that XStream // exception and creating a JAX-RS response containing the original stream // (with the ExceptionReport) and rethrowing it as a WebApplicationException, // which CXF will wrap as a ClientException that the WfsSource catches, converts // to a WfsException, and logs. ByteArrayInputStream bis = new ByteArrayInputStream( originalInputStream.getBytes(StandardCharsets.UTF_8)); ResponseBuilder responseBuilder = Response.ok(bis); responseBuilder.type("text/xml"); Response response = responseBuilder.build(); throw new WebApplicationException(e1, response); } catch (JAXBException e1) { LOGGER.error("Error in retrieving feature collection.", e1); } catch (RuntimeException | Error e) { LOGGER.error("Error processing collection", e); throw e; } Wfs20FeatureCollection featureCollection = null; if (null != wfsFeatureCollectionType && null != wfsFeatureCollectionType.getValue()) { BigInteger numberReturned = wfsFeatureCollectionType.getValue().getNumberReturned(); String numberMatched = wfsFeatureCollectionType.getValue().getNumberMatched(); // Re-create the input stream (since it has already been read for potential // exception message creation) inStream = new ByteArrayInputStream(originalInputStream.getBytes("UTF-8")); try { featureCollection = (Wfs20FeatureCollection) xstream.fromXML(inStream); featureCollection.setNumberMatched(numberMatched); featureCollection.setNumberReturned(numberReturned); } catch (XStreamException e) { LOGGER.error("Exception unmarshalling {}", e); } finally { IOUtils.closeQuietly(inStream); } } return featureCollection; } finally { Thread.currentThread().setContextClassLoader(ccl); } }
From source file:us.mn.state.health.lims.testanalyte.form.TestAnalyteTestResultActionForm.java
/** * <p>//from w w w. ja v a 2s . c o m * Set the value of an indexed property with the specified name. * </p> * * @param name * Name of the property whose value is to be set * @param index * Index of the property to be set * @param value * Value to which this property is to be set * * @exception ConversionException * if the specified value cannot be converted to the type * required for this property * @exception IllegalArgumentException * if there is no property of the specified name * @exception IllegalArgumentException * if the specified property exists, but is not indexed * @exception IndexOutOfBoundsException * if the specified index is outside the range of the * underlying property */ public void set(String name, int index, Object value) { //System.out //.println("I am in set(String name, int index, Object value) with " //+ name + " " + index + " " + value); Object prop = dynaValues.get(name); if (prop == null) { throw new NullPointerException("No indexed value for '" + name + "[" + index + "]'"); } else if (prop.getClass().isArray()) { Array.set(prop, index, value); } else if (prop instanceof List) { try { setAList(name, index, value); } catch (ClassCastException e) { //bugzilla 2154 LogEvent.logError("TestAnalyteTestResultActionForm", "set()", e.getMessage()); throw new ConversionException(e.getMessage()); } } else { throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]'"); } }
From source file:DigestUtils.java
/** * Converts a String or an array of character bytes representing hexidecimal * values into an array of bytes of those same values. The returned array will * be half the length of the passed String or array, as it takes two * characters to represent any given byte. An exception is thrown if the * passed char array has an odd number of elements. * /*from ww w . j av a 2s .co m*/ * @param object * A String or, an array of character bytes containing hexidecimal * digits * @return A byte array containing binary data decoded from the supplied byte * array (representing characters). * @throws DecoderException * Thrown if an odd number of characters is supplied to this * function or the object is not a String or char[] * @see #decodeHex(char[]) */ public Object decode(Object object) throws RuntimeException { try { char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; return decodeHex(charArray); } catch (ClassCastException e) { throw new RuntimeException(e.getMessage()); } }
From source file:DigestUtils.java
/** * Converts a String or an array of bytes into an array of characters * representing the hexidecimal values of each byte in order. The returned * array will be double the length of the passed String or array, as it takes * two characters to represent any given byte. * /* w w w .ja v a2s. co m*/ * @param object * a String, or byte[] to convert to Hex characters * @return A char[] containing hexidecimal characters * @throws EncoderException * Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) */ public Object encode(Object object) throws Exception { try { byte[] byteArray = object instanceof String ? ((String) object).getBytes() : (byte[]) object; return encodeHex(byteArray); } catch (ClassCastException e) { throw new RuntimeException(e.getMessage()); } }
From source file:com.github.jakubkolar.autobuilder.impl.NamedResolver.java
@Nullable @Override// w w w .j a v a 2s .c o m public <T> T resolve(Class<T> type, Optional<Type> typeInfo, String name, Collection<Annotation> annotations) { // If type is primitive like int.class, we must use its wrapper type // because the wrapper type is used as a part of the key in the namedValues // and also because int.class cannot be used in the end to 'unbox' the result // (same in BuiltInResolvers.primitiveTypeResolver, you would get ClassCastException) Class<T> wrappedType = Primitives.wrap(type); @SuppressWarnings("rawtypes") RegisteredValue rv = namedValues.get(ImmutablePair.of(name, (Class) wrappedType)); if (rv == null) { // TODO: try to lookup null, which this way applies to _any_ type rv = namedValues.get(ImmutablePair.of(name, (Class) null)); if (rv == null) { throw new UnsupportedOperationException(String.format( "There is no registered named value with name %s and type %s", name, type.getSimpleName())); } } for (Annotation requiredAnnotation : rv.getAnnotations()) { if (!annotations.contains(requiredAnnotation)) { throw new UnsupportedOperationException(String.format( "The named value with name %s and type %s requires annotations %s, " + "but only these annotations were present: %s", name, type.getSimpleName(), requiredAnnotation, annotations)); } } try { return wrappedType.cast(rv.getValue()); } catch (ClassCastException e) { throw new UnsupportedOperationException( String.format("Named value %s cannot be converted to the required type %s because of: %s", name, type.getSimpleName(), e.getMessage()), e); } }
From source file:com.xunlei.util.codec.Hex.java
/** * Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those same values. The returned array will be half the length of the passed String or * array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements. * /*from w ww. ja va 2 s .c o m*/ * @param object A String or, an array of character bytes containing hexadecimal digits * @return A byte array containing binary data decoded from the supplied byte array (representing characters). * @throws DecoderException Thrown if an odd number of characters is supplied to this function or the object is not a String or char[] * @see #decodeHex(char[]) */ public Object decode(Object object) throws DecoderException { try { char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; return decodeHex(charArray); } catch (ClassCastException e) { throw new DecoderException(e.getMessage(), e); } }