tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.jni / src / org / eclipse / linuxtools / internal / lttng / jni / common / Jni_C_Pointer.java
CommitLineData
ce38c104 1package org.eclipse.linuxtools.internal.lttng.jni.common;
c357e4b6
WB
2/*******************************************************************************
3 * Copyright (c) 2009 Ericsson
4 *
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
0152140d
ASL
13
14/**
15 * <b><u>Jni_C_Pointer</u></b>
16 * <p>
17 * Class pointer to handle properly "C pointer" <p>
18 *
19 * Can transparently handle pointer of 32 or 64 bits.
20 */
21public class Jni_C_Pointer extends Jni_C_Constant {
22
c85e8cb2
WB
23 protected long ptr = NULL;
24 protected boolean isLong = true;
0152140d
ASL
25
26 /**
27 * Default constructor.<p>
28 *
29 * Note : Pointer will be set to a 64bits "NULL".
30 */
31 public Jni_C_Pointer() {
32 ptr = NULL;
33 }
34
35 /**
36 * Constructor with parameters for 64bits pointers.
37 *
38 * @param newPtr long-converted (64 bits) C pointer.
39 */
40 public Jni_C_Pointer(long newPtr) {
41 ptr = newPtr;
42 isLong = true;
43 }
44
45 /**
46 * Constructor with parameters for 32bits pointers.
47 *
48 * @param newPtr int-converted (32 bits) C pointer.
49 */
50 public Jni_C_Pointer(int newPtr) {
51 ptr = (long)newPtr;
52 isLong = false;
53 }
54
55 /**
56 * Get the current pointer.
57 *
58 * @return The current pointer, in long.
59 */
60 public long getPointer() {
61 return ptr;
62 }
63
64 /**
65 * Set the pointer, as a 64bits pointer.
66 *
67 * @param newPtr long-converted (64 bits) C pointer.
68 */
69 public void setPointer(long newPtr) {
70 ptr = newPtr;
71 isLong = true;
72 }
73
74 /**
75 * Set the pointer, as a 64bits pointer.
76 *
77 * @param newPtr int-converted (32 bits) C pointer.
78 */
79 public void setPointer(int newPtr) {
80 ptr = newPtr;
81 isLong = false;
82 }
83
84 /**
85 * toString() method. <p>
86 *
87 * Convert the pointer to a nice looking int/long hexadecimal format.
88 *
89 * @return Attributes of the object concatenated in String
90 */
91 @Override
3b38ea61 92 @SuppressWarnings("nls")
0152140d
ASL
93 public String toString() {
94 String returnData = "0x";
95
96 if (isLong == true) {
97 returnData += Long.toHexString(ptr);
98 }
99 else {
100 returnData += Integer.toHexString((int) ptr);
101 }
102
103 return returnData;
104 }
105}
This page took 0.037963 seconds and 5 git commands to generate.