001/* 002 * (C) Copyright 2006-2009 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 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.types; 023 024import java.io.Serializable; 025import java.util.ArrayList; 026import java.util.Arrays; 027import java.util.List; 028 029import org.nuxeo.common.xmap.annotation.XNode; 030import org.nuxeo.common.xmap.annotation.XObject; 031 032/** 033 * Type view to display a given document sub-type. 034 * 035 * @author <a href="mailto:cbaican@nuxeo.com">Catalin Baican</a> 036 */ 037@XObject("type") 038public class SubType implements Serializable { 039 040 private static final long serialVersionUID = 1L; 041 042 @XNode 043 protected String name; 044 045 protected List<String> hidden; 046 047 public List<String> getHidden() { 048 if (hidden == null) { 049 hidden = new ArrayList<String>(); 050 } 051 return hidden; 052 } 053 054 @XNode("@hidden") 055 public void setHidden(String value) { 056 String[] hiddenCases = value.split("(\\s+)(?=[^,])|(\\s*,\\s*)"); 057 hidden = new ArrayList<String>(Arrays.asList(hiddenCases)); 058 } 059 060 public String getName() { 061 return name; 062 } 063 064 public void setName(String name) { 065 this.name = name; 066 } 067 068 /** 069 * Clone method to handle hot reload 070 * 071 * @since 5.6 072 */ 073 @Override 074 protected SubType clone() { 075 SubType clone = new SubType(); 076 clone.setName(getName()); 077 List<String> hidden = getHidden(); 078 if (hidden != null) { 079 List<String> chidden = new ArrayList<String>(); 080 chidden.addAll(hidden); 081 clone.hidden = chidden; 082 } 083 return clone; 084 } 085}