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 import java.util.ArrayList; 23 import java.util.Collection; 24 import org.codehaus.jackson.map.annotate.JsonSerialize; 25 26 /** 27 * Information which describes logical set of fields. 28 */ 29 @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) 30 public class Form { 31 32 /** 33 * The name of this form. The form name must identify the form uniquely 34 * from other forms. 35 */ 36 private String name; 37 38 /** 39 * All fields associated with this form. 40 */ 41 private Collection<Field> fields; 42 43 /** 44 * Creates a new Form object with no associated fields. The name is left 45 * unset as null. If no form name is provided, this form must not be used 46 * in the same context as another unnamed form. 47 */ Form()48 public Form() { 49 fields = new ArrayList<Field>(); 50 } 51 52 /** 53 * Creates a new Form object having the given name and containing the given 54 * fields. 55 * 56 * @param name 57 * A name which uniquely identifies this form. 58 * 59 * @param fields 60 * The fields to provided within the new Form. 61 */ Form(String name, Collection<Field> fields)62 public Form(String name, Collection<Field> fields) { 63 this.name = name; 64 this.fields = fields; 65 } 66 67 /** 68 * Returns a mutable collection of the fields associated with this form. 69 * Changes to this collection affect the fields exposed to the user. 70 * 71 * @return 72 * A mutable collection of fields. 73 */ getFields()74 public Collection<Field> getFields() { 75 return fields; 76 } 77 78 /** 79 * Sets the collection of fields associated with this form. 80 * 81 * @param fields 82 * The collection of fields to associate with this form. 83 */ setFields(Collection<Field> fields)84 public void setFields(Collection<Field> fields) { 85 this.fields = fields; 86 } 87 88 /** 89 * Returns the name of this form. Form names must uniquely identify each 90 * form. 91 * 92 * @return 93 * The name of this form, or null if the form has no name. 94 */ getName()95 public String getName() { 96 return name; 97 } 98 99 /** 100 * Sets the name of this form. Form names must uniquely identify each form. 101 * 102 * @param name 103 * The name to assign to this form. 104 */ setName(String name)105 public void setName(String name) { 106 this.name = name; 107 } 108 109 } 110