private boolean checkValidCodeInput(String code){
    int CL = (Integer)this.state.get(CODELENGTH);
    if (code.length() != CL) {
      return false;
    }
    int maxDigit = (Integer)this.state.get(MAXDIGIT);
    for (char c: code.toCharArray()){
      if (c <'0' || c > '0' + maxDigit) {
        return false;
      }
    }
    return true;
  }