ctf: Hide internal functionalities of StringDefinition.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / StringDefinition.java
index 5e79cef7bf0a5add0534f9b007710b81e7e2081c..ff27e849be33c820dd96bf08857d8bced2fdf2b4 100644 (file)
@@ -32,9 +32,9 @@ public class StringDefinition extends Definition {
     // Attributes
     // ------------------------------------------------------------------------
 
-    private StringDeclaration declaration;
+    private StringDeclaration fDeclaration;
 
-    private StringBuilder string;
+    private String fString;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -54,9 +54,9 @@ public class StringDefinition extends Definition {
             IDefinitionScope definitionScope, String fieldName) {
         super(definitionScope, fieldName);
 
-        this.declaration = declaration;
+        fDeclaration = declaration;
 
-        string = new StringBuilder();
+        fString = ""; //$NON-NLS-1$
     }
 
     // ------------------------------------------------------------------------
@@ -65,7 +65,7 @@ public class StringDefinition extends Definition {
 
     @Override
     public StringDeclaration getDeclaration() {
-        return declaration;
+        return fDeclaration;
     }
 
     /**
@@ -75,35 +75,25 @@ public class StringDefinition extends Definition {
      *            the declaration
      */
     public void setDeclaration(StringDeclaration declaration) {
-        this.declaration = declaration;
+        fDeclaration = declaration;
     }
 
     /**
-     * Gets the string
-     *
-     * @return the stringbuilder
-     */
-    public StringBuilder getString() {
-        return string;
-    }
-
-    /**
-     * Sets a stringbuilder for the definition
+     * Gets the string (value)
      *
-     * @param string
-     *            the stringbuilder
+     * @return the string
      */
-    public void setString(StringBuilder string) {
-        this.string = string;
+    public String getValue() {
+        return fString;
     }
 
     /**
-     * Gets the string (value)
+     * Sets the string (value)
      *
-     * @return the string
+     * @param str the string
      */
-    public String getValue() {
-        return string.toString();
+    public void setValue(String str) {
+        fString = str;
     }
 
     // ------------------------------------------------------------------------
@@ -113,13 +103,15 @@ public class StringDefinition extends Definition {
     @Override
     public void read(BitBuffer input) throws CTFReaderException {
         /* Offset the buffer position wrt the current alignment */
-        alignRead(input, this.declaration);
-        string.setLength(0);
-        char c = (char) input.getInt(8, false);
+        alignRead(input, fDeclaration);
+
+        StringBuilder sb = new StringBuilder();
+        char c = (char) input.get(8, false);
         while (c != 0) {
-            string.append(c);
-            c = (char) input.getInt(8, false);
+            sb.append(c);
+            c = (char) input.get(8, false);
         }
+        fString = sb.toString();
     }
 
     @Override
This page took 0.028355 seconds and 5 git commands to generate.