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

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

Introduction

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

Prototype

public static String right(String str, int len) 

Source Link

Document

Gets the rightmost len characters of a String.

Usage

From source file:com.intel.cosbench.config.common.KVConfigParser.java

private static void addConfigEntry(String entry, Configuration config) {
    int pos = StringUtils.indexOf(entry, '=');
    if (pos < 0)
        logger.warn("cannot parse config entry {}", entry);

    String key = StringUtils.trim(StringUtils.left(entry, pos));
    String value = StringUtils.trim(StringUtils.right(entry, entry.length() - pos - 1));
    logger.debug("key=" + key + ";value=" + value);

    config.setProperty(key, value);/*from w  ww.j  a v  a  2 s  .  c  o m*/
}

From source file:com.norconex.collector.http.util.PathUtils.java

public static String urlToPath(final String url) {
    if (url == null) {
        return null;
    }/*from ww w  . java  2s .  com*/
    String sep = File.separator;
    if (sep.equals("\\")) {
        sep = "\\" + sep;
    }

    String domain = url.replaceFirst("(.*?)(://)(.*?)(/)(.*)", "$1_$3");
    domain = domain.replaceAll("[\\W]+", "_");
    String path = url.replaceFirst("(.*?)(://)(.*?)(/)(.*)", "$5");
    path = path.replaceAll("[\\W]+", "_");
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < path.length(); i++) {
        if (i % PATH_SEGMENT_SIZE == 0) {
            b.append(sep);
        }
        b.append(path.charAt(i));
    }
    path = b.toString();

    //TODO is truncating after 256 a risk of creating false duplicates?
    if (path.length() > MAX_PATH_LENGTH) {
        path = StringUtils.right(path, MAX_PATH_LENGTH);
        if (!path.startsWith(File.separator)) {
            path = File.separator + path;
        }
    }
    return domain + path;
}

From source file:de.softwareforge.pgpsigner.key.KeyId.java

public KeyId(final Long id) {
    this.id = id;
    this.keyId = "0x" + StringUtils.right(Long.toHexString(id), 8);
}

From source file:hudson.plugins.blazemeter.BlazemeterCredentialImpl.java

private String calcLegacyId(String jobApiKey) {
    return StringUtils.left(jobApiKey, 4) + "..." + StringUtils.right(jobApiKey, 4);
}

From source file:de.innovationgate.webgate.api.jdbc.PortletRegistryImplV4.java

public static String buildNamespacePrefix(String dbkey) {

    dbkey = dbkey.toLowerCase();/* w w  w .  j  a v  a 2 s  . c om*/
    String prefix = StringUtils.left(dbkey, 1) + StringUtils.right(dbkey, 2);
    if (prefix.length() < 3) {
        prefix += StringUtils.repeat("x", 3 - prefix.length());
    }

    // Escape non alphanumeric characters as x
    char[] chars = prefix.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        if (!Character.isLetterOrDigit(chars[i])) {
            chars[i] = 'x';
        }
    }

    return new String(chars);

}

From source file:com.openshift.internal.restclient.apis.TypeMetaFactory.java

@Override
public Object stubKind(String kind, Optional<String> name, Optional<String> namespace) {
    if (StringUtils.isEmpty(kind)) {
        throw new OpenShiftException("Unable to stub a kind when the kind passed in is empty");
    }//w w  w . j  ava  2s .c  o  m
    try {
        String version = "";
        if (kind.contains(DELIMITER)) {
            int delimeter = kind.indexOf(DELIMITER);
            version = StringUtils.left(kind, delimeter);
            kind = StringUtils.right(kind, kind.length() - delimeter - DELIMITER.length());
        }
        Map<String, String[]> properyKeyMap = ResourcePropertiesRegistry.getInstance().get(version, kind);
        ModelNode node = new ModelNode();
        JBossDmrExtentions.set(node, properyKeyMap, APIVERSION, version);
        JBossDmrExtentions.set(node, properyKeyMap, KIND, kind);

        ITypeMeta instance = null;
        if (IMPL_MAP.containsKey(kind)) {
            Constructor<? extends ITypeMeta> constructor = IMPL_MAP.get(kind).getConstructor(ModelNode.class,
                    Map.class);
            instance = constructor.newInstance(node, properyKeyMap);
        } else {
            instance = new TypeMeta(node, properyKeyMap);
        }

        if (name.isPresent() && instance instanceof INameSetable) {
            ((INameSetable) instance).setName(name.get());
        }
        if (namespace.isPresent() && instance instanceof INamespaceSetable) {
            ((INamespaceSetable) instance).setNamespace(namespace.get());
        }

        return instance;
    } catch (UnsupportedVersionException e) {
        throw e;
    } catch (Exception e) {
        throw new ResourceFactoryException(e, "Unable to stub instance from %s", kind);
    }
}

From source file:iddb.runtime.cache.impl.CacheImpl.java

private String getCachePrefix() {
    return StringUtils.right(Long.toString(System.currentTimeMillis() / 1000), 5);
}

From source file:id.ac.idu.policy.PasswordEncoderImpl.java

@Override
public boolean isPasswordValid(String encPass, String rawPass, Object token) {
    /*/*from   w  ww  . j av a 2  s.c  o m*/
       * encPass -> Passwort aus UserDetais rawPass -> Passwort aus dem
       * Eingabefels token -> Ist null oder ein Md5Token und kommt aus
       * User.getToken()
       */

    if (encPass == null) {
        /*
        * Passwort auf der DB ist null Da null nicht im Webformular
        * eingegeben werden kann, wird ein false geliefert. (vergleich ist
        * nicht notwendig!)
        */
        return false;
    }

    if (token == null) {
        /*
        * Kein Token Verwenden. Einfach nur die Passwrter vergleichen.
        */
        return encPass.equals(rawPass);
    }

    /*
       * Ab hier wird ein Token verwendet! Wenn man in Debugger wartet, kann
       * der eingegebene Token Ablaufen!
       */

    if (rawPass.length() <= Md5Token.TOKEN_LENGTH) {
        /*
        * Passwort ist zu klein, um einen Token zu enthalten!
        */
        return false;
    }

    /*
       * Passwort ohne Token ermitteln
       */
    String newRawPass = StringUtils.left(rawPass, rawPass.length() - Md5Token.TOKEN_LENGTH);
    if (encPass.equals(newRawPass)) {
        /*
        * eingegebenes Token ermitteln
        */
        String rawToken = StringUtils.right(rawPass, Md5Token.TOKEN_LENGTH);
        Md5Token md5Token = (Md5Token) token;
        /*
        * Token prfen
        */
        return md5Token.isEqualsToken(rawToken);
    }
    return false;
}

From source file:de.forsthaus.policy.PasswordEncoderImpl.java

@Override
public boolean isPasswordValid(String encPass, String rawPass, Object token) {
    /*/* ww w  .  jav a  2s .  com*/
     * encPass -> Passwort aus UserDetais rawPass -> Passwort aus dem
     * Eingabefels token -> Ist null oder ein Md5Token und kommt aus
     * User.getToken()
     */

    if (encPass == null) {
        /*
         * Passwort auf der DB ist null Da null nicht im Webformular
         * eingegeben werden kann, wird ein false geliefert. (vergleich ist
         * nicht notwendig!)
         */
        return false;
    }

    if (token == null) {
        /*
         * Kein Token Verwenden. Einfach nur die Passwrter vergleichen.
         */
        return encPass.equals(rawPass);
    }

    /*
     * Ab hier wird ein Token verwendet! Wenn man in Debugger wartet, kann
     * der eingegebene Token Ablaufen!
     */

    if (rawPass.length() <= Md5Token.TOKEN_LENGTH) {
        /*
         * Passwort ist zu klein, um einen Token zu enthalten!
         */
        return false;
    }

    /*
     * Passwort ohne Token ermitteln
     */
    String newRawPass = StringUtils.left(rawPass, rawPass.length() - Md5Token.TOKEN_LENGTH);
    if (encPass.equals(newRawPass)) {
        /*
         * eingegebenes Token ermitteln
         */
        String rawToken = StringUtils.right(rawPass, Md5Token.TOKEN_LENGTH);
        Md5Token md5Token = (Md5Token) token;
        /*
         * Token prfen
         */
        return md5Token.isEqualsToken(rawToken);
    }
    return false;
}

From source file:net.bible.service.common.CommonUtils.java

/** return true if Android 2.3.7 or greater
 *//*from   w ww  .  ja  v a  2 s.c o m*/
public static boolean is2_3_7_Plus() {
    if (Build.VERSION.SDK_INT > 9) {
        return true;
    } else if (Build.VERSION.SDK_INT < 9) {
        return false;
    } else {
        // this isn't brilliant code but should not fail and should work most times, maybe all
        String rel = Build.VERSION.RELEASE;
        String finalDigit = StringUtils.right(rel, 1);
        return "789".contains(finalDigit);
    }
}