1 package org
.eclipse
.linuxtools
.lttng
.jni
;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
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
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
16 * <b><u>JniMarkerField</u></b> <p>
17 * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
19 * Provides access to the marker_field C structure (from LTT) in java.<p>
21 * Most important attributes in the JniMarkerField are :
23 * <li> the name (field) of in String
24 * <li> the marker field format (in C style printf format)
27 public final class JniMarkerField
extends Jni_C_Common
29 // Internal C pointer of the JniEvent used in LTT
30 private Jni_C_Pointer thisMarkerFieldPtr
= new Jni_C_Pointer();
32 private String field
= "";
33 private String format
= "";
35 // Native access method
36 private native String
ltt_getField(long markerFieldPtr
);
37 @SuppressWarnings("unused")
38 private native int ltt_getType(long markerFieldPtr
);
39 @SuppressWarnings("unused")
40 private native long ltt_getOffset(long markerFieldPtr
);
41 @SuppressWarnings("unused")
42 private native long ltt_getSize(long markerFieldPtr
);
43 @SuppressWarnings("unused")
44 private native long ltt_getAlignment(long markerFieldPtr
);
45 @SuppressWarnings("unused")
46 private native long ltt_getAttributes(long markerFieldPtr
);
47 @SuppressWarnings("unused")
48 private native int ltt_getStatic_offset(long markerFieldPtr
);
49 private native String
ltt_getFormat(long markerFieldPtr
);
51 // Debug native function, ask LTT to print marker structure
52 private native void ltt_printMarkerField(long markerFieldPtr
);
55 System
.loadLibrary("lttvtraceread");
59 * Default constructor is forbidden
61 @SuppressWarnings("unused")
62 private JniMarkerField() {
66 * Copy constructor.<p>
68 * @param oldMarkerField Reference to the JniMarkerField you want to copy.
70 public JniMarkerField(JniMarkerField oldMarkerField
) {
71 thisMarkerFieldPtr
= oldMarkerField
.getMarkerFieldPtr();
72 field
= oldMarkerField
.getField();
73 format
= oldMarkerField
.getFormat();
77 * Constructor, using pointer.<p>
79 * @param newMarkerFieldPtr Pointer to a C marker_field structure
81 * @exception JniException
83 public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr
) throws JniException
{
84 thisMarkerFieldPtr
= newMarkerFieldPtr
;
86 // Populate the marker field
87 populateMarkerFieldInformation();
91 * This function populates the marker field data with data from LTT
94 private void populateMarkerFieldInformation() throws JniException
{
95 if (thisMarkerFieldPtr
.getPointer() == NULL
) {
96 throw new JniMarkerFieldException(
97 "Pointer is NULL, trace closed? (populateMarkerInformation)");
99 field
= ltt_getField(thisMarkerFieldPtr
.getPointer());
100 format
= ltt_getFormat(thisMarkerFieldPtr
.getPointer());
104 public String
getField() {
108 public String
getFormat() {
113 * Pointer to the marker_field C structure.<p>
115 * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
116 * know what you are doing.<p>
118 * @return The actual (long converted) pointer or NULL
120 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
122 public Jni_C_Pointer
getMarkerFieldPtr() {
123 return thisMarkerFieldPtr
;
127 * Print information for this event. <u>Intended to debug</u><br>
129 * This function will call Ltt to print, so information printed will be the one from
130 * the C structure, not the one populated in java.<p>
132 * This function will not throw but will complain loudly if pointer is NULL
134 public void printMarkerFieldInformation() {
136 // If null pointer, print a warning!
137 if (thisMarkerFieldPtr
.getPointer() == NULL
) {
138 printlnC("Pointer is NULL, cannot print. (printMarkerFieldInformation)");
140 ltt_printMarkerField(thisMarkerFieldPtr
.getPointer());
146 * <u>Intended to debug</u><br>
148 * @return Attributes of the object concatenated in String
151 public String
toString() {
152 String returnData
= "";
153 returnData
+= "field : " + field
+ "\n";
154 returnData
+= "format : " + format
+ "\n";