Example usage for java.lang Long toHexString

List of usage examples for java.lang Long toHexString

Introduction

In this page you can find the example usage for java.lang Long toHexString.

Prototype

public static String toHexString(long i) 

Source Link

Document

Returns a string representation of the long argument as an unsigned integer in base 16.

Usage

From source file:org.jcodec.codecs.mjpeg.JpegParser.java

public CodedImage parse(PushbackInputStream is, CountingInputStream counter) throws IOException {
    CodedImage image = new CodedImage();
    int curQTable = 0;
    while (true) {
        int marker = is.read();
        if (marker == -1)
            return image;
        if (marker == 0)
            continue;
        if (marker != 0xFF)
            throw new RuntimeException("@" + Long.toHexString(counter.getByteCount()) + " Marker expected: 0x"
                    + Integer.toHexString(marker));

        int b = is.read();
        Debug.trace("%s", Markers.toString(b));
        switch (b) {
        case Markers.SOF0:
            image.frame = FrameHeader.read(is);
            Debug.trace("    %s", image.frame);
            break;
        case Markers.DHT:
            int len1 = readShort(is);
            CountingInputStream cis = new CountingInputStream(is);
            while (cis.getCount() < len1 - 2) {
                readHuffmanTable(cis, image);
            }/*from ww w . j  a va2 s . com*/
            break;
        case Markers.DQT:
            int len4 = readShort(is);
            CountingInputStream cis1 = new CountingInputStream(is);
            while (cis1.getCount() < len4 - 2) {
                QuantTable quantTable = readQuantTable(cis1);
                if (curQTable == 0)
                    image.setQuantLum(quantTable);
                else
                    image.setQuantChrom(quantTable);
                curQTable++;
            }
            break;
        case Markers.SOS:
            if (image.scan != null) {
                throw new IllegalStateException("unhandled - more than one scan header");
            }
            image.scan = ScanHeader.read(is);
            Debug.trace("    %s", image.scan);
            image.setData(readData(is));
            break;
        case Markers.SOI:
            break;
        case Markers.EOI:
            return image;
        case Markers.APP0:
            // int len10 = readShort(is);
            // byte[] id = new byte[4];
            // is.read(id);
            // if (!Arrays.equals(JFIF, id))
            // throw new RuntimeException("Not a JFIF file");
            // is.skip(1);
            //
            // is.skip(2);
            // int units = is.read();
            // int dx = readShort(is);
            // int dy = readShort(is);
            // int tx = is.read();
            // int ty = is.read();
            // is.skip(tx * ty * 3);
            // break;
        case Markers.APP1:
        case Markers.APP2:
        case Markers.APP3:
        case Markers.APP4:
        case Markers.APP5:
        case Markers.APP6:
        case Markers.APP7:
        case Markers.APP8:
        case Markers.APP9:
        case Markers.APPA:
        case Markers.APPB:
        case Markers.APPC:
        case Markers.APPD:
        case Markers.APPE:
        case Markers.APPF:
            int len3 = readShort(is);
            StringReader.sureSkip(is, len3 - 2);
            break;
        case Markers.DRI:
            /*
             * Lr: Define restart interval segment length  Specifies the
             * length of the parameters in the DRI segment shown in Figure
             * B.9 (see B.1.1.4).
             */
            int lr = readShort(is);
            // Ri: Restart interval  Specifies the number of MCU in the
            // restart interval.
            int ri = readShort(is);
            Debug.trace("DRI Lr: %d Ri: %d", lr, ri);
            // A DRI marker segment with Ri equal to zero shall disable
            // restart intervals for the following scans.
            Asserts.assertEquals(0, ri);
            break;
        default: {
            throw new IllegalStateException("unhandled marker " + Markers.toString(b));
        }
        }
    }
}

From source file:org.eclipse.gyrex.cloud.internal.zk.console.GateStatusCmd.java

@Override
protected void doExecute() throws Exception {
    try {// w w w  . j a v  a 2s . com
        final ZooKeeperGate gate = ZooKeeperGate.get();
        final ZooKeeper zk = gate.getZooKeeper();
        printf("Connect String: %s", gate.getConnectString());
        printf("       Timeout: %dms", gate.getSessionTimeout());
        if (gate.getLastStateChangeTimestamp() > 0L) {
            printf("         State: %s (since %s)", zk.getState(),
                    DateFormatUtils.SMTP_DATETIME_FORMAT.format(gate.getLastStateChangeTimestamp()));
        } else {
            printf("         State: %s (initial state)", zk.getState());
        }
        printf("       Session: 0x%s", Long.toHexString(zk.getSessionId()));
        printf("    Connection: %s", gate.getConnectedServerInfo());
    } catch (final GateDownException e) {
        printf("Gate is down.");
    }
}

From source file:org.exnebula.warless.WarLessTest.java

@Before
public void setUp() throws Exception {
    archive = mock(WarArchive.class);
    target = mock(WarTarget.class);
    targetDirectory = File.createTempFile("app", "dir");
    appSubDirectory = "webapp/" + Long.toHexString(System.currentTimeMillis()) + "/app";

    warLess = new WarLess(archive, target);
    when(target.getTargetDirectory()).thenReturn(targetDirectory);
    when(archive.getWebAppDirectory()).thenReturn(appSubDirectory);
    newSignature = buildMD5Digest("new");
}

From source file:de.micromata.genome.chronos.spi.HostUtils.java

/**
 * Gets the run context./*ww  w .  jav a 2s . com*/
 *
 * @param thread the thread
 * @return the run context
 */
public static String getRunContext(Thread thread) {
    String tid = "-1";
    if (thread != null) {
        tid = Long.toHexString(thread.getId());
    }
    String time = Long.toHexString(START_TIME / 1000);
    String t = time + ';' + tid;
    return t;
}

From source file:org.segrada.model.base.AbstractColoredModel.java

@Override
public String getColorCode() {
    return (color == null) ? "" : "#" + StringUtils.leftPad(Long.toHexString(color).toUpperCase(), 6, "0");
}

From source file:com.sangupta.andruil.commands.checksum.Crc32.java

/**
 * @see com.sangupta.andruil.commands.AbstractAndruilCommand#execute(java.lang.String[])
 *//*from w  ww  .  jav a 2 s .c  om*/
@Override
protected boolean processFile(File file) throws IOException {
    if (file.isDirectory()) {
        return true;
    }

    byte[] bytes = FileUtils.readFileToByteArray(file);
    CRC32 crc32 = new CRC32();
    crc32.update(bytes);
    System.out.println(Long.toHexString(crc32.getValue()) + " *" + file.getName());

    return true;
}

From source file:org.codice.ddf.checksum.impl.Adler32ChecksumProvider.java

@Override
public String calculateChecksum(InputStream inputStream) throws IOException, NoSuchAlgorithmException {

    if (inputStream == null) {
        throw new IllegalArgumentException("InputStream cannot be null");
    }/*from   www .  j  a  v  a  2  s  .  c om*/

    long checksumValue = 0L;

    try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) {
        IOUtils.toByteArray(cis);
        checksumValue = cis.getChecksum().getValue();
    }

    return Long.toHexString(checksumValue);

}

From source file:org.lib4j._2fa.GoogleAuthenticator.java

/**
 * @param secretKey Base32 encoded secret key (will be converted to
 *        upper-case, and may have optional whitespace which will be removed)
 * @return The TOTP code for the secret key.
 */// ww w .  ja  v  a 2s . c  om
public static String getTOTPCode(final String secretKey) {
    final String normalizedBase32Key = secretKey.replace(" ", "").toUpperCase();
    final byte[] bytes = new Base32().decode(normalizedBase32Key);
    final long time = (System.currentTimeMillis() / 1000) / 30;
    final String hexTime = Long.toHexString(time);
    return TOTP.generateTOTP(Hex.encodeHexString(bytes), hexTime, "6");
}

From source file:org.apache.zookeeper.graph.JsonGenerator.java

public JSONObject txnEntry(TransactionEntry e) {
    JSONObject event = new JSONObject();

    event.put("time", Long.toString(e.getTimestamp()));
    event.put("client", Long.toHexString(e.getClientId()));
    event.put("cxid", Long.toHexString(e.getCxid()));
    event.put("zxid", Long.toHexString(e.getZxid()));
    event.put("op", e.getOp());
    event.put("extra", e.getExtra());
    event.put("type", "transaction");

    return event;
}

From source file:com.savoycraft.util.TimeUtil.java

/**
 * Just returns the system time in millis, formatted in hex
 * //from  w w  w. j a v a  2 s .c  o m
 * @return
 */
public static String getHexTime() {
    return Long.toHexString(System.currentTimeMillis());
}