001/**
002 * Get more info at : www.jrebirth.org .
003 * Copyright JRebirth.org © 2011-2013
004 * Contact : sebastien.bordes@jrebirth.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jrebirth.af.core.resource.image;
019
020import java.util.Arrays;
021import java.util.List;
022
023import org.jrebirth.af.api.resource.image.ImageExtension;
024import org.jrebirth.af.api.resource.image.ImageParams;
025
026/**
027 * The interface <strong>LocalImage</strong>.
028 *
029 * @author Sébastien Bordes
030 */
031public class RelImage extends AbstractBaseImage implements ImageParams {
032
033    /**
034     * Default Constructor.
035     *
036     * @param path the image local path
037     * @param name the file name
038     * @param extension the image extension
039     */
040    public RelImage(final String path, final String name, final ImageExtension extension) {
041        super(path, name, extension);
042    }
043
044    /**
045     * Default Constructor.
046     *
047     * @param name the file name
048     * @param extension the image extension
049     */
050    public RelImage(final String name, final ImageExtension extension) {
051        this("", name, extension);
052    }
053
054    /**
055     * Default Constructor.
056     *
057     * @param fullName the full file name (including path and image extension)
058     */
059    public RelImage(final String fullName) {
060        this("", fullName, ImageExtension.NONE);
061    }
062
063    /**
064     * {@inheritDoc}
065     */
066    @Override
067    public void parse(final String... parameters) {
068        if (parameters.length == 1) {
069            nameProperty().set(parameters[0]);
070        }
071        if (parameters.length == 2) {
072            nameProperty().set(parameters[0]);
073            extensionProperty().set(ImageExtension.valueOf(parameters[1]));
074        }
075        if (parameters.length == 3) {
076            pathProperty().set(parameters[0]);
077            nameProperty().set(parameters[1]);
078            extensionProperty().set(ImageExtension.valueOf(parameters[2]));
079        }
080    }
081
082    /**
083     * {@inheritDoc}
084     */
085    @Override
086    protected List<? extends Object> getFieldValues() {
087        return Arrays.asList(path(), name(), extension().toString());
088    }
089
090}