001/* 002 * Copyright 2010 Anyware Services 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 */ 016package org.ametys.cms.contenttype; 017 018/** 019 * A reference to a metadata definition. 020 */ 021public class MetadataDefinitionReference extends AbstractMetadataSetElement 022{ 023 private String _metadataName; 024 025 private String _metadataSetName; 026 027 /** 028 * Constructor. 029 * @param metadataName the metadata name. 030 */ 031 public MetadataDefinitionReference(String metadataName) 032 { 033 this(metadataName, null); 034 } 035 036 /** 037 * Constructor. 038 * @param metadataName the metadata name. 039 * @param metadataSetName for content metadatas, the metadata-set name. 040 */ 041 public MetadataDefinitionReference(String metadataName, String metadataSetName) 042 { 043 _metadataName = metadataName; 044 _metadataSetName = metadataSetName; 045 } 046 047 /** 048 * Retrieves the metadata name. 049 * @return the metadata name. 050 */ 051 public String getMetadataName() 052 { 053 return _metadataName; 054 } 055 056 /** 057 * Set the metadata name. 058 * @param metadataName the metadata name. 059 */ 060 public void setMetadataName(String metadataName) 061 { 062 _metadataName = metadataName; 063 } 064 065 /** 066 * Retrieves the metadata-set name. 067 * @return the metadata-set name. 068 */ 069 public String getMetadataSetName() 070 { 071 return _metadataSetName; 072 } 073 074 /** 075 * Set the metadata-set name. 076 * @param metadataSetName the metadata-set name. 077 */ 078 public void setMetadataSetName(String metadataSetName) 079 { 080 _metadataSetName = metadataSetName; 081 } 082 083 @Override 084 public String toString() 085 { 086 StringBuilder metadataSet = new StringBuilder(); 087 088 metadataSet.append(_metadataName); 089 if (_metadataSetName != null) 090 { 091 metadataSet.append(" (").append(_metadataSetName).append(')'); 092 } 093 metadataSet.append(" ["); 094 metadataSet.append(getElements().size()); 095 metadataSet.append("]"); 096 097 return metadataSet.toString(); 098 } 099}