<commit_before>/*
 * $Id$
 *
 * Copyright 2003-2005 Wanadoo Nederland B.V.
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.common.spec;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.xins.common.text.FastStringBuffer;
import org.xins.common.text.ParseException;
import org.xins.common.xml.Element;
import org.xins.common.xml.ElementParser;

/**
 * Specification of an API.
 *
 * @version $Revision$
 * @author <NAME> (<a href="mailto:<EMAIL>"><EMAIL></a>)
 */
public class API {
   
   //-------------------------------------------------------------------------
   // Class functions
   //-------------------------------------------------------------------------
   
   /**
    * Gets the content of the file without the DTD declaration.
    *
    * @param reference
    *    the reference class used to located the specifications, cannot be <code>null</code>.
    *
    * @param fileName
    *    the name of the file that contains the specifications, cannot be <code>null</code>.
    *
    * @return
    *    the content of the file, never <code>null</code>.
    *
    * @throws IllegalArgumentException
    *    if the specified file cannot be found.
    *
    * @throws IOException
    *    if the specification cannot be read.
    */
   static Reader getReader(Class reference, String fileName) throws IOException {
      InputStream in = reference.getResourceAsStream("/specs/" + fileName);
      if (in == null) {
         throw new IllegalArgumentException("File \"" + fileName +"\" not found in the specifications.");
      }
      
      // Return the XML file without the DTD declaration
      BufferedReader contentReader = new BufferedReader(new InputStreamReader(in));
      FastStringBuffer content = new FastStringBuffer(1024);
      String nextLine = "";
      while (nextLine != null) {
         nextLine = contentReader.readLine();
         if (nextLine != null) {
            content.append(nextLine);<commit_msg>An InvalidSpecificationException is thrown if the file is not found.<commit_after>/*
 * $Id$
 *
 * Copyright 2003-2005 Wanadoo Nederland B.V.
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.common.spec;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.xins.common.text.FastStringBuffer;
import org.xins.common.text.ParseException;
import org.xins.common.xml.Element;
import org.xins.common.xml.ElementParser;

/**
 * Specification of an API.
 *
 * @version $Revision$
 * @author <NAME> (<a href="mailto:<EMAIL>"><EMAIL></a>)
 */
public class API {
   
   //-------------------------------------------------------------------------
   // Class functions
   //-------------------------------------------------------------------------
   
   /**
    * Gets the content of the file without the DTD declaration.
    *
    * @param reference
    *    the reference class used to located the specifications, cannot be <code>null</code>.
    *
    * @param fileName
    *    the name of the file that contains the specifications, cannot be <code>null</code>.
    *
    * @return
    *    the content of the file, never <code>null</code>.
    *
    * @throws InvalidSpecificationException
    *    if the specified file cannot be found.
    *
    * @throws IOException
    *    if the specification cannot be read.
    */
   static Reader getReader(Class reference, String fileName)
   throws InvalidSpecificationException, IOException {
      
      InputStream in = reference.getResourceAsStream("/specs/" + fileName);
      if (in == null) {
         throw new InvalidSpecificationException("File \"" + fileName +"\" not found in the specifications.");
      }
      
      // Return the XML file without the DTD declaration
      BufferedReader contentReader = new BufferedReader(new InputStreamReader(in));
      FastStringBuffer content = new FastStringBuffer(1024);
      String nextLine = "";
      while (nextLine != null) {
         nextLine = contentReader.readLine();
         if (nextLine != null) {
            content.append(nextLine);
{'fraction_non_alphanumeric': 0.16499345264076823, 'fraction_numerical': 0.005237887385421213, 'mean_word_length': 2.389792899408284, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3129147', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1213, 'n_words': 371}