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.rendering;
016
017import java.util.HashMap;
018import java.util.Map;
019
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022
023@XObject("standalone-filter")
024public final class StandaloneFilterType extends FilterType {
025
026    @XNode("@name")
027    public String name;
028
029    @XNode("engine")
030    public String engine = "*";
031
032    @XNode("@template-engine")
033    public String templateEngine = "*";
034
035    @XNode("mode")
036    public String mode = "*";
037
038    @XNode("class")
039    public String className;
040
041    private final Map<String, Filter> filters = new HashMap<String, Filter>();
042
043    @Override
044    public Filter getFilter() {
045        String typeName = getTypeName();
046        if (filters.containsKey(typeName)) {
047            return filters.get(typeName);
048        }
049        Filter filter = StandaloneFilterFactory.create(typeName);
050        filters.put(typeName, filter);
051        return filter;
052    }
053
054    @Override
055    public FilterTypeFamily getFilterTypeFamily() {
056        return FilterTypeFamily.STANDALONE;
057    }
058
059    @Override
060    public String getTypeName() {
061        return String.format("%s/%s/%s/%s", engine, templateEngine, mode, name);
062    }
063
064    @Override
065    public String getClassName() {
066        return className;
067    }
068
069}