List of usage examples for java.lang String getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.vulpe.model.dao.impl.jpa.VulpeBaseDAOJPA.java
private void mountParameters(final ENTITY entity, final Map<String, Object> params, final String parent) { final List<Field> fields = VulpeReflectUtil.getFields(entity.getClass()); if (StringUtils.isNotEmpty(entity.getAutocomplete())) { try {//from w w w. j av a2s .c o m if (entity.getId() != null) { params.put("id", entity.getId()); } else { final String[] autocompleteParts = entity.getAutocomplete().split(","); if (autocompleteParts.length > 1) { for (final String autocomplete : autocompleteParts) { final String value = "[like]%" + entity.getAutocompleteTerm() + "%"; params.put(autocomplete, value); } } else { final String value = "[like]%" + entity.getAutocompleteTerm() + "%"; params.put(entity.getAutocomplete(), value); } } } catch (Exception e) { throw new VulpeSystemException(e); } } else { for (final Field field : fields) { if ((field.isAnnotationPresent(SkipAutoFilter.class) || field.isAnnotationPresent(Transient.class) || Modifier.isTransient(field.getModifiers())) && !field.isAnnotationPresent(QueryParameter.class)) { continue; } try { Object value = PropertyUtils.getProperty(entity, field.getName()); Class<?> valueClass = PropertyUtils.getPropertyType(entity, field.getName()); if (VulpeEntity.class.isAssignableFrom(valueClass)) { final ManyToOne manyToOne = field.getAnnotation(ManyToOne.class); final QueryParameter queryParameter = field.getAnnotation(QueryParameter.class); final String paramName = (StringUtils.isNotEmpty(parent) ? parent + "." : "") + (queryParameter != null && StringUtils.isNotEmpty(queryParameter.value()) ? "_" + queryParameter.value() : field.getName()); if (value != null) { if (manyToOne != null || (queryParameter != null && StringUtils.isNotEmpty(queryParameter.value()))) { if (!value.getClass().getSimpleName().contains(CGLIB_ENHANCER)) { mountParameters((ENTITY) value, params, paramName); } } else if (isNotEmpty(value)) { params.put(paramName, value); } } } else if (value instanceof Collection) { final OneToMany oneToMany = field.getAnnotation(OneToMany.class); final String paramName = (StringUtils.isNotEmpty(parent) ? parent + "." : "") + field.getName(); if (oneToMany != null) { for (final ENTITY item : (Collection<ENTITY>) value) { mountParameters(item, params, paramName); } } } else if (isNotEmpty(value)) { final QueryParameter queryParameter = field.getAnnotation(QueryParameter.class); String alias = StringUtils.isNotEmpty(parent) ? parent + "." : ""; StringBuilder paramName = new StringBuilder(alias); String fieldName = field.getName(); if (queryParameter != null) { if (queryParameter.fake() && StringUtils.isNotEmpty(queryParameter.value())) { fieldName = "!" + fieldName; } else if (StringUtils.isNotEmpty(queryParameter.value()) && queryParameter.type().equals(TypeParameter.DATE)) { value = new String(queryParameter.value().replaceAll(" ", "").replace(":value", new SimpleDateFormat(queryParameter.pattern()).format(value))); } } paramName.append(fieldName); final Like like = field.getAnnotation(Like.class); if (like != null) { if (like.type().equals(LikeType.BEGIN)) { value = value + "%"; } else if (like.type().equals(LikeType.END)) { value = "%" + value; } else { value = "%" + value + "%"; } value = "[like]" + value; } params.put(paramName.toString(), value); } } catch (Exception e) { throw new VulpeSystemException(e); } } } }
From source file:com.sun.j2ee.blueprints.taglibs.smart.ClientStateTag.java
public int doEndTag() throws JspTagException { if (imageURL == null && buttonText == null) { throw new JspTagException( "ClientStateTag error: either an " + "imageURL or buttonText attribute must be specified."); }//from w ww. ja va 2s . co m HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); StringBuffer buffer = new StringBuffer(); buffer.append("<form method=\"POST\" action=\"" + targetURL + "\">"); // insert any parameters that may have been added via sub tags if (parameters != null) { Iterator it = parameters.keySet().iterator(); // put the request attributes stored in the session in the request while (it.hasNext()) { String key = (String) it.next(); String value = (String) parameters.get(key); buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + value + "\" />"); } } String fullURL = request.getRequestURI(); // find the url that sent us this page String targetURL = null; int lastPathSeparator = fullURL.lastIndexOf("/") + 1; if (lastPathSeparator != -1) { targetURL = fullURL.substring(lastPathSeparator, fullURL.length()); } buffer.append(" <input type=\"hidden\" name=\"referring_URL\"" + "value=\"" + targetURL + "\">"); String referringScreen = (String) request.getSession().getAttribute(WebKeys.PREVIOUS_SCREEN); buffer.append(" <input type=\"hidden\" name=\"referring_screen\"" + "value=\"" + referringScreen + "\">"); buffer.append(" <input type=\"hidden\" name=\"cacheId\"" + "value=\"" + cacheId + "\">"); // check the request for previous parameters Map params = (Map) request.getParameterMap(); if (!params.isEmpty() && encodeRequestParameters) { Iterator it = params.entrySet().iterator(); // copy in the request parameters stored while (it.hasNext()) { Entry entry = (Entry) it.next(); String key = (String) entry.getKey(); if (!key.startsWith(cacheId)) { String[] values = (String[]) entry.getValue(); String valueString = values[0]; buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + valueString + "\" />"); } } } /** * Now serialize the request attributes into the page (only sealizable objects are going * to be processed). */ if (encodeRequestAttributes) { // put the request attributes into tattributres Enumeration enumeration = request.getAttributeNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); // check if we have already serialized the items // also don't serialize javax items because if (!key.startsWith(cacheId) && !key.startsWith("javax.servlet")) { Object value = request.getAttribute(key); if (serializableClass == null) { try { serializableClass = Class.forName("java.io.Serializable"); } catch (java.lang.ClassNotFoundException cnf) { logger.error("ClientStateTag caught: ", cnf); } } // check if seralizable if (serializableClass.isAssignableFrom(value.getClass())) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos); out.writeObject(value); out.close(); buffer.append(" <input type=\"hidden\" name=\"" + cacheId + "_attribute_" + key + "\" value=\"" + new String(Base64.encode(bos.toByteArray()), "ISO-8859-1") + "\" />"); } catch (java.io.IOException iox) { logger.error("ClientStateTag caught: ", iox); } } else { logger.info(key + " not to Serializeable"); } } } } // end get attributes // now put the link in if (imageURL != null) { buffer.append(" <input alt=\"" + altText + "\" type=\"image\" " + "src=\"" + imageURL + "\"/>"); } else { buffer.append(" <input alt=\"" + altText + "\" type=\"submit\" " + "value=\"" + buttonText + "\"/>"); } buffer.append("</form>"); // write the output to the output stream try { JspWriter out = pageContext.getOut(); out.print(buffer.toString()); } catch (IOException ioe) { logger.error("ClientStateTag: Problems with writing...", ioe); } // reset everything parameters = null; altText = ""; buttonText = null; imageURL = null; cacheId = null; targetURL = null; encodeRequestAttributes = true; encodeRequestParameters = true; serializableClass = null; return EVAL_PAGE; }
From source file:ar.edu.unicen.exa.aop.aopetstore.waf.view.taglibs.smart.ClientStateTag.java
public int doEndTag() throws JspTagException { HttpServletRequest request = ((HttpServletRequest) pageContext.getRequest()); StringBuffer buffer = new StringBuffer(); buffer.append("<form method=\"POST\" action=\"" + targetURL + "\">"); // insert any parameters that may have been added via sub tags if (parameters != null) { Iterator<String> it = parameters.keySet().iterator(); // put the request attributes stored in the session in the request while (it.hasNext()) { String key = it.next(); String value = parameters.get(key); buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + value + "\" />"); }/* w w w . ja v a 2 s . co m*/ } String fullURL = request.getRequestURI(); // find the url that sent us this page String targetURL = null; int lastPathSeparator = fullURL.lastIndexOf("/") + 1; if (lastPathSeparator != -1) { targetURL = fullURL.substring(lastPathSeparator, fullURL.length()); } buffer.append(" <input type=\"hidden\" name=\"referring_URL\"" + "value=\"" + targetURL + "\">"); String referringScreen = (String) request.getSession().getAttribute(WebKeys.PREVIOUS_SCREEN); buffer.append(" <input type=\"hidden\" name=\"referring_screen\"" + "value=\"" + referringScreen + "\">"); buffer.append(" <input type=\"hidden\" name=\"cacheId\"" + "value=\"" + cacheId + "\">"); // check the request for previous parameters Map<?, ?> params = (Map<?, ?>) request.getParameterMap(); if (!params.isEmpty() && encodeRequestParameters) { Iterator<?> it = params.keySet().iterator(); // copy in the request parameters stored while (it.hasNext()) { String key = (String) it.next(); if (!key.startsWith(cacheId)) { String[] values = (String[]) params.get(key); String valueString = values[0]; buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + valueString + "\" />"); } } } /** * Now serialize the request attributes into the page (only sealizable objects are going * to be processed). */ if (encodeRequestAttributes) { // put the request attributes into tattributres Enumeration<?> myEnumeration = request.getAttributeNames(); while (myEnumeration.hasMoreElements()) { String key = (String) myEnumeration.nextElement(); // check if we have already serialized the items // also don't serialize javax items because if (!key.startsWith(cacheId) && !key.startsWith("javax.servlet")) { Object value = request.getAttribute(key); if (serializableClass == null) { try { getClass(); serializableClass = Class.forName("java.io.Serializable"); } catch (java.lang.ClassNotFoundException cnf) { System.err.println("ClientStateTag caught: " + cnf); } } // check if seralizable if (serializableClass.isAssignableFrom(value.getClass())) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos); out.writeObject(value); out.close(); buffer.append(" <input type=\"hidden\" name=\"" + cacheId + "_attribute_" + key + "\" value=\"" + new String(Base64.encodeBase64(bos.toByteArray()), "ISO-8859-1") + "\" />"); } catch (java.io.IOException iox) { System.err.println("ClientStateTag caught: " + iox); } } else { System.out.println(key + " not to Serializeable"); } } } } // end get attributes // now put the link in if (imageURL != null) { buffer.append(" <input alt=\"" + altText + "\" type=\"image\" " + "src=\"" + imageURL + "\"/>"); } else { buffer.append(" <input alt=\"" + altText + "\" type=\"submit\" " + "value=\"" + buttonText + "\"/>"); } buffer.append("</form>"); // write the output to the output stream try { JspWriter out = pageContext.getOut(); out.print(buffer.toString()); } catch (IOException ioe) { System.err.println("ClientStateTag: Problems with writing..."); } // reset everything parameters = null; altText = ""; buttonText = null; imageURL = null; cacheId = null; targetURL = null; encodeRequestAttributes = true; encodeRequestParameters = true; serializableClass = null; return EVAL_PAGE; }
From source file:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java
/** * ????s?B//from w w w. j a v a 2 s .co m * * @throws Exception ?\bh?O * @see junit.framework.TestCase#setUp() */ @SuppressWarnings("unchecked") @Override protected void setUp() throws Exception { super.setUp(); // create formEx // ?set?\bh?o?Av?peB?L?qt@Cw this.formEx = (DynaValidatorActionFormEx) creator.create(CONFIG_FILE_PATH); // i[l?? int hogeInt = 123; String hogeString = "data1"; int[] hogeIntArray = { -100, 0, 10, 111 }; String[] hogeStringArray = new String[4]; Object[] hogeObjectArray = new Object[4]; List<Object> hogeList = new ArrayList<Object>(); Map<String, Object> hogeMap = new HashMap<String, Object>(); Runnable hogeRunnable = new Runnable() { public void run() { } }; boolean hogeBoolean = true; byte hogeByte = 1; char hogeChar = 'A'; double hogeDouble = 999.9; float hogeFloat = 999; short hogeShort = 9; long hogeLong = 9; for (int i = 0; i < 4; i++) { hogeStringArray[i] = "data" + (i + 1); hogeObjectArray[i] = new Integer(i + 1); hogeList.add(i, "data" + (i + 1)); hogeMap.put("field" + (i + 1), "data" + (i + 1)); } String[] fields = { "hogeInt", "hogeString", "hogeIntArray", "hogeStringArray", "hogeObjectArray", "hogeList", "hogeMap", "hogeRunnable", "hogeBoolean", "hogeByte", "hogeChar", "hogeDouble", "hogeFloat", "hogeShort", "hogeLong" }; Class[] fieldClasses = { int.class, hogeString.getClass(), hogeIntArray.getClass(), hogeStringArray.getClass(), hogeObjectArray.getClass(), hogeList.getClass(), hogeMap.getClass(), hogeRunnable.getClass(), boolean.class, byte.class, char.class, double.class, float.class, short.class, long.class }; DynaProperty[] props = new DynaProperty[fields.length]; HashMap<String, DynaProperty> propsMap = new HashMap<String, DynaProperty>(); for (int i = 0; i < fields.length; i++) { props[i] = new DynaProperty(fields[i], fieldClasses[i]); propsMap.put(props[i].getName(), props[i]); } DynaActionFormClass dynaActionFormClass = (DynaActionFormClass) UTUtil.getPrivateField(this.formEx, "dynaClass"); UTUtil.setPrivateField(dynaActionFormClass, "properties", props); UTUtil.setPrivateField(dynaActionFormClass, "propertiesMap", propsMap); Map<String, Object> map = (Map) UTUtil.getPrivateField(this.formEx, "dynaValues"); map.put("hogeInt", hogeInt); map.put("hogeString", hogeString); map.put("hogeIntArray", hogeIntArray); map.put("hogeStringArray", hogeStringArray); map.put("hogeObjectArray", hogeObjectArray); map.put("hogeList", hogeList); map.put("hogeMap", hogeMap); map.put("hogeRunnable", hogeRunnable); map.put("hogeBoolean", hogeBoolean); map.put("hogeByte", hogeByte); map.put("hogeChar", hogeChar); map.put("hogeDouble", hogeDouble); map.put("hogeFloat", hogeFloat); map.put("hogeShort", hogeShort); map.put("hogeLong", hogeLong); }
From source file:catalina.startup.BootstrapService.java
/** * Load the Catalina Service./*from ww w . java 2s. c o m*/ */ public void init(DaemonContext context) throws Exception { String arguments[] = null; /* Read the arguments from the Daemon context */ if (context != null) { arguments = context.getArguments(); if (arguments != null) { for (int i = 0; i < arguments.length; i++) { if (arguments[i].equals("-debug")) { debug = 1; } } } } log("Create Catalina server"); // Set Catalina path setCatalinaHome(); setCatalinaBase(); // Construct the class loaders we will need ClassLoader commonLoader = null; ClassLoader catalinaLoader = null; ClassLoader sharedLoader = null; try { File unpacked[] = new File[1]; File packed[] = new File[1]; File packed2[] = new File[2]; ClassLoaderFactory.setDebug(debug); unpacked[0] = new File(getCatalinaHome(), "common" + File.separator + "classes"); packed2[0] = new File(getCatalinaHome(), "common" + File.separator + "endorsed"); packed2[1] = new File(getCatalinaHome(), "common" + File.separator + "lib"); commonLoader = ClassLoaderFactory.createClassLoader(unpacked, packed2, null); unpacked[0] = new File(getCatalinaHome(), "server" + File.separator + "classes"); packed[0] = new File(getCatalinaHome(), "server" + File.separator + "lib"); catalinaLoader = ClassLoaderFactory.createClassLoader(unpacked, packed, commonLoader); System.err.println("Created catalinaLoader in: " + getCatalinaHome() + File.separator + "server" + File.separator + "lib"); unpacked[0] = new File(getCatalinaBase(), "shared" + File.separator + "classes"); packed[0] = new File(getCatalinaBase(), "shared" + File.separator + "lib"); sharedLoader = ClassLoaderFactory.createClassLoader(unpacked, packed, commonLoader); } catch (Throwable t) { log("Class loader creation threw exception", t); } Thread.currentThread().setContextClassLoader(catalinaLoader); SecurityClassLoad.securityClassLoad(catalinaLoader); // Load our startup class and call its process() method if (debug >= 1) log("Loading startup class"); Class startupClass = catalinaLoader.loadClass("org.apache.catalina.startup.CatalinaService"); Object startupInstance = startupClass.newInstance(); // Set the shared extensions class loader if (debug >= 1) log("Setting startup class properties"); String methodName = "setParentClassLoader"; Class paramTypes[] = new Class[1]; paramTypes[0] = Class.forName("java.lang.ClassLoader"); Object paramValues[] = new Object[1]; paramValues[0] = sharedLoader; Method method = startupInstance.getClass().getMethod(methodName, paramTypes); method.invoke(startupInstance, paramValues); catalinaService = startupInstance; // Call the load() method methodName = "load"; Object param[]; if (arguments == null || arguments.length == 0) { paramTypes = null; param = null; } else { paramTypes[0] = arguments.getClass(); param = new Object[1]; param[0] = arguments; } method = catalinaService.getClass().getMethod(methodName, paramTypes); if (debug >= 1) log("Calling startup class " + method); method.invoke(catalinaService, param); }
From source file:org.hyperic.hq.product.jmx.MBeanUtil.java
public static OperationParams getOperationParams(MBeanInfo info, String method, Object args[]) throws PluginException { boolean isDebug = log.isDebugEnabled(); MBeanOperationInfo[] ops = info.getOperations(); MBeanParameterInfo[] pinfo = null; HashMap sigs = new HashMap(); String methodSignature = null; if (args.length != 0) { String arg = (String) args[0]; if (arg.startsWith("@(") && arg.endsWith(")")) { methodSignature = arg.substring(1); String[] dst = new String[args.length - 1]; System.arraycopy(args, 1, dst, 0, dst.length); args = dst;//from ww w . jav a2 s.c o m } } if (isDebug) { String msg = "Converting params for: " + method + Arrays.asList(args); if (methodSignature != null) { msg += ", using provided signature: " + methodSignature; } log.debug(msg); } for (int i = 0; i < ops.length; i++) { if (ops[i].getName().equals(method)) { pinfo = ops[i].getSignature(); StringBuffer sig = new StringBuffer(); sig.append("("); for (int j = 0; j < pinfo.length; j++) { sig.append(pinfo[j].getType()); if (j + 1 != pinfo.length) { sig.append(';'); } } sig.append(')'); log.debug("Found operation: " + method + sig); sigs.put(sig.toString(), pinfo); sigs.put(new Integer(pinfo.length), pinfo); //XXX might have more than 1 method w/ same //number of args but different signature } } if (sigs.size() == 0) { OperationParams op = getAttributeParams(info, method, args); if (op != null) { return op; } String msg = "No MBean Operation or Attribute Info found for: " + method; throw new PluginException(msg); } else if (sigs.size() > 1) { if (methodSignature == null) { //try exact match, else last one wins. Object o = sigs.get(new Integer(args.length)); if (o != null) { pinfo = (MBeanParameterInfo[]) o; if (log.isDebugEnabled()) { log.debug("Using default sig: " + toString(pinfo)); } } } else { pinfo = (MBeanParameterInfo[]) sigs.get(methodSignature); if (pinfo == null) { String msg = "No matching Operation signature found for: " + method + methodSignature; throw new PluginException(msg); } else if (log.isDebugEnabled()) { log.debug("Using matched sig: " + toString(pinfo)); } } } int len = pinfo.length; int nargs = args.length; int consumed; String[] signature = new String[len]; List arguments = new ArrayList(); for (int i = 0, j = 0; i < len; i++, j += consumed) { consumed = 1; String sig = pinfo[i].getType(); signature[i] = sig; if (!hasConverter(sig)) { String msg = "Cannot convert String argument to " + sig; throw new PluginException(msg); } if (j >= args.length) { throw invalidParams(method, sigs, args); } if (isListType(sig)) { String[] listArgs; if (len == 1) { listArgs = (String[]) args; } else { int remain = (len - 1) - j; consumed = args.length - j - remain; listArgs = new String[consumed]; System.arraycopy(args, j, listArgs, 0, consumed); } nargs -= listArgs.length; try { arguments.add(convert(sig, listArgs)); } catch (Exception e) { String msg = "Exception converting " + Arrays.asList(listArgs) + "' to type '" + sig + "'"; throw new PluginException(msg + ": " + e); } } else { nargs--; try { arguments.add(convert(sig, (String) args[j])); } catch (Exception e) { String msg = "Exception converting param[" + j + "] '" + args[j] + "' to type '" + sig + "'"; throw new PluginException(msg + ": " + e); } } if (isDebug) { Object arg = arguments.get(i); if (arg.getClass().isArray()) { if ((arg = asObjectArray(arg)) == null) { arg = arguments.get(i).toString(); } else { arg = Arrays.asList((Object[]) arg).toString(); } } log.debug(method + "() arg " + i + "=" + arg + ", type=" + sig); } } if (nargs != 0) { throw invalidParams(method, sigs, args); } OperationParams params = new OperationParams(); params.signature = signature; params.arguments = arguments.toArray(); return params; }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java
/** * This method creates a RegistryObject type * dynamically. To add new Related ROB's. * // w ww . j a v a 2 s . com * @param none * @return String */ public String doAddCurrentComposedROB() { String status = "failure"; try { LifeCycleManagerImpl lcm = RegistryBrowser.getBLCM(); Class<? extends LifeCycleManagerImpl> clazz = lcm.getClass(); String type = getCurrentComposedRegistryObjectType(); String methodName = "createObject"; Method m = null; // Create new composed RO using the LCM; create and store the ROB Class<?> argClass[] = new Class[1]; argClass[0] = type.getClass(); m = clazz.getMethod(methodName, argClass); Object args[] = new Object[1]; args[0] = type; Object ro = m.invoke(lcm, args); if (ro instanceof RegistryObject) { VersionInfoType vit = BindingUtility.getInstance().rimFac.createVersionInfoType(); ((RegistryObjectImpl) ro).setVersionInfo(vit); } RegistryObjectBean rob = null; List<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(4); searchResultValueBeans.add(new SearchResultValueBean("", "")); searchResultValueBeans.add(new SearchResultValueBean("", "")); searchResultValueBeans.add(new SearchResultValueBean("", "")); searchResultValueBeans.add(new SearchResultValueBean("", "")); if (ro instanceof TelephoneNumber) { rob = new RegistryObjectBean(searchResultValueBeans, currentRegistryObject.getRegistryObject(), "TelephoneNumber", (TelephoneNumber) ro, false); } else if (ro instanceof PostalAddress) { rob = new RegistryObjectBean(searchResultValueBeans, currentRegistryObject.getRegistryObject(), "PostalAddress", (PostalAddress) ro, false); } else if (ro instanceof EmailAddress) { rob = new RegistryObjectBean(searchResultValueBeans, currentRegistryObject.getRegistryObject(), "EmailAddress", (EmailAddress) ro, false); } else if (ro instanceof Slot) { List<String> valueList = new ArrayList<String>(); valueList.add(""); ((Slot) ro).setValues(valueList); rob = new RegistryObjectBean(searchResultValueBeans, currentRegistryObject.getRegistryObject(), "Slot", (Slot) ro, false); } else if (ro instanceof Concept) { if (currentRegistryObject.getRegistryObject().getObjectType().getValue() .equalsIgnoreCase("ClassificationScheme")) { ClassificationScheme cs = (ClassificationScheme) currentRegistryObject.getRegistryObject(); ((ConceptImpl) ro).setClassificationScheme(cs); } else { Concept cn = (Concept) currentRegistryObject.getRegistryObject(); ClassificationScheme cs = cn.getClassificationScheme(); if (null != cs) { ((ConceptImpl) ro).setClassificationScheme(cn.getClassificationScheme()); } ((ConceptImpl) ro).setParentConcept(cn); } rob = new RegistryObjectBean(searchResultValueBeans, (RegistryObject) ro); } else if (ro instanceof RegistryObject) { rob = new RegistryObjectBean(searchResultValueBeans, (RegistryObject) ro); } rob.setNew(true); currentComposedRegistryObject = rob; registryObjectLookup.put(rob.getId(), rob); // Return status so JSF runtime can do page navigation status = "showDetailsPage"; } catch (Throwable t) { log.warn(WebUIResourceBundle.getInstance().getString("message.UnableToCreateComposedObject"), t); append(WebUIResourceBundle.getInstance().getString("createCOError") + " " + t.getLocalizedMessage()); } return status; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Create the query 'select * from' for selected the column in the table * /*from w w w . j a v a 2s.c o m*/ * @param mode * The integer value for the different modes */ private void queryStar(int mode) { String value; LOGGER.debug("Row:" + table.getSelectedRow() + " Col:" + table.getSelectedColumn()); LOGGER.debug("Row Count:" + table.getSelectedRowCount() + " Col Count:" + table.getSelectedColumnCount()); if (table.getSelectedRowCount() != 1 || table.getSelectedColumnCount() != 1) { userMessage(Resources.getString("errChooseOneCellText"), Resources.getString("errChooseOneCellTitle"), JOptionPane.ERROR_MESSAGE); } else { value = table.getModel().getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString(); LOGGER.debug("Value class: " + value.getClass().getName()); if (value == null || value.trim().length() == 0) { userMessage(Resources.getString("errNoDataInCellText"), Resources.getString("errNoDataInCellTitle"), JOptionPane.WARNING_MESSAGE); } else { value = "select * from " + value; messageOut(Resources.getString("msgMadeSQL", value)); queryText.setText(value); checkForNewString(querySelection); querySelection.setSelectedItem(value); selectMode(mode); } } }
From source file:org.springframework.integration.http.support.DefaultHttpHeaderMapper.java
private void setHttpHeader(HttpHeaders target, String name, Object value) { if (ACCEPT.equalsIgnoreCase(name)) { if (value instanceof Collection<?>) { Collection<?> values = (Collection<?>) value; if (!CollectionUtils.isEmpty(values)) { List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); for (Object type : values) { if (type instanceof MediaType) { acceptableMediaTypes.add((MediaType) type); } else if (type instanceof String) { acceptableMediaTypes.addAll(MediaType.parseMediaTypes((String) type)); } else { Class<?> clazz = (type != null) ? type.getClass() : null; throw new IllegalArgumentException( "Expected MediaType or String value for 'Accept' header value, but received: " + clazz); }/* w ww . ja v a 2 s . c om*/ } target.setAccept(acceptableMediaTypes); } } else if (value instanceof MediaType) { target.setAccept(Collections.singletonList((MediaType) value)); } else if (value instanceof String[]) { List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); for (String next : (String[]) value) { acceptableMediaTypes.add(MediaType.parseMediaType(next)); } target.setAccept(acceptableMediaTypes); } else if (value instanceof String) { target.setAccept(MediaType.parseMediaTypes((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected MediaType or String value for 'Accept' header value, but received: " + clazz); } } else if (ACCEPT_CHARSET.equalsIgnoreCase(name)) { if (value instanceof Collection<?>) { Collection<?> values = (Collection<?>) value; if (!CollectionUtils.isEmpty(values)) { List<Charset> acceptableCharsets = new ArrayList<Charset>(); for (Object charset : values) { if (charset instanceof Charset) { acceptableCharsets.add((Charset) charset); } else if (charset instanceof String) { acceptableCharsets.add(Charset.forName((String) charset)); } else { Class<?> clazz = (charset != null) ? charset.getClass() : null; throw new IllegalArgumentException( "Expected Charset or String value for 'Accept-Charset' header value, but received: " + clazz); } } target.setAcceptCharset(acceptableCharsets); } } else if (value instanceof Charset[] || value instanceof String[]) { List<Charset> acceptableCharsets = new ArrayList<Charset>(); Object[] values = ObjectUtils.toObjectArray(value); for (Object charset : values) { if (charset instanceof Charset) { acceptableCharsets.add((Charset) charset); } else if (charset instanceof String) { acceptableCharsets.add(Charset.forName((String) charset)); } } target.setAcceptCharset(acceptableCharsets); } else if (value instanceof Charset) { target.setAcceptCharset(Collections.singletonList((Charset) value)); } else if (value instanceof String) { String[] charsets = StringUtils.commaDelimitedListToStringArray((String) value); List<Charset> acceptableCharsets = new ArrayList<Charset>(); for (String charset : charsets) { acceptableCharsets.add(Charset.forName(charset.trim())); } target.setAcceptCharset(acceptableCharsets); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Charset or String value for 'Accept-Charset' header value, but received: " + clazz); } } else if (ALLOW.equalsIgnoreCase(name)) { if (value instanceof Collection<?>) { Collection<?> values = (Collection<?>) value; if (!CollectionUtils.isEmpty(values)) { Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>(); for (Object method : values) { if (method instanceof HttpMethod) { allowedMethods.add((HttpMethod) method); } else if (method instanceof String) { allowedMethods.add(HttpMethod.valueOf((String) method)); } else { Class<?> clazz = (method != null) ? method.getClass() : null; throw new IllegalArgumentException( "Expected HttpMethod or String value for 'Allow' header value, but received: " + clazz); } } target.setAllow(allowedMethods); } } else { if (value instanceof HttpMethod) { target.setAllow(Collections.singleton((HttpMethod) value)); } else if (value instanceof HttpMethod[]) { Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>(); for (HttpMethod next : (HttpMethod[]) value) { allowedMethods.add(next); } target.setAllow(allowedMethods); } else if (value instanceof String || value instanceof String[]) { String[] values = (value instanceof String[]) ? (String[]) value : StringUtils.commaDelimitedListToStringArray((String) value); Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>(); for (String next : values) { allowedMethods.add(HttpMethod.valueOf(next.trim())); } target.setAllow(allowedMethods); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected HttpMethod or String value for 'Allow' header value, but received: " + clazz); } } } else if (CACHE_CONTROL.equalsIgnoreCase(name)) { if (value instanceof String) { target.setCacheControl((String) value); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected String value for 'Cache-Control' header value, but received: " + clazz); } } else if (CONTENT_LENGTH.equalsIgnoreCase(name)) { if (value instanceof Number) { target.setContentLength(((Number) value).longValue()); } else if (value instanceof String) { target.setContentLength(Long.parseLong((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Number or String value for 'Content-Length' header value, but received: " + clazz); } } else if (CONTENT_TYPE.equalsIgnoreCase(name)) { if (value instanceof MediaType) { target.setContentType((MediaType) value); } else if (value instanceof String) { target.setContentType(MediaType.parseMediaType((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected MediaType or String value for 'Content-Type' header value, but received: " + clazz); } } else if (DATE.equalsIgnoreCase(name)) { if (value instanceof Date) { target.setDate(((Date) value).getTime()); } else if (value instanceof Number) { target.setDate(((Number) value).longValue()); } else if (value instanceof String) { target.setDate(Long.parseLong((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Date, Number, or String value for 'Date' header value, but received: " + clazz); } } else if (ETAG.equalsIgnoreCase(name)) { if (value instanceof String) { target.setETag((String) value); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected String value for 'ETag' header value, but received: " + clazz); } } else if (EXPIRES.equalsIgnoreCase(name)) { if (value instanceof Date) { target.setExpires(((Date) value).getTime()); } else if (value instanceof Number) { target.setExpires(((Number) value).longValue()); } else if (value instanceof String) { target.setExpires(Long.parseLong((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Date, Number, or String value for 'Expires' header value, but received: " + clazz); } } else if (IF_MODIFIED_SINCE.equalsIgnoreCase(name)) { if (value instanceof Date) { target.setIfModifiedSince(((Date) value).getTime()); } else if (value instanceof Number) { target.setIfModifiedSince(((Number) value).longValue()); } else if (value instanceof String) { target.setIfModifiedSince(Long.parseLong((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Date, Number, or String value for 'If-Modified-Since' header value, but received: " + clazz); } } else if (IF_NONE_MATCH.equalsIgnoreCase(name)) { if (value instanceof String) { target.setIfNoneMatch((String) value); } else if (value instanceof String[]) { String delmitedString = StringUtils.arrayToCommaDelimitedString((String[]) value); target.setIfNoneMatch(delmitedString); } else if (value instanceof Collection) { Collection<?> values = (Collection<?>) value; if (!CollectionUtils.isEmpty(values)) { List<String> ifNoneMatchList = new ArrayList<String>(); for (Object next : values) { if (next instanceof String) { ifNoneMatchList.add((String) next); } else { Class<?> clazz = (next != null) ? next.getClass() : null; throw new IllegalArgumentException( "Expected String value for 'If-None-Match' header value, but received: " + clazz); } } target.setIfNoneMatch(ifNoneMatchList); } } } else if (LAST_MODIFIED.equalsIgnoreCase(name)) { if (value instanceof Date) { target.setLastModified(((Date) value).getTime()); } else if (value instanceof Number) { target.setLastModified(((Number) value).longValue()); } else if (value instanceof String) { target.setLastModified(Long.parseLong((String) value)); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected Date, Number, or String value for 'Last-Modified' header value, but received: " + clazz); } } else if (LOCATION.equalsIgnoreCase(name)) { if (value instanceof URI) { target.setLocation((URI) value); } else if (value instanceof String) { try { target.setLocation(new URI((String) value)); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected URI or String value for 'Location' header value, but received: " + clazz); } } else if (PRAGMA.equalsIgnoreCase(name)) { if (value instanceof String) { target.setPragma((String) value); } else { Class<?> clazz = (value != null) ? value.getClass() : null; throw new IllegalArgumentException( "Expected String value for 'Pragma' header value, but received: " + clazz); } } else if (value instanceof String) { target.set(name, (String) value); } else if (value instanceof String[]) { for (String next : (String[]) value) { target.add(name, next); } } else if (value instanceof Iterable<?>) { for (Object next : (Iterable<?>) value) { String convertedValue = null; if (next instanceof String) { convertedValue = (String) next; } else { convertedValue = this.convertToString(value); } if (StringUtils.hasText(convertedValue)) { target.add(name, (String) next); } else { logger.warn("Element of the header '" + name + "' with value '" + value + "' will not be set since it is not a String and no Converter " + "is available. Consider registering a Converter with ConversionService (e.g., <int:converter>)"); } } } else { String convertedValue = this.convertToString(value); if (StringUtils.hasText(convertedValue)) { target.set(name, convertedValue); } else { logger.warn("Header '" + name + "' with value '" + value + "' will not be set since it is not a String and no Converter " + "is available. Consider registering a Converter with ConversionService (e.g., <int:converter>)"); } } }