List of usage examples for java.lang StringBuilder delete
@Override public StringBuilder delete(int start, int end)
From source file:it.unibas.spicy.model.algebra.query.operators.sql.GenerateSQL.java
private static String generateWhereClauseFromEqualities(NegatedComplexQuery negation, String positiveViewName, String negationViewName) { StringBuilder result = new StringBuilder(); result.append("where \n"); if (negation.isTargetDifference()) { for (int i = 0; i < negation.getTargetEqualities().getLeftCorrespondences().size(); i++) { VariableCorrespondence leftCorrespondence = negation.getTargetEqualities().getLeftCorrespondences() .get(i);/* ww w . j a v a 2 s . c om*/ VariableCorrespondence rightCorrespondence = negation.getTargetEqualities() .getRightCorrespondences().get(i); //giannisk //so as not to take into account constant values if (!leftCorrespondence.isConstant() && !rightCorrespondence.isConstant()) { VariablePathExpression leftPath = leftCorrespondence.getFirstSourcePath(); VariablePathExpression rightPath = rightCorrespondence.getFirstSourcePath(); result.append(DOUBLE_INDENT).append(positiveViewName).append(".") .append(attributeNameInVariable(leftPath)); result.append(" = "); result.append(negationViewName).append(".").append(attributeNameInVariable(rightPath)); //if (i != negation.getTargetEqualities().getLeftCorrespondences().size() - 1) { result.append(" AND\n"); //} //so as not to take into account constant values /*if ((i != negation.getTargetEqualities().getLeftCorrespondences().size() - 1) && (!negation.getTargetEqualities().getLeftCorrespondences().get(i+1).isConstant()) ) result.append(" AND\n");*/ } } //giannisk //delete the last AND result = result.delete(result.length() - 5, result.length()); } else { for (int i = 0; i < negation.getSourceEqualities().getLeftPaths().size(); i++) { VariablePathExpression leftPath = negation.getSourceEqualities().getLeftPaths().get(i); VariablePathExpression rightPath = negation.getSourceEqualities().getRightPaths().get(i); result.append(DOUBLE_INDENT).append(positiveViewName).append(".") .append(attributeNameInVariable(leftPath)); result.append(" = "); result.append(negationViewName).append(".").append(attributeNameInVariable(rightPath)); if (i != negation.getSourceEqualities().getLeftPaths().size() - 1) result.append(" AND\n"); } } result.append("\n"); return result.toString(); }
From source file:com.vmware.bdd.manager.ClusterConfigManager.java
private void validateMemorySize(Set<NodeGroupEntity> nodeGroups, List<String> failedMsgList) { boolean validated = true; StringBuilder invalidNodeGroupNames = new StringBuilder(); for (NodeGroupEntity nodeGroup : nodeGroups) { if (nodeGroup.getMemorySize() < Constants.MIN_MEM_SIZE) { validated = false;/*from w w w. j a va2s . com*/ invalidNodeGroupNames.append(nodeGroup.getName()).append(","); } } if (!validated) { StringBuilder errorMsgBuff = new StringBuilder(); invalidNodeGroupNames.delete(invalidNodeGroupNames.length() - 1, invalidNodeGroupNames.length()); failedMsgList.add(errorMsgBuff .append("'memCapacityMB' cannot be less than " + Constants.MIN_MEM_SIZE + " in group ") .append(invalidNodeGroupNames.toString()).append(" in order for nodes to run normally") .toString()); } }
From source file:com.virtusa.akura.student.controller.StudentAssignmentMarkController.java
/** * Populate student assignment list.// w w w .j a v a 2 s .co m * * @param request the request * @return the string * @throws AkuraException the akura exception */ @RequestMapping(POPULATE_ASSIGNMENT_LIST_HTM) @ResponseBody public String populateStudentAssignmentList(HttpServletRequest request) throws AkuraException { String classGradeId = request.getParameter(CLASS_GRADE_ID); List<Object[]> assignments = SortUtil.sortStudentAssignmentMarks( commonService.getAssignmentsListByGrade(Integer.parseInt(classGradeId))); StringBuilder assignmentsListBuilder = new StringBuilder(); StringBuilder assignmentBuilder = new StringBuilder(); boolean isFirst = true; int indexZero = 0; int indexOne = 1; if (!assignments.isEmpty()) { for (Object[] object : assignments) { Assignment assignment = (Assignment) object[indexZero]; String subject = (String) object[indexOne]; assignmentBuilder.append(assignment.getAssignmentId()); assignmentBuilder.append(AkuraWebConstant.UNDERSCORE_STRING); assignmentBuilder.append(assignment.getName()); assignmentBuilder.append(AkuraWebConstant.UNDERSCORE_STRING); assignmentBuilder.append(subject); if (isFirst) { assignmentsListBuilder.append(assignmentBuilder.toString()); isFirst = false; } else { assignmentsListBuilder.append(AkuraWebConstant.STRING_COMMA); assignmentsListBuilder.append(assignmentBuilder.toString()); } assignmentBuilder.delete(0, assignmentBuilder.length()); } } return assignmentsListBuilder.toString(); }
From source file:com.virtusa.akura.common.controller.ManageSpecialEventsController.java
/** * Method is to return SpecialEvents map. * //from w w w . j a v a 2s . co m * @return map of Special Events * @throws AkuraAppException - Detailed exception */ @ModelAttribute(MODEL_ATT_SPECIAL_EVENT_MAP) public Map<SpecialEvents, String> populateSpecialEventWithParticipant() throws AkuraAppException { List<SpecialEvents> specialEventLst = SortUtil.sortSpecialEventsList(commonService.getSpecialEventList()); // Map<SpecialEvents, String> lastMap = new HashMap<SpecialEvents, String>(); Map<SpecialEvents, String> lastMap = new LinkedHashMap<SpecialEvents, String>(); List<SpecialEventsParticipation> participants = null; for (SpecialEvents event : specialEventLst) { participants = commonService.getParticipantListBySpecialEvent(event); StringBuilder allParticipents = new StringBuilder(); StringBuilder participents = new StringBuilder(); boolean isFirst = true; for (SpecialEventsParticipation cg : participants) { if (cg.getClassGrade() != null) { participents.append(cg.getClassGrade().getDescription()); } if (cg.getClubSociety() != null) { participents.append(cg.getClubSociety().getName()); } if (cg.getSportCategory() != null) { participents.append(cg.getSportCategory().getSport().getDescription()); participents.append("-"); participents.append(cg.getSportCategory().getSportSubCategory().getDescription()); } if (isFirst) { allParticipents.append(participents.toString()); // no comma isFirst = false; } else { allParticipents.append(", "); // comma allParticipents.append(participents.toString()); } participents.delete(0, participents.length()); } lastMap.put(event, allParticipents.toString()); allParticipents.delete(0, allParticipents.length()); } return lastMap; }
From source file:hydrograph.ui.graph.execution.tracking.replay.ViewExecutionHistoryUtility.java
public void subjobParams(Map<String, String> componentNameAndLink, Component subjobComponent, StringBuilder subjobPrefix, boolean isParent) { Container container = (Container) subjobComponent.getSubJobContainer().get(Constants.SUBJOB_CONTAINER); for (Object object : container.getChildren()) { Component component = (Component) object; if (!(component.getComponentName().equals(Messages.INPUT_SUBJOB_COMPONENT)) && !(component.getComponentName().equals(Messages.OUTPUT_SUBJOB_COMPONENT))) { if (Constants.SUBJOB_COMPONENT.equals(component.getComponentName())) { subjobPrefix.append(component.getComponentId() + "."); subjobParams(componentNameAndLink, component, subjobPrefix, false); }//www .j av a2 s. co m if (!Constants.SUBJOB_COMPONENT.equals(component.getComponentName())) { if (isParent) { componentNameAndLink.put( subjobComponent.getComponentId() + "." + component.getComponentId(), subjobComponent.getComponentId() + "." + component.getComponentId()); } else { componentNameAndLink.put(subjobPrefix + component.getComponentId(), subjobPrefix + component.getComponentId()); } } else { String string[] = StringUtils.split(subjobPrefix.toString(), "."); subjobPrefix.delete(0, subjobPrefix.length()); for (int index = 0; index < string.length - 1; index++) { subjobPrefix.append(string[index] + "."); } } } } }
From source file:com.ah.ui.actions.teacherView.TvRedirectionAction.java
private List<String> getCASCLIs() { List<String> clis = new ArrayList<String>(); /*/* w w w .j a v a2s . c o m*/ * CLI for CAS settings */ String[] casServer = getCASServer(); if (casServer == null) { return clis; } /* * cas address */ StringBuilder cli = new StringBuilder(); cli.append("hiveui cas client server name ").append(casServer[0]).append("\n"); clis.add(cli.toString()); cli.delete(0, cli.length()); /* * port */ cli.append("hiveui cas client server port ").append(casServer[1]).append("\n"); clis.add(cli.toString()); cli.delete(0, cli.length()); return clis; }
From source file:com.colorchen.qbase.utils.FileUtil.java
/** * ??/* w ww. j av a2s . co m*/ * * @param file * @param charsetName ?? * @return */ public static String readFile2String(File file, String charsetName) { if (file == null) return null; BufferedReader reader = null; try { StringBuilder sb = new StringBuilder(); if (DataUtil.isNullString(charsetName)) { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); } else { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName)); } String line; while ((line = reader.readLine()) != null) { sb.append(line).append("\r\n");// windows?\r\nLinux\n } // ??? return sb.delete(sb.length() - 2, sb.length()).toString(); } catch (IOException e) { e.printStackTrace(); return null; } finally { closeIO(reader); } }
From source file:gtu._work.mvn.MavenRepositoryUI.java
void defaultPopupMenu(final List<PomFile> pomFileList, Component component, MouseEvent evt) { if (pomFileList == null || pomFileList.isEmpty()) { return;/*w ww . j a va 2 s.c o m*/ } final PomFile pomFile = pomFileList.size() == 1 ? pomFileList.get(0) : null; if (pomFileList.size() > 0) { final JMenuItem copyAllMenu = new JMenuItem(); { final Set<File> jarList = new HashSet<File>(); final StringBuilder sb = new StringBuilder(); for (PomFile _pomFile : pomFileList) { if (_pomFile.jarFile != null) { sb.append(_pomFile.jarFile.getName() + "\n"); jarList.add(_pomFile.jarFile); } } if (sb.length() > 200) { sb.delete(200, sb.length() - 1); sb.append("...etc"); } final String title = "COPY SELECTED JAR : " + jarList.size(); copyAllMenu.setText(title); copyAllMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { System.out.println("# copyMenu action ..."); JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance() .confirmButtonYesNoCancel().showConfirmDialog(// "are you sure copy file : \n" + sb + "\tto \n" + copyTo + "\n\t???", title); if (result != JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) { return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { long startTime = System.currentTimeMillis(); File copyToFile = null; int successCount = 0; int errorCount = 0; StringBuilder err = new StringBuilder(); for (File jar : jarList) { copyToFile = new File(copyTo, jar.getName()); try { FileUtil.copyFile(jar, copyToFile); successCount++; } catch (IOException e) { e.printStackTrace(); errorCount++; err.append(jar + "\n"); } } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(// "copy completed!! \n" + // "during : " + (System.currentTimeMillis() - startTime) + "\n" + "success : " + successCount + "\n" + // "fail : " + errorCount + "\n" + // "fail list : \n" + err, "COMPLETED"); } }, "copy all jar to target " + hashCode()).start(); } }); } final JMenuItem copyAllNewMenu = new JMenuItem(); { final Set<File> jarList = new HashSet<File>(); final StringBuilder sb = new StringBuilder(); DependencyKey depenKey = null; PomFile _newPomFile = null; for (PomFile _pomFile : pomFileList) { if (_pomFile.jarFile != null) { depenKey = new DependencyKey(_pomFile.pom.groupId, _pomFile.pom.artifactId); if (pomFileMap.containsKey(depenKey)) { _newPomFile = pomFileMap.get(depenKey); System.out.println("find new success: " + _pomFile + " --> " + _newPomFile); _pomFile = _newPomFile; } else { System.out.println("find new faild!!: " + _pomFile); } if (_pomFile.jarFile != null) { sb.append(_pomFile.jarFile.getName() + "\n"); jarList.add(_pomFile.jarFile); } } } if (sb.length() > 200) { sb.delete(200, sb.length() - 1); sb.append("...etc"); } final String title = "COPY SELECTED JAR(newest) : " + jarList.size(); copyAllNewMenu.setText(title); copyAllNewMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { System.out.println("# copyMenu action ..."); JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance() .confirmButtonYesNoCancel().showConfirmDialog(// "are you sure copy file : \n" + sb + "\tto \n" + copyTo + "\n\t???", title); if (result != JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) { return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { long startTime = System.currentTimeMillis(); File copyToFile = null; int successCount = 0; int errorCount = 0; StringBuilder err = new StringBuilder(); for (File jar : jarList) { copyToFile = new File(copyTo, jar.getName()); try { FileUtil.copyFile(jar, copyToFile); successCount++; } catch (IOException e) { e.printStackTrace(); errorCount++; err.append(jar + "\n"); } } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(// "copy completed!! \n" + // "during : " + (System.currentTimeMillis() - startTime) + "\n" + "success : " + successCount + "\n" + // "fail : " + errorCount + "\n" + // "fail list : \n" + err, "COMPLETED"); } }, "copy all jar to target " + hashCode()).start(); } }); } JPopupMenuUtil.newInstance(component).applyEvent(evt).addJMenuItem(copyAllMenu, copyAllNewMenu).show(); } if (pomFile != null) { final JMenuItem copyMenu = new JMenuItem(); { if (pomFile.jarFile == null) { copyMenu.setText("COPY : no jar file"); copyMenu.setEnabled(false); } else if (copyTo == null) { copyMenu.setText("COPY : copy to not set"); copyMenu.setEnabled(false); } else { copyMenu.setText("COPY : " + this.getJarName(pomFile)); copyMenu.setEnabled(true); } copyMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { System.out.println("# copyMenu action ..."); File copyToFile = new File(copyTo, pomFile.jarFile.getName()); JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance() .confirmButtonYesNoCancel().showConfirmDialog(// "are you sure copy file : \n" + // pomFile.jarFile.getParent() + "\nto\n" + // copyToFile.getParent() + "\n" + // "\t???", getJarName(pomFile)); if (result == JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) { try { FileUtil.copyFile(pomFile.jarFile, copyToFile); } catch (IOException e) { e.printStackTrace(); JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(e.toString(), "ERROR"); } JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("copy success!!", "SUCCESS"); } } }); } final JMenuItem updateSnapshotMenu = new JMenuItem(); { updateSnapshotMenu.setText("update snapshot"); updateSnapshotMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { try { String command = String.format("cmd /c mvn -U -f \"%s\"", pomFile.xmlFile); System.out.println(command); final ProcessWatcher watcher = ProcessWatcher .newInstance(Runtime.getRuntime().exec("cmd /c @echo TODO!!")); //TODO //FIXME //XXX JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("TODO", "MAVEN UPDATE"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }, "execute Maven update").start(); } }); } final JMenuItem jdJarMenu = new JMenuItem(); { jdJarMenu.setText("jd-gui"); if (pomFile.jarFile == null) { jdJarMenu.setEnabled(false); } jdJarMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { try { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"", // "C:/apps/jd-gui-0.3.1.windows/jd-gui.exe", pomFile.jarFile)); } catch (IOException ex) { JCommonUtil.handleException(ex); } } }); } final JMenuItem openJarDirMenu = new JMenuItem(); { openJarDirMenu.setText("open dir"); openJarDirMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { try { Desktop.getDesktop().open(pomFile.xmlFile.getParentFile()); } catch (IOException ex) { JCommonUtil.handleException(ex); } } }); } final JMenuItem showDepedencyMessage = new JMenuItem(); { showDepedencyMessage.setText("show dependency"); showDepedencyMessage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { clipboardPomJarConfig(pomFile, true); } }); } JPopupMenuUtil.newInstance(component).applyEvent(evt) .addJMenuItem(copyMenu, updateSnapshotMenu, jdJarMenu, openJarDirMenu, showDepedencyMessage) .show(); } }
From source file:lcmc.data.DrbdXML.java
/** Prepares a new <code>DrbdXML</code> object. */ public DrbdXML(final Host[] hosts, final Map<Host, String> drbdParameters) { super();/* w w w . j av a 2 s . co m*/ addSpecialParameter("resource", "name", true); for (final Host host : hosts) { String output = null; if (drbdParameters.get(host) == null) { final String command = host.getDistCommand("Drbd.getParameters", (ConvertCmdCallback) null); final SSH.SSHOutput ret = Tools.execCommand(host, command, null, /* ExecCallback */ false, /* outputVisible */ SSH.DEFAULT_COMMAND_TIMEOUT); if (ret.getExitCode() != 0) { return; } output = ret.getOutput(); if (output == null) { return; } drbdParameters.put(host, output); } else { output = drbdParameters.get(host); } /* TODO: move this part somewhere else, it should be called once per invocation or interactively. (drbd-get-xml) */ final String[] lines = output.split("\\r?\\n"); final Pattern bp = Pattern.compile("^<command name=\"(.*?)\".*"); final Pattern ep = Pattern.compile("^</command>$"); final StringBuilder xml = new StringBuilder(); String section = null; for (final String line : lines) { final Matcher m = bp.matcher(line); if (m.matches()) { section = m.group(1); } if (section != null) { xml.append(line); xml.append('\n'); final Matcher m2 = ep.matcher(line); if (m2.matches()) { parseSection(section, xml.toString(), host, hosts); section = null; xml.delete(0, xml.length()); } } } if (!parametersList.contains("protocol")) { /* prior 8.4 */ addParameter("resource", "protocol", PROTOCOL_C, PROTOCOLS, true); } } }