KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > extensions > ApplicationParameterDefinition


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.extensions;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.jdom.Element;
25 import org.jdom.JDOMException;
26
27 import com.sslexplorer.boot.PropertyClassManager;
28 import com.sslexplorer.boot.PropertyDefinition;
29 import com.sslexplorer.boot.XMLPropertyDefinition;
30
31 /**
32  * Implementation of {@link com.sslexplorer.boot.XMLPropertyDefinition}
33  * to be used for <i>Application Shortcut Parameters</i>.
34  * <p>
35  * These parameters are constructed from the the entries in an
36  * <i>Application Descriptor</i> that is embedded in the
37  * <i>Extension Descriptor</i>.
38  * <p>
39  * As the interface used implies, shortcut parameters support <i>Confidentials Properties</i>,
40  * in the case known as <i>Confidential Application Shortcut Parameters</i>.
41  *
42  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
43  */

44 public class ApplicationParameterDefinition extends XMLPropertyDefinition {
45     
46     final static Log log = LogFactory.getLog(ApplicationParameterDefinition.class);
47     
48     // Protected instance variables
49
protected boolean optional;
50
51     /**
52      * Constructor
53      *
54      * @param element XML element to construct parameter from
55      * @throws JDOMException on invalid XML
56      */

57     public ApplicationParameterDefinition(Element element) throws JDOMException {
58         super(element);
59         
60         // DEPRECATED attributes
61
if(element.getAttribute("sequence") != null) {
62             try {
63                 log.warn("DEPRECATED. Application parameter definition element now user 'sortOrder' instead of 'sequence'.");
64                 sortOrder = Integer.parseInt(element.getAttributeValue("sequence"));
65             } catch (Exception JavaDoc e) {
66                 sortOrder = 0;
67             }
68         }
69         if(element.getAttribute("default") != null) {
70             log.warn("DEPRECATED. Application parameter definition element now user 'defaultValue' instead of 'default'.");
71             defaultValue = element.getAttributeValue("default");
72             defaultValue = defaultValue == null ? PropertyDefinition.UNDEFINED_PARAMETER : defaultValue;
73         }
74         
75         // Additional attributes
76
optional = "true".equalsIgnoreCase(element.getAttributeValue("optional"));
77         
78         //
79
init(PropertyClassManager.getInstance().getPropertyClass(ApplicationParameters.NAME));
80     }
81
82     /**
83      * Get if this is an optional parameter.
84      *
85      * @return optional
86      */

87     public boolean isOptional() {
88         return optional;
89     }
90
91 }
Popular Tags