~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/StringFormatter.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
public class StringFormatter implements IFormattingStyles {
19
 
        public StringFormatter() {
20
 
                format = IFormattingStyles.UNFORMATED;
21
 
        }
22
 
 
23
 
        @Override
24
 
        public int getFormat() {
25
 
                return format;
26
 
        }
27
 
 
28
 
        @Override
29
 
        public void setFormat(int format) {
30
 
                this.format = format;
31
 
        }
32
 
 
33
 
        /**
34
 
         * Potentially modifies a string value according to a certain format based on the current value
35
 
         * of format.
36
 
         *
37
 
         * @param s The string to potential modify.
38
 
         *
39
 
         * @return The modified string.
40
 
         */
41
 
        @Override
42
 
        public String format(String s) {
43
 
                switch (format) {
44
 
                        case STRING:
45
 
                                return s;
46
 
                        case DATE:
47
 
                                return DateFormat.getDateTimeInstance().format(new Date(Long.parseLong(s)));
48
 
                        case HEX:
49
 
                                return "0x"+Long.toHexString(Long.parseLong(s)); //$NON-NLS-1$
50
 
                        case OCTAL:
51
 
                                return "0x"+Long.toOctalString(Long.parseLong(s)); //$NON-NLS-1$
52
 
                        case BINARY:
53
 
                                return "0x" + Long.toBinaryString(Long.parseLong(s)); //$NON-NLS-1$
54
 
                        case DOUBLE:
55
 
                                return "" + Double.parseDouble(s); //$NON-NLS-1$
56
 
                }
57
 
                return s;
58
 
        }
59
 
 
60
 
        private int format;
 
19
    public StringFormatter() {
 
20
        format = IFormattingStyles.UNFORMATED;
 
21
    }
 
22
 
 
23
    @Override
 
24
    public int getFormat() {
 
25
        return format;
 
26
    }
 
27
 
 
28
    @Override
 
29
    public void setFormat(int format) {
 
30
        this.format = format;
 
31
    }
 
32
 
 
33
    /**
 
34
     * Potentially modifies a string value according to a certain format based on the current value
 
35
     * of format.
 
36
     *
 
37
     * @param s The string to potential modify.
 
38
     *
 
39
     * @return The modified string.
 
40
     */
 
41
    @Override
 
42
    public String format(String s) {
 
43
        switch (format) {
 
44
            case STRING:
 
45
                return s;
 
46
            case DATE:
 
47
                return DateFormat.getDateTimeInstance().format(new Date(Long.parseLong(s)));
 
48
            case HEX:
 
49
                return "0x"+Long.toHexString(Long.parseLong(s)); //$NON-NLS-1$
 
50
            case OCTAL:
 
51
                return "0x"+Long.toOctalString(Long.parseLong(s)); //$NON-NLS-1$
 
52
            case BINARY:
 
53
                return "0x" + Long.toBinaryString(Long.parseLong(s)); //$NON-NLS-1$
 
54
            case DOUBLE:
 
55
                return "" + Double.parseDouble(s); //$NON-NLS-1$
 
56
        }
 
57
        return s;
 
58
    }
 
59
 
 
60
    private int format;
61
61
}