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.themes; 023 024import java.util.Arrays; 025import java.util.List; 026 027import org.nuxeo.common.xmap.annotation.XNode; 028import org.nuxeo.common.xmap.annotation.XObject; 029 030@XObject("theme") 031public class ThemeSetEntry { 032 033 @XNode("@name") 034 public String name; 035 036 @XNode("@features") 037 public String features = ""; 038 039 public ThemeSetEntry() { 040 } 041 042 public ThemeSetEntry(String name) { 043 this.name = name; 044 } 045 046 public String getName() { 047 return name; 048 } 049 050 public List<String> getFeatures() { 051 return Arrays.asList(features.split(",")); 052 } 053 054 public void addFeature(String feature) { 055 if (!getFeatures().contains(feature)) { 056 features += features.concat(",").concat(feature); 057 } 058 } 059 060 public void removeFeature(String feature) { 061 List<String> featuresList = getFeatures(); 062 features = ""; 063 for (String f : featuresList) { 064 if (!f.equals(feature)) { 065 addFeature(f); 066 } 067 } 068 } 069 070}