More javadoc updates
[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 * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
10 *
11 * Provides access to the marker_field C structure (from LTT) in java.<p>
12 *
13 * Most important attributes in the JniMarkerField are :
14 * <ul>
15 * <li> the name (field) of in String
16 * <li> the marker field format (in C style printf format)
17 * </ul>
18 *
19 * <b>NOTE</b><p>
20 * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<p>
21 *
22 * @version 0.1
23 * @author William Bourque
24 */
25 public abstract class JniMarkerField extends Jni_C_Common
26 {
27 // Internal C pointer of the JniEvent used in LTT
28 private Jni_C_Pointer_And_Library_Id thisMarkerFieldPtr = new Jni_C_Pointer_And_Library_Id();
29
30 private String field = ""; //$NON-NLS-1$
31 private String format = ""; //$NON-NLS-1$
32
33 // Native access method
34 protected native String ltt_getField(int libId, long markerFieldPtr);
35 protected native int ltt_getType(int libId, long markerFieldPtr);
36 protected native long ltt_getOffset(int libId, long markerFieldPtr);
37 protected native long ltt_getSize(int libId, long markerFieldPtr);
38 protected native long ltt_getAlignment(int libId, long markerFieldPtr);
39 protected native long ltt_getAttributes(int libId, long markerFieldPtr);
40 protected native int ltt_getStatic_offset(int libId, long markerFieldPtr);
41 protected native String ltt_getFormat(int libId, long markerFieldPtr);
42
43 // Debug native function, ask LTT to print marker structure
44 protected native void ltt_printMarkerField(int libId, long markerFieldPtr);
45
46 /*
47 * Default constructor is forbidden
48 */
49 protected JniMarkerField() {
50 }
51
52 /**
53 * Copy constructor.<p>
54 *
55 * @param oldMarkerField Reference to the JniMarkerField you want to copy.
56 */
57 public JniMarkerField(JniMarkerField oldMarkerField) {
58 thisMarkerFieldPtr = oldMarkerField.getMarkerFieldPtr();
59 field = oldMarkerField.getField();
60 format = oldMarkerField.getFormat();
61 }
62
63 /**
64 * Constructor, using pointer.
65 * <p>
66 *
67 * @param newMarkerFieldPtr
68 * Pointer to a C marker_field structure
69 * @exception JniException
70 * If the JNI call fails
71 *
72 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
73 */
74 public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException {
75 thisMarkerFieldPtr = newMarkerFieldPtr;
76
77 // Populate the marker field
78 populateMarkerFieldInformation();
79 }
80
81 /*
82 * This function populates the marker field data with data from LTT
83 *
84 */
85 private void populateMarkerFieldInformation() throws JniException {
86 if (thisMarkerFieldPtr.getPointer() == NULL) {
87 throw new JniMarkerFieldException(
88 "Pointer is NULL, trace closed? (populateMarkerInformation)"); //$NON-NLS-1$
89 }
90 field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
91 format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
92 }
93
94 /**
95 * Get the field of this marker
96 *
97 * @return The field name
98 */
99 public String getField() {
100 return field;
101 }
102
103 /**
104 * Get the format of this marker
105 *
106 * @return The format, as a String
107 */
108 public String getFormat() {
109 return format;
110 }
111
112 /**
113 * Pointer to the marker_field C structure.<p>
114 *
115 * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
116 * know what you are doing.<p>
117 *
118 * @return The actual (long converted) pointer or NULL
119 *
120 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
121 */
122 public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() {
123 return thisMarkerFieldPtr;
124 }
125
126 /**
127 * Print information for this event. <u>Intended to debug</u><br>
128 *
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>
131 */
132 public void printMarkerFieldInformation() {
133 ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
134 }
135
136 /**
137 * toString() method.
138 * <u>Intended to debug</u><br>
139 *
140 * @return Attributes of the object concatenated in String
141 */
142 @Override
143 @SuppressWarnings("nls")
144 public String toString() {
145 String returnData = "";
146 returnData += "field : " + field + "\n";
147 returnData += "format : " + format + "\n";
148
149 return returnData;
150 }
151
152 }
This page took 0.071924 seconds and 6 git commands to generate.