This method is static is available as utility for users that are passing the contents of a script
and want to set the engineName property based on a filename.

@param filename the filename
@return script engine name
966281
public static String getScriptEngineName(String filename) {
        String extension = FilenameUtils.getExtension(filename);
        if (StringUtils.isBlank(extension)) {
            logger.warn("Can't determine engine name based on filename without extension {}",filename);
            return null;
        }
        ScriptEngineManager manager = new ScriptEngineManager();
        List<ScriptEngineFactory> engines = manager.getEngineFactories();
        for (ScriptEngineFactory engineFactory : engines) {
            List<String> extensions = engineFactory.getExtensions();
            for (String supportedExt : extensions) {
                if (extension.equals(supportedExt)) {
                    // return first short name
                    return engineFactory.getNames().get(0);
                }
            }
        }
        logger.warn("Can't determine engine name based on filename and available script engines {}",filename);
        return null;
    }
521329
@Pure
	public static String largeBasename(URL filename) {
		if (filename == null) {
			return null;
		}
		final String fullPath = filename.getPath();
		assert !isWindowsNativeFilename(fullPath);
		int idx;
		int end = fullPath.length();
		do {
			end--;
			idx = fullPath.lastIndexOf(URL_PATH_SEPARATOR_CHAR, end);
		}
		while (idx >= 0 && end >= 0 && idx >= end);
		final String result;
		if (idx < 0) {
			if (end < fullPath.length() - 1) {
				result = fullPath.substring(0, end + 1);
			} else {
				result = fullPath;
			}
		} else {
			result = fullPath.substring(idx + 1, end + 1);
		}
		return decodeHTMLEntities(result);
	}
1134074
public static File searchForGroovyScriptFile(String input) {
        String scriptFileName = input.trim();
        File scriptFile = new File(scriptFileName);
        // TODO: Shouldn't these extensions be kept elsewhere?  What about CompilerConfiguration?
        // This method probably shouldn't be in GroovyMain either.
        String[] standardExtensions = {".groovy",".gvy",".gy",".gsh"};
        int i = 0;
        while (i < standardExtensions.length && !scriptFile.exists()) {
            scriptFile = new File(scriptFileName + standardExtensions[i]);
            i++;
        }
        // if we still haven't found the file, point back to the originally specified filename
        if (!scriptFile.exists()) {
            scriptFile = new File(scriptFileName);
        }
        return scriptFile;
    }
1312905
public boolean add(String fileName) {
      writeLock.lock();
      try {
         return filenames.add(fileName);
      } finally {
         writeLock.unlock();
      }
   }
859364
public static <T> T executeGroovyScriptEngine(final String script,
                                                  final Map<String, Object> variables,
                                                  final Class<T> clazz) {
        try {
            val engine = new ScriptEngineManager().getEngineByName("groovy");
            if (engine == null) {
                LOGGER.warn("Script engine is not available for Groovy");
                return null;
            }
            val binding = new SimpleBindings();
            if (variables != null && !variables.isEmpty()) {
                binding.putAll(variables);
            }
            if (!binding.containsKey("logger")) {
                binding.put("logger", LOGGER);
            }
            val result = engine.eval(script, binding);
            return getGroovyScriptExecutionResultOrThrow(clazz, result);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
1218531
public static String getGetterName(String propertyName) {
        final String suffix = getSuffixForGetterOrSetter(propertyName);
        return PROPERTY_GET_PREFIX + suffix;
    }
968888
protected static String oldFileNameToViewName(String fileName) throws CouchbaseLiteException {
        if (!fileName.endsWith(kViewIndexPathExtension) || fileName.startsWith("."))
            throw new CouchbaseLiteException(Status.BAD_PARAM);
        String viewName = fileName.substring(0, fileName.indexOf("."));
        return viewName.replaceAll(":", "/");
    }
985194
protected static String getFileName(final Map<String, String> properties) {
		String fileName = properties.get("file");
		if (fileName == null) {
			throw new IllegalArgumentException("File name is missing for file writer");
		} else {
			return fileName;
		}
	}
1154347
public synchronized static Engine create(String engineName) {
		if (StrKit.isBlank(engineName)) {
			throw new IllegalArgumentException("Engine name can not be blank");
		}
		engineName = engineName.trim();
		if (engineMap.containsKey(engineName)) {
			throw new IllegalArgumentException("Engine already exists : " + engineName);
		}
		Engine newEngine = new Engine(engineName);
		engineMap.put(engineName, newEngine);
		return newEngine;
	}
146244
def find_by_filename(filename=None, engines=None):
    
    if engines is None:
        engines = ENGINES

    if filename is None:
        return list_engines_by_priority(engines)

    return sorted((e for e in engines if e.supports(filename)),
                  key=operator.methodcaller("priority"))
380409
public Response filenameHeader(String filename) {
        if (filename != null && !filename.isEmpty()) {
            header(HttpConstants.Header.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"");
        } else {
            header(HttpConstants.Header.CONTENT_DISPOSITION, "attachment; filename=\"\"");
        }

        return this;
    }
1125702
private static String basename(final File file) {
        final String name = file.getName();
        if(name.contains(".")) {
            return name.substring(0, name.lastIndexOf("."));
        }
        return name;
    }
202761
private static int scriptNameToCode(String name) {
        try{
            int[] codes = UScript.getCode(name);
            return codes != null ? codes[0] : UScript.INVALID_CODE;
        }catch( MissingResourceException e){
            ///CLOVER:OFF
            return UScript.INVALID_CODE;
            ///CLOVER:ON
        }
    }
976686
public ScriptEnvironment getEnvironment(String environmentName) {
      Preconditions.checkArgument(StringUtils.isNotNullOrBlank(environmentName),
                                  "Environment name cannot be null or empty"
                                 );
      ScriptEngine engine = engineManager.getEngineByName(environmentName);
      Preconditions.checkArgument(engine != null, environmentName + " is an unknown.");
      environmentName = engine.getFactory().getEngineName();
      if (!environments.containsKey(environmentName)) {
         environments.put(environmentName, new ScriptEnvironment(engine));
      }
      return environments.get(environmentName);
   }
882085
public static Properties readPropertiesFile(String fileName) {
		InputStream in = getInputStream(fileName);
		if (in != null) {
			return readPropertiesStream(in);
		}
		return new Properties();
	}
1212853
def javascript(filename, type='text/javascript'):
    ''''''
    if '?' in filename and len(filename.split('?')) is 2:
        filename, params = filename.split('?')
        return '<script type="%s" src="%s?%s"></script>' % (type, staticfiles_storage.url(filename), params)
    else:
        return '<script type="%s" src="%s"></script>' % (type, staticfiles_storage.url(filename))
639234
public static String getSetterName(String propertyName) {
        final String suffix = getSuffixForGetterOrSetter(propertyName);
        return PROPERTY_SET_PREFIX + suffix;
    }