List of usage examples for java.lang StringBuffer lastIndexOf
@Override public int lastIndexOf(String str)
From source file:org.squale.squalix.tools.clearcase.configuration.ClearCaseConfiguration.java
/** * Cette mthode est appele dans le cas d'un audit de jalon pour mettre en minuscules une partie prcise (le nom de * la branche) de la commande.<br /> * Typiquement, elle modifie la chane de la faon suivante : <br /> * // ww w . j a v a 2 s . c o m * <pre> * /usr/atria/bin/Perl -S /DINB/outils/gcl/script/mkview.pl -application * {APP_NAME} -vob /vobs/tonus_intranet -consultation TONUS_INTRANET_V1_2_ACT * -vws /app/SQUALE/clearcase/cc_storage/views/ * TONUS_INTRANET_V1_2_ACT_mon_application_mon_projet_squale.vws * -login mon_application_mon_projet_squale -snap -dir * /app/SQUALE/<b>TONUS_INTRANET_V1_2_ACT</b>_mon_application_mon_projet_squale * </pre> * * <br /> * en <br /> * * <pre> * /usr/atria/bin/Perl -S /DINB/outils/gcl/script/mkview.pl -application * {APP_NAME} -vob /vobs/tonus_intranet -consultation TONUS_INTRANET_V1_2_ACT * -vws /app/SQUALE/clearcase/cc_storage/views/ * TONUS_INTRANET_V1_2_ACT_mon_application_mon_projet_squale.vws * -login mon_application_mon_projet_squale -snap -dir * /app/SQUALE/<b>tonus_intranet_v1_2_act</b>_mon_application_mon_projet_squale * </pre> * * @param pCommand commande modifier. * @return la commande modifie. */ private String lowerBranchName(String pCommand) { StringBuffer buf = new StringBuffer(pCommand); /* * on cherche la position du caractre situ juste aprs le dernier sparateur UNIX ("/") de la chane. */ int pos = buf.lastIndexOf(ClearCaseConfiguration.UNIX_SEPARATOR) + 1; /* longueur de la chaine. */ int length = buf.length(); /* on met en minuscules la chaine comprise entre "pos" et "length". */ buf.replace(pos, length, buf.substring(pos, length).toLowerCase()); return buf.toString(); }
From source file:org.sakaiproject.component.app.roster.RosterManagerImpl.java
private List<Participant> buildParticipantList(Map<String, UserRole> userMap, Map<String, Profile> profilesMap) { List<Participant> participants = new ArrayList<Participant>(); Site site = null;/*from w ww . j a v a 2 s .c om*/ try { site = siteService().getSite(getSiteId()); } catch (IdUnusedException e) { log.error("getGroupsWithMember: " + e.getMessage(), e); return participants; } Collection<Group> groups = site.getGroups(); for (Iterator<Entry<String, Profile>> iter = profilesMap.entrySet().iterator(); iter.hasNext();) { Entry<String, Profile> entry = iter.next(); String userId = entry.getKey(); Profile profile = entry.getValue(); UserRole userRole = userMap.get(userId); // Profiles may exist for users that have been removed. If there's a profile // for a missing user, skip the profile. See SAK-10936 if (userRole == null || userRole.user == null) { log.warn("A profile exists for non-existent user " + userId); continue; } String groupsString = ""; StringBuffer sb = new StringBuffer(); for (Group group : groups) { Member member = group.getMember(userId); if (member != null) { sb.append(group.getTitle() + ", "); } } if (sb.length() > 0) { int endIndex = sb.lastIndexOf(", "); if (endIndex > 0) { groupsString = sb.substring(0, endIndex); } else { groupsString = sb.toString(); } } participants.add(new ParticipantImpl(userRole.user, profile, userRole.role, groupsString)); } return participants; }
From source file:ubic.gemma.loader.protein.ProteinLinkOutFormatter.java
/** * Convert a byte representing the evidence as stored in db to a textural display of evidence. e.g {0,1,0,0,0,1,0} > * GeneFusion:Database/*from w ww . j a v a2s.c o m*/ * * @param bytes byte array representing evidence * @return Formated text of evidence */ public String getEvidenceDisplayText(byte[] bytes) { StringBuffer evidenceString; try { evidenceString = new StringBuffer(); if (bytes != null && bytes.length == StringProteinInteractionEvidenceCodeEnum.values().length) { for (StringProteinInteractionEvidenceCodeEnum currentEvidence : StringProteinInteractionEvidenceCodeEnum .values()) { // if the byte at that particular position is 1 then that means that there is evidence if ((bytes[currentEvidence.getPositionInArray()]) == 1) { evidenceString.append(currentEvidence.getDisplayText()).append(EVIDENCESPACER); } } return evidenceString.substring(0, (evidenceString.lastIndexOf(EVIDENCESPACER))); } log.warn("The byte array provided was not the correct size for the protein protein interaction"); } catch (Exception e) { // should really be a more specific exception throw new RuntimeException("Bit Vector representing evidence codes for proteins was at error " + e); } return evidenceString.toString(); }
From source file:ubic.gemma.core.loader.protein.ProteinLinkOutFormatter.java
/** * Convert a byte representing the evidence as stored in db to a textural display of evidence. e.g {0,1,0,0,0,1,0} > * GeneFusion:Database/*from ww w.ja va 2 s.com*/ * * @param bytes byte array representing evidence * @return Formatted text of evidence */ public String getEvidenceDisplayText(byte[] bytes) { StringBuffer evidenceString; try { evidenceString = new StringBuffer(); if (bytes != null && bytes.length == StringProteinInteractionEvidenceCodeEnum.values().length) { for (StringProteinInteractionEvidenceCodeEnum currentEvidence : StringProteinInteractionEvidenceCodeEnum .values()) { // if the byte at that particular position is 1 then that means that there is evidence if ((bytes[currentEvidence.getPositionInArray()]) == 1) { evidenceString.append(currentEvidence.getDisplayText()).append(EVIDENCE_SPACER); } } return evidenceString.substring(0, (evidenceString.lastIndexOf(EVIDENCE_SPACER))); } log.warn("The byte array provided was not the correct size for the protein protein interaction"); } catch (Exception e) { // should really be a more specific exception throw new RuntimeException("Bit Vector representing evidence codes for proteins was at error " + e); } return evidenceString.toString(); }
From source file:com.bayontechnologies.bi.pentaho.plugin.openflashchart.OpenFlashChartComponent.java
/** * Flash Template String Replacement. It is the latest replacement. * @param flashFragment2 the flash template * @param id the id of the content item// w w w . ja v a 2 s .co m * @param chartWidth * @param chartHeight * @param ofcURL * @return the working flash codes */ public String replace(String flashFragment2, String id, Integer chartWidth, Integer chartHeight, String ofcURL) { StringBuffer buff = new StringBuffer(flashFragment2); //replace the {chart-width} String token = "{chart-width}"; int index; replaceByToken(buff, "" + chartWidth, token); //replace the {chart-height} token = "{chart-height}"; replaceByToken(buff, "" + chartHeight, token); //replace the {ofc-url} token = "{ofc-url}"; replaceByToken(buff, ofcURL, token); //replace the {data} token = "{data}"; index = buff.lastIndexOf(token); buff.replace(index, index + token.length(), getTmpContentURL(id)); //replace the {data} again index = buff.lastIndexOf(token); if (index != -1) { buff.replace(index, index + token.length(), getTmpContentURL(id)); } log.debug(" flash codes after replacing:" + buff.toString()); return buff.toString(); }
From source file:cc.siara.csv_ml_demo.MultiLevelCSVSwingDemo.java
/** * Runs each statement in the Output textbox *//* w w w. jav a 2 s. c o m*/ void runSQL() { if (parser.getSchema().getSeqPathNodeMap().size() == 0) { JOptionPane.showMessageDialog(null, "No schema. First parse a valid csv_ml"); return; } Connection con = null; try { con = DriverManager.getConnection(tfDBURL.getText()); StringBuffer out_str = new StringBuffer(); String id = tfID.getText(); String[] arr_id = null; if (id.indexOf(',') == -1) arr_id = new String[] { id }; else arr_id = id.split(","); DBBind.generateSQL(parser.getSchema(), out_str, con, arr_id); String end_schema = "end_schema\n"; if (out_str.lastIndexOf(end_schema) == out_str.length() - end_schema.length()) { JOptionPane.showMessageDialog(null, "No data found. Please run DDL/DML first"); } else { taInput.setText(out_str.toString()); tfInputSize.setText(String.valueOf(out_str.length())); } } catch (SQLException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, "SQL Exception" + e.getMessage()); return; } finally { try { if (con != null) con.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.java2s.intents4.IntentsDemo4Activity.java
String filterToString(IntentFilter filter) { StringBuffer buffer = new StringBuffer("IntentFilter { "); Iterator<String> actionsIter = filter.actionsIterator(); if (actionsIter != null) { buffer.append("act=["); while (actionsIter.hasNext()) { String temp = actionsIter.next().trim(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter action: >" + temp + "<"); }/*from w w w . jav a2 s . co m*/ if (buffer.lastIndexOf(",") >= 0) { buffer.setCharAt(buffer.lastIndexOf(","), ']'); } else { buffer.append(']'); } buffer.append(" "); } Iterator<String> schemesIter = filter.schemesIterator(); if (schemesIter != null) { buffer.append("sche=["); while (schemesIter.hasNext()) { String temp = schemesIter.next().trim(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter scheme: >" + temp + "<"); } buffer.setCharAt(buffer.lastIndexOf(","), ']'); buffer.append(" "); } Iterator<IntentFilter.AuthorityEntry> authsIter = filter.authoritiesIterator(); if (authsIter != null) { buffer.append("auth=["); while (authsIter.hasNext()) { IntentFilter.AuthorityEntry entry = authsIter.next(); String temp = entry.getHost() + ":" + entry.getPort(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter authority: >" + temp + "<"); } buffer.setCharAt(buffer.lastIndexOf(","), ']'); buffer.append(" "); } Iterator<PatternMatcher> pathsIter = filter.pathsIterator(); if (pathsIter != null) { buffer.append("path=["); while (pathsIter.hasNext()) { PatternMatcher entry = pathsIter.next(); String temp = entry.toString(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter path: >" + temp + "<"); } buffer.setCharAt(buffer.lastIndexOf(","), ']'); buffer.append(" "); } Iterator<String> typesIter = filter.typesIterator(); if (typesIter != null) { buffer.append("typ=["); while (typesIter.hasNext()) { String temp = typesIter.next().trim(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter type: >" + temp + "<"); } buffer.setCharAt(buffer.lastIndexOf(","), ']'); buffer.append(" "); } Iterator<String> catsIter = filter.categoriesIterator(); if (catsIter != null) { buffer.append("cat=["); while (catsIter.hasNext()) { String temp = catsIter.next().trim(); buffer.append(temp + ","); Log.i(CLASSNAME, "Filter category: >" + temp + "<"); } buffer.setCharAt(buffer.lastIndexOf(","), ']'); buffer.append(" "); } buffer.append('}'); return buffer.toString(); }
From source file:org.nuxeo.ecm.platform.ui.web.auth.cas2.Cas2Authenticator.java
protected String getAppURL(HttpServletRequest httpRequest) { if (isValidStartupPage(httpRequest)) { StringBuffer sb = new StringBuffer(VirtualHostHelper.getServerURL(httpRequest)); if (VirtualHostHelper.getServerURL(httpRequest).endsWith("/")) { sb.deleteCharAt(sb.length() - 1); }/*from w w w . j a v a2 s . c o m*/ sb.append(httpRequest.getRequestURI()); if (httpRequest.getQueryString() != null) { sb.append("?"); sb.append(httpRequest.getQueryString()); // remove ticket parameter from URL to correctly validate the // service int indexTicketKey = sb.lastIndexOf(ticketKey + "="); if (indexTicketKey != -1) { sb.delete(indexTicketKey - 1, sb.length()); } } return sb.toString(); } if (appURL == null || appURL.equals("")) { appURL = NUXEO_SERVER_PATTERN_KEY; } if (appURL.contains(NUXEO_SERVER_PATTERN_KEY)) { String nxurl = BaseURL.getBaseURL(httpRequest); return appURL.replace(NUXEO_SERVER_PATTERN_KEY, nxurl); } else { return appURL; } }
From source file:fr.univlille2.ecm.platform.ui.web.auth.cas2.Cas2Authenticator.java
protected String getAppURL(HttpServletRequest httpRequest) { log.debug("getAppURL"); if (isValidStartupPage(httpRequest)) { StringBuffer sb = new StringBuffer(VirtualHostHelper.getServerURL(httpRequest)); if (VirtualHostHelper.getServerURL(httpRequest).endsWith("/")) { sb.deleteCharAt(sb.length() - 1); }//from ww w. jav a 2 s.c om sb.append(httpRequest.getRequestURI()); if (httpRequest.getQueryString() != null) { sb.append("?"); sb.append(httpRequest.getQueryString()); // remove ticket parameter from URL to correctly validate the // service int indexTicketKey = sb.lastIndexOf(ticketKey + "="); if (indexTicketKey != -1) { sb.delete(indexTicketKey - 1, sb.length()); } } log.debug(sb.toString()); return sb.toString(); } if (appURL == null || appURL.equals("")) { log.debug("null app url"); appURL = NUXEO_SERVER_PATTERN_KEY; } if (appURL.contains(NUXEO_SERVER_PATTERN_KEY)) { String nxurl = BaseURL.getBaseURL(httpRequest); log.debug(String.format("nxurl app url : %s", appURL.replace(NUXEO_SERVER_PATTERN_KEY, nxurl))); return appURL.replace(NUXEO_SERVER_PATTERN_KEY, nxurl); } else { log.debug(String.format("appurl: %s", appURL)); return appURL; } }
From source file:com.leosys.core.telnet.Telent.java
public void readUntil(String str) { char last = str.charAt(str.length() - 1); String[] ss;// w w w. j a va2 s . co m try { StringBuffer sb = new StringBuffer(); char c; int code = -1; boolean ansiControl = false; boolean start = true; while ((code = (in.read())) != -1) { c = (char) code; if (c == '\033') {//vt100?\033 ansiControl = true; int code2 = in.read(); char cc = (char) code2; if (cc == '[' || cc == '(') { } } if (!ansiControl) { if (c == '\r') { String olds = new String(sb.toString().getBytes(ORIG_CODEC), TRANSLATE_CODEC); System.out.println(olds); if (sb.lastIndexOf(str) != -1) { break; } sb.delete(0, sb.length()); } else if (c == '\n') ; else sb.append(c); if (sb.lastIndexOf(str) != -1) { break; } } if (ansiControl) { if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '"') { ansiControl = false; } } } System.out.println(new String(sb.toString().getBytes(ORIG_CODEC), TRANSLATE_CODEC)); } catch (Exception e) { e.printStackTrace(); } }