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

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

Introduction

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

Prototype

public static String reverse(final String str) 

Source Link

Document

Reverses a String as per StringBuilder#reverse() .

A null String returns null .

 StringUtils.reverse(null)  = null StringUtils.reverse("")    = "" StringUtils.reverse("bat") = "tab" 

Usage

From source file:com.github.jrh3k5.mojo.flume.FlumePluginTest.java

/**
 * If the group ID differs, then the two should not match.
 *///from ww  w  .ja v  a 2 s. c  om
@Test
public void testMatchesDifferentGroupId() {
    when(artifact.getGroupId()).thenReturn(StringUtils.reverse(groupId));
    when(artifact.getArtifactId()).thenReturn(artifactId);
    when(artifact.getClassifier()).thenReturn(classifier);
    when(artifact.getType()).thenReturn(type);
    assertThat(flumePlugin.matches(artifact)).isFalse();
}

From source file:com.neatresults.mgnltweaks.ui.contentapp.browser.DetailBrowserSubApp.java

@Override
protected void restoreBrowser(BrowserLocation location) {
    super.restoreBrowser(location);
    caption = StringUtils.reverse(StringUtils.abbreviate(StringUtils.reverse(location.getNodePath()), 20));

    final Object item = contentConnector.getItemIdByUrlFragment(location.getNodePath());
    // expand our item
    workbenchPresenter.expand(item);//from  w w  w . ja va 2 s .  c  o m
}

From source file:com.github.jrh3k5.mojo.flume.FlumePluginTest.java

/**
 * If the type differs, then the two should not match.
 *//* ww  w. ja va 2  s .c  o m*/
@Test
public void testMatchesDifferentType() {
    when(artifact.getGroupId()).thenReturn(groupId);
    when(artifact.getArtifactId()).thenReturn(artifactId);
    when(artifact.getClassifier()).thenReturn(classifier);
    when(artifact.getType()).thenReturn(StringUtils.reverse(type));
    assertThat(flumePlugin.matches(artifact)).isFalse();
}

From source file:com.atomicleopard.thundr.gae.channels.ChannelService.java

private static final String limitTo64Bytes(String clientId) {
    try {/*from  w w w.  j  a  v  a  2  s  .co  m*/
        byte[] bytes = clientId.getBytes("UTF-8");
        byte[] newBytes = Arrays.copyOfRange(bytes, Math.max(0, bytes.length - 64), bytes.length);
        return new String(newBytes, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        Logger.warn(
                "Unsupported encoding exception while determining clientId, making a best guess and continuing: %s",
                e.getMessage());
        return StringUtils.reverse(StringUtils.reverse(clientId).substring(0, 64));
    }
}

From source file:com.xpn.xwiki.objects.classes.StaticListClassTest.java

/**
 * Tests that the list values are joined using the specified separator without being XML-encoded.
 *
 * @see "XWIKI-9680: Apostrophes in static list value are encoded on .display()"
 *///from www  .j ava2s . com
@Test
public void testDisplayView() {
    ListProperty listProperty = new ListProperty();
    listProperty.setValue(VALUES_WITH_HTML_SPECIAL_CHARS);

    String propertyName = "foo";
    BaseObject object = new BaseObject();
    object.addField(propertyName, listProperty);

    StaticListClass staticListClass = new StaticListClass();
    staticListClass.setSeparator(" * ");
    staticListClass
            .setValues(VALUES_WITH_HTML_SPECIAL_CHARS.get(0) + '|' + VALUES_WITH_HTML_SPECIAL_CHARS.get(1) + '='
                    + StringUtils.reverse(VALUES_WITH_HTML_SPECIAL_CHARS.get(1)) + '|'
                    + VALUES_WITH_HTML_SPECIAL_CHARS.get(2));
    assertEquals("a<b>c * 3'2\"1 * x{y&z", staticListClass.displayView(propertyName, "", object, null));
}

From source file:com.glaf.core.security.RSAUtils.java

/**
 * ?JS??/*  w  w  w .j  a v  a 2 s .com*/
 * 
 * @param encrypttext
 *            
 * @return {@code encrypttext} 
 */
public static String decryptStringByJs(String encrypttext) {
    String text = decryptString(encrypttext);
    if (text == null) {
        return null;
    }
    return StringUtils.reverse(text);
}

From source file:com.xpn.xwiki.objects.classes.StaticListClassTest.java

/**
 * Tests the HTML output produced in edit mode.
 *
 * @param displayType the display type (input, radio, select, etc.)
 * @param selectedValues the selected values
 * @param expectedHTML the expected HTML output
 *//*from  w w w  . j  a  v  a 2s .  com*/
private void testDisplayEdit(String displayType, List<String> selectedValues, String expectedHTML) {
    ListProperty listProperty = new ListProperty();
    listProperty.setValue(selectedValues);

    // Use special XML characters, even if they are not valid inside an XML name, just to test the XML escaping.
    String propertyName = "b&a<r";
    String prefix = "w>v";
    BaseObject object = new BaseObject();
    object.addField(propertyName, listProperty);

    StaticListClass staticListClass = new StaticListClass();
    staticListClass.setSize(7);
    StringBuilder values = new StringBuilder();
    for (String value : VALUES_WITH_HTML_SPECIAL_CHARS) {
        if (values.length() > 0) {
            values.append('|');
        }
        values.append(value).append('=').append(StringUtils.reverse(value));
    }
    staticListClass.setValues(values.toString());

    staticListClass.setDisplayType(displayType);
    assertEquals(expectedHTML, staticListClass.displayEdit(propertyName, prefix, object, null));
}

From source file:com.joyent.manta.http.MantaHttpHeadersIT.java

public void canFailToDeleteDirectoryOnBadIfMatch() throws IOException {
    final String path = generatePath();

    final MantaObjectResponse empty = mantaClient.put(path, new byte[0]);
    // the etag reversed should not be equal to the etag (so we can fail if-match on purpose)
    assertFalse(empty.getEtag().equals(StringUtils.reverse(empty.getEtag())));

    final MantaHttpHeaders headers = new MantaHttpHeaders();

    // fail on bad if-match
    headers.setIfMatch(StringUtils.reverse(empty.getEtag()));
    final MantaClientHttpResponseException badIfMatchEx = expectThrows(MantaClientHttpResponseException.class,
            () -> mantaClient.delete(path, headers));

    assertEquals(badIfMatchEx.getStatusCode(), HttpStatus.SC_PRECONDITION_FAILED);

    // the object should still exist
    assertTrue(mantaClient.existsAndIsAccessible(path));

    // set the correct If-Match header
    headers.setIfMatch(empty.getEtag());
    mantaClient.delete(path, headers);//ww  w .ja  va  2s .c o  m

    // the object should not exist
    assertFalse(mantaClient.existsAndIsAccessible(path));
}

From source file:com.xpn.xwiki.objects.classes.StaticListClassTest.java

/**
 * Tests the suggest code generated when "use suggest" is set.
 *//*w  w  w  .  java  2  s . co  m*/
@Test
public void testDisplayEditWithSuggest() throws Exception {
    ListProperty listProperty = new ListProperty();
    listProperty.setValue(VALUES_WITH_HTML_SPECIAL_CHARS);

    // Use special XML characters, even if they are not valid inside an XML name, just to test the XML escaping.
    String propertyName = "b&a<r";
    String prefix = "w>v";
    BaseObject object = new BaseObject();
    object.addField(propertyName, listProperty);

    StaticListClass staticListClass = new StaticListClass();
    BaseClass ownerClass = new BaseClass();
    ownerClass.setDocumentReference(new DocumentReference("xwiki", "ClassSpace", "ClassName"));
    staticListClass.setName(propertyName);
    staticListClass.setObject(ownerClass);
    staticListClass.setSize(7);
    StringBuilder values = new StringBuilder();
    for (String value : VALUES_WITH_HTML_SPECIAL_CHARS) {
        if (values.length() > 0) {
            values.append('|');
        }
        values.append(value).append('=').append(StringUtils.reverse(value));
    }
    staticListClass.setValues(values.toString());

    staticListClass.setDisplayType("input");
    staticListClass.setPicker(true);
    doReturn("/xwiki/bin/view/Main/WebHome").when(this.oldcore.getSpyXWiki()).getURL("Main.WebHome", "view",
            this.oldcore.getXWikiContext());
    String output = staticListClass.displayEdit(propertyName, prefix, object, this.oldcore.getXWikiContext());
    System.err.println(output);
    assertTrue(output
            .contains("new ajaxSuggest(this, &#123;script:&#34;/xwiki/bin/view/Main/WebHome?xpage=suggest&#38;"
                    + "classname=ClassSpace.ClassName&#38;fieldname=b&#38;a&#60;r&#38;firCol=-&#38;"
                    + "secCol=-&#38;&#34;, varname:&#34;input&#34;} )"));
}

From source file:com.epam.catgenome.util.ProteinSequenceUtils.java

/**
 * Provides reverse complement operation on sequence string
 *
 * @param sequence nucleotide sequence//  ww w . j  a  v  a  2  s .c o  m
 * @return reversed complement nucleotide sequence string
 */
public static String reverseComplement(final String sequence) {
    char[] chars = sequence.toCharArray();
    char[] complementChars = new char[chars.length];
    for (int i = 0; i < chars.length; i++) {
        complementChars[i] = complement(chars[i]);
    }

    return StringUtils.reverse(new String(complementChars));
}