/* * [IniCharCategory.java] * * Summary: top level enum to define the categories of character for the CSVTokenizer. * * 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 CSVTokenizer. * * @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 IniCharCategory { /** * ] */ BRACKET_CLOSE, /** * [ */ BRACKET_OPEN, /** * End of line character */ EOL, /** * equals */ EQUALS, /** * ignore control chars */ IGNORE, /** * ordinary chars, including punct, ", space, high ascii, unicode */ ORDINARY, /** * " */ QUOTE, /** * ; comment start , sometimes # */ START_COMMENT,; /** * char that introduces a comment. EOL terminates it. ';' or '#' */ private static char commentChar = ';'; /** * Categorise one character * * @param theChar character to categorise * * @return category code, e.g. PLAIN QUOTE */ static IniCharCategory categorise( char theChar ) { switch ( theChar ) { case ']': return BRACKET_CLOSE; case '[': return BRACKET_OPEN; case '\n': return EOL; case '=': return EQUALS; case '\r': case 127: case 0xfeff: /* bom */ case 0xfffd: /* replaced bom */ return IGNORE; case ' ': case 0xa0://   return ORDINARY; case '\"': return QUOTE; default: if ( 0 <= theChar && theChar <= 31 ) { return IGNORE; } else { return theChar == commentChar ? START_COMMENT : ORDINARY; } } // end switch } // end categorise /** * set comment introducer * * @param commentChar, either ';' or '#' */ static void setCommentChar( char commentChar ) { IniCharCategory.commentChar = commentChar; } } // end IniCharCategory