(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.jni / src / org / eclipse / linuxtools / lttng / jni / JniMarkerField.java
1 package org.eclipse.linuxtools.lttng.jni;
2
3 import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id;
4 import org.eclipse.linuxtools.lttng.jni.exception.JniException;
5 import org.eclipse.linuxtools.lttng.jni.exception.JniMarkerFieldException;
6
7
8 /**
9 * <b><u>JniMarkerField</u></b> <p>
10 * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
11 *
12 * Provides access to the marker_field C structure (from LTT) in java.<p>
13 *
14 * Most important attributes in the JniMarkerField are :
15 * <ul>
16 * <li> the name (field) of in String
17 * <li> the marker field format (in C style printf format)
18 * </ul>
19 *
20 * <b>NOTE</b><p>
21 * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<p>
22 *
23 */
24 public abstract class JniMarkerField extends Jni_C_Common
25 {
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();
28
29 private String field = "";
30 private String format = "";
31
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);
41
42 // Debug native function, ask LTT to print marker structure
43 protected native void ltt_printMarkerField(int libId, long markerFieldPtr);
44
45 /*
46 * Default constructor is forbidden
47 */
48 protected JniMarkerField() {
49 }
50
51 /**
52 * Copy constructor.<p>
53 *
54 * @param oldMarkerField Reference to the JniMarkerField you want to copy.
55 */
56 public JniMarkerField(JniMarkerField oldMarkerField) {
57 thisMarkerFieldPtr = oldMarkerField.getMarkerFieldPtr();
58 field = oldMarkerField.getField();
59 format = oldMarkerField.getFormat();
60 }
61
62 /**
63 * Constructor, using pointer.<p>
64 *
65 * @param newMarkerFieldPtr Pointer to a C marker_field structure
66 *
67 * @exception JniException
68 *
69 * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id
70 */
71 public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException {
72 thisMarkerFieldPtr = newMarkerFieldPtr;
73
74 // Populate the marker field
75 populateMarkerFieldInformation();
76 }
77
78 /*
79 * This function populates the marker field data with data from LTT
80 *
81 */
82 private void populateMarkerFieldInformation() throws JniException {
83 if (thisMarkerFieldPtr.getPointer() == NULL) {
84 throw new JniMarkerFieldException(
85 "Pointer is NULL, trace closed? (populateMarkerInformation)");
86 } else {
87 field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
88 format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
89 }
90 }
91
92 public String getField() {
93 return field;
94 }
95
96 public String getFormat() {
97 return format;
98 }
99
100 /**
101 * Pointer to the marker_field C structure.<p>
102 *
103 * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
104 * know what you are doing.<p>
105 *
106 * @return The actual (long converted) pointer or NULL
107 *
108 * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id
109 */
110 public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() {
111 return thisMarkerFieldPtr;
112 }
113
114 /**
115 * Print information for this event. <u>Intended to debug</u><br>
116 *
117 * This function will call Ltt to print, so information printed will be the one from
118 * the C structure, not the one populated in java.<p>
119 */
120 public void printMarkerFieldInformation() {
121 ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
122 }
123
124 /**
125 * toString() method.
126 * <u>Intended to debug</u><br>
127 *
128 * @return Attributes of the object concatenated in String
129 */
130 @Override
131 public String toString() {
132 String returnData = "";
133 returnData += "field : " + field + "\n";
134 returnData += "format : " + format + "\n";
135
136 return returnData;
137 }
138
139 }
This page took 0.043803 seconds and 6 git commands to generate.