package org.exist.xquery.functions.fn;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.exist.dom.QName;
import org.exist.xquery.*;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.StringValue;
import org.exist.xquery.value.Type;

public class FnDefaultLanguage extends BasicFunction {

    private static final Logger logger = LogManager.getLogger(FunCurrentDateTime.class);

    public static final FunctionSignature FS_DEFAULT_LANGUAGE = FunctionDSL.functionSignature(
            new QName("default-language", Function.BUILTIN_FUNCTION_NS),
            "Returns the xs:language that is " +
                    "the value of the default language property from the dynamic context " +
                    "during the evaluation of a query or transformation in which " +
                    "fn:default-language() is executed.",
            FunctionDSL.returns(Type.LANGUAGE, Cardinality.EXACTLY_ONE, "the default language within query execution time span"));

    public FnDefaultLanguage(final XQueryContext context) {
        super(context, FS_DEFAULT_LANGUAGE);
    }

    public Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException {
        if (context.getProfiler().isEnabled()) {
            context.getProfiler().start(this);
            context.getProfiler().message(this, Profiler.DEPENDENCIES,
                    "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));
            if (contextSequence != null) {
                context.getProfiler().message(this, Profiler.START_SEQUENCES,
                        "CONTEXT SEQUENCE", contextSequence);
            }
        }
        final Sequence result = new StringValue(context.getDefaultLanguage());
        if (context.getProfiler().isEnabled()) {
            context.getProfiler().end(this, "", result);
        }
        return result;

    }

}

@@ -1,8 +1,897 @@
+/*%0A * eXist-db Open Source Native XML Database%0A * Copyright (C) 2001 The eXist-db Authors%0A *%0A * info@exist-db.org%0A * http://www.exist-db.org%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA%0A */%0A
 package 

Add correct licence header to new fn