Update Javadoc for the public API in legacy LTTng
[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.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;
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 = ""; //$NON-NLS-1$
30 private String format = ""; //$NON-NLS-1$
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.
64 * <p>
65 *
66 * @param newMarkerFieldPtr
67 * Pointer to a C marker_field structure
68 * @exception JniException
69 * If the JNI call fails
70 *
71 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
72 */
73 public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException {
74 thisMarkerFieldPtr = newMarkerFieldPtr;
75
76 // Populate the marker field
77 populateMarkerFieldInformation();
78 }
79
80 /*
81 * This function populates the marker field data with data from LTT
82 *
83 */
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$
88 }
89 field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
90 format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
91 }
92
93 /**
94 * Get the field of this marker
95 *
96 * @return The field name
97 */
98 public String getField() {
99 return field;
100 }
101
102 /**
103 * Get the format of this marker
104 *
105 * @return The format, as a String
106 */
107 public String getFormat() {
108 return format;
109 }
110
111 /**
112 * Pointer to the marker_field C structure.<p>
113 *
114 * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
115 * know what you are doing.<p>
116 *
117 * @return The actual (long converted) pointer or NULL
118 *
119 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
120 */
121 public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() {
122 return thisMarkerFieldPtr;
123 }
124
125 /**
126 * Print information for this event. <u>Intended to debug</u><br>
127 *
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>
130 */
131 public void printMarkerFieldInformation() {
132 ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
133 }
134
135 /**
136 * toString() method.
137 * <u>Intended to debug</u><br>
138 *
139 * @return Attributes of the object concatenated in String
140 */
141 @Override
142 @SuppressWarnings("nls")
143 public String toString() {
144 String returnData = "";
145 returnData += "field : " + field + "\n";
146 returnData += "format : " + format + "\n";
147
148 return returnData;
149 }
150
151 }
This page took 0.037841 seconds and 6 git commands to generate.