/*
This should explain itself, but the context here is of course not a
FileContext entity, but the keys to find one. And the answer to the
question is easy, if there are one or more FileContexts, there are
files.
490928
public function contextHasFiles($context_data)
    {
        $qb2 = $this->_em->createQueryBuilder();
        $qb2->select('mc')
              ->from($this->_entityName, 'mc')
              ->where('mc.system = :system')
              ->andWhere('mc.object_name = :object_name')
              ->andWhere('mc.external_id = :external_id')
              ->setParameter("system", $context_data['system'])
              ->setParameter("object_name", $context_data['object_name'])
              ->setParameter("external_id", $context_data['external_id'])
              ->setMaxResults(1);

        $file_context = $qb2->getQuery()->getResult();
        return !empty($file_context);
    }
685089
function Context(data, parent, path, env) {
	/** 
	 * Context will inherit of AsyncCollector to manage all internal or external asynchroneous calls.
	 * It allows us to know when a context and its descendants are stabilised(i.e.all data are up to date).
	 **/
	AsyncCollector.call(this);
	this.__yContext__ = true;
	this.data = (data !== undefined) ? data : {};
	this.map = {};
	this.binds = [];
	if (parent) {
		this.parent = parent;
		this.env = env ? new Context(env) : parent.env;
		if (path) {
			var self = this;
			this.path = path;
			this.data = this.data || parent.get(path);
			this.parent.subscribe(path, function(value, type, p, key) {
				// console.log('binded context update : ', type, path, p, key, value);
				if (!p.length)
					p.push('$this');
				switch (type) {
					case 'set':
						self.set(p, value, true);
						break;
					case 'push':
						self.push(p, value, true);
						break;
					case 'delete':
						self.del(p, true);
						break;
					case 'displaceItem':
						self.displaceItem(p, value, true);
						break;
					case 'insertItem':
						self.insertItem(p, value, true);
						break;
					case 'deleteItem':
						self.deleteItem(p, value, true);
						break;
				}
			}, true, this.binds);
		}
	} else
		this.env = env ? (env.__yContext__ ? env : new Env(env)) : Context.env;
}
61913
function includeServedOnly(files) {
	files = Object.assign({}, files);
	let oldIncluded = files.included;
	files.included = files.served
		// Don’t include the files that are included in the outer context
		.filter(file => oldIncluded.indexOf(file) === -1)
		// Don’t include this (or other) contexts
		.filter(file => !isIFrameHtml(file.path))
		// Don’t include files that were never included to begin with (before the framework ran)
		// FIXME: find the most specific applicable pattern first
		.filter(file => !nonIncludedFiles.some(pattern => minimatch(file.originalPath, pattern.pattern)))
		// Don’t include the reverse context (it is included by the `transform` function below)
		.filter(file => file.originalPath !== REVERSE_CONTEXT);
	return files;
}
410500
public function has_course_overviewfiles() {
        global $CFG;
        if (empty($CFG->courseoverviewfileslimit)) {
            return false;
        }
        $fs = get_file_storage();
        $context = context_course::instance($this->id);
        return !$fs->is_area_empty($context->id, 'course', 'overviewfiles');
    }
513599
private static BundleContext checkBundleContext() {
        if (bundleContext == null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "BundleContext is null and should not be");
            }
        }
        return bundleContext;
    }
1222334
public static boolean isExistAccessContextOnThread() {
        final Stack<AccessContext> stack = threadLocal.get();
        return stack != null ? !stack.isEmpty() : false;
    }
40328
public boolean isShowInContext(String currentContext) {

        if ((m_settings == null)
            || !m_settings.containsKey(CmsTemplateContextInfo.SETTING)
            || CmsStringUtil.isEmptyOrWhitespaceOnly(m_settings.get(CmsTemplateContextInfo.SETTING))) {
            return true;
        }
        return CmsStringUtil.splitAsList(m_settings.get(CmsTemplateContextInfo.SETTING), "|").contains(currentContext);
    }
1308567
protected boolean checkResourcesModified(GeneratorContext context, List<FilePathMapping> fMappings) {
		boolean resourceModified = false;

		for (Iterator<FilePathMapping> iter = fMappings.iterator(); iter.hasNext() && !resourceModified;) {
			FilePathMapping fMapping = iter.next();
			resourceModified = fMapping.getLastModified() != rsHandler.getLastModified(fMapping.getPath());
		}
		return resourceModified;
	}
128831
public boolean containsFile(SftpFile f) {
		return unchangedFiles.contains(f) || newFiles.contains(f)
				|| updatedFiles.contains(f) || deletedFiles.contains(f)
				|| recursedDirectories.contains(f.getAbsolutePath())
				|| failedTransfers.containsKey(f);
	}
760056
function(data) {
    for (var n in data) {
      if (data[n] instanceof Blob) {
        return true;
      }
      if ((angular.isObject(data[n]) || angular.isArray(data[n])) && hasFile(data[n])) {
        return true;
      }
    }
    return false;
  }
1097948
function isNodeInContext(node, context) {
	'use strict';

	var include =
		context.include &&
		getDeepest(
			context.include.filter(function(candidate) {
				return axe.utils.contains(candidate, node);
			})
		);
	var exclude =
		context.exclude &&
		getDeepest(
			context.exclude.filter(function(candidate) {
				return axe.utils.contains(candidate, node);
			})
		);
	if (
		(!exclude && include) ||
		(exclude && axe.utils.contains(exclude, include))
	) {
		return true;
	}
	return false;
}
605754
private boolean checkFilesExists(String[] requiredFiles, File childResource) {

        File setupFile = null;
        boolean hasMissingSetupFiles = false;

        for (int j = 0; j < requiredFiles.length; j++) {
            setupFile = new File(childResource.getPath() + File.separatorChar + requiredFiles[j]);

            if (!setupFile.exists() || !setupFile.isFile() || !setupFile.canRead()) {
                hasMissingSetupFiles = true;
                System.err.println(
                    "[" + getClass().getName() + "] missing or unreadable database setup file: " + setupFile.getPath());
                break;
            }

            if (!hasMissingSetupFiles) {
                return true;
            }
        }
        return false;
    }
711865
public boolean containsFile(File f) {
		return unchangedFiles.contains(f) || newFiles.contains(f)
				|| updatedFiles.contains(f) || deletedFiles.contains(f)
				|| recursedDirectories.contains(f)
				|| failedTransfers.containsKey(f);
	}
905802
public static ZipFileIndexCache instance(Context context) {
        ZipFileIndexCache instance = context.get(ZipFileIndexCache.class);
        if (instance == null)
            context.put(ZipFileIndexCache.class, instance = new ZipFileIndexCache());
        return instance;
    }
382326
@Override
    protected boolean hasChildren(final String relative) throws IOException {
        ZipFile zip = createZipFile();
        if (null == zip) {
            return false;
        }
        Enumeration<? extends ZipEntry> entries = zip.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if ((relative.equals("")) || entry.getName().startsWith(relative + File.separator)) {
                return true;
            }
        }

        zip.close();
        return false;
    }
554744
function _checkContext(c) {
    if (c.hasOwnProperty('_stopped')) return; // Already done?

    c._stopped = null;

    // Indicate that we gracefully stop
    //  if set, stops the flow until we are back to the main callback
    function _flw_stop(reason, cb) {
      if (!cb && typeof reason === 'function') {
        cb = reason;
        reason = 'stopped';
      }
      c._stopped = reason;
      return cb();
    }
    Object.defineProperty(c, '_stop', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_stop,
    });

    // Stores the data returned from the callback in the context with key 'key'
    //  then calls the callback
    function _flw_store(key, cb) {
      const self = this;

      const fn = function (err, data) {
        if (err) return cb(err);

        self[key] = data;
        return cb();
      };
      return fn;
    }
    Object.defineProperty(c, '_store', {
      enumerable: false,
      configurable: false,
      value: _flw_store,
    });

    // Cleans all flw related properties from the context object
    function _flw_clean() {
      const self = this;
      const contextCopy = {};
      Object.keys(this).forEach(function (k) {
        if (ourContextKeys.indexOf(k) !== -1) return;
        contextCopy[k] = self[k];
      });
      return contextCopy;
    }
    Object.defineProperty(c, '_clean', {
      enumerable: false,
      configurable: false,
      value: _flw_clean,
    });

    // compatibilty for a while
    Object.defineProperty(c, '_flw_store', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_store,
    });

    return c;
  }
1348112
private boolean isValidFile(String s, Set<JavaFileObject.Kind> fileKinds) {
        JavaFileObject.Kind kind = getKind(s);
        return fileKinds.contains(kind);
    }