001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017package org.apache.logging.log4j.core.util;
018
019import java.util.ArrayList;
020import java.util.List;
021
022/**
023 *
024 */
025public enum ExtensionLanguageMapping {
026    JS("js", "JavaScript"), JAVASCRIPT("javascript", "JavaScript"), GVY("gvy", "Groovy"),
027    GROOVY("groovy", "Groovy"), BSH("bsh", "beanshell"), BEANSHELL("beanshell", "beanshell"),
028    JY("jy", "jython"), JYTHON("jython", "jython"), FTL("ftl", "freemarker"),
029    FREEMARKER("freemarker", "freemarker"), VM("vm", "velocity"), VELOCITY("velocity", "velocity"),
030    AWK("awk", "awk"), EJS("ejs", "ejs"), TCL("tcl", "tcl"), HS("hs", "jaskell"), JELLY("jelly", "jelly"),
031    JEP("jep", "jep"), JEXL("jexl", "jexl"), JEXL2("jexl2", "jexl2"),
032    RB("rb", "ruby"), RUBY("ruby", "ruby"), JUDO("judo", "judo"), JUDI("judi", "judo"), SCALA("scala", "scala"),
033    CLJ("clj", "Clojure");
034
035
036    private final String extension;
037    private final String language;
038
039    ExtensionLanguageMapping(final String extension, final String language) {
040        this.extension = extension;
041        this.language = language;
042    }
043
044    public String getExtension() {
045        return this.extension;
046    }
047
048    public String getLanguage() {
049        return this.language;
050    }
051
052    public static ExtensionLanguageMapping getByExtension(final String extension) {
053        for (final ExtensionLanguageMapping mapping : values()) {
054            if (mapping.extension.equals(extension)) {
055                return mapping;
056            }
057        }
058        return null;
059    }
060
061    public static List<ExtensionLanguageMapping> getByLanguage(final String language) {
062        final List<ExtensionLanguageMapping> list = new ArrayList<>();
063        for (final ExtensionLanguageMapping mapping : values()) {
064            if (mapping.language.equals(language)) {
065                list.add(mapping);
066            }
067        }
068        return list;
069    }
070
071}