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.commons.vfs2.provider.hdfs;
018
019import java.nio.charset.StandardCharsets;
020
021import org.apache.commons.vfs2.FileContent;
022import org.apache.commons.vfs2.FileContentInfo;
023import org.apache.commons.vfs2.FileContentInfoFactory;
024import org.apache.commons.vfs2.FileSystemException;
025import org.apache.commons.vfs2.impl.DefaultFileContentInfo;
026
027/**
028 * Creates FileContentInfo instances for HDFS.
029 *
030 * @since 2.1
031 */
032public class HdfsFileContentInfoFactory implements FileContentInfoFactory {
033
034    private static final String CONTENT = "text/plain";
035    private static final String ENCODING = StandardCharsets.UTF_8.name();
036
037    /**
038     * Constructs a new instance.
039     */
040    public HdfsFileContentInfoFactory() {
041        // empty
042    }
043
044    /**
045     * Creates a FileContentInfo for the given FileContent.
046     *
047     * @param fileContent Use this FileContent to create a matching FileContentInfo
048     * @return a FileContentInfo for the given FileContent with content set to "text/plain" and encoding set to "UTF-8"
049     * @throws FileSystemException when a problem occurs creating the FileContentInfo.
050     */
051    @Override
052    public FileContentInfo create(final FileContent fileContent) throws FileSystemException {
053        return new DefaultFileContentInfo(CONTENT, ENCODING);
054    }
055
056}