KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > macro > MacroParameters


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroParameters.java,v 1.8 2004/07/28 09:35:25 ib Exp $
3  * $Revision: 1.8 $
4  * $Date: 2004/07/28 09:35:25 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.macro;
25
26 /**
27  * Macro parameters.
28  *
29  */

30 import java.util.HashMap JavaDoc;
31 import java.util.Map JavaDoc;
32
33 public class MacroParameters {
34     
35     private static final String JavaDoc RECURSIVE = "recursive";
36     private static final String JavaDoc OVERWRITE = "overwrite";
37     private static final String JavaDoc DELETE_CREATE = "deleteCreate";
38     
39     private Map JavaDoc parameters = new HashMap JavaDoc();
40     
41     /**
42      * Constructor.
43      */

44     public MacroParameters() {
45         this(true, false);
46     }
47     
48     /**
49      * Constructor.
50      *
51      * @param recursive True if the macro is recursive
52      * @param overwrite True if we should try to overwrite stuff
53      */

54     public MacroParameters(boolean recursive, boolean overwrite) {
55         this(recursive, overwrite, overwrite);
56     }
57     
58     /**
59      * Constructor.
60      *
61      * @param recursive True if the macro is recursive
62      * @param overwrite True if we should try to overwrite stuff
63      * @param deleteCreate if true, and if overwrite=true, resource at destination is
64      * deleted first and a new resource is created at detination
65      *
66      */

67     public MacroParameters(boolean recursive, boolean overwrite, boolean deleteCreate) {
68         setBooleanParameter( RECURSIVE, recursive );
69         setBooleanParameter( OVERWRITE, overwrite );
70         setBooleanParameter( DELETE_CREATE, (overwrite && deleteCreate) );
71     }
72     
73     /**
74      * Recursive accessor.
75      *
76      * @return boolean True if the macro is recursive
77      */

78     public boolean isRecursive() {
79         return getBooleanParameter( RECURSIVE );
80     }
81     
82     /**
83      * Overwrite accessor.
84      *
85      * @return boolean True if the macro will overwrite any items on the
86      * destination (may not apply to all macros)
87      */

88     public boolean isOverwrite() {
89         return getBooleanParameter( OVERWRITE );
90     }
91     
92     /**
93      * DeleteCreate accessor
94      *
95      * @return True if the macro will overwrite any items on the
96      * destination by 1st deleting resources and then creating new
97      * resources at detination
98      */

99     public boolean isDeleteCreate() {
100         return getBooleanParameter( DELETE_CREATE );
101     }
102     
103     public void setParameter( String JavaDoc name, Object JavaDoc value ) {
104         parameters.put( name, value );
105     }
106     
107     public void setBooleanParameter( String JavaDoc name, boolean value ) {
108         parameters.put( name, new Boolean JavaDoc(value) );
109     }
110     
111     public Object JavaDoc getParameter( String JavaDoc name ) {
112         return parameters.get( name );
113     }
114     
115     public boolean getBooleanParameter( String JavaDoc name ) {
116         return ((Boolean JavaDoc)parameters.get(name)).booleanValue();
117     }
118 }
119
Popular Tags