Java Long to longToName(long l)

Here you can find the source of longToName(long l)

Description

Converts long to name string.

License

Open Source License

Parameter

Parameter Description
l the long value

Return

the name string

Declaration

public static String longToName(long l) 

Method Source Code

//package com.java2s;
/*/*from  w w  w.  j  a  v a  2s.c o m*/
 * This file is part of Solace Framework.
 * Solace is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * Solace is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Solace. If not, see <http://www.gnu.org/licenses/>.
 *
 */

public class Main {
    public static final char VALID_CHARS[] = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
            '8', '9', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', ':', ';', '.', '>', '<', ',',
            '"', '[', ']', '|', '?', '/', '`' };

    /**
     * Converts long to name string.
     * 
     * @param l
     *            the long value
     * 
     * @return the name string
     */
    public static String longToName(long l) {
        int i = 0;
        char ac[] = new char[12];
        while (l != 0L) {
            long l1 = l;
            l /= 37L;
            ac[11 - i++] = VALID_CHARS[(int) (l1 - l * 37L)];
        }
        return new String(ac, 12 - i, i);
    }
}

Related

  1. longToFourBytes(long value)
  2. longToFrontInt(long data)
  3. longToLex(long v)
  4. longToLittleEndianBytes(long value, byte[] destination, int offset, int length)
  5. longToN62(long l)
  6. longToNBuf(long l, char[] chars)
  7. longToNetworkByteOrderArray(long addr)
  8. longToNetworkBytes(long value)
  9. longToNumberWithDecimalPlaces(long longValue, int decimalPlaces)