code: private int[] getPrimaryCodewords() {
  
          assert mode == 2 || mode == 3;
  
          if (primaryData.length() != 15) {
              throw new OkapiException("Invalid Primary String");
          }
  
          for (int i = 9; i < 15; i++) { /* check that country code and service are numeric */
              if (primaryData.charAt(i) < '0' || primaryData.charAt(i) > '9') {
                  throw new OkapiException("Invalid Primary String");
              }
          }
  
          String postcode;
          if (mode == 2) {
              postcode = primaryData.substring(0, 9);
              int index = postcode.indexOf(' ');
              if (index != -1) {
                  postcode = postcode.substring(0, index);
              }
          } else {
              // if (mode == 3)
              postcode = primaryData.substring(0, 6);
          }
  
          int country = Integer.parseInt(primaryData.substring(9, 12));
          int service = Integer.parseInt(primaryData.substring(12, 15));
  
          if (debug) {
              System.out.println("Using mode " + mode);
              System.out.println("     Postcode: " + postcode);
              System.out.println("     Country Code: " + country);
              System.out.println("     Service: " + service);
          }
  
          if (mode == 2) {
              return getMode2PrimaryCodewords(postcode, country, service);
          } else { // mode == 3
              return getMode3PrimaryCodewords(postcode, country, service);
          }
      }
docs: Extracts the postal code, country code and service code from the primary data and returns the corresponding primary message
  codewords.
  
  @return the primary message codewords