~ubuntu-branches/ubuntu/vivid/eclipse-linuxtools/vivid-proposed

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.pcap.core/src/org/eclipse/linuxtools/internal/tmf/pcap/core/util/ProtocolConversion.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:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2014 Ericsson
 
3
 *
 
4
 * All rights reserved. This program and the accompanying materials are
 
5
 * made available under the terms of the Eclipse Public License v1.0 which
 
6
 * accompanies this distribution, and is available at
 
7
 * http://www.eclipse.org/legal/epl-v10.html
 
8
 *
 
9
 * Contributors:
 
10
 *   Vincent Perot - Initial API and implementation
 
11
 *******************************************************************************/
 
12
 
 
13
package org.eclipse.linuxtools.internal.tmf.pcap.core.util;
 
14
 
 
15
import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol;
 
16
import org.eclipse.linuxtools.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
 
17
 
 
18
/**
 
19
 * Helper class that allows the conversion between Protocol and TmfProtocol.
 
20
 * This is only used by this project and thus is internal (not API).
 
21
 *
 
22
 * @author Vincent Perot
 
23
 */
 
24
public final class ProtocolConversion {
 
25
 
 
26
    private ProtocolConversion() {}
 
27
 
 
28
    /**
 
29
     * Wrap a {@link PcapProtocol} into a {@link TmfPcapProtocol}.
 
30
     *
 
31
     * @param protocol
 
32
     *            The {@link PcapProtocol} to match
 
33
     * @return The TmfProtocol
 
34
     */
 
35
    public static TmfPcapProtocol wrap(PcapProtocol protocol) {
 
36
        switch (protocol) {
 
37
        case ETHERNET_II:
 
38
            return TmfPcapProtocol.ETHERNET_II;
 
39
        case IPV4:
 
40
            return TmfPcapProtocol.IPV4;
 
41
        case PCAP:
 
42
            return TmfPcapProtocol.PCAP;
 
43
        case TCP:
 
44
            return TmfPcapProtocol.TCP;
 
45
        case UDP:
 
46
            return TmfPcapProtocol.UDP;
 
47
        case UNKNOWN:
 
48
            return TmfPcapProtocol.UNKNOWN;
 
49
        default:
 
50
            throw new IllegalArgumentException();
 
51
        }
 
52
    }
 
53
 
 
54
    /**
 
55
     * Unwrap a {@link TmfPcapProtocol} from a {@link PcapProtocol}.
 
56
     *
 
57
     * @param protocol
 
58
     *            The TmfProtocol
 
59
     * @return The Protocol
 
60
     */
 
61
    public static PcapProtocol unwrap(TmfPcapProtocol protocol) {
 
62
        switch (protocol) {
 
63
        case ETHERNET_II:
 
64
            return PcapProtocol.ETHERNET_II;
 
65
        case IPV4:
 
66
            return PcapProtocol.IPV4;
 
67
        case PCAP:
 
68
            return PcapProtocol.PCAP;
 
69
        case TCP:
 
70
            return PcapProtocol.TCP;
 
71
        case UDP:
 
72
            return PcapProtocol.UDP;
 
73
        case UNKNOWN:
 
74
            return PcapProtocol.UNKNOWN;
 
75
        default:
 
76
            throw new IllegalArgumentException();
 
77
        }
 
78
    }
 
79
 
 
80
}