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 *     Jean-Marc Orliaguet, Chalmers
018 *
019 * $Id$
020 */
021
022package org.nuxeo.theme.resources;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XNodeList;
026import org.nuxeo.common.xmap.annotation.XObject;
027import org.nuxeo.runtime.api.Framework;
028import org.nuxeo.theme.types.Type;
029import org.nuxeo.theme.types.TypeFamily;
030
031@XObject("resource")
032public final class ResourceType implements Type {
033
034    @XNode("@name")
035    public String name;
036
037    @XNode("path")
038    public String path;
039
040    @XNode("url")
041    public String url;
042
043    public String contextPath;
044
045    @XNode("shrinkable")
046    public boolean shrinkable = true;
047
048    @XNodeList(value = "require", type = String[].class, componentType = String.class)
049    public String[] dependencies;
050
051    public ResourceType() {
052    }
053
054    public ResourceType(String name, String path, String[] dependencies) {
055        this.name = name;
056        this.path = path;
057        this.dependencies = dependencies;
058    }
059
060    @Override
061    public TypeFamily getTypeFamily() {
062        return TypeFamily.RESOURCE;
063    }
064
065    @Override
066    public String getTypeName() {
067        return name;
068    }
069
070    @XNode("context-path")
071    public void setContextPath(String contextPath) {
072        this.contextPath = Framework.expandVars(contextPath);
073    }
074
075    public String[] getDependencies() {
076        return dependencies;
077    }
078
079    public String getName() {
080        return name;
081    }
082
083    public String getPath() {
084        return path;
085    }
086
087    public boolean isShrinkable() {
088        return shrinkable;
089    }
090
091    public String getUrl() {
092        return url;
093    }
094
095    public void setName(String name) {
096        this.name = name;
097    }
098
099    public void setPath(String path) {
100        this.path = path;
101    }
102
103    public void setUrl(String url) {
104        this.url = url;
105    }
106
107    public String getContextPath() {
108        return contextPath;
109    }
110
111    public void setShrinkable(boolean shrinkable) {
112        this.shrinkable = shrinkable;
113    }
114
115    public void setDependencies(String[] dependencies) {
116        this.dependencies = dependencies;
117    }
118
119}