List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:de.clusteval.data.dataset.generator.DataSetGenerator.java
/** * Parses a dataset generator from string. * /* w w w . ja va 2 s.co m*/ * @param repository * the repository * @param dataSetGenerator * The simple name of the dataset generator class. * @return the clustering quality measure * @throws UnknownDataSetGeneratorException */ public static DataSetGenerator parseFromString(final Repository repository, String dataSetGenerator) throws UnknownDataSetGeneratorException { Class<? extends DataSetGenerator> c = repository.getRegisteredClass(DataSetGenerator.class, "de.clusteval.data.dataset.generator." + dataSetGenerator); try { DataSetGenerator generator = c.getConstructor(Repository.class, boolean.class, long.class, File.class) .newInstance(repository, false, System.currentTimeMillis(), new File(dataSetGenerator)); return generator; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NullPointerException e) { } catch (IllegalArgumentException e1) { e1.printStackTrace(); } catch (SecurityException e1) { e1.printStackTrace(); } catch (InvocationTargetException e1) { e1.printStackTrace(); } catch (NoSuchMethodException e1) { e1.printStackTrace(); } throw new UnknownDataSetGeneratorException( "\"" + dataSetGenerator + "\" is not a known dataset generator."); }
From source file:org.vuphone.wwatch.asterisk.AsteriskConnector.java
/** * This will call the specified user and play the specified file * //ww w . j av a2s. co m * @param user - The user to call. This must be a sip account. If it is not * an extension on the connected Asterisk server (trixbox), it * must contain the fully qualified host location. It may or may * not contain the prefix 'SIP/'. * Examples: juleswhite-1@pbxes.org * SIP/210@129.59.177.177 * * @param file - The audio file to play back to the user. The file type must * NOT be specified. The file must be located in * /var/lib/asterisk/sounds on the Asterisk server (trixbox), * and it must be of type .gsm * */ public static void makeCallPlayRecording(String user, String file) { ManagerConnectionFactory f = new ManagerConnectionFactory(SERVER, ADMIN_USERNAME, ADMIN_PASSWORD); ManagerConnection mc = f.createManagerConnection(); // Make sure that user includes the prefix 'SIP/' if (!user.startsWith("SIP/")) { user = "SIP/" + user; } OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); originateAction.setChannel(user); // This will set it to play back a pre-recorded message that is located // in /var/lib/asterisk/sounds on the Asterisk Server (trixbox) // The audio file must be of type .gsm. The four lines below and these // are mutually exclusive. originateAction.setApplication("Playback"); originateAction.setData(file); // This will set it to establish a call between the user above // and the destinationExtension given below. Note that this extension // must be one that resides on the trixbox you connected to above. // The two lines above and these are mutually exclusive. //String destinationExtension = "200"; //originateAction.setContext("default"); //originateAction.setExten(destinationExtension); //originateAction.setPriority(new Integer(1)); try { mc.login(); // send the originate action and wait for a maximum of 30 seconds for // Asterisk to send a reply originateResponse = mc.sendAction(originateAction, 30000); System.out.println(originateResponse.getResponse()); System.out.println(originateResponse.getMessage()); System.out.println(originateResponse.toString()); mc.logoff(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } catch (AuthenticationFailedException e) { e.printStackTrace(); } }
From source file:co.cask.cdap.gateway.util.Util.java
/** * Convert a byte array into its hex string representation. * * @param bytes the byte array to convert * @return A hex string representing the bytes */// w w w . j a va 2s. co m public static String toHex(byte[] bytes) { StringBuilder builder = new StringBuilder(bytes.length * 2); for (byte b : bytes) { try { builder.append(Character.forDigit(b >> 4 & 0x0F, 16)); builder.append(Character.forDigit(b & 0x0F, 16)); } catch (IllegalArgumentException e) { // odd, that should never happen e.printStackTrace(); } } return builder.toString(); }
From source file:com.netsteadfast.greenstep.base.model.SqlGenerateUtil.java
private static Object getPKvalue(Object entityObject) { Method[] methods = entityObject.getClass().getMethods(); if (methods == null) { return null; }//from www .j a v a2s .c o m Object value = null; for (int ix = 0; ix < methods.length && value == null; ix++) { Annotation[] annotations = methods[ix].getDeclaredAnnotations(); if (annotations == null) { continue; } for (Annotation annotation : annotations) { if (annotation instanceof Id) { if (methods[ix].getName().indexOf("get") == 0) { try { value = methods[ix].invoke(entityObject); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } } return value; }
From source file:com.netsteadfast.greenstep.base.model.SqlGenerateUtil.java
private static Map<String, Object> getUKParameter(Object entityObject) { Method[] methods = entityObject.getClass().getMethods(); if (methods == null) { return null; }//w w w. j a va 2 s . c o m Map<String, Object> ukMap = new HashMap<String, Object>(); for (int ix = 0; ix < methods.length; ix++) { Annotation[] annotations = methods[ix].getDeclaredAnnotations(); if (annotations == null) { continue; } for (Annotation annotation : annotations) { if (annotation instanceof EntityUK) { if (methods[ix].getName().indexOf("get") == 0) { for (int nx = 0; nx < annotations.length; nx++) { if (annotations[nx] instanceof Column) { try { ukMap.put(((Column) annotations[nx]).name(), methods[ix].invoke(entityObject)); nx = annotations.length; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } } } } return ukMap; }
From source file:org.apache.calcite.adapter.geode.util.GeodeUtils.java
private static Object handleStructEntry(List<RelDataTypeField> relDataTypeFields, Object obj) { Struct struct = (Struct) obj; Object[] values = new Object[relDataTypeFields.size()]; int index = 0; for (RelDataTypeField relDataTypeField : relDataTypeFields) { Type javaType = JAVA_TYPE_FACTORY.getJavaClass(relDataTypeField.getType()); Object rawValue;//from ww w . j a v a2 s .co m try { rawValue = struct.get(relDataTypeField.getName()); } catch (IllegalArgumentException e) { rawValue = "<error>"; System.err.println("Could find field : " + relDataTypeField.getName()); e.printStackTrace(); } values[index++] = convert(rawValue, (Class) javaType); } if (values.length == 1) { return values[0]; } return values; }
From source file:org.apache.marmotta.commons.sesame.facading.util.FacadeUtils.java
/** * Transform a value passed as string to the base type (i.e. non-complex type) given as argument * * @param <T>//from w ww . j a va 2 s. c om * @param value * @param returnType * @return * @throws IllegalArgumentException */ @SuppressWarnings("unchecked") public static <T> T transformToBaseType(String value, Class<T> returnType) throws IllegalArgumentException { // transformation to appropriate primitive type /* * README: the "dirty" cast: "(T) x" instead of "returnType.cast(x)" is required since * .cast does not work for primitive types (int, double, float, etc...). * Somehow it results in a ClassCastException */ if (Integer.class.equals(returnType) || int.class.equals(returnType)) { if (value == null) { return (T) (Integer) (0); } return (T) (Integer.decode(value)); } else if (Long.class.equals(returnType) || long.class.equals(returnType)) { if (value == null) { return (T) (Long) (0L); } return (T) (Long.decode(value)); } else if (Double.class.equals(returnType) || double.class.equals(returnType)) { if (value == null) { return (T) (Double) (0.0); } return (T) (Double.valueOf(value)); } else if (Float.class.equals(returnType) || float.class.equals(returnType)) { if (value == null) { return (T) (Float) (0.0F); } return (T) (Float.valueOf(value)); } else if (Byte.class.equals(returnType) || byte.class.equals(returnType)) { if (value == null) { return (T) (Byte) ((byte) 0); } return (T) (Byte.decode(value)); } else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) { return (T) (Boolean.valueOf(value)); } else if (Character.class.equals(returnType) || char.class.equals(returnType)) { if (value == null) { if (Character.class.equals(returnType)) { return null; } else { return (T) new Character((char) 0); } } else if (value.length() > 0) { return (T) (Character) (value.charAt(0)); } else { return null; } } else if (Locale.class.equals(returnType)) { if (value == null) { return null; } else { return returnType.cast(LocaleUtils.toLocale(value)); } } else if (Date.class.equals(returnType)) { if (value == null) { return null; } else { try { return returnType.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(value).toDate()); } catch (final IllegalArgumentException e) { e.printStackTrace(); return null; } } } else if (DateTime.class.equals(returnType)) { if (value == null) { return null; } else { try { return returnType.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(value)); } catch (final IllegalArgumentException e) { e.printStackTrace(); return null; } } } else if (String.class.equals(returnType)) { return returnType.cast(value); } else { throw new IllegalArgumentException( "primitive type " + returnType.getName() + " not supported by transformation"); } }
From source file:edu.mit.csail.sdg.alloy4.Terminal.java
static boolean getBoolean(Field f, Object obj) { f.setAccessible(true);//from ww w . j a v a 2s .c o m try { return (Boolean) f.get(obj); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
From source file:jp.go.nict.langrid.p2pgridbasis.data.langrid.converter.ConvertUtil.java
public static void decode(DataAttributes from, Object to) throws DataConvertException { setLangridConverter();//from w ww .j a v a 2 s . c o m logger.debug("##### decode #####"); try { for (PropertyDescriptor descriptor : PropertyUtils.getPropertyDescriptors(to)) { logger.debug( "Name : " + descriptor.getName() + " / PropertyType : " + descriptor.getPropertyType()); Object value = from.getValue(descriptor.getName()); if (PropertyUtils.isWriteable(to, descriptor.getName()) && value != null) { //Write OK try { Converter converter = ConvertUtils.lookup(descriptor.getPropertyType()); if (!ignoreProps.contains(descriptor.getName())) { if (converter == null) { logger.error("no converter is registered : " + descriptor.getName() + " " + descriptor.getPropertyType()); } else { Object obj = converter.convert(descriptor.getPropertyType(), value); PropertyUtils.setProperty(to, descriptor.getName(), obj); } } } catch (IllegalArgumentException e) { e.printStackTrace(); logger.info(e.getMessage()); } catch (NoSuchMethodException e) { logger.info(e.getMessage()); } } else { if (value != null) { //Write NG logger.debug("isWriteable = false"); } else { //Write NG logger.debug("value = null"); } } } } catch (IllegalAccessException e) { throw new DataConvertException(e); } catch (InvocationTargetException e) { throw new DataConvertException(e); } }
From source file:com.xlythe.engine.theme.Theme.java
@SuppressWarnings("rawtypes") public static void buildResourceMap(Class r) { RES_MAP = new SparseArray<Theme.Res>(); try {/* w w w.j a v a 2s .c o m*/ Log.d("Theme", "Building resource map"); Class color = Class.forName(r.getName() + "$color"); for (Field f : color.getFields()) { RES_MAP.put(f.getInt(null), new Res(COLOR, f.getName())); } Log.d("Theme", "color loaded"); Class drawable = Class.forName(r.getName() + "$drawable"); for (Field f : drawable.getFields()) { RES_MAP.put(f.getInt(null), new Res(DRAWABLE, f.getName())); } Log.d("Theme", "drawable loaded"); Class bool = Class.forName(r.getName() + "$bool"); for (Field f : bool.getFields()) { RES_MAP.put(f.getInt(null), new Res(BOOLEAN, f.getName())); } Log.d("Theme", "bool loaded"); Class raw = Class.forName(r.getName() + "$raw"); for (Field f : raw.getFields()) { RES_MAP.put(f.getInt(null), new Res(RAW, f.getName())); } Log.d("Theme", "raw loaded"); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { // Do nothing here } }