List of usage examples for org.apache.commons.lang3 StringUtils replaceOnce
public static String replaceOnce(final String text, final String searchString, final String replacement)
Replaces a String with another String inside a larger String, once.
A null reference passed to this method is a no-op.
StringUtils.replaceOnce(null, *, *) = null StringUtils.replaceOnce("", *, *) = "" StringUtils.replaceOnce("any", null, *) = "any" StringUtils.replaceOnce("any", *, null) = "any" StringUtils.replaceOnce("any", "", *) = "any" StringUtils.replaceOnce("aba", "a", null) = "aba" StringUtils.replaceOnce("aba", "a", "") = "ba" StringUtils.replaceOnce("aba", "a", "z") = "zba"
From source file:mfi.filejuggler.responsibles.BasicApplication.java
@Responsible(conditions = { Condition.WEBLINK_INTERN }) public void fjWeblinkInternOeffnen(StringBuilder sb, Map<String, String> parameters, Model model) throws Exception { int index = Integer.parseInt(parameters.get(HTMLUtils.TABLEINDEX)); String link = model.lookupConversation().getAnzeigeAuswahlListe().get(index); String iframe = HTMLUtils.buildIFrame("weblinkIntern", link); String host = null;/*from w ww . jav a2s. c o m*/ try { host = new URL(link).getHost(); if (StringUtils.startsWith(host, "www.")) { host = StringUtils.replaceOnce(host, "www.", ""); } } catch (MalformedURLException mue) { host = ""; } ButtonBar buttonBar = new ButtonBar(); buttonBar.getButtons().add(new Button("Im Browser ffnen", link, true)); sb.append(HTMLUtils.buildMenuNar(model, "Website Vorschau", true, buttonBar, true)); HTMLTable table = new HTMLTable(); table.addTD(host, 1, HTMLTable.TABLE_HEADER); table.addNewRow(); table.addTDSource(iframe, 1, HTMLTable.NO_BORDER); table.setWidthTo100Percent(true); sb.append(table.buildTable(model)); return; }
From source file:com.xpn.xwiki.doc.XWikiDocument.java
public void insertText(String text, String marker, XWikiContext context) throws XWikiException { setContent(StringUtils.replaceOnce(getContent(), marker, text + marker)); context.getWiki().saveDocument(this, context); }
From source file:org.apache.syncope.core.persistence.jpa.dao.JPAAccessTokenDAO.java
@Transactional(readOnly = true) @Override// w ww.ja v a 2s.c om public int count() { StringBuilder queryString = buildFindAllQuery(); Query query = entityManager() .createQuery(StringUtils.replaceOnce(queryString.toString(), "SELECT e", "SELECT COUNT(e)")); return ((Number) query.getSingleResult()).intValue(); }
From source file:org.apache.syncope.core.persistence.jpa.dao.JPATaskDAO.java
@Override public int count(final TaskType type, final ExternalResource resource, final Notification notification, final AnyTypeKind anyTypeKind, final String entityKey) { StringBuilder queryString = buildFindAllQuery(type, resource, notification, anyTypeKind, entityKey); Query query = entityManager() .createQuery(StringUtils.replaceOnce(queryString.toString(), "SELECT t", "SELECT COUNT(t)")); if (resource != null) { query.setParameter("resource", resource); }/*from w ww . j a va 2 s . c o m*/ if (notification != null) { query.setParameter("notification", notification); } if (anyTypeKind != null && entityKey != null) { query.setParameter("anyTypeKind", anyTypeKind); query.setParameter("entityKey", entityKey); } return ((Number) query.getSingleResult()).intValue(); }
From source file:org.blockartistry.mod.ThermalRecycling.util.ItemStackHelper.java
public static ItemStack convertToDustIfPossible(final ItemStack stack) { String oreName = ItemHelper.getOreName(stack); if (oreName == null) return stack; if (oreName.startsWith("ingot")) oreName = StringUtils.replaceOnce(oreName, "ingot", "dust"); else if (oreName.startsWith("plank")) oreName = StringUtils.replaceOnce(oreName, "plank", "dust"); else/*from w w w. j av a 2s . c o m*/ return stack; return getItemStack(oreName); }
From source file:org.eclipse.jdt.ls.core.internal.handlers.NavigateToDefinitionHandler.java
private static Location fixLocation(IJavaElement element, Location location, IJavaProject javaProject) { if (location == null) { return null; }/*from w w w . j a v a2 s .co m*/ if (!javaProject.equals(element.getJavaProject()) && element.getJavaProject().getProject().getName().equals(ProjectsManager.DEFAULT_PROJECT_NAME)) { // see issue at: https://github.com/eclipse/eclipse.jdt.ls/issues/842 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=541573 // for jdk classes, jdt will reuse the java model by altering project to share the model between projects // so that sometimes the project for `element` is default project and the project is different from the project for `unit` // this fix is to replace the project name with non-default ones since default project should be transparent to users. if (location.getUri().contains(ProjectsManager.DEFAULT_PROJECT_NAME)) { String patched = StringUtils.replaceOnce(location.getUri(), ProjectsManager.DEFAULT_PROJECT_NAME, javaProject.getProject().getName()); try { IClassFile cf = (IClassFile) JavaCore.create(JDTUtils.toURI(patched).getQuery()); if (cf != null && cf.exists()) { location.setUri(patched); } } catch (Exception ex) { } } } return location; }
From source file:org.gsweb.components.tag.FilteringSelectTag.java
private FilteringSelect handler() { this.width = this.width.toLowerCase(); if (this.width.endsWith("px")) { this.width = StringUtils.replaceOnce(this.width, "px", ""); }/*from w w w .j a v a 2s . c o m*/ FilteringSelect select = new FilteringSelect(); select.setId(this.id); select.setName(this.name); select.setWidth(Integer.parseInt(this.width)); select.setDataSource(this.dataSource); select.setValue(this.value); select.setOnChange(this.onChange); select.setReadonly(this.readonly); return select; }
From source file:org.gsweb.components.tag.GridTag.java
private Grid handler() { this.width = this.width.toLowerCase(); if (this.width.endsWith("px")) { this.width = StringUtils.replaceOnce(this.width, "px", ""); }/* w ww. jav a2 s. co m*/ Grid grid = new Grid(); grid.setId(this.id); grid.setGridFieldStructure(this.gridFieldStructure); grid.setClearQueryFn(this.clearQueryFn); grid.setWidth(Integer.parseInt(this.width)); grid.setProgramId(this.programId); grid.setDisableOnHeaderCellClick(this.disableOnHeaderCellClick); return grid; }
From source file:org.gsweb.components.tag.SelectTag.java
private Select handler() { this.width = this.width.toLowerCase(); if (this.width.endsWith("px")) { this.width = StringUtils.replaceOnce(this.width, "px", ""); }/*w ww . ja v a2 s . co m*/ Select select = new Select(); select.setId(this.id); select.setName(this.name); select.setWidth(Integer.parseInt(this.width)); select.setDataSource(this.dataSource); select.setValue(this.value); select.setOnChange(this.onChange); select.setReadonly(this.readonly); return select; }
From source file:org.gsweb.components.tag.TextBoxTag.java
private TextBox handler() { this.width = this.width.toLowerCase(); if (this.width.endsWith("px")) { this.width = StringUtils.replaceOnce(this.width, "px", ""); }//from w w w. jav a 2 s . c o m TextBox textBox = new TextBox(); textBox.setId(this.id); textBox.setName(this.name); textBox.setMaxlength(Integer.parseInt(this.maxlength)); textBox.setPlaceHolder(this.placeHolder); textBox.setWidth(Integer.parseInt(this.width)); textBox.setValue(this.value); textBox.setReadonly(this.readonly); return textBox; }