001    package ezvcard.parameters;
002    
003    /**
004     * Copyright 2011 George El-Haddad. All rights reserved.
005     * 
006     * Redistribution and use in source and binary forms, with or without modification, are
007     * permitted provided that the following conditions are met:
008     * 
009     *    1. Redistributions of source code must retain the above copyright notice, this list of
010     *       conditions and the following disclaimer.
011     * 
012     *    2. Redistributions in binary form must reproduce the above copyright notice, this list
013     *       of conditions and the following disclaimer in the documentation and/or other materials
014     *       provided with the distribution.
015     * 
016     * THIS SOFTWARE IS PROVIDED BY GEORGE EL-HADDAD ''AS IS'' AND ANY EXPRESS OR IMPLIED
017     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
018     * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEORGE EL-HADDAD OR
019     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
020     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
021     * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
022     * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
023     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
024     * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
025     * 
026     * The views and conclusions contained in the software and documentation are those of the
027     * authors and should not be interpreted as representing official policies, either expressed
028     * or implied, of George El-Haddad.
029     */
030    
031    /*
032     Copyright (c) 2012, Michael Angstadt
033     All rights reserved.
034    
035     Redistribution and use in source and binary forms, with or without
036     modification, are permitted provided that the following conditions are met: 
037    
038     1. Redistributions of source code must retain the above copyright notice, this
039     list of conditions and the following disclaimer. 
040     2. Redistributions in binary form must reproduce the above copyright notice,
041     this list of conditions and the following disclaimer in the documentation
042     and/or other materials provided with the distribution. 
043    
044     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
045     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
046     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
047     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
048     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
049     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
050     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
051     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
052     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
053     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
054    
055     The views and conclusions contained in the software and documentation are those
056     of the authors and should not be interpreted as representing official policies, 
057     either expressed or implied, of the FreeBSD Project.
058     */
059    
060    /**
061     * Represents the TYPE parameter of the KEY type.
062     * <p>
063     * vCard versions: 2.1, 3.0, 4.0
064     * </p>
065     * @author George El-Haddad Mar 10, 2010
066     * @author Michael Angstadt Jul 06, 2012
067     */
068    public class KeyTypeParameter extends MediaTypeParameter {
069            public static final KeyTypeParameter PGP = new KeyTypeParameter("PGP", "application/pgp-keys", "pgp");
070            public static final KeyTypeParameter GPG = new KeyTypeParameter("GPG", "application/gpg", "gpg");
071            public static final KeyTypeParameter X509 = new KeyTypeParameter("X509", "application/x509", null);
072    
073            /**
074             * Use of this constructor is discouraged and should only be used for
075             * defining non-standard TYPEs. Please use one of the predefined static
076             * objects.
077             * @param value the type value (e.g. "pgp")
078             * @param mediaType the media type (e.g. "application/pgp-keys")
079             * @param extension the file extension used for this type (e.g. "pgp")
080             */
081            public KeyTypeParameter(String value, String mediaType, String extension) {
082                    super(value, mediaType, extension);
083            }
084    
085            /**
086             * Searches the static objects in this class for one that has a certain type
087             * value.
088             * @param value the type value to search for (e.g. "pgp")
089             * @return the object or null if not found
090             */
091            public static KeyTypeParameter valueOf(String value) {
092                    return findByValue(value, KeyTypeParameter.class);
093            }
094    
095            /**
096             * Searches the static objects in this class for one that has a certain
097             * media type.
098             * @param mediaType the media type to search for (e.g. "application/pgp-keys")
099             * @return the object or null if not found
100             */
101            public static KeyTypeParameter findByMediaType(String mediaType) {
102                    return findByMediaType(mediaType, KeyTypeParameter.class);
103            }
104    }