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     */
017    package org.apache.camel.language.simple;
018    
019    import org.apache.camel.Expression;
020    
021    /**
022     * File language is an extension to Simple language to add file specific expressions.
023     *
024     * Examples of supported file expressions are:
025     * <ul>
026     *   <li><tt>file:name</tt> to access the file name (is relative, see note below))</li>
027     *   <li><tt>file:name.noext</tt> to access the file name with no extension</li>
028     *   <li><tt>file:ext</tt> to access the file extension</li>
029     *   <li><tt>file:onlyname</tt> to access the file name (no paths)</li>
030     *   <li><tt>file:onlyname.noext</tt> to access the file name (no paths) with no extension </li>
031     *   <li><tt>file:parent</tt> to access the parent file name</li>
032     *   <li><tt>file:path</tt> to access the file path name</li>
033     *   <li><tt>file:absolute</tt> is the file regarded as absolute or relative</li>
034     *   <li><tt>file:absolute.path</tt> to access the absolute file path name</li>
035     *   <li><tt>file:length</tt> to access the file length as a Long type</li>
036     *   <li><tt>file:modified</tt> to access the file last modified as a Date type</li>
037     *   <li><tt>date:&lt;command&gt;:&lt;pattern&gt;</tt> for date formatting using the {@link java.text.SimpleDateFormat} patterns.
038     *     Additional Supported commands are: <tt>file</tt> for the last modified timestamp of the file.
039     *     All the commands from {@link SimpleLanguage} is also available.
040     *   </li>
041     * </ul>
042     * The <b>relative</b> file is the filename with the starting directory clipped, as opposed to <b>path</b> that will
043     * return the full path including the starting directory.
044     * <br/>
045     * The <b>only</b> file is the filename only with all paths clipped.
046     * <br/>
047      * All the simple expression is also available so you can eg use <tt>${in.header.foo}</tt> to access the foo header.
048     *
049     * @see org.apache.camel.language.simple.SimpleLanguage
050     * @see org.apache.camel.language.bean.BeanLanguage
051     * @deprecated file language is now included as standard in simple language, will be removed in Camel 2.4
052     */
053    @Deprecated
054    public class FileLanguage extends SimpleLanguageSupport {
055    
056        private static final SimpleLanguage SIMPLE = new SimpleLanguage();
057    
058        public static Expression file(String expression) {
059            return SimpleLanguage.simple(expression);
060        }
061    
062        protected Expression createSimpleExpression(String expression, boolean strict) {
063            return SIMPLE.createSimpleExpression(expression, strict);
064        }
065    
066        public boolean isSingleton() {
067            return true;
068        }
069    }