001/*
002 *  Copyright 2017 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.odf.enumeration;
017
018import java.util.Locale;
019
020import org.ametys.cms.repository.Content;
021
022/**
023 * This class represents a entry of ODF reference table
024 *
025 */
026public class OdfReferenceTableEntry
027{
028    /** Metadata name for code */
029    public static final String METADATA_CODE = "code";
030    /** Metadata name for CDM value */
031    public static final String METADATA_CDM_VALUE = "cdmValue";
032    
033    private Content _entry;
034    
035    /**
036     * Constructor
037     * @param content The content representing the entry
038     */
039    public OdfReferenceTableEntry (Content content)
040    {
041        _entry = content;
042    }
043    
044    /**
045     * Get the identifier
046     * @return The identifier
047     */
048    public String getId()
049    {
050        return _entry.getId();
051    }
052    
053    /**
054     * Get the label
055     * @param lang The language
056     * @return The label
057     */
058    public String getLabel(String lang)
059    {
060        return _entry.getTitle(new Locale(lang));
061    }
062    
063    /**
064     * Get the code
065     * @return the code
066     */
067    public String getCode()
068    {
069        return _entry.getMetadataHolder().getString(METADATA_CODE, "");
070    }
071    
072    /** 
073     * Get the CDM value
074     * @return the CDM value
075     */
076    public String getCdmValue()
077    {
078        return _entry.getMetadataHolder().getString(METADATA_CDM_VALUE, "");
079    }
080}