1 package ist.coach.coachEmfClientComponents.gui; 2 3 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 PHYS_STR = "Physical Layer"; 19 private static final String DATALINK_STR = "Link Layer"; 20 private static final String NETWORK_STR = "Network Layer"; 21 private static final String TRANSPORT_STR = "Transport Layer"; 22 private static final String SESSION_STR = "Session Layer"; 23 private static final String PRESENTATION_STR = "Presentation Layer"; 24 private static final String APPLICATION_STR = "Application Layer"; 25 private static final String DELIMITER = ", "; 26 private static final String END_DELIMITER = "."; 27 28 public static String 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 ("System Services id (" + 35 sysServices + ") could not be parsed!"); 36 37 String systemSupportedServices = new String (); 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 |