<commit_before>package de.braintags.io.vertx.util.security;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * A CRUDPermissionMap manages permissions for different keys, where a key can be a role / group, a class-definition
 * etc.
 * 
 * @author <NAME>
 * 
 */
public class CRUDPermissionMap {
  /**
   * The name of the key, which defines the default permission
   */
  public static final String DEFAULT_PERMISSION_KEY_NAME = "*";
  private Map<String, BitSet> permissionMap = new HashMap<>();

  /**
   * Creates a new instance, where the permissions for the default key are set
   */
  public CRUDPermissionMap() {
    permissionMap.put(DEFAULT_PERMISSION_KEY_NAME, new BitSet());
  }

  /**
   * Creates a new instance by parsing the
   * 
   * @param perms
   */
  public CRUDPermissionMap(String perms) {
    String[] ps = perms.split(";");
    for (String p : ps) {
      int index = p.indexOf('{');
      if (index > 0) {
        String key = p.substring(0, index).trim();
        String actions = p.substring(index + 1).replaceAll("}", "").trim();
        addPermissions(key, actions);
      } else {
        String key = p.trim();
        permissionMap.put(key, new BitSet());
      }
    }
  }

  /**
   * Set the permission for the given action for the given key to true
   * 
   * @param key
   *          the key to be set, for example "admin" for a role
   * @param action
   *          the action to be allowed, one of CRUD
   */
  public void addPermission(String key, char action) {<commit_msg>checking data input<commit_after>package de.braintags.io.vertx.util.security;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * A CRUDPermissionMap manages permissions for different keys, where a key can be a role / group, a class-definition
 * etc.
 * 
 * @author <NAME>
 * 
 */
public class CRUDPermissionMap {
  /**
   * The name of the key, which defines the default permission
   */
  public static final String DEFAULT_PERMISSION_KEY_NAME = "*";
  private Map<String, BitSet> permissionMap = new HashMap<>();

  /**
   * Creates a new instance, where the permissions for the default key are set
   */
  public CRUDPermissionMap() {
    permissionMap.put(DEFAULT_PERMISSION_KEY_NAME, new BitSet());
  }

  /**
   * Creates a new instance by parsing the
   * 
   * @param perms
   */
  public CRUDPermissionMap(String perms) {
    if (perms == null) {
      throw new NullPointerException("permission string is null");
    }
    String[] ps = perms.split(";");
    for (String p : ps) {
      int index = p.indexOf('{');
      if (index > 0) {
        String key = p.substring(0, index).trim();
        String actions = p.substring(index + 1).replaceAll("}", "").trim();
        addPermissions(key, actions);
      } else {
        String key = p.trim();
        permissionMap.put(key, new BitSet());
      }
    }
  }

  /**
   * Set the permission for the given action for the given key to true
   * 
   * @param key
   *          the key to be set, for example "admin" for a role
   * @param action
   *          the action to be allowed, one of CRUD
   */
  public void addPermission(String key, char action) {
{'fraction_non_alphanumeric': 0.11862864077669903, 'fraction_numerical': 0.0018203883495145632, 'mean_word_length': 2.7338618346545864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2498917', 'n_tokens_mistral': 1010, 'n_tokens_neox': 992, 'n_words': 329}