001/* 002 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.types; 021 022import java.io.Serializable; 023import java.util.ArrayList; 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/** 031 * Type view to display a given document sub-type. 032 * 033 * @author <a href="mailto:cbaican@nuxeo.com">Catalin Baican</a> 034 */ 035@XObject("type") 036public class SubType implements Serializable { 037 038 private static final long serialVersionUID = 1L; 039 040 @XNode 041 protected String name; 042 043 protected List<String> hidden; 044 045 public List<String> getHidden() { 046 if (hidden == null) { 047 hidden = new ArrayList<String>(); 048 } 049 return hidden; 050 } 051 052 @XNode("@hidden") 053 public void setHidden(String value) { 054 String[] hiddenCases = value.split("(\\s+)(?=[^,])|(\\s*,\\s*)"); 055 hidden = new ArrayList<String>(Arrays.asList(hiddenCases)); 056 } 057 058 public String getName() { 059 return name; 060 } 061 062 public void setName(String name) { 063 this.name = name; 064 } 065 066 /** 067 * Clone method to handle hot reload 068 * 069 * @since 5.6 070 */ 071 @Override 072 protected SubType clone() { 073 SubType clone = new SubType(); 074 clone.setName(getName()); 075 List<String> hidden = getHidden(); 076 if (hidden != null) { 077 List<String> chidden = new ArrayList<String>(); 078 chidden.addAll(hidden); 079 clone.hidden = chidden; 080 } 081 return clone; 082 } 083}