List of usage examples for java.lang IllegalAccessException toString
public String toString()
From source file:uk.co.modularaudio.util.hibernate.ReflectionUtils.java
public static void copyOverGetAttributes(final Class<?> interfaceListingAttributes, final Object src, final Object dest) throws DatastoreException { try {/*from w w w . j a v a2 s . c o m*/ final Method methods[] = interfaceListingAttributes.getMethods(); for (int i = 0; i < methods.length; i++) { final Method getMethod = methods[i]; final String methodName = getMethod.getName(); if (methodName.startsWith("get")) { final Class<?> returnType = getMethod.getReturnType(); final Object result = getMethod.invoke(src); final String setMethodName = methodName.replaceFirst("get", "set"); final Method setMethod = interfaceListingAttributes.getDeclaredMethod(setMethodName, new Class[] { returnType }); setMethod.invoke(dest, result); } } } catch (final IllegalAccessException iae) { throw new DatastoreException("iae: " + iae.toString()); } catch (final InvocationTargetException ite) { throw new DatastoreException("ite: " + ite.toString()); } catch (final NoSuchMethodException nsme) { throw new DatastoreException("nsme: " + nsme.toString()); } }
From source file:au.com.cybersearch2.classyjpa.entity.ObjectMonitor.java
/** * Merge entity objects. Performs copy using reflection. * @param dest Entity to be updated/* www . j av a 2s . com*/ * @param orig Source entity */ private static <T> void mergeObjects(T dest, T orig) { try { PropertyUtils.copyProperties(dest, orig); } catch (IllegalAccessException e) { throw createReflectionErrorException("refresh", e.toString()); } catch (InvocationTargetException e) { throw createReflectionErrorException("refresh", e.getCause() == null ? e.toString() : e.getCause().toString()); } catch (NoSuchMethodException e) { throw createReflectionErrorException("refresh", e.toString()); } }
From source file:BeanUtility.java
/** This method takes a JavaBean and generates a standard toString() type result for it. * @param o JavaBean object to stringinate * @return STRINGIATION! Stringingating the countryside. Stringinating all the peasants. */// w ww . j av a 2 s .c om public static String beanToString(Object o) { StringBuffer result = new StringBuffer(); if (o == null) return "--- null"; result.append("--- begin"); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\r\n"); try { PropertyDescriptor[] pds = Introspector.getBeanInfo(o.getClass()).getPropertyDescriptors(); for (int pdi = 0; pdi < pds.length; pdi++) { try { result.append( "Property: " + pds[pdi].getName() + " Value: " + pds[pdi].getReadMethod().invoke(o)); } catch (IllegalAccessException iae) { result.append("Property: " + pds[pdi].getName() + " (Illegal Access to Value) "); } catch (InvocationTargetException iae) { result.append( "Property: " + pds[pdi].getName() + " (InvocationTargetException) " + iae.toString()); } catch (Exception e) { result.append("Property: " + pds[pdi].getName() + " (Other Exception )" + e.toString()); } result.append("\r\n"); } } catch (IntrospectionException ie) { result.append("Introspection Exception: " + ie.toString()); result.append("\r\n"); } result.append("--- end "); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\n"); return result.toString(); }
From source file:com.github.rcaller.util.RCodeUtils.java
public static void addRespectToType(StringBuffer rCode, String name, Object o, boolean useEquals) { if (o instanceof double[]) { RCodeUtils.addDoubleArray(rCode, name, (double[]) o, useEquals); } else if (o instanceof int[]) { RCodeUtils.addIntArray(rCode, name, (int[]) o, useEquals); } else if (o instanceof float[]) { RCodeUtils.addFloatArray(rCode, name, (float[]) o, useEquals); } else if (o instanceof boolean[]) { RCodeUtils.addLogicalArray(rCode, name, (boolean[]) o, useEquals); } else if (o instanceof long[]) { RCodeUtils.addLongArray(rCode, name, (long[]) o, useEquals); } else if (o instanceof String[]) { RCodeUtils.addStringArray(rCode, name, (String[]) o, useEquals); } else if (o instanceof short[]) { RCodeUtils.addShortArray(rCode, name, (short[]) o, useEquals); } else if (o instanceof Double) { RCodeUtils.addDouble(rCode, name, (Double) o, useEquals); } else if (o instanceof Integer) { RCodeUtils.addInt(rCode, name, (Integer) o, useEquals); } else if (o instanceof Long) { RCodeUtils.addLong(rCode, name, (Long) o, useEquals); } else if (o instanceof Short) { RCodeUtils.addShort(rCode, name, (Short) o, useEquals); } else if (o instanceof String) { RCodeUtils.addString(rCode, name, (String) o, useEquals); } else if (o instanceof double[][]) { RCodeUtils.addDoubleMatrix(rCode, name, (double[][]) o, useEquals); } else if (o instanceof LanguageElement) { RCodeUtils.addValue(rCode, name, ((LanguageElement) o).getObjectName(), useEquals); } else if (o instanceof DataFrame) { RCodeUtils.addDataFrame(rCode, name, (DataFrame) o); } else if (o != null) { try {//w w w . j a va2 s. c o m rCode.append(JavaObject.ConvertToRCode(name, o, /*useList=no*/false, useEquals)); } catch (IllegalAccessException iae) { throw new ExecutionException("Cannot convert Java object " + o.toString() + " in type of " + o.getClass().getCanonicalName() + " to R code due to " + iae.toString()); } } }
From source file:org.lsc.beans.LscBean.java
/** * Set a bean from an LDAP entry/*w w w .j a va 2s . co m*/ * * @param entry * the LDAP entry * @param baseDn * the base Dn used to set the right Dn * @param c * class to instantiate * @return the bean * @throws NamingException * thrown if a directory exception is encountered while looking * at the entry */ public static LscBean getInstance(final SearchResult entry, final String baseDn, final Class<?> c) throws NamingException { try { if (entry != null) { LscBean ab = (LscBean) c.newInstance(); String dn = entry.getName(); if ((dn.length() > 0) && (dn.charAt(0) == '"') && (dn.charAt(dn.length() - 1) == '"')) { dn = dn.substring(1, dn.length() - 1); } if (dn.startsWith("ldap://")) { ab.setDistinguishName(entry.getNameInNamespace()); } else { // Manually concat baseDn because getNameInNamespace returns // a differently escaped DN, causing LSC to detect a MODRDN if ((baseDn != null) && (baseDn.length() > 0)) { if (dn.length() > 0) { ab.setDistinguishName(dn + "," + baseDn); } else { ab.setDistinguishName(baseDn); } } else { ab.setDistinguishName(dn); } } NamingEnumeration<?> ne = entry.getAttributes().getAll(); while (ne.hasMore()) { ab.setAttribute((Attribute) ne.next()); } return ab; } else { return null; } } catch (InstantiationException ie) { LOGGER.error(ie.toString()); LOGGER.debug(ie.toString(), ie); } catch (IllegalAccessException iae) { LOGGER.error(iae.toString()); LOGGER.debug(iae.toString(), iae); } return null; }
From source file:com.alvermont.javascript.tools.shell.ShellMain.java
private static Script loadCompiledScript(Context cx, String path, Object securityDomain) { final byte[] data = (byte[]) readFileOrUrl(path, false); if (data == null) { exitCode = EXITCODE_FILE_NOT_FOUND; return null; }/* w w w .j a v a 2s .c o m*/ // XXX: For now extract class name of compiled Script from path // instead of parsing class bytes int nameStart = path.lastIndexOf('/'); if (nameStart < 0) { nameStart = 0; } else { ++nameStart; } int nameEnd = path.lastIndexOf('.'); if (nameEnd < nameStart) { // '.' does not exist in path (nameEnd < 0) // or it comes before nameStart nameEnd = path.length(); } final String name = path.substring(nameStart, nameEnd); try { final GeneratedClassLoader loader = SecurityController.createLoader(cx.getApplicationClassLoader(), securityDomain); final Class clazz = loader.defineClass(name, data); loader.linkClass(clazz); if (!Script.class.isAssignableFrom(clazz)) { throw Context.reportRuntimeError("msg.must.implement.Script"); } return (Script) clazz.newInstance(); } catch (RhinoException rex) { ToolErrorReporter.reportException(cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (IllegalAccessException iaex) { exitCode = EXITCODE_RUNTIME_ERROR; Context.reportError(iaex.toString()); } catch (InstantiationException inex) { exitCode = EXITCODE_RUNTIME_ERROR; Context.reportError(inex.toString()); } return null; }
From source file:com.kangdainfo.common.util.BeanUtil.java
/** This method takes a JavaBean and generates a standard toString() type result for it. * @param o JavaBean object to stringinate * @return STRINGIATION! Stringingating the countryside. Stringinating all the peasants. *///w w w .j av a 2 s .c om public static String beanToString(Object o) { StringBuffer result = new StringBuffer(); if (o == null) { return "--- null"; } result.append("--- begin"); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\r\n"); try { PropertyDescriptor[] pds = Introspector.getBeanInfo(o.getClass()).getPropertyDescriptors(); for (int pdi = 0; pdi < pds.length; pdi++) { try { result.append( "Property: " + pds[pdi].getName() + " Value: " + pds[pdi].getReadMethod().invoke(o)); } catch (IllegalAccessException iae) { result.append("Property: " + pds[pdi].getName() + " (Illegal Access to Value) "); } catch (InvocationTargetException iae) { result.append( "Property: " + pds[pdi].getName() + " (InvocationTargetException) " + iae.toString()); } catch (Exception e) { result.append("Property: " + pds[pdi].getName() + " (Other Exception )" + e.toString()); } result.append("\r\n"); } } catch (IntrospectionException ie) { result.append("Introspection Exception: " + ie.toString()); result.append("\r\n"); } result.append("--- end "); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\n"); return result.toString(); }
From source file:nc.noumea.mairie.annuairev2.saisie.viewmodel.ContainsSimpleListModel.java
@Override public boolean inSubModel(Object key, Object value) { String searchString = (String) key; if (StringUtils.isEmpty(searchString)) return true; try {/*from w w w. j a v a 2 s .c o m*/ return StringUtils.containsIgnoreCase(field.get(value).toString(), searchString); } catch (IllegalAccessException e) { LOGGER.error(e.toString(), e); return false; } }
From source file:volumesculptor.shell.Main.java
private static Script loadCompiledScript(Context cx, String path, byte[] data, Object securityDomain) throws FileNotFoundException { if (data == null) { throw new FileNotFoundException(path); }//w w w . j av a 2 s . c o m // XXX: For now extract class name of compiled Script from path // instead of parsing class bytes int nameStart = path.lastIndexOf('/'); if (nameStart < 0) { nameStart = 0; } else { ++nameStart; } int nameEnd = path.lastIndexOf('.'); if (nameEnd < nameStart) { // '.' does not exist in path (nameEnd < 0) // or it comes before nameStart nameEnd = path.length(); } String name = path.substring(nameStart, nameEnd); try { GeneratedClassLoader loader = SecurityController.createLoader(cx.getApplicationClassLoader(), securityDomain); Class<?> clazz = loader.defineClass(name, data); loader.linkClass(clazz); if (!Script.class.isAssignableFrom(clazz)) { throw Context.reportRuntimeError("msg.must.implement.Script"); } return (Script) clazz.newInstance(); } catch (IllegalAccessException iaex) { Context.reportError(iaex.toString()); throw new RuntimeException(iaex); } catch (InstantiationException inex) { Context.reportError(inex.toString()); throw new RuntimeException(inex); } }
From source file:com.parrot.cyclops.CameraView.java
private void setVoutVideoView(boolean vout) { try {//from w ww . j a v a 2s . c o m // If a window of SurfaceView has a title VoutVideoView // than the surface wont be destroyed by WindowManagerService // while video is playing on external screen in background mode. String title = vout ? "VoutVideoView" : "VideoView"; logdebug("set title to SurfaceView: " + title); mSetTitleMethod.invoke(this, title); } catch (IllegalAccessException e) { Log.e(TAG, e.toString()); } catch (InvocationTargetException e) { Log.e(TAG, e.toString()); } }