Don't accept a cache or manager names with too weird characters.

@see org.cache2k.Cache2kBuilder#name(String)
551523
public static void checkName(String s) {
    for (char c : s.toCharArray()) {
      if (c == '.' ||
          c == '-' ||
          c == '~' ||
          c == ',' ||
          c == '@' ||
          c == ' ' ||
          c == '(' ||
          c == ')' ||
          c == '+' ||
          c == '!' ||
          c == '\'' ||
          c == '%' ||
          c == '#') {
        continue;
      }
      if (c < 32 || c >= 127 || !Character.isJavaIdentifierPart(c)) {
        throw new IllegalArgumentException(
          "Cache name contains illegal character: '" + c + "', name=\"" + s + "\"");
      }
    }
  }
127001
public static String fixPropertyName(String name) {
		// captialize every char after the underscore , and remove underscores
		final char[] charArray = name.toCharArray();
		for (int i = 0; i < charArray.length; i++) {
			if (charArray[i] == '_') {
				charArray[i + 1] = Character.toUpperCase(charArray[i + 1]);
			}
		}
		name = new String(charArray).replaceAll("_", "");
		return name;
	}
825027
public void validateName(final String name) {
        Validate.validState(
                TENANT_NAME_VALIDATOR_PATTERN.matcher(name).matches(),
                "Invalid tenant name '%s'  -- names must match %s .",
                name,
                TENANT_NAME_VALIDATOR_REGEX);
    }
70802
public void setCacheNames(Collection<String> names) {
        if (names != null) {
            for (String name : names) {
                getCache(name);
            }
            dynamic = false;
        } else {
            dynamic = true;
        }
    }
743529
private String excludeKey(String name, String cmpname, String value) {
        StringBuilder sb = new StringBuilder(cmpname == null ? "" : cmpname + ".");
        sb.append(name).append(value == null ? "" : "=" + value);
        return sb.toString();
    }
820414
@Override
    public boolean validateName(String name) {
        return name != null && !name.isEmpty() && StringUtils.isAlphanumericSpace(name.replace('_', ' '));
    }
924608
public String generateName(String name) {
    checkName(name);
    names.add(name);
    int count = names.count(name);
    if (count == 1) {
      return name;
    }
    return name + collisionSeparator + (count - 1);
  }
979938
private static <T> String name(T item, String name) {
    if (name != null && !name.isEmpty()) {
      return name;
    } else if (item instanceof HasMetadata) {
      HasMetadata h = (HasMetadata) item;
      return h.getMetadata() != null ? h.getMetadata().getName() : null;
    }
    return null;
  }
471528
final int resolveNameIndex(CharSequence name)
    {
        int size = 0;
        int index = 0;
        constantReadLock.lock();
        try
        {
            size = getConstantPoolSize();
            index = getNameIndex(name);
        }
        finally
        {
            constantReadLock.unlock();
        }
        if (index != -1)
        {
            return index;
        }
        else
        {
            return addConstantInfo(new Utf8(name), size);
        }
    }
1135126
public static String escapeName(String name) {
        if (StringUtils.isBlank(name)) {
            throw new IllegalArgumentException("Blank or null is not a valid name.");
        } else if (java.util.regex.Pattern.matches(NAME, name)) {
            return name;
        } else {
            return name.replaceAll("[^A-Za-z0-9\\.\\-_]", "-");
        }
    }
743925
private String prepareName(String name) {
        // \s = A whitespace character: [ \t\n\x0B\f\r]
        String[] arr = name.split("\\s");
        List<String> list = new ArrayList<>(arr.length);
        for (int i = 0; i < arr.length; i++) {
            String rewrite = NON_WORD_CHAR.matcher(toLowerCase(arr[i])).replaceAll("");
            String tmp = rewriteMap.get(rewrite);
            if (tmp != null)
                rewrite = tmp;
            // Ignore matching short frases like de, la, ...
            if (!rewrite.isEmpty() && rewrite.length() > 2) {
                list.add(rewrite);
            }
        }
        return listToString(list);
    }
1276037
public void setName(String name) {
        if (name.endsWith(ARRAY_SUFFIX)) {
            this.name = name.substring(0, name.length() - 2);
            type = ItemType.ARRAY;
        } else if (name.endsWith(MAP_SUFFIX)) {
            this.name = name.substring(0, name.length() - 2);
            type = ItemType.MAP;
        } else {
            this.name = name;
            if (type == null) {
                type = ItemType.SINGLE;
            }
        }
    }
1362723
public static String name(String name, String... names) {
        final StringBuilder builder = new StringBuilder();
        append(builder, name);
        if (names != null) {
            for (String s : names) {
                append(builder, s);
            }
        }
        return builder.toString();
    }
1220226
public CookieBuilder withName(String name) {
        Mutils.notNull("name", name);
        boolean matches = name.matches("^[0-9A-Za-z!#$%&'*+\\-.^_`|~]+$");
        if (!matches) {
            throw new IllegalArgumentException("A cookie name can only be alphanumeric ASCII characters or any of \"!#$%&'*+-.^_`|~\" (excluding quotes)");
        }
        this.name = name;
        return this;
    }
475620
public static String getValidName(String name) {
        StringBuilder validname = new StringBuilder();
        char ch = name.charAt(0);
        if (!XML11Char.isXML11NameStart(ch)) {
            LOG.warn("Prepend _ to " + name);
            validname.append("_");
        }
        for (int i = 0; i < name.length(); i++) {
            ch = name.charAt(i);
            if (!XML11Char.isXML11Name(ch)) {
                LOG.warn("Character " + ch + " in " + name
                    + " is converted to _");
                validname.append("_");
            } else {
                validname.append(ch);
            }
        }

        return validname.toString();
    }
1272724
private static String sanitizeName(String name) {
        StringBuilder ret = new StringBuilder();
        int underscores = 0;
        boolean lastWasADot = false;
        for (char c : name.toCharArray()) {
            if (c == '_') {
                underscores++;
                // Only _ in a row are allowed
                if (underscores <= 2) {
                    ret.append(c);
                }
                continue;
            }

            if (c == '.') {
                // Only one dot in a row is allowed
                if (!lastWasADot) {
                    ret.append(c);
                }
                lastWasADot = true;
                continue;
            }

            underscores = 0;
            lastWasADot = false;
            if (Character.isLetter(c) || Character.isDigit(c) || c == '-') {
                ret.append(c);
            }
        }

        // All characters must be lowercase
        return ret.toString().toLowerCase();
    }
266069
public void setName(String name) {
		if (name == null || name.isEmpty()) {
			throw new IllegalContextNameException(
					IllegalContextNameException.Reason.EMPTY_NAME,
					"The context name must not be null nor empty.");
		}

		this.name = name;
	}