001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: MimetypeEntryImpl.java 21445 2007-06-26 14:47:16Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.mimetype;
023
024import java.util.List;
025
026import org.nuxeo.ecm.platform.mimetype.interfaces.MimetypeEntry;
027
028/**
029 * MimetypeEntry.
030 * <p>
031 * A mimetype instance holds mimetype meta information.
032 *
033 * @see MimetypeEntry
034 * @author <a href="ja@nuxeo.com">Julien Anguenot</a>
035 */
036public class MimetypeEntryImpl implements MimetypeEntry {
037
038    private static final long serialVersionUID = 5416098564564151631L;
039
040    protected final List<String> extensions;
041
042    protected final String iconPath;
043
044    protected final boolean binary;
045
046    protected final boolean onlineEditable;
047
048    protected final boolean oleSupported;
049
050    protected final List<String> mimetypes;
051
052    protected final String normalized;
053
054    public MimetypeEntryImpl(String normalized, List<String> mimetypes, List<String> extensions, String iconPath,
055            boolean binary, boolean onlineEditable, boolean oleSupported) {
056        this.normalized = normalized;
057        this.mimetypes = mimetypes;
058        this.extensions = extensions;
059        this.iconPath = iconPath;
060        this.binary = binary;
061        this.onlineEditable = onlineEditable;
062        this.oleSupported = oleSupported;
063    }
064
065    @Override
066    public List<String> getExtensions() {
067        return extensions;
068    }
069
070    @Override
071    public String getIconPath() {
072        return iconPath;
073    }
074
075    @Override
076    public List<String> getMimetypes() {
077        return mimetypes;
078    }
079
080    @Override
081    public String getMajor() {
082        return normalized.split("/")[0];
083    }
084
085    @Override
086    public String getMinor() {
087        return normalized.split("/")[1];
088    }
089
090    @Override
091    public String getNormalized() {
092        return normalized;
093    }
094
095    @Override
096    public boolean isBinary() {
097        return binary;
098    }
099
100    @Override
101    public boolean isOnlineEditable() {
102        return onlineEditable;
103    }
104
105    @Override
106    public boolean isOleSupported() {
107        return oleSupported;
108    }
109
110}