Example usage for org.apache.commons.lang3 StringUtils remove

List of usage examples for org.apache.commons.lang3 StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils remove.

Prototype

public static String remove(final String str, final char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

A null source string will return null .

Usage

From source file:com.google.dart.tools.ui.internal.text.dart.DartAutoIndentStrategyTest.java

private static void assert_customizeDocumentCommand(String initial, String newText, String expected) {
    int initialOffset = initial.indexOf('!');
    int expectedOffset = expected.indexOf('!');
    assertTrue("No cursor position in initial: " + initial, initialOffset != -1);
    assertTrue("No cursor position in expected: " + expected, expectedOffset != -1);
    initial = StringUtils.remove(initial, '!');
    expected = StringUtils.remove(expected, '!');
    // force "smart mode"
    DartAutoIndentStrategy_NEW strategy = new DartAutoIndentStrategy_NEW(DartPartitions.DART_PARTITIONING,
            null) {/*  w  w w .j  a  va  2s  .c  om*/
        @Override
        protected boolean computeSmartMode() {
            return true;
        }
    };
    // prepare document
    IDocument document = new Document(initial);
    // handle command
    DocumentCommand command = new DocumentCommand() {
    };
    command.caretOffset = -1;
    command.doit = true;
    command.offset = initialOffset;
    command.text = newText;
    strategy.customizeDocumentCommand(document, command);
    // update document
    ReflectionUtils.invokeMethod(command, "execute(org.eclipse.jface.text.IDocument)", document);
    // check new content
    String actual = document.get();
    assertEquals(expected, actual);
    // check caret offset
    int actualOffset = command.caretOffset;
    if (actualOffset == -1) {
        actualOffset = initialOffset + command.text.length();
    }
    assertThat(actualOffset).isEqualTo(expectedOffset);
}

From source file:com.anrisoftware.prefdialog.miscswing.editcontextmenu.DeleteAction.java

@Override
public void actionPerformed(ActionEvent e) {
    String text = textField.getText();
    String selected = textField.getSelectedText();
    String deleted = StringUtils.remove(text, selected);
    textField.setText(deleted);/*from  w w w . j a  v  a  2 s. co  m*/
}

From source file:com.norconex.importer.parser.GenericDocumentParserFactoryTest.java

@Test
public void testIgnoringContentTypes() throws IOException, ImporterException {

    GenericDocumentParserFactory factory = new GenericDocumentParserFactory();
    factory.setIgnoredContentTypesRegex("application/pdf");
    ImporterMetadata metadata = new ImporterMetadata();

    ImporterConfig config = new ImporterConfig();
    config.setParserFactory(factory);//  w w w  .j a  v a2 s .c  o m
    Importer importer = new Importer(config);
    ImporterDocument doc = importer
            .importDocument(TestUtil.getAlicePdfFile(), ContentType.PDF, null, metadata, "n/a").getDocument();

    try (InputStream is = doc.getContent()) {
        String output = IOUtils.toString(is).substring(0, 100);
        output = StringUtils.remove(output, '\n');
        Assert.assertTrue("Non-parsed output expected to be binary.", !StringUtils.isAsciiPrintable(output));
    }
}

From source file:com.mirth.connect.plugins.dashboardstatus.DashboardConnectorStatusServlet.java

@Override
public Map<String, String> getChannelStates() {
    Map<String, Object[]> connectorStates = redactChannelIds(
            monitor.getConnectorListener().getConnectorStateMap());
    Map<String, String> channelStates = new HashMap<String, String>();

    for (Entry<String, Object[]> entry : connectorStates.entrySet()) {
        if (StringUtils.contains(entry.getKey(), "_0")) {
            String channelId = StringUtils.remove(entry.getKey(), "_0");
            if (!isChannelRedacted(channelId)) {
                channelStates.put(channelId, (String) entry.getValue()[1]);
            }/*from   w  ww .  j a va 2s  . com*/
        }
    }

    return channelStates;
}

From source file:io.wcm.handler.url.integrator.IntegratorPlaceholder.java

/**
 * Get placeholder name without surrounding ###
 * @param placeholder Placeholder/* w  w w .j a va2s.  c  o  m*/
 * @return Placeholder name
 */
private static String getPlaceholderName(String placeholder) {
    return StringUtils.remove(placeholder, "###");
}

From source file:com.inkubator.hrm.util.HrmUserInfoUtil.java

public static Boolean isValidRemoteAddress() throws Exception {
    HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance()
            .getExternalContext().getRequest();
    String ipClient = IpUtil.getIpFromRequest(httpServletRequest);
    String riversIp = StringUtils.reverse(ipClient);
    String ipHeaderReverse = StringUtils.substringAfter(riversIp, ".");
    String ipEnd = StringUtils.substringBefore(riversIp, ".");
    int ipLast = Integer.parseInt(StringUtils.reverse(ipEnd));
    LOGGER.info("Nilai Ip " + IpUtil.getIpFromRequest(httpServletRequest));
    String ip = StringUtils.remove(ipHeaderReverse, ".");
    int ipHeader = Integer.parseInt(StringUtils.reverse(ip));
    IpPermitService ipPermitService = (IpPermitService) ServiceWebUtil.getService("ipPermitService");
    List<IpPermit> dataToCheck = ipPermitService.getByIpHeader(ipHeader);
    for (IpPermit ipPermit : dataToCheck) {
        int fromAddres2 = ipPermit.getUntilAddress1();
        int untilAddress2 = ipPermit.getUntilAddress2();
        if (ipLast >= fromAddres2 && ipLast <= untilAddress2) {
            return Boolean.TRUE;
        }/*from  w ww .  j  a v a2s . c  o m*/
    }
    return Boolean.FALSE;
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.rte.els.RteImageDomElementListener.java

@Override
public boolean listen(DomElementEvent event) {
    String pageId = event.getAttr("data-pageid");
    if (StringUtils.isBlank(pageId) == true) {
        pageId = event.getAttr("data-wiki-url");
    }/*  w  w  w.  jav  a 2  s . c om*/
    pageId = handleDataImage(event, pageId);
    GWikiFragmentImage image = parseImage(event, pageId);

    String styleClass = image.getStyleClass();
    styleClass = StringUtils.remove(styleClass, "weditimg");
    if (StringUtils.isBlank(styleClass) == true) {
        styleClass = "";
    }
    image.setStyleClass(styleClass);
    event.getParseContext().addFragment(image);
    return false;

}

From source file:at.ac.tuwien.infosys.jcloudscale.datastore.driver.couchdb.CouchDBDriver.java

@Override
protected String getLastRevision(Datastore datastore, String id) {
    Request request = new Request.Builder(ProtocolType.HTTP, RequestType.HEAD,
            URLUtil.getCouchDBCurrentRevision(datastore, id), datastore.getHost(), datastore.getPort()).build();
    Response response = requestHandler.handle(request);
    response.verify();/*w w  w  .j a v  a2 s  . c  om*/
    return StringUtils.remove(response.getHeaderField("ETag"), '"');
}

From source file:ch.cyberduck.core.AbstractHostCollection.java

/**
 * @param h Bookmark//from  w  ww.j av a 2 s  . c  o m
 * @return User comment for bookmark or null
 */
public String getComment(final Host h) {
    if (StringUtils.isNotBlank(h.getComment())) {
        return StringUtils.remove(StringUtils.remove(h.getComment(), CharUtils.LF), CharUtils.CR);
    }
    return null;
}

From source file:de.jfachwert.bank.IBAN.java

@SuppressWarnings("squid:SwitchLastCaseIsDefaultCheck")
private static String validate(String iban, PruefzifferVerfahren<String> pzVerfahren) {
    String normalized = StringUtils.remove(iban, ' ').toUpperCase();
    LengthValidator.validate(normalized, 16, 34);
    switch (normalized.substring(0, 1)) {
    case "AT":
        LengthValidator.validate(iban, 20);
        break;/*  w w w.  j a v  a 2s  .  c  om*/
    case "CH":
        LengthValidator.validate(iban, 21);
        break;
    case "DE":
        LengthValidator.validate(iban, 22);
        break;
    }
    return pzVerfahren.validate(normalized);
}