1 package org
.eclipse
.linuxtools
.lttng
.jni
;
3 import org
.eclipse
.linuxtools
.internal
.lttng
.jni
.common
.Jni_C_Pointer_And_Library_Id
;
4 import org
.eclipse
.linuxtools
.internal
.lttng
.jni
.exception
.JniException
;
5 import org
.eclipse
.linuxtools
.internal
.lttng
.jni
.exception
.JniMarkerFieldException
;
9 * <b><u>JniMarkerField</u></b> <p>
10 * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
12 * Provides access to the marker_field C structure (from LTT) in java.<p>
14 * Most important attributes in the JniMarkerField are :
16 * <li> the name (field) of in String
17 * <li> the marker field format (in C style printf format)
21 * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<p>
24 public abstract class JniMarkerField
extends Jni_C_Common
26 // Internal C pointer of the JniEvent used in LTT
27 private Jni_C_Pointer_And_Library_Id thisMarkerFieldPtr
= new Jni_C_Pointer_And_Library_Id();
29 private String field
= ""; //$NON-NLS-1$
30 private String format
= ""; //$NON-NLS-1$
32 // Native access method
33 protected native String
ltt_getField(int libId
, long markerFieldPtr
);
34 protected native int ltt_getType(int libId
, long markerFieldPtr
);
35 protected native long ltt_getOffset(int libId
, long markerFieldPtr
);
36 protected native long ltt_getSize(int libId
, long markerFieldPtr
);
37 protected native long ltt_getAlignment(int libId
, long markerFieldPtr
);
38 protected native long ltt_getAttributes(int libId
, long markerFieldPtr
);
39 protected native int ltt_getStatic_offset(int libId
, long markerFieldPtr
);
40 protected native String
ltt_getFormat(int libId
, long markerFieldPtr
);
42 // Debug native function, ask LTT to print marker structure
43 protected native void ltt_printMarkerField(int libId
, long markerFieldPtr
);
46 * Default constructor is forbidden
48 protected JniMarkerField() {
52 * Copy constructor.<p>
54 * @param oldMarkerField Reference to the JniMarkerField you want to copy.
56 public JniMarkerField(JniMarkerField oldMarkerField
) {
57 thisMarkerFieldPtr
= oldMarkerField
.getMarkerFieldPtr();
58 field
= oldMarkerField
.getField();
59 format
= oldMarkerField
.getFormat();
63 * Constructor, using pointer.
66 * @param newMarkerFieldPtr
67 * Pointer to a C marker_field structure
68 * @exception JniException
69 * If the JNI call fails
71 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
73 public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr
) throws JniException
{
74 thisMarkerFieldPtr
= newMarkerFieldPtr
;
76 // Populate the marker field
77 populateMarkerFieldInformation();
81 * This function populates the marker field data with data from LTT
84 private void populateMarkerFieldInformation() throws JniException
{
85 if (thisMarkerFieldPtr
.getPointer() == NULL
) {
86 throw new JniMarkerFieldException(
87 "Pointer is NULL, trace closed? (populateMarkerInformation)"); //$NON-NLS-1$
89 field
= ltt_getField(thisMarkerFieldPtr
.getLibraryId(), thisMarkerFieldPtr
.getPointer());
90 format
= ltt_getFormat(thisMarkerFieldPtr
.getLibraryId(), thisMarkerFieldPtr
.getPointer());
94 * Get the field of this marker
96 * @return The field name
98 public String
getField() {
103 * Get the format of this marker
105 * @return The format, as a String
107 public String
getFormat() {
112 * Pointer to the marker_field C structure.<p>
114 * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
115 * know what you are doing.<p>
117 * @return The actual (long converted) pointer or NULL
119 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
121 public Jni_C_Pointer_And_Library_Id
getMarkerFieldPtr() {
122 return thisMarkerFieldPtr
;
126 * Print information for this event. <u>Intended to debug</u><br>
128 * This function will call Ltt to print, so information printed will be the one from
129 * the C structure, not the one populated in java.<p>
131 public void printMarkerFieldInformation() {
132 ltt_printMarkerField(thisMarkerFieldPtr
.getLibraryId(), thisMarkerFieldPtr
.getPointer());
137 * <u>Intended to debug</u><br>
139 * @return Attributes of the object concatenated in String
142 @SuppressWarnings("nls")
143 public String
toString() {
144 String returnData
= "";
145 returnData
+= "field : " + field
+ "\n";
146 returnData
+= "format : " + format
+ "\n";