List of usage examples for java.lang ClassCastException getMessage
public String getMessage()
From source file:com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil.java
public static <T> Set<T> getSetProperty(Node node, String name) { try {/*from w ww .j av a2s.c o m*/ if (node == null) { throw new IllegalArgumentException("Cannot set a property on a null-node!"); } if (name == null) { throw new IllegalArgumentException("Cannot set a property without a provided name"); } if (node.hasProperty(name)) { Set<T> result = new HashSet<T>((Collection<T>) getProperty(node, name)); return result; } else { return Collections.emptySet(); } } catch (ClassCastException e) { throw new MetadataRepositoryException("Wrong property data type for set", e); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to get set property: " + name, e); } }
From source file:com.xunlei.util.codec.Hex.java
/** * Converts a String or an array of bytes into an array of characters representing the hexadecimal 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. * <p>//from w ww. jav a 2s . co m * The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by {@link #getCharsetName()}. * </p> * * @param object a String, or byte[] to convert to Hex characters * @return A char[] containing hexadecimal characters * @throws EncoderException Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) */ public Object encode(Object object) throws EncoderException { try { byte[] byteArray = object instanceof String ? ((String) object).getBytes(getCharsetName()) : (byte[]) object; return encodeHex(byteArray); } catch (ClassCastException e) { throw new EncoderException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { throw new EncoderException(e.getMessage(), e); } }
From source file:com.espertech.esper.event.map.TestMapEventType.java
public void testGetGetter() { SupportBean nestedSupportBean = new SupportBean(); nestedSupportBean.setIntPrimitive(100); SupportBeanComplexProps complexPropBean = SupportBeanComplexProps.makeDefaultBean(); assertEquals(null, eventType.getGetter("dummy")); Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put("myInt", 20); valuesMap.put("myString", "a"); valuesMap.put("mySupportBean", nestedSupportBean); valuesMap.put("myComplexBean", complexPropBean); valuesMap.put("myNullableSupportBean", null); valuesMap.put("myNullableString", null); EventBean eventBean = new MapEventBean(valuesMap, eventType); EventPropertyGetter getter = eventType.getGetter("myInt"); assertEquals(20, getter.get(eventBean)); getter = eventType.getGetter("myString"); assertEquals("a", getter.get(eventBean)); getter = eventType.getGetter("myNullableString"); assertNull(getter.get(eventBean));/*from w w w . j a va 2 s .co m*/ getter = eventType.getGetter("mySupportBean"); assertEquals(nestedSupportBean, getter.get(eventBean)); getter = eventType.getGetter("mySupportBean.intPrimitive"); assertEquals(100, getter.get(eventBean)); getter = eventType.getGetter("myNullableSupportBean.intPrimitive"); assertNull(getter.get(eventBean)); getter = eventType.getGetter("myComplexBean.nested.nestedValue"); assertEquals("nestedValue", getter.get(eventBean)); try { eventBean = SupportEventBeanFactory.createObject(new Object()); getter.get(eventBean); assertTrue(false); } catch (ClassCastException ex) { // Expected log.debug(".testGetGetter Expected exception, msg=" + ex.getMessage()); } }
From source file:org.apache.jcs.auxiliary.lateral.socket.tcp.discovery.UDPDiscoveryReceiver.java
/** Main processing method for the LateralUDPReceiver object */ public void run() { try {/*from w w w . j av a 2 s .co m*/ while (!shutdown) { Object obj = waitForMessage(); // not thread safe, but just for debugging cnt++; if (log.isDebugEnabled()) { log.debug(getCnt() + " messages received."); } UDPDiscoveryMessage message = null; try { message = (UDPDiscoveryMessage) obj; // check for null if (message != null) { MessageHandler handler = new MessageHandler(message); pooledExecutor.execute(handler); if (log.isDebugEnabled()) { log.debug("Passed handler to executor."); } } else { log.warn("message is null"); } } catch (ClassCastException cce) { log.warn("Received unknown message type " + cce.getMessage()); } } // end while } catch (Exception e) { log.error("Unexpected exception in UDP receiver.", e); try { Thread.sleep(100); // TODO consider some failure count so we don't do this // forever. } catch (Exception e2) { log.error("Problem sleeping", e2); } } return; }
From source file:jatools.component.chart.customizer.Tabs.java
/** * DOCUMENT ME!/*from w w w . ja va 2 s .c o m*/ * * @param cb * DOCUMENT ME! */ public final void setChart(JFreeChart chart, int type) { try { /* * chartBean = (ChartBean) cb; chart = chartBean.getChart(); */ this.chart = chart; } catch (java.lang.ClassCastException e) { System.out.println("oops!"); System.out.println("this is not a javachart bean!"); System.out.println("it's " + e.getMessage()); return; } initializeCustomizer(type); }
From source file:com.seal.ui.fragments.StartPageFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!mInitialized) { try {/*from w ww .j a va 2 s.c o m*/ mUIManager = ((SealBrowserActivity) activity).getUIManager(); } catch (ClassCastException e) { Log.e("StartPageFragment.onAttach()", e.getMessage()); } mInitialized = true; } }
From source file:jatools.component.chart.customizer.Tabs.java
/** * DOCUMENT ME!/*from w w w .java 2s . c o m*/ * * @param javachart DOCUMENT ME! */ public void setJavaChart(Chart javachart, int type) { try { /* * chartBean = (ChartBean) cb; chart = chartBean.getChart(); */ this.javachart = javachart; this.chart = javachart.chart; } catch (java.lang.ClassCastException e) { System.out.println("oops!"); System.out.println("this is not a javachart bean!"); System.out.println("it's " + e.getMessage()); return; } initializeCustomizer(type); }
From source file:com.github.restdriver.matchers.HasJsonPath.java
@Override public boolean matchesSafely(JsonNode jsonNode) { Object jsonPathResult = null; try {//from w w w . j a v a 2 s . c o m jsonPathResult = JsonPath.read(jsonNode.toString(), jsonPath); if (matcher == null) { return jsonPathResult != null; } boolean initialMatchResult = matcher.matches(jsonPathResult); // if matcher is for longs and jsonPath returns an integer, do our best if (!initialMatchResult && jsonPathResult instanceof Integer) { return matcher.matches(intToLong(jsonPathResult)); } return initialMatchResult; } catch (InvalidPathException e) { return false; } catch (ClassCastException cce) { if (matcher.matches(intToLong(jsonPathResult))) { return true; } else { throw new RuntimeJsonTypeMismatchException( "JSONpath returned a type unsuitable for matching with the given matcher: " + cce.getMessage(), cce); } } }
From source file:edu.umich.flowfence.service.KVSSharedPrefs.java
/** * Wrap a {@link ClassCastException} to be thrown across the wire. * @param cce The ClassCastException to wrap. * @return An exception capable of being handled by {@link android.os.Parcel#writeException(Exception)}. *//*from www. j a v a 2 s . c om*/ private RuntimeException wrapClassCast(final ClassCastException cce) { return new IllegalArgumentException(cce.getMessage()); }
From source file:com.microsoft.rightsmanagement.ui.PolicyPickerActivity.java
/** * Retrieve data from intent.//from w w w .j a va 2 s .com * * @param bundle the bundle * @return the UI policy pick orientation info. */ private void parseBundleInput(Bundle bundle) { if (bundle.containsKey(REQUEST_ORIGINAL_TEMPLATE_DESCRIPTOR_ITEM)) { Logger.d(TAG, "parseBundleInput - parsing OriginalTemplateDescriptorItem"); Parcelable requestOriginalTemplateDescriptor = bundle .getParcelable(PolicyPickerActivity.REQUEST_ORIGINAL_TEMPLATE_DESCRIPTOR_ITEM); if (requestOriginalTemplateDescriptor != null) { Logger.ie(TAG, "requestOriginalTemplateDescriptor is null"); } try { mOriginalTemplateDescriptorItem = (TemplateDescriptorModel) requestOriginalTemplateDescriptor; } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); throw ex; } } if (bundle.containsKey(REQUEST_TEMPLATE_DESCRIPTOR_ITEM_ARRAY)) { Logger.d(TAG, "parseBundleInput - parsing TemplateDescriptorItemArray"); Parcelable[] requestArray = bundle .getParcelableArray(PolicyPickerActivity.REQUEST_TEMPLATE_DESCRIPTOR_ITEM_ARRAY); try { Object[] requestObjectArray = requestArray; mTemplateDescriptorItemArray = Arrays.copyOf(requestObjectArray, requestObjectArray.length, TemplateDescriptorModel[].class); } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); throw ex; } } if (bundle.containsKey(REQUEST_CALLBACK_ID)) { Logger.d(TAG, "parseBundleInput - parsing RequestCallbackId"); mRequestCallbackId = bundle.getInt(REQUEST_CALLBACK_ID); } if (bundle.containsKey(CURRENT_SELECTED_TEMPLATE_DESCRIPTOR_INDEX)) { Logger.d(TAG, "parseBundleInput - parsing CurrentSelectedtemplateDescriptorItemIndex"); mCurrentSelectedtemplateDescriptorItemIndex = bundle.getInt(CURRENT_SELECTED_TEMPLATE_DESCRIPTOR_INDEX); } }