1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *   http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 package org.apache.guacamole.form;
21 
22 /**
23  * Represents a time zone field. The field may contain only valid time zone
24  * identifiers, as defined by the IANA time zone database. Such identifiers are
25  * also valid Java time zone IDs as dictated by TimeZone.getAvailableIDs().
26  */
27 public class TimeZoneField extends Field {
28 
29     /**
30      * Creates a new TimeZoneField with the given name.
31      *
32      * @param name
33      *     The unique name to associate with this field.
34      */
TimeZoneField(String name)35     public TimeZoneField(String name) {
36         super(name, Field.Type.TIMEZONE);
37     }
38 
39     /**
40      * Parses the given string into a time zone ID string. As these strings are
41      * equivalent, the only transformation currently performed by this function
42      * is to ensure that a blank time zone string is parsed into null.
43      *
44      * @param timeZone
45      *     The time zone string to parse, which may be null.
46      *
47      * @return
48      *     The ID of the time zone corresponding to the given string, or null
49      *     if the given time zone string was null or blank.
50      */
parse(String timeZone)51     public static String parse(String timeZone) {
52 
53         // Return null if no time zone provided
54         if (timeZone == null || timeZone.isEmpty())
55             return null;
56 
57         // Otherwise, assume time zone is valid
58         return timeZone;
59 
60     }
61 
62 }
63