⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyfactoryregistry.java

📁 JAVA编写的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/** * Copyright (c) 2009, Ben Fortuna * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * *  o Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * *  o Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * *  o Neither the name of Ben Fortuna nor the names of any other contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package net.fortuna.ical4j.vcard;import java.net.URISyntaxException;import java.text.ParseException;import java.util.HashMap;import java.util.Map;import net.fortuna.ical4j.vcard.Property.Id;import net.fortuna.ical4j.vcard.property.Address;import net.fortuna.ical4j.vcard.property.Agent;import net.fortuna.ical4j.vcard.property.BDay;import net.fortuna.ical4j.vcard.property.Birth;import net.fortuna.ical4j.vcard.property.CalAdrUri;import net.fortuna.ical4j.vcard.property.CalUri;import net.fortuna.ical4j.vcard.property.Categories;import net.fortuna.ical4j.vcard.property.Clazz;import net.fortuna.ical4j.vcard.property.DDay;import net.fortuna.ical4j.vcard.property.Death;import net.fortuna.ical4j.vcard.property.Email;import net.fortuna.ical4j.vcard.property.FbUrl;import net.fortuna.ical4j.vcard.property.Fn;import net.fortuna.ical4j.vcard.property.Gender;import net.fortuna.ical4j.vcard.property.Geo;import net.fortuna.ical4j.vcard.property.Impp;import net.fortuna.ical4j.vcard.property.Key;import net.fortuna.ical4j.vcard.property.Kind;import net.fortuna.ical4j.vcard.property.Label;import net.fortuna.ical4j.vcard.property.Language;import net.fortuna.ical4j.vcard.property.Logo;import net.fortuna.ical4j.vcard.property.Member;import net.fortuna.ical4j.vcard.property.N;import net.fortuna.ical4j.vcard.property.Name;import net.fortuna.ical4j.vcard.property.Nickname;import net.fortuna.ical4j.vcard.property.Note;import net.fortuna.ical4j.vcard.property.Org;import net.fortuna.ical4j.vcard.property.Photo;import net.fortuna.ical4j.vcard.property.ProdId;import net.fortuna.ical4j.vcard.property.Related;import net.fortuna.ical4j.vcard.property.Revision;import net.fortuna.ical4j.vcard.property.Role;import net.fortuna.ical4j.vcard.property.SortString;import net.fortuna.ical4j.vcard.property.Sound;import net.fortuna.ical4j.vcard.property.Source;import net.fortuna.ical4j.vcard.property.Telephone;import net.fortuna.ical4j.vcard.property.Title;import net.fortuna.ical4j.vcard.property.Tz;import net.fortuna.ical4j.vcard.property.Uid;import net.fortuna.ical4j.vcard.property.Url;import net.fortuna.ical4j.vcard.property.Version;/** * $Id: PropertyFactoryRegistry.java,v 1.4 2009/01/12 03:51:13 fortuna Exp $ * * Created on: 05/01/2009 * * @author Ben * */public class PropertyFactoryRegistry {    private Map<Id, PropertyFactory<? extends Property>> defaultFactories;        public PropertyFactoryRegistry() {        defaultFactories = new HashMap<Id, PropertyFactory<? extends Property>>();        defaultFactories.put(Property.Id.VERSION, new PropertyFactory<Version>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Version createProperty(final String value) {                if (Version.VERSION_4_0.getValue().equals(value)) {                    return Version.VERSION_4_0;                }                return new Version(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Version createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                // TODO Auto-generated method stub                return null;            }        });        defaultFactories.put(Property.Id.FN, new PropertyFactory<Fn>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Fn createProperty(final String value) {                return new Fn(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Fn createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                // TODO Auto-generated method stub                return null;            }        });        defaultFactories.put(Property.Id.N, new PropertyFactory<N>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public N createProperty(final String value) {                return new N(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public N createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                // TODO Auto-generated method stub                return null;            }        });        defaultFactories.put(Property.Id.BDAY, new PropertyFactory<BDay>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public BDay createProperty(final String value) {                return new BDay(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public BDay createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                // TODO Auto-generated method stub                return null;            }        });        defaultFactories.put(Property.Id.GENDER, new PropertyFactory<Gender>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Gender createProperty(final String value) {                if (Gender.FEMALE.getValue().equals(value)) {                    return Gender.FEMALE;                }                else if (Gender.MALE.getValue().equals(value)) {                    return Gender.MALE;                }                return new Gender(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Gender createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                // TODO Auto-generated method stub                return null;            }        });        defaultFactories.put(Property.Id.ORG, new PropertyFactory<Org>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Org createProperty(final String value) {                return new Org(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Org createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                return new Org(group, value);            }        });        defaultFactories.put(Property.Id.ADR, new PropertyFactory<Address>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Address createProperty(final String value) {                return new Address(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Address createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                return new Address(group, value);            }        });        defaultFactories.put(Property.Id.TEL, new PropertyFactory<Telephone>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Telephone createProperty(final String value) {                return new Telephone(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Telephone createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                return new Telephone(group, value);            }        });        defaultFactories.put(Property.Id.EMAIL, new PropertyFactory<Email>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Email createProperty(final String value) {                return new Email(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Email createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                return new Email(group, value);            }        });        defaultFactories.put(Property.Id.GEO, new PropertyFactory<Geo>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Geo createProperty(final String value) {                return new Geo(value);            }            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(net.fortuna.ical4j.vcard.Group, java.lang.String)             */            @Override            public Geo createProperty(final Group group, final String value)                    throws URISyntaxException, ParseException {                return new Geo(group, value);            }        });        defaultFactories.put(Property.Id.CLASS, new PropertyFactory<Clazz>() {            /* (non-Javadoc)             * @see net.fortuna.ical4j.vcard.PropertyFactory#createProperty(java.lang.String)             */            @Override            public Clazz createProperty(final String value) {                if (Clazz.CONFIDENTIAL.getValue().equals(value)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -