parses and validates the given File using the given DefaultHandler
344718
public void parse(File f, DefaultHandler dh) throws SAXException, IOException
    {
        XMLReader reader = getXMLReader();
        InputSource source = new InputSource(new FileInputStream(f));
        reader.setContentHandler(dh);
        reader.parse(source);
    }
443919
public static void parse(Reader src, StatementHandler handler)
    throws IOException {
    new NTriplesParser(src, handler).parse();
  }
505838
private Document loadValidating(File file) {
		try {
			return getDOMObject(file.getAbsolutePath(), true);
		} catch (SAXException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		}
		return null;
	}
1197672
async function handleGenericFile(req, res, fileExtension) {
    const nodeFilePath = `.${req.url}`;

    // check if the file is in the cache
    if (compiledFiles[nodeFilePath]) {
        res.end(compiledFiles[nodeFilePath]);
        return;
    }

    // the file is not in the cache
    // watch the file if necessary
    // compile the file and return the compiled source
    if (await fs.exists(nodeFilePath)) {
        watchFile(nodeFilePath, watchFiles);
        const source = await fs.readFile(nodeFilePath);
        compiledFiles[nodeFilePath] = source;
        res.end(source);
        return;
    }

    //TODO this code is repeated multiple times
    // if SPA is enabled, return the contents to index.html
    // if SPA is not enabled, return a 404 error
    if (!disableSpa) {
        const indexFileContents = (await fs.readFile(`./index.html`)).toString();
        const modifiedIndexFileContents = modifyHTML(indexFileContents, 'index.html', watchFiles, webSocketPort);
        const directoryPath = req.url.slice(0, req.url.lastIndexOf('/')) || '/';
        res.end(modifyHTML(modifiedIndexFileContents, directoryPath, watchFiles, webSocketPort));
        return;
    }
    else {
        res.statusCode = 404;
        res.end();
        return;
    }
}
495161
public Collection<XLog> parse(File file) throws Exception {
		Collection<XLog> result = null;
		for(XParser parser : XParserRegistry.instance().getAvailable()) {
			if(parser.canParse(file)) {
				try {
					result = parser.parse(file);
					return result;
				} catch(Exception e) {
					// ignore and move on
				}
			}
		}
		throw new Exception("No suitable parser could be found!");
	}
293182
def read(self, filehandle):
        """"""
        return self.__import(json.load(filehandle, **self.kwargs))
1006847
public void parse( String line, File sourceFile, int lineNumber ) {

		// Reset
		this.rawNameToVariables.clear();
		this.errors.clear();
		this.cursor = 0;

		// Parse
		while( this.cursor < line.length()) {

			char c = line.charAt( this.cursor );
			if( Character.isWhitespace( c ) || c == ',' )
				this.cursor ++;

			recognizeVariable( line, sourceFile, lineNumber );
		}
	}
577113
@SuppressWarnings("unchecked")
    private Result parseAndExecute(List<String> argList, Iterable<? extends JavaFileObject> fileObjects)
            throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException {
        long tm = System.currentTimeMillis();

        List<String> javaNames = new ArrayList<>();

        compOpts = Options.instance(context);

        // Make sure no obsolete source/target messages are reported
        try {
            com.sun.tools.javac.main.Option.XLINT_CUSTOM.process(getOptionHelper(), "-Xlint:-options");
        } catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) {
        }

        Arguments arguments = Arguments.instance(context);
        arguments.init(ProgramName);
        arguments.allowEmpty();

        doclet.init(locale, messager);
        parseArgs(argList, javaNames);

        if (!arguments.handleReleaseOptions(extra -> true)) {
            // Arguments does not always increase the error count in the
            // case of errors, so increment the error count only if it has
            // not been updated previously, preventing complaints by callers
            if (!messager.hasErrors() && !messager.hasWarnings())
                messager.nerrors++;
            return CMDERR;
        }

        if (!arguments.validate()) {
            // Arguments does not always increase the error count in the
            // case of errors, so increment the error count only if it has
            // not been updated previously, preventing complaints by callers
            if (!messager.hasErrors() && !messager.hasWarnings())
                messager.nerrors++;
            return CMDERR;
        }

        if (fileManager instanceof BaseFileManager) {
            ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
        }

        compOpts.notifyListeners();
        List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE,
                s -> Collections.EMPTY_LIST);

        if (modules.isEmpty()) {
            List<String> subpkgs = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.SUBPACKAGES,
                    s -> Collections.EMPTY_LIST);
            if (subpkgs.isEmpty()) {
                if (javaNames.isEmpty() && isEmpty(fileObjects)) {
                    String text = messager.getText("main.No_modules_packages_or_classes_specified");
                    throw new ToolException(CMDERR, text);
                }
            }
        }

        JavadocTool comp = JavadocTool.make0(context);
        if (comp == null) return ABNORMAL;

        DocletEnvironment docEnv = comp.getEnvironment(jdtoolOpts,
                javaNames,
                fileObjects);

        // release resources
        comp = null;

        if (breakiterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
            JavacTrees trees = JavacTrees.instance(context);
            trees.setBreakIterator(BreakIterator.getSentenceInstance(locale));
        }
        // pass off control to the doclet
        Result returnStatus = docEnv != null && doclet.run(docEnv)
                ? OK
                : ERROR;

        // We're done.
        if (compOpts.get("-verbose") != null) {
            tm = System.currentTimeMillis() - tm;
            messager.notice("main.done_in", Long.toString(tm));
        }

        return returnStatus;
    }
401168
List<MonitoringHandlerRun> extractRuleSections( File file, String fileContent, Properties params ) {

		// Find rules sections
		StringBuilder sb = new StringBuilder();
		List<String> sections = new ArrayList<String>();
		for( String s : Arrays.asList( fileContent.trim().split( "\n" ))) {
			s = s.trim();
			if( s.length() == 0
					|| s.startsWith( COMMENT_DELIMITER ))
				continue;

			if( s.toLowerCase().startsWith( RULE_BEGINNING )) {
				addSectionIfNotEmpty(sections, sb.toString());
				sb.setLength( 0 );
			}

			sb.append( Utils.expandTemplate(s, params) + "\n" );
		}

		addSectionIfNotEmpty(sections, sb.toString());

		// Now, prepare handler invocations
		List<MonitoringHandlerRun> result = new ArrayList<MonitoringHandlerRun> ();
		for( String s : sections ) {

			Matcher m = this.eventPattern.matcher( s );
			if( ! m.find())
				continue;

			s = s.substring( m.end()).trim();
			MonitoringHandlerRun bean = new MonitoringHandlerRun();
			bean.handlerName = m.group( 1 );
			bean.eventId = m.group( 2 );
			bean.rawRulesText = s;

			result.add( bean );
		}

		return result;
	}
753262
public static void parse (DefaultHandler handler, InputStream in)
        throws IOException, ParserConfigurationException, SAXException
    {
        XMLReader xr = _pfactory.newSAXParser().getXMLReader();

        xr.setContentHandler(handler);
        xr.setErrorHandler(handler);

        xr.parse(new InputSource(in));
    }
1233596
public void read(final String filename, final AsyncResultHandler<String> handler) {
        isFresh(filename, new Handler<Boolean>() {
            @Override
            public void handle(Boolean fresh) {
                if (fresh) {
                    String cachedValue = getFileFromCache(filename);
                    if (cachedValue != null) {
                        handler.handle(new YokeAsyncResult<>(null, cachedValue));
                        return;
                    }
                }
                // either fresh is false or cachedValue is null
                loadToCache(filename, new Handler<Throwable>() {
                    @Override
                    public void handle(Throwable error) {
                        if (error != null) {
                            handler.handle(new YokeAsyncResult<String>(error, null));
                            return;
                        }
                        // no error
                        handler.handle(new YokeAsyncResult<>(null, getFileFromCache(filename)));
                    }
                });
            }
        });
    }
831792
def file_handler
      @_element_file_handler = ElementFileHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_element_file_handler.nil?
      @_element_file_handler
    end
1309831
def validate(filename):
    
    import HTMLParser
    from py_w3c.validators.html.validator import HTMLValidator

    h = HTMLParser.HTMLParser()  # for unescaping WC3 messages

    vld = HTMLValidator()
    LOG.info("Validating: {0}".format(filename))

    # call w3c webservice
    vld.validate_file(filename)

    # display errors and warning
    for err in vld.errors:
        LOG.error(u'line: {0}; col: {1}; message: {2}'.
                  format(err['line'], err['col'], h.unescape(err['message']))
                  )
    for err in vld.warnings:
        LOG.warning(u'line: {0}; col: {1}; message: {2}'.
                    format(err['line'], err['col'], h.unescape(err['message']))
                    )
589740
private HttpHandler validate(final HttpServletRequest request,
                               final HttpServletResponse response,
                               final ParsedHttpRequest parsedHttpRequest) throws IOException, ServletException {
    final String specification = parsedHttpRequest.getTargetSpecification();
    final String version = parsedHttpRequest.getVersion();

    if (specification == null) {
      writeMessage(response, "Specification is not provided in the request.", HttpServletResponse.SC_BAD_REQUEST);
      return null;
    }

    final HttpHandler handler = eventHandlers.get(specification.toLowerCase());
    if (handler == null) {
      writeMessage(response, String.format("No event handler registered for: [%s].", specification),
          HttpServletResponse.SC_NOT_FOUND);
      return null;
    }

    if (version == null) {
      writeMessage(response, "Version is not provided in the request.", HttpServletResponse.SC_BAD_REQUEST);
      return null;
    }
    return handler;
  }
60575
@Override
    public void parse(InputSource is, HandlerBase hb)
        throws SAXException, IOException
    {
        if (hb != null) {
            /* Ok: let's ONLY set if there are no explicit sets... not
             * extremely clear, but JDK tries to set them always so
             * let's at least do damage control.
             */
            if (mContentHandler == null) {
                setDocumentHandler(hb);
            }
            if (mEntityResolver == null) {
                setEntityResolver(hb);
            }
            if (mErrorHandler == null) {
                setErrorHandler(hb);
            }
            if (mDTDHandler == null) {
                setDTDHandler(hb);
            }
        }
        parse(is);
    }
88785
private static void parseAST(String[] srcFiles, Charset srcCharset,
            String[] classPathEntries, FileASTRequestor requestor) {
        ASTParser parser = ASTParser.newParser(AST.JLS8);
        Map<String, String> options = JavaCore.getOptions();
        JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
        parser.setCompilerOptions(options);
        parser.setKind(ASTParser.K_COMPILATION_UNIT);
        parser.setResolveBindings(true);
        parser.setBindingsRecovery(true);
        parser.setEnvironment(classPathEntries, null, null, true);
        String[] srcEncodings = new String[srcFiles.length];
        for (int i = 0; i < srcEncodings.length; i++) {
            srcEncodings[i] = srcCharset.name();
        }
        parser.createASTs(
                srcFiles, srcEncodings, new String[]{}, requestor, null);
    }
1086212
function DefaultHandle(done, req, res, parsedUrl) {
  this.res = res;
  this.res.once('error', this.error.bind(this));
  this.req = req;
  this.req.once('error', this.error.bind(this));
  this.url = parsedUrl;

  // If this is the actual constructor call done now
  if (this.constructor === DefaultHandle) done(null);
}