LongRenderer.java revision 6ef13753e78bb7abc7e7683d5e533c3395d4a9b6
1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)/*
2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * [The "BSD licence"]
3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * Copyright (c) 2009 Ben Gruver
4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * All rights reserved.
5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) *
6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * modification, are permitted provided that the following conditions
8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * are met:
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * 3. The name of the author may not be used to endorse or promote products
15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) *    derived from this software without specific prior written permission.
16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) *
17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) */
28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)package org.jf.baksmali.Renderers;
30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)import org.antlr.stringtemplate.AttributeRenderer;
32f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)public class LongRenderer implements AttributeRenderer {
34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    public String toString(Object o) {
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)        Long l = (Long)o;
36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)        if (l < 0) {
37f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            return "-0x" + Long.toHexString(-1 * l);
38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)        }
39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)        return "0x" + Long.toHexString((Long)o);
40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    }
41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
42f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    public String toString(Object o, String s) {
43010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)         return toString(o);
44010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    }
45010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)}
46010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)