Parses a CSV file from a given reader.
@param reader the reader
@param separator the CSV separator
@throws ParseException if any parse errors ocur
@throws IOException if any IO errors occur
517970
private void parse(Reader reader, char separator) throws IOException, ParseException {
    LOG.info("Parsing CSV file...");
    /*
     * Ideally one would configure the format using withHeader(String ...) but since the master column is optional
     * this is of no use. Therefore, you'll get null if you were to call getHeaderMap() later on the parser. The header
     * is returned as the 1st record (i.e. row).
     */
    CSVParser csvParser = CSVFormat.DEFAULT.withDelimiter(separator).withIgnoreSurroundingSpaces(true).parse(reader);

    List<CSVRecord> records = csvParser.getRecords();

    String[] header = transformHeaderMapToArray(records.get(0));
    verifyHeader(header);

    for (int i = 1; i < records.size(); i++) {
      CSVRecord csvRecord = records.get(i);

      if (csvRecord.size() != header.length) {
        throw new ParseException(String.format("Expected %d columns but got %d.",  header.length, csvRecord.size()),
          i + 1);
      }
      String key = csvRecord.get(0);
      Status status = Status.valueOf(csvRecord.get(1));
      String masterValue = null;
      String value;
      if (hasMasterLanguage()) {
        masterValue = csvRecord.get(2);
        value = csvRecord.get(3);
      } else {
        value = csvRecord.get(2);
      }

      // the context is irrelevant, so it is not added
      add(key, status, masterValue, value);
    }
    LOG.info("Parsing of CSV file finished.");
  }
757440
private static Map<String, String> readPrefixDeclaration(BufferedReader reader) throws IOException {
        Map<String, String> prefixes = new HashMap<>();
        String line;
        while (!(line = reader.readLine()).isEmpty()) {
            String[] tokens = line.split("[\t| ]+");
            prefixes.put(tokens[0], tokens[1]);
        }
        return prefixes;
    }
419444
public void readConfig(Reader reader) throws IOException {
		try {
			XMLStreamReader xr = XMLInputFactory.newInstance().createXMLStreamReader(reader);
			try {
				while (!xr.isStartElement()) {
					xr.next();
				}
				processStartElement(xr, "simon-configuration");
				while (true) {
					if (isStartTag(xr, "callback")) {
						manager.callback().addCallback(processCallback(xr));
					} else if (isStartTag(xr, "filter-callback")) {
						manager.callback().addCallback(processFilterCallback(xr));
					} else if (isStartTag(xr, "simon")) {
						processSimon(xr);
					} else {
						break;
					}
				}
				assertEndTag(xr, "simon-configuration");
			} finally {
				xr.close();
			}
		} catch (XMLStreamException e) {
			manager.callback().onManagerWarning(null, e);
		} catch (SimonException e) {
			manager.callback().onManagerWarning(e.getMessage(), e);
		}
	}
744822
void parse(Reader reader) throws ParseException {
        if (reader == null) {
            //just log and return default properties
            Log.warn("parsing NULL reader, so fallback on default configuration!");
            return;
        }
        
        BufferedReader br = new BufferedReader(reader);
        String line;
        try {
            while ((line = br.readLine()) != null) {
                int commentMarker = line.indexOf('#');
                if (commentMarker != -1) {
                    if (commentMarker == 0) {
                        //skip its a comment
                        continue;
                    } else {
                        //it's a malformed comment
                        throw new ParseException(line, commentMarker);
                    }
                } else {
                    if (line.isEmpty() || line.matches("^\\s*$")) {
                        //skip it's a black line
                        continue;
                    }
                    
                    //split till the first space
                    int deilimiterIdx = line.indexOf(' ');
                    String key = line.substring(0, deilimiterIdx).trim();
                    String value = line.substring(deilimiterIdx).trim();
                    
                    m_properties.put(key, value);
                }
            }
        } catch (IOException ex) {
            throw new ParseException("Failed to read", 1);
        }
    }
761769
public void parse(InputStream inputStream) throws IOException {

		currentMatrix = null;
		currentRows = "";
		currentCols = "";
		max = Short.MIN_VALUE;
		min = Short.MAX_VALUE;
		inMatrix = false;

		BufferedReader buf = new BufferedReader (new InputStreamReader (inputStream));
		String line = null;
		line = buf.readLine();

		while (  line != null ) {

			if ( line.startsWith("//")) {
				finalizeMatrix();
				inMatrix = false;

			} else if ( line.startsWith("H ")){
				// a new matric!
				newMatrix(line);
			} else if ( line.startsWith("D ")) {
				currentMatrix.setDescription(line.substring(2));
			} else if ( line.startsWith("M ")) {
				initMatrix(line);
				inMatrix = true;
			} else if ( line.startsWith("  ")){
				if ( inMatrix)
					processScores(line);
			}

			line = buf.readLine();
		}

	}
355569
private static void parse(final Reader r) throws IOException {
		final BufferedReader br = new BufferedReader(r);
		String line;
		final ArrayList<String> sequence = new ArrayList<String>();

		line = br.readLine();
		while (true) {
			if (line == null) {
				break;
			}
			line = line.trim();
			if (line.length() == 0 || line.charAt(0) == '#') {
				line = br.readLine();
				continue;
			}
			sequence.add(line);

			// read the following lines until a line does not begin with '>' or
			// EOF
			while (true) {
				line = br.readLine();
				if (line == null) {
					addEntry(sequence);
					sequence.clear();
					break;
				}
				line = line.trim();
				if (line.length() == 0 || line.charAt(0) == '#') {
					continue;
				}
				if (line.charAt(0) != '>') {
					addEntry(sequence);
					sequence.clear();
					break;
				}
				sequence.add(line);
			}
		}
		if (!sequence.isEmpty()) {
			addEntry(sequence);
		}
	}
872019
public void read(BufferedReader reader) throws Exception {
		String line;

		clear();

		while ((line = reader.readLine()) != null) {
			line = line.trim();
			// comment?
			if (line.startsWith("#"))
				continue;
			add(line);
		}

		reader.close();
	}
14361
public static Object[] parse(Reader reader, Class<?>[] types,
                                 Converter<Object, Map<String, Object>> mc) throws IOException,
            ParseException {
        return (Object[]) parse(reader, new JSONVisitor(types,
                new JSONValue(mc)), JSONToken.LSQUARE);
    }
1249622
protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary)
    throws IOException, XmlPullParserException {
    this.xmlPullParser.setInput(reader);
    Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null);
  }
1357088
public CSVParserBuilder<T, K> usingSeparatorWithQuote(char separator, char quote) {
        this.metadata = new CSVFileMetadata(separator, Optional.of(quote));
        return this;
    }
583942
public static Object parse(Reader reader, JSONVisitor handler)
            throws IOException, ParseException {
        return parse(reader, handler, JSONToken.ANY);
    }
801186
public static JsonElement parse(JsonReader reader) throws JsonParseException {
    boolean isEmpty = true;
    try {
      reader.peek();
      isEmpty = false;
      return TypeAdapters.JSON_ELEMENT.read(reader);
    } catch (EOFException e) {
      /*
       * For compatibility with JSON 1.5 and earlier, we return a JsonNull for
       * empty documents instead of throwing.
       */
      if (isEmpty) {
        return JsonNull.INSTANCE;
      }
      // The stream ended prematurely so it is likely a syntax error.
      throw new JsonSyntaxException(e);
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);
    } catch (IOException e) {
      throw new JsonIOException(e);
    } catch (NumberFormatException e) {
      throw new JsonSyntaxException(e);
    }
  }
1032753
public <T> T parse(Reader in, JsonReaderI<T> mapper) throws ParseException {
		return getPStream().parse(in, mapper);
	}
781029
public void parse (Reader reader) {
		try {
			char[] data = new char[1024];
			int offset = 0;
			while (true) {
				int length = reader.read(data, offset, data.length - offset);
				if (length == -1) break;
				if (length == 0) {
					char[] newData = new char[data.length * 2];
					System.arraycopy(data, 0, newData, 0, data.length);
					data = newData;
				} else
					offset += length;
			}
			parse(data, 0, offset);
		} catch (IOException ex) {
			throw new SerializationException(ex);
		} finally {
			StreamUtils.closeQuietly(reader);
		}
	}
65254
void parse(File file) throws ParseException {
        if (file == null) {
            Log.warn("parsing NULL file, so fallback on default configuration!");
            return;
        }
        if (!file.exists()) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()));
            return;
        }
        try {
            FileReader reader = new FileReader(file);
            parse(reader);
        } catch (FileNotFoundException fex) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex);
            return;
        }
    }
1061280
public <T> T parse(InputStream in, JsonReaderI<T> mapper) throws ParseException, UnsupportedEncodingException {
		return getPBinStream().parse(in, mapper);
	}
285546
private int readChar(Reader source) throws ParseException
    {
        int c;

        try {
            c = source.read();
        } catch (IOException e) {
            throw new ParseException("Failed to read input source", e);
        }

        return c;
    }