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.fragments;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.theme.Manager;
027import org.nuxeo.theme.models.ModelType;
028import org.nuxeo.theme.types.Type;
029import org.nuxeo.theme.types.TypeFamily;
030
031@XObject("fragment")
032public final class FragmentType implements Type {
033
034    @XNode("@name")
035    public String name;
036
037    @XNode("class")
038    public String className;
039
040    @XNode("model-type")
041    public String modelName;
042
043    @XNode("dynamic")
044    public boolean dynamic = true;
045
046    public FragmentType() {
047    }
048
049    public FragmentType(String name, String className, String modelName, boolean dynamic) {
050        this.name = name;
051        this.className = className;
052        this.modelName = modelName;
053        this.dynamic = dynamic;
054    }
055
056    public TypeFamily getTypeFamily() {
057        return TypeFamily.FRAGMENT;
058    }
059
060    public String getTypeName() {
061        return name;
062    }
063
064    public String getClassName() {
065        return className;
066    }
067
068    public String getModelName() {
069        return modelName;
070    }
071
072    public ModelType getModelType() {
073        return (ModelType) Manager.getTypeRegistry().lookup(TypeFamily.MODEL, modelName);
074    }
075
076    public boolean isDynamic() {
077        return dynamic;
078    }
079
080}