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

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

Introduction

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

Prototype

public static String reverse(String str) 

Source Link

Document

Reverses a String as per StrBuilder#reverse() .

Usage

From source file:Main.java

public static void main(String[] args) {
    String words = "The quick brown fox jumps over the lazy dog";

    String reversed = StringUtils.reverse(words);

    String delimitedReverse = StringUtils.reverseDelimited(words, ' ');

    System.out.println("Original: " + words);
    System.out.println("Reversed: " + reversed);
    System.out.println("Delimited Reverse: " + delimitedReverse);
}

From source file:StringUtilsTrial.java

public static void main(String[] args) {

    // Reverse a String
    System.out.println("9) Reverse >>>" + StringUtils.reverse("REVERSE"));

}

From source file:net.pj.games.eulerproject.elements.StringPermutator.java

public static String getNextPermutationOf(String s) {

    String next;/*from   ww w  . j  av a 2 s  .  c  o m*/
    //log.debug("next of {}", s);
    if (isReverseOrdered(s)) {
        //log.debug("Reverse ordered. End of Chain", s);
        return null;
    } else if (s.length() == 2) {
        next = StringUtils.reverse(s);
    } else {
        int max = getIndexOfMax(s);
        if (max > 0 && isReverseOrdered(s.substring(max))) {
            final String suffix = s.substring(max - 1);
            next = s.replace(suffix, incrementWithNextAvailableValue(suffix));
        } else {
            final String suffix = s.substring(max + 1);
            final String nextSuffix = getNextPermutationOf(suffix);
            if (nextSuffix != null) {
                next = s.replace(suffix, nextSuffix);
            } else {
                //log.debug("suffix {} has no next permutation", suffix);
                next = null;
            }
        }
    }
    //log.debug("next is {}", next);
    return next;

}

From source file:com.discursive.jccook.xml.bean.ReverseRule.java

public void body(String namespace, String name, String text) throws Exception {
    Message result = (Message) digester.getRoot();
    String reversed = StringUtils.reverse(result.getText());
    result.setText(reversed);//from   ww  w.  ja  v a 2 s  .c o  m
}

From source file:de.doncarnage.minecraft.babble.patterns.constant.ReversePattern.java

@Override
public String transformString(String original) {
    return StringUtils.reverse(original);
}

From source file:com.atlassian.theplugin.util.CodeNavigationUtil.java

/**
 * Note: must be run from event dispatch thread or inside read-action only!
 *///from   w  w  w. j  av  a2s .  c om
@Nullable
public static PsiFile guessMatchingFile(String pathname, PsiFile[] psifiles, VirtualFile baseDir) {
    // PL-822 fix
    // for making it work if pathname comes from different OS than the file itself
    // e.g. Bamboo works on Windows, send pathname and the user has a project opened in IDEA on Linux
    pathname = pathname.replace('\\', '/');

    PsiFile bestMatch = null;

    int difference = 0;

    if (psifiles != null) {

        for (PsiFile psiFile : psifiles) {
            // we use hard-coded '/' as separator in order to make string comparison platform independent
            String absolutePath = psiFile.getVirtualFile().getUrl();
            if (absolutePath == null) {
                continue;
            }

            int diff = StringUtils.indexOfDifference(StringUtils.reverse(pathname),
                    StringUtils.reverse(absolutePath));
            if (diff >= FilenameUtils.getName(absolutePath).length()
                    && (diff > difference || absolutePath.equals(pathname))) {
                difference = diff;
                bestMatch = psiFile;
                if (absolutePath.equals(pathname)) {
                    break;
                }
            }
        }
    }
    return bestMatch;
}

From source file:net.shopxx.service.impl.AuthServiceImpl.java

@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws Exception {
    try {//from  w  w w .  ja v  a 2  s .  com
        if (securityManager == null) {
            return;
        }
        Collection<Realm> realms = securityManager.getRealms();
        if (CollectionUtils.isEmpty(realms)) {
            return;
        }

        String a = StringUtils.reverse("mlaeRgnizirohtuA.mlaer.orihs.ehcapa.gro");
        String b = StringUtils.reverse("mlaeRhtuA.mlaer.orihs.ehcapa.gro");
        String c = StringUtils.reverse(";L0 = tnuoc gnol etavirp");
        String d = StringUtils.reverse(";mlaer mlaeRgnizirohtuA.mlaer.orihs.ehcapa.gro etavirp");
        String e = StringUtils
                .reverse("};))(emaNehcaCnoitazirohtuAteg.1$(emaNehcaCnoitazirohtuAtes ;1$ = mlaer.0${");
        String f = StringUtils.reverse(
                "} ;)(noitpecxEesneciLtcerrocnI.noitpecxe.xxpohs.ten wen worht } ;)(noitpecxEesneciLtcerrocnI.noitpecxe.xxpohs.ten wen worht { )e noitpecxE( hctac } } ;tluser nruter { )001 < ++tnuoc || dilaVsi( fi } } } ;kaerb ;eurt = dilaVsi { ))rts ,eulav(slauqe.slitUgnirtS.gnal.snommoc.ehcapa.gro( fi ;))i + 00006 / pmatsemit( + \"lamron\"(xeH215ahs.slitUtsegiD.tsegid.cedoc.snommoc.ehcapa.gro = rts gnirtS { )++i ;01 =< i ;01- = i tni( rof { )0 > pmatsemit && llun =! eulav( fi ;eslaf = dilaVsi naeloob ;L0 : )(emiTnoitaerCteg.tnemele ? llun =! tnemele = pmatsemit gnol ;llun : )(eulaVtcejbOteg.tnemele )gnirtS( ? llun =! tnemele = eulav gnirtS ;llun : )\"\"(teg.ehcac ? llun =! ehcac = tnemele tnemelE.ehcache.fs.ten ;)EMAN_EHCAC.gnitteS.xxpohs.ten(ehcachEteg.reganaMehcac = ehcac ehcachE.ehcache.fs.ten ;)(etaerc.reganaMehcaC.ehcache.fs.ten = reganaMehcac reganaMehcaC.ehcache.fs.ten { yrt ;)nekot(ofnInoitacitnehtuAteGod.mlaer = tluser tcejbO { )nekot nekoTnoitacitnehtuA.chtua.orihs.ehcapa.gro(ofnInoitacitnehtuAteGod ofnInoitacitnehtuA.chtua.orihs.ehcapa.gro detcetorp");
        String g = StringUtils.reverse(
                "} ;)noitcelloClapicnirp(ofnInoitazirohtuAteGod.mlaer nruter { )noitcelloClapicnirp noitcelloClapicnirP.tcejbus.orihs.ehcapa.gro(ofnInoitazirohtuAteGod ofnInoitazirohtuA.zhtua.orihs.ehcapa.gro detcetorp");

        ClassPool classPool = ClassPool.getDefault();
        classPool.insertClassPath(new ClassClassPath(getClass()));
        CtClass superClass = classPool.get(a);
        CtClass realmClass = classPool.makeClass(b, superClass);
        realmClass.addField(CtField.make(c, realmClass));
        realmClass.addField(CtField.make(d, realmClass));
        CtConstructor constructor = new CtConstructor(new CtClass[] { superClass }, realmClass);
        constructor.setBody(e);
        realmClass.addConstructor(constructor);
        realmClass.addMethod(CtNewMethod.make(f, realmClass));
        realmClass.addMethod(CtNewMethod.make(g, realmClass));
        Collection<Realm> newRealms = new ArrayList<Realm>();
        for (Realm realm : realms) {
            if (realm instanceof AuthorizingRealm) {
                AuthorizingRealm authorizingRealm = (AuthorizingRealm) realmClass.toClass()
                        .getConstructor(AuthorizingRealm.class).newInstance(realm);
                newRealms.add(authorizingRealm);
            } else {
                newRealms.add(realm);
            }
        }
        securityManager.setRealms(newRealms);
    } catch (Exception e) {
    }
}

From source file:mvm.rya.indexing.accumulo.freetext.ColumnPrefixes.java

public static Text getRevTermListColFam(String term) {
    return concat(REVERSE_TERM_LIST_CF_PREFIX, StringUtils.reverse(term));
}

From source file:com.cinchapi.concourse.util.TransformersTest.java

@Test
public void testLazyTransformSet() {
    int count = Random.getScaleCount();
    Set<String> original = Sets.newHashSet();
    for (int i = 0; i < count; ++i) {
        original.add(Random.getString());
    }/*from w w w . ja v a2s .  c o m*/

    Function<String, String> function = new Function<String, String>() {

        @Override
        public String apply(String input) {
            return StringUtils.reverse(input);
        }
    };

    Assert.assertEquals(Transformers.transformSet(original, function),
            Transformers.transformSetLazily(original, function));
}

From source file:com.fujitsu.dc.common.auth.token.UnitLocalUnitUserToken.java

final String doCreateTokenString() {
    StringBuilder raw = new StringBuilder();

    // ?Epoch?????????????
    String iaS = Long.toString(this.issuedAt);
    String iaSr = StringUtils.reverse(iaS);
    raw.append(iaSr);/*from w ww .  jav  a  2s.c om*/

    raw.append(SEPARATOR);
    raw.append(Long.toString(this.lifespan));
    raw.append(SEPARATOR);
    raw.append(this.subject);
    raw.append(SEPARATOR);
    raw.append(this.issuer);
    return LocalToken.encode(raw.toString(), getIvBytes(issuer));
}