/** * Parser expects given character. */ void expect (int c) throws InvalidLabelException { if ( ch == c ) return ; String msg = ("expected " + (new Character((char) c)).toString() + "[" + c + "]" + " got " + (new Character((char) ch)).toString() + "[" + ch + "]"); if (file == null) throw new InvalidLabelException(in.getLineNumber(), msg) ; else throw new InvalidLabelFileException (file, in.getLineNumber(), msg) ; }
/** * This will parse the provided file and returns the parsed key and value content * * @param propertiesStream the Reader of property information * @return a list of {@link PropertiesEntry}s * @throws IOException if something cant be read */ public List<PropertiesEntry> parse(InputStream propertiesStream) throws IOException { List<PropertiesEntry> entryList = new ArrayList<PropertiesEntry>(); LineNumberInputStream in = new LineNumberInputStream(propertiesStream); try { StringBuilder currentComment = new StringBuilder(); String line = readLine(in); while (line != null) { // does it start with a comment marker if (isCommentOrWhiteSpaceLine(line)) { currentComment.append(line).append('\n'); line = readLine(in); } else { // we have changed state. Its a property value. line = readEntryPrimed(in, currentComment, entryList, line, in.getLineNumber()); } } } finally { in.close(); } return entryList; }