code: public List<Integer> matchOccurence(int maxAttachments) {
  
          List<Integer> validValues = new ArrayList<Integer>();
  
          for (int val = 0; val <= maxAttachments; val++) {
              boolean addVal = false;
  
              StringTokenizer st = new StringTokenizer(occurrence, ",");
              while (st.hasMoreTokens() && !addVal) {
                  String cond = st.nextToken().trim().replaceAll(" ", "");
                  if (match("^\\d+$", cond)) { // n
                      if (Integer.valueOf(cond) == val) addVal = true;
                  }
                  if (match("^\\d+-\\d+$", cond)) { // n-m
                      int from = Integer.valueOf(cond.substring(0, cond.indexOf('-')));
                      int to = Integer.valueOf(cond.substring(cond.indexOf('-') + 1, cond.length()));
                      if (val >= from && val <= to) {
                          addVal = true;
                      }
                  }
                  if (match("^>\\d+$", cond)) { // <n
                      int n = Integer.valueOf(cond.substring(cond.indexOf('>') + 1, cond.length()));
                      if (val > n) {
                          addVal = true;
                      }
                  }
                  if (match("^<\\d+$", cond)) { // >n
                      int n = Integer.valueOf(cond.substring(cond.indexOf('<') + 1, cond.length()));
                      if (val < n) {
                          addVal = true;
                      }
                  }
                  if (addVal) {
                      validValues.add(val);
                  }
  
              }
          }
          return validValues;
      }
docs: Matches the 'occurrence' condition with a provided maximum number of
  RGroup attachments. Returns the valid occurrences (numeric) for these
  two combined. If none found, returns empty list.
  <br>
  Example: if R1 occurs 3 times attached to some root structure, then
  stating "&gt;5" as an occurrence for that RGoupList does not make
  sense: the example R1 can occur 0..3 times. Empty would be returned.<br>
  If the occurence would be &gt;2, then 3 would be returned. Etcetera.
  
  @param maxAttachments number of attachments
  @return valid values by combining a max for R# with the occurrence cond.