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.form;
017
018import java.util.Map;
019
020/**
021 * This field is used for reference metadata
022 */
023public class ReferenceField extends AbstractField
024{
025    private String _value;
026    private String _type;
027
028    /**
029     * Creates a {@link ReferenceField}
030     * @param refValues The reference values
031     */
032    public ReferenceField (Map<String, Object> refValues)
033    {
034        _value = (String) refValues.get("value");
035        if (refValues.containsKey("type"))
036        {
037            _type = (String) refValues.get("type");
038        }
039        else
040        {
041            _type = "__external";
042        }
043    }
044    
045    /**
046     * Get the value
047     * @return the value
048     */
049    public String getValue()
050    {
051        return _value;
052    }
053    
054    /**
055     * Returns the type of reference
056     * @return the type
057     */
058    public String getType()
059    {
060        return _type;
061    }
062}