/* * [CSSCharCategory.java] * * Summary: top level enum to define the categories of character for the PropTokenizer. * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 3.1 2009-04-12 shorter style names, improved highlighting. */ package com.mindprod.jprep; /** * top level enum to define the categories of character for the PropTokenizer. * * @author Roedy Green, Canadian Mind Products * @version 3.1 2009-04-12 shorter style names, improved highlighting. * @since 2004-05-15 */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) public enum CSSCharCategory { BANG, CLOSE_BRACE, COLON, COMMA, /** * End of line character */ EOL, /** * ignore control chars, BOM */ IGNORE, OPEN_BRACE, /** * operators you can use in a selector */ SELECTOR_OPERATOR, /** * ordinary chars inculding punct and digits */ ORDINARY, /** * high ascii ` and chars not used in bat language */ OTHER, PERCENT, QUOTE, SEMICOLON, SLASH, STAR, WHITESPACE /* not including EOL */; /** * Categorise one character * * @param theChar character to categorise * * @return category code, e.g. PLAIN QUOTE */ static CSSCharCategory categorise( char theChar ) { switch ( theChar ) { case '!': return BANG; case '}': return CLOSE_BRACE; case ':': return COLON; case ',': return COMMA; case '\n': return EOL; case '\r': case 127: case 0xfeff: /* bom */ case 0xfffd: /* replaced bom */ return IGNORE; case '{': return OPEN_BRACE; case '>': case '+': return SELECTOR_OPERATOR; case '%': return PERCENT; case '\"': return QUOTE; case ';': return SEMICOLON; case '/': return SLASH; case '*': return STAR; case ' ': case '\t': case 0xa0://   return WHITESPACE; default: if ( 0 <= theChar && theChar <= 31 ) { return IGNORE; } else if ( ' ' <= theChar && theChar <= '~' ) { return ORDINARY; } else { return OTHER; } } // end switch } // end categorise }