KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > gui > SysServicesParser


1 package ist.coach.coachEmfClientComponents.gui;
2
3 /**
4  * @author Administrator (digi@intracom.gr)
5  *
6  * Copyright (c) Intracom S.A., N.T., 2003
7  */

8 public class SysServicesParser {
9     
10     private static final int PHYS_MASK = 1;
11     private static final int DATALINK_MASK = 2;
12     private static final int NETWORK_MASK = 4;
13     private static final int TRANSPORT_MASK = 8;
14     private static final int SESSION_MASK = 16;
15     private static final int PRESENTATION_MASK = 32;
16     private static final int APPLICATION_MASK = 64;
17     
18     private static final String JavaDoc PHYS_STR = "Physical Layer";
19     private static final String JavaDoc DATALINK_STR = "Link Layer";
20     private static final String JavaDoc NETWORK_STR = "Network Layer";
21     private static final String JavaDoc TRANSPORT_STR = "Transport Layer";
22     private static final String JavaDoc SESSION_STR = "Session Layer";
23     private static final String JavaDoc PRESENTATION_STR = "Presentation Layer";
24     private static final String JavaDoc APPLICATION_STR = "Application Layer";
25     private static final String JavaDoc DELIMITER = ", ";
26     private static final String JavaDoc END_DELIMITER = ".";
27     
28     public static String JavaDoc parseSysServices(int sysServices) {
29         
30         if (sysServices > (PHYS_MASK + DATALINK_MASK +
31             NETWORK_MASK + TRANSPORT_MASK + SESSION_MASK +
32             PRESENTATION_MASK + APPLICATION_MASK))
33         
34             return new String JavaDoc ("System Services id (" +
35                 sysServices + ") could not be parsed!");
36         
37         String JavaDoc systemSupportedServices = new String JavaDoc();
38         
39         if ( (sysServices & PHYS_MASK) == 1)
40         systemSupportedServices = systemSupportedServices.concat(PHYS_STR);
41         
42             
43         if ( (sysServices & DATALINK_MASK) == DATALINK_MASK) {
44             if(systemSupportedServices.equals("") == false)
45                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
46             systemSupportedServices = systemSupportedServices.concat(DATALINK_STR);
47         }
48         
49         if ( (sysServices & NETWORK_MASK) == NETWORK_MASK) {
50             if(systemSupportedServices.equals("") == false)
51                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
52             systemSupportedServices = systemSupportedServices.concat(NETWORK_STR);
53         }
54         
55         if ( (sysServices & TRANSPORT_MASK) == TRANSPORT_MASK) {
56             if(systemSupportedServices.equals("") == false)
57                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
58             systemSupportedServices = systemSupportedServices.concat(TRANSPORT_STR);
59         }
60         
61         if ( (sysServices & SESSION_MASK) == SESSION_MASK) {
62             if(systemSupportedServices.equals("") == false)
63                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
64             systemSupportedServices = systemSupportedServices.concat(SESSION_STR);
65         }
66         
67         if ( (sysServices & PRESENTATION_MASK) == PRESENTATION_MASK) {
68             if(systemSupportedServices.equals("") == false)
69                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
70             systemSupportedServices = systemSupportedServices.concat(PRESENTATION_STR);
71         }
72         
73         if ( (sysServices & APPLICATION_MASK) == APPLICATION_MASK) {
74             if(systemSupportedServices.equals("") == false)
75                 systemSupportedServices = systemSupportedServices.concat(DELIMITER);
76             systemSupportedServices = systemSupportedServices.concat(APPLICATION_STR);
77         }
78         
79         systemSupportedServices = systemSupportedServices.concat(END_DELIMITER);
80         
81         
82         return systemSupportedServices;
83     }
84     
85 }
86
Popular Tags