src/com/thetransactioncompany/cors/HeaderFieldName.java
protected static String formatCanonical(final String name) {
	
		String nameTrimmed = name.trim();
	
		if (nameTrimmed.isEmpty())
			throw new IllegalArgumentException("The header field name must not be an empty string");
		
		// Check for valid syntax: must begin with letter, then only word and dash chars allowed
		if (! nameTrimmed.matches("^[a-zA-Z][\\w-]*$"))
			throw new IllegalArgumentException("Invalid header field name syntax");
		
	
		String[] tokens = nameTrimmed.toLowerCase().split("-");
		
		String out = "";
		
		for (int i=0; i < tokens.length; i++) {
		
			char[] c = tokens[i].toCharArray();
			
			// Capitalise first char
			c[0] = Character.toUpperCase(c[0]);
			
			if (i >= 1)
				out = out + "-";
			
			out = out + new String(c);
		}
		
		return out;
	}
protected static String formatCanonical(final String name) {
	
		String nameTrimmed = name.trim();
	
		if (nameTrimmed.isEmpty())
			throw new IllegalArgumentException("The header field name must not be an empty string");
		
		// Check for valid syntax: must begin with letter, then only word and dash chars allowed
		if (! nameTrimmed.matches("^[a-zA-Z][\\w-]*$"))
			throw new IllegalArgumentException("Invalid header field name syntax");
		
	
		String[] tokens = nameTrimmed.toLowerCase().split("-");
		
		String out = "";
		
		for (int i=0; i < tokens.length; i++) {
		
			char[] c = tokens[i].toCharArray();
			
			// Capitalise first char
			c[0] = Character.toUpperCase(c[0]);
			
			if (i >= 1)
				out = out + "-";
			
			out = out + new String(c);
		}
		
		return out;
	}
Applies a {@code Aaa-Bbb-Ccc} format to a header field name.

@param name The header field name to format, must not be an empty
string or {@code null}.

@return The formatted header field name.

@throws IllegalArgumentException On a empty or invalid header field
name.