All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jfxtras.icalendarfx.properties.component.time.TimeTransparency Maven / Gradle / Ivy

The newest version!
package jfxtras.icalendarfx.properties.component.time;

import java.util.HashMap;
import java.util.Map;

import jfxtras.icalendarfx.components.VEvent;
import jfxtras.icalendarfx.properties.VPropertyBase;
import jfxtras.icalendarfx.properties.component.time.TimeTransparency;
import jfxtras.icalendarfx.properties.component.time.TimeTransparency.TimeTransparencyType;
import jfxtras.icalendarfx.utilities.StringConverter;

/**
 * TRANSP
 * Time Transparency
 * RFC 5545 iCalendar 3.8.2.7. page 101
 * 
 * This property defines whether or not an event is transparent to busy time searches.
 * Events that consume actual time SHOULD be recorded as OPAQUE.  Other
 * events, which do not take up time SHOULD be recorded as TRANSPARENT.
 *    
 * Example:
 * TRANSP:TRANSPARENT
 *
 * @author David Bal
 * 
 * The property can be specified in following components:
 * @see VEvent
 */
public class TimeTransparency extends VPropertyBase
{
    private final static StringConverter CONVERTER = new StringConverter()
    {
        @Override
        public String toString(TimeTransparencyType object)
        {
            return object.toString();
        }

        @Override
        public TimeTransparencyType fromString(String string)
        {
            return TimeTransparencyType.enumFromName(string);
        }
    };
    
    public TimeTransparency(TimeTransparencyType value)
    {
        super();
        setConverter(CONVERTER);
        setValue(value);
    }
    
    public TimeTransparency(TimeTransparency source)
    {
        super(source);
    }
    
    public TimeTransparency()
    {
        super();
        setConverter(CONVERTER);
        setValue(TimeTransparencyType.OPAQUE); // default value
    }
    
    public static TimeTransparency parse(String content)
    {
    	return TimeTransparency.parse(new TimeTransparency(), content);
    }
    
    public enum TimeTransparencyType
    {
        OPAQUE,
        TRANSPARENT;
//        UNKNOWN;
        
        private static Map enumFromNameMap = makeEnumFromNameMap();
        private static Map makeEnumFromNameMap()
        {
            Map map = new HashMap<>();
            TimeTransparencyType[] values = TimeTransparencyType.values();
            for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy