001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Jean-Marc Orliaguet, Chalmers
011 *
012 * $Id$
013 */
014
015package org.nuxeo.theme.formats;
016
017import org.nuxeo.common.xmap.annotation.XNode;
018import org.nuxeo.common.xmap.annotation.XObject;
019import org.nuxeo.theme.relations.DefaultPredicate;
020import org.nuxeo.theme.relations.Predicate;
021import org.nuxeo.theme.types.Type;
022import org.nuxeo.theme.types.TypeFamily;
023
024@XObject("format")
025public final class FormatType implements Type {
026
027    @XNode("@name")
028    public String name;
029
030    @XNode("class")
031    public String className;
032
033    @XNode("predicate")
034    public String predicateName;
035
036    private Predicate predicate;
037
038    public FormatType() {
039    }
040
041    public FormatType(String name, String predicateName, String className) {
042        this.name = name;
043        this.predicateName = predicateName;
044        this.className = className;
045    }
046
047    public TypeFamily getTypeFamily() {
048        return TypeFamily.FORMAT;
049    }
050
051    public String getTypeName() {
052        return name;
053    }
054
055    public String getFormatClass() {
056        return className;
057    }
058
059    public Predicate getPredicate() {
060        if (predicate == null) {
061            predicate = new DefaultPredicate(predicateName);
062        }
063        return predicate;
064    }
065
066}