List of usage examples for java.lang StringBuffer insert
@Override public StringBuffer insert(int offset, double d)
From source file:SignificantFigures.java
/** * Formats this number in scientific notation. * <p>/*from w ww . j a v a 2 s . c o m*/ * A string such as "NaN" or "Infinity" may be returned by this method. * * @return representation of this number in scientific notation. * * @since ostermillerutils 1.00.00 */ public String toScientificNotation() { if (digits == null) return original; StringBuffer digits = new StringBuffer(this.digits.toString()); int length = digits.length(); if (length > 1) { digits.insert(1, '.'); } if (mantissa != 0) { digits.append("E" + mantissa); } if (!sign) { digits.insert(0, '-'); } return digits.toString(); }
From source file:com.timesoft.kaitoo.ws.hibernate.AbstractPojo.java
/** * DOCUMENT ME!/* ww w. j a v a 2 s . c o m*/ * * @return DOCUMENT ME! */ public String toString() { PropertyDescriptor[] pd = PropertyUtils.getPropertyDescriptors(this); StringBuffer buffer = new StringBuffer(); if (((List) callStack.get()).contains(this)) { buffer.append("Cyclic Reference!!!"); } else { ((List) callStack.get()).add(this); for (int index = 0; index < pd.length; ++index) { if ((null != PropertyUtils.getReadMethod(pd[index])) && (pd[index].getPropertyType() != Class.class)) { if (buffer.length() > 0) { buffer.append(", "); } String prop_name = pd[index].getName(); buffer.append(prop_name).append("="); try { buffer.append(PropertyUtils.getProperty(this, prop_name)); } catch (Exception e) { buffer.append(e.getMessage()); } } } ((List) callStack.get()).remove(this); } buffer.insert(0, " { ").insert(0, getClass().getName()).append(" }"); return buffer.toString(); }
From source file:javax.faces.component.UIComponentBase.java
private String getPathToComponent(UIComponent component) { StringBuffer buf = new StringBuffer(); if (component == null) { buf.append("{Component-Path : "); buf.append("[null]}"); return buf.toString(); }//from w w w . j av a2s . co m getPathToComponent(component, buf); buf.insert(0, "{Component-Path : "); buf.append("}"); return buf.toString(); }
From source file:org.kuali.kfs.sys.context.CheckModularization.java
public boolean testSpring() throws Exception { boolean testSucceeded = true; StringBuffer errorMessage = new StringBuffer(); // test the core modules alone System.out.println("\n\n------>Testing for core modules:"); System.out.println("------>Using Base Configuration: " + coreSpringFiles); testSucceeded &= testOptionalModuleSpringConfiguration( new ModuleGroup(KFSConstants.ParameterNamespaces.KFS), coreSpringFiles, errorMessage); if (!testSucceeded) { errorMessage.insert(0, "The Core modules have dependencies on the optional modules:\n"); }//from w ww. j a v a 2 s . c om errorMessage.append("The following optional modules have interdependencies in Spring configuration:\n"); List<ModuleGroup> optionalModuleGroups = retrieveOptionalModuleGroups(); for (ModuleGroup optionalModuleGroup : optionalModuleGroups) { // if ( !optionalModuleGroup.namespaceCode.equals( "KFS-AR" ) ) continue; System.out.println("\n\n------>Testing for optional module group: " + optionalModuleGroup); System.out.println("------>Using Base Configuration: " + coreSpringFiles); String moduleConfigFiles = buildOptionalModuleSpringFileList(optionalModuleGroup); System.out.println("------>Module configuration files: " + moduleConfigFiles); testSucceeded &= testOptionalModuleSpringConfiguration(optionalModuleGroup, coreSpringFiles + "," + moduleConfigFiles, errorMessage); } if (!testSucceeded) { System.out.print(errorMessage.append("\n\n").toString()); } return testSucceeded; }
From source file:org.apache.axis.utils.JavaUtils.java
/** * Makes the value passed in <code>initValue</code> unique among the * {@link String} values contained in <code>values</code> by suffixing * it with a decimal digit suffix.//w w w . ja v a 2s . co m */ public static String getUniqueValue(Collection values, String initValue) { if (!values.contains(initValue)) { return initValue; } else { StringBuffer unqVal = new StringBuffer(initValue); int beg = unqVal.length(), cur, end; while (Character.isDigit(unqVal.charAt(beg - 1))) { beg--; } if (beg == unqVal.length()) { unqVal.append('1'); } cur = end = unqVal.length() - 1; while (values.contains(unqVal.toString())) { if (unqVal.charAt(cur) < '9') { unqVal.setCharAt(cur, (char) (unqVal.charAt(cur) + 1)); } else { while (cur-- > beg) { if (unqVal.charAt(cur) < '9') { unqVal.setCharAt(cur, (char) (unqVal.charAt(cur) + 1)); break; } } // See if there's a need to insert a new digit. if (cur < beg) { unqVal.insert(++cur, '1'); end++; } while (cur < end) { unqVal.setCharAt(++cur, '0'); } } } return unqVal.toString(); } /* For else clause of selection-statement If(!values ... */ }
From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java
public void addLocalFieldInPersistenceMethods(JavaSourceFileEditor entityClassFile, String fieldName, String fieldType) {// ww w.j av a 2 s .c o m ArrayList<JavaSourceMethod> globalMethodList = entityClassFile.getGlobalMethodList(); String pluralRemoteEntity = GwUtils.getInflectorPlural(entityClassFile.CLASS_NAME, Locale.ENGLISH); String smallRemoteEntity = StringUtils.uncapitalize(entityClassFile.CLASS_NAME); for (JavaSourceMethod method : globalMethodList) { String methodName = method.getMethodName(); /* * We insert the new field in the findAll and find<Entity>Entries methods */ if (methodName.endsWith("findAll" + pluralRemoteEntity) || methodName.endsWith("find" + entityClassFile.CLASS_NAME + "Entries")) { StringBuffer methodBody = new StringBuffer(method.getMethodBody()); methodBody.insert(methodBody.indexOf("virtual" + entityClassFile.CLASS_NAME + "List.add"), makeLocalShowFieldCode("\t\t", smallRemoteEntity + "Instance", entityClassFile.CLASS_NAME, fieldName)); method.setMethodBody(methodBody.toString()); } /* NO NEED TO INSERT IN THE FIND METHOD ANYMORE AS ONCE FOUND IN THE LOCAL DB, THE LOCAL FIELDS ARE AUTOMATICALLY POPULATED * We insert the new field in the find<Entity> method * else if (methodName.endsWith("find" + entityClassFile.CLASS_NAME)) { StringBuffer methodBody = new StringBuffer(method.getMethodBody()); methodBody.insert(methodBody.indexOf("return "), makeLocalShowFieldCode("\t", "virtual" + entityClassFile.CLASS_NAME, entityClassFile.CLASS_NAME, fieldName)); method.setMethodBody(methodBody.toString()); }*/ } }
From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java
public void addRemoteFieldInPersistenceMethods(JavaSourceFileEditor entityClassFile, Map.Entry<String[], String> fieldObj) { ArrayList<JavaSourceMethod> globalMethodList = entityClassFile.getGlobalMethodList(); String pluralRemoteEntity = GwUtils.getInflectorPlural(entityClassFile.CLASS_NAME, Locale.ENGLISH); String smallRemoteEntity = StringUtils.uncapitalize(entityClassFile.CLASS_NAME); for (JavaSourceMethod method : globalMethodList) { String methodName = method.getMethodName(); /*//from w w w. ja v a 2 s . c o m * We insert the new field in the persist and merge methods */ if (methodName.endsWith("persist") || methodName.endsWith("merge")) { StringBuffer methodBody = new StringBuffer(method.getMethodBody()); methodBody.insert(methodBody.lastIndexOf(".execute()"), makeGWPersistFieldCode("", fieldObj)); method.setMethodBody(methodBody.toString()); } /* * We insert the new field in the findAll and find<Entity>Entries methods */ else if (methodName.endsWith("findAll" + pluralRemoteEntity) || methodName.endsWith("find" + entityClassFile.CLASS_NAME + "Entries")) { StringBuffer methodBody = new StringBuffer(method.getMethodBody()); methodBody.insert(methodBody.indexOf("virtual" + entityClassFile.CLASS_NAME + "List.add"), makeGWShowFieldCode("", smallRemoteEntity + "Instance", smallRemoteEntity + "Item", fieldObj)); method.setMethodBody(methodBody.toString()); } /* * We insert the new field in the find<Entity> method */ else if (methodName.endsWith("find" + entityClassFile.CLASS_NAME)) { StringBuffer methodBody = new StringBuffer(method.getMethodBody()); methodBody.insert(methodBody.indexOf("return "), makeGWShowFieldCode("", "virtual" + entityClassFile.CLASS_NAME, smallRemoteEntity, fieldObj)); method.setMethodBody(methodBody.toString()); } } }
From source file:com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJobMailNotificationImpl.java
protected void embedOutput(MimeMessageHelper messageHelper, ReportOutput output) throws MessagingException, JobExecutionException { /***/*from w ww . ja v a 2s .c o m*/ try { BufferedReader in = new BufferedReader(new FileReader("C:/Users/ichan/Desktop/employee.html")); StringBuffer strBuffer = new StringBuffer(); String strLine; while ((strLine = in.readLine()) != null) { strBuffer = strBuffer.append(strLine + "\n"); } content = strBuffer.toString(); } catch (Exception ex) { ex.printStackTrace(); } System.out.println("CONTENT = " + content); ****/ // modify content to use inline images StringBuffer primaryPage = new StringBuffer(new String(output.getData().getData())); for (Iterator it = output.getChildren().iterator(); it.hasNext();) { ReportOutput child = (ReportOutput) it.next(); String childName = child.getFilename(); // NOTE: add the ".dat" extension to all image resources // email client will automatically append ".dat" extension to all the files with no extension // should do it in JasperReport side if (output.getFileType().equals(ContentResource.TYPE_HTML)) { if (primaryPage == null) primaryPage = new StringBuffer(new String(output.getData().getData())); int fromIndex = 0; while ((fromIndex = primaryPage.indexOf("src=\"" + childName + "\"", fromIndex)) > 0) { primaryPage.insert(fromIndex + 5, "cid:"); } } } messageHelper.setText(primaryPage.toString(), true); // add inline images after setting the text in the main body for (Iterator it = output.getChildren().iterator(); it.hasNext();) { ReportOutput child = (ReportOutput) it.next(); String childName = child.getFilename(); DataContainerResource dataContainerResource = new DataContainerResource(child.getData()); dataContainerResource.setFilename(childName); messageHelper.addInline(childName, dataContainerResource); } }
From source file:com.flexive.core.search.genericSQL.GenericSQLForeignTableSelector.java
/** * {@inheritDoc}//from www . j a v a 2 s . c om */ @Override public void apply(Property prop, PropertyEntry entry, StringBuffer statement) throws FxSqlSearchException { if (hasTranslationTable && translatedColumn.equalsIgnoreCase(prop.getField())) { // select label from translation table statement.delete(0, statement.length()); final long lang = FxContext.getUserTicket().getLanguage().getId(); DBStorage storage = StorageManager.getStorageImpl(); statement.append(("COALESCE(\n" + getLabelSelect() + "lang=" + lang + storage.getLimit(true, 1) + ") ,\n" + getLabelSelect() + "deflang=" + storage.getBooleanTrueExpression() + " " + storage.getLimit(true, 1) + ") \n" + ")")); entry.overrideDataType(FxDataType.String1024); return; } FxDataType type = columns.get(prop.getField().toUpperCase()); if (type == null) { // This field does not exist throw new FxSqlSearchException(LOG, "ex.sqlSearch.query.undefinedField", prop.getField(), prop.getPropertyName(), getAllowedFields()); } else { statement.insert(0, "(SELECT " + prop.getField() + " FROM " + tableName + " WHERE " + linksOn + "=") .append(")"); entry.overrideDataType(type); } }
From source file:com.opendesign.controller.ProductController.java
/** * ??() ?//* w w w. j a va2 s .c o m*/ * * @param product * @param request * @param saveType * @return * @throws Exception */ private JsonModelAndView saveProduct(DesignWorkVO product, MultipartHttpServletRequest request, int saveType) throws Exception { /* * ?? ? ? */ boolean isUpdate = saveType == SAVE_TYPE_UPDATE; Map<String, Object> resultMap = new HashMap<String, Object>(); UserVO loginUser = CmnUtil.getLoginUser(request); if (loginUser == null || !StringUtil.isNotEmpty(loginUser.getSeq())) { resultMap.put("result", "100"); return new JsonModelAndView(resultMap); } /* ? ? */ if (isUpdate) { DesignWorkVO prevProduct = designerService.getDesignWork(product.getSeq()); if (!loginUser.getSeq().equals(prevProduct.getMemberSeq())) { resultMap.put("result", "101"); return new JsonModelAndView(resultMap); } } /* * ? ? */ MultipartFile fileUrlFile = request.getFile("fileUrlFile"); if (fileUrlFile != null) { String fileName = fileUrlFile.getOriginalFilename().toLowerCase(); if (!(fileName.endsWith(".jpg") || fileName.endsWith(".png"))) { resultMap.put("result", "202"); return new JsonModelAndView(resultMap); } } else { /* ? ? . */ if (!isUpdate) { resultMap.put("result", "201"); return new JsonModelAndView(resultMap); } } /* * license */ String license01 = request.getParameter("license01"); String license02 = request.getParameter("license02"); String license03 = request.getParameter("license03"); String license = license01 + license02 + license03; product.setLicense(license); //?? ?///// String stem = request.getParameter("origin"); if (stem == null) { product.setOriginSeq("0"); } else { product.setOriginSeq(stem); } ////////////////////////////// /* * ?? ? "0" */ String point = request.getParameter("point"); point = String.valueOf(CmnUtil.getIntValue(point)); //null--> 0 product.setPoint(point); /* * ? ? */ List<MultipartFile> productFileList = new ArrayList<MultipartFile>(); List<MultipartFile> openSourceFileList = new ArrayList<MultipartFile>(); Iterator<String> iterator = request.getFileNames(); while (iterator.hasNext()) { String fileNameKey = iterator.next(); MultipartFile reqFile = request.getFile(fileNameKey); if (reqFile != null) { boolean existProuductFile = fileNameKey.startsWith("productFile"); boolean existOpenSourceFile = fileNameKey.startsWith("openSourceFile"); if (existProuductFile || existOpenSourceFile) { long fileSize = reqFile.getSize(); if (fileSize > LIMIT_FILE_SIZE) { resultMap.put("result", "203"); resultMap.put("fileName", reqFile.getOriginalFilename()); return new JsonModelAndView(resultMap); } if (existProuductFile) { productFileList.add(reqFile); } if (existOpenSourceFile) { openSourceFileList.add(reqFile); } } } } product.setMemberSeq(loginUser.getSeq()); /* * ?? */ String fileUploadDir = CmnUtil.getFileUploadDir(request, FileUploadDomain.PRODUCT); File thumbFile = null; if (fileUrlFile != null) { String saveFileName = UUID.randomUUID().toString(); thumbFile = CmnUtil.saveFile(fileUrlFile, fileUploadDir, saveFileName); String fileUploadDbPath = CmnUtil.getFileUploadDbPath(request, thumbFile); product.setThumbUri(fileUploadDbPath); } /* * ??() */ List<DesignPreviewImageVO> productList = new ArrayList<DesignPreviewImageVO>(); List<String> productFilePaths = new ArrayList<>(); for (MultipartFile aFile : productFileList) { String saveFileName = UUID.randomUUID().toString(); File file = CmnUtil.saveFile(aFile, fileUploadDir, saveFileName); productFilePaths.add(file.getAbsolutePath()); String fileUploadDbPath = CmnUtil.getFileUploadDbPath(request, file); DesignPreviewImageVO productFile = new DesignPreviewImageVO(); productFile.setFilename(aFile.getOriginalFilename()); productFile.setFileUri(fileUploadDbPath); productList.add(productFile); } product.setImageList(productList); /* * */ List<DesignWorkFileVO> openSourceList = new ArrayList<DesignWorkFileVO>(); for (MultipartFile aFile : openSourceFileList) { String saveFileName = UUID.randomUUID().toString(); File file = CmnUtil.saveFile(aFile, fileUploadDir, saveFileName); String fileUploadDbPath = CmnUtil.getFileUploadDbPath(request, file); //openSourceFile? ??? client? . String filenameOpenSourceFile = StringUtils .stripToEmpty(request.getParameter("filename_" + aFile.getName())); DesignWorkFileVO openSourceFile = new DesignWorkFileVO(); openSourceFile.setFilename(filenameOpenSourceFile); openSourceFile.setFileUri(fileUploadDbPath); openSourceList.add(openSourceFile); } product.setFileList(openSourceList); /* * ??/? ? ? ? * ?? ? ? ? ? ? */ String thumbFilePath = ""; if (thumbFile != null) { thumbFilePath = thumbFile.getAbsolutePath(); } ThumbnailManager.resizeNClone4DesignWork(thumbFilePath, productFilePaths); /* * */ String tag = request.getParameter("tag"); if (StringUtil.isNotEmpty(tag)) { String[] tags = tag.split(","); int addIndex = 0; StringBuffer tagBuffer = new StringBuffer(); for (String aTag : tags) { if (StringUtil.isNotEmpty(aTag)) { aTag = aTag.trim(); tagBuffer.append(aTag); tagBuffer.append("|"); addIndex++; } if (addIndex >= 5) { break; } } if (addIndex > 0) { tagBuffer.insert(0, "|"); tag = tagBuffer.toString(); } } product.setTags(tag); String currentDate = Day.getCurrentTimestamp().substring(0, 12); product.setRegisterTime(currentDate); product.setUpdateTime(currentDate); String[] categoryCodes = request.getParameterValues("categoryCodes"); /* * */ if (isUpdate) { String[] removeProductSeqs = request.getParameterValues("removeProductSeq"); String[] removeOpenSourceSeqs = request.getParameterValues("removeOpenSourceSeq"); int projectSeq = service.updateProduct(product, categoryCodes, removeProductSeqs, removeOpenSourceSeqs); } else { int projectSeq = service.insertProduct(product, categoryCodes); } resultMap.put(RstConst.P_NAME, RstConst.V_SUCESS); return new JsonModelAndView(resultMap); }