KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > deploy > DeploymentProgressImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.appserv.management.deploy;
24
25 import java.util.Locale JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.io.Serializable JavaDoc;
28
29
30 import com.sun.appserv.management.deploy.DeploymentProgress;
31 import com.sun.appserv.management.base.MapCapableBase;
32
33 /**
34     Use DeploymentSupport to create a new instance of this class.
35  */

36 public final class DeploymentProgressImpl
37     extends MapCapableBase
38     implements DeploymentProgress
39 {
40     /**
41         Create a new instance based on another.
42      */

43         public
44     DeploymentProgressImpl( final DeploymentProgress src )
45     {
46         this( src.asMap() );
47     }
48     
49         protected boolean
50     validate()
51     {
52         final byte progressPercent = getProgressPercent();
53         return( progressPercent >= 0 && progressPercent <= 100 );
54     }
55     
56     /**
57         Create a new instance with explicit params
58         
59         @param progressPercent
60         @param description
61         @param other other values, see this( Map m )
62      */

63         public <T extends Serializable JavaDoc>
64     DeploymentProgressImpl(
65         final byte progressPercent,
66         final String JavaDoc description,
67         final Map JavaDoc<String JavaDoc,T> other )
68     {
69         this( other, false );
70         
71         putField( PROGRESS_PERCENT_KEY, new Byte JavaDoc( (byte)progressPercent ) );
72         putField( DESCRIPTION_KEY, description );
73         
74         validateThrow();
75     }
76     
77     /**
78         @param m a Map representing a DeploymentProgress
79         @param validate true if should validate
80      */

81         private <T extends Serializable JavaDoc>
82     DeploymentProgressImpl( final Map JavaDoc<String JavaDoc,T> m, final boolean validate )
83     {
84         super( m, DEPLOYMENT_PROGRESS_CLASS_NAME);
85
86         if ( validate )
87         {
88             validateThrow();
89         }
90     }
91     
92     /**
93         @param data a Map representing a DeploymentProgress
94      */

95     /**
96         Create a new instance. The Map must contain the following
97         keyed values:
98         
99         <ul>
100         <li>{@link com.sun.appserv.management.base.MapCapable}.MAP_CAPABLE_TYPE_KEY with
101             value DEPLOYMENT_PROGRESS_CLASS_NAME</li>
102         <li>PROGRESS_PERCENT_KEY</li>
103         <li>DESCRIPTION_KEY</li>
104         </ul>
105         <p>
106         The map may contain also contain localized descriptions.
107         See {@link DeploymentProgress}.LOCALIZED_DESCRIPTION_KEY_BASE.
108         
109         @param m a Map representing a DeploymentProgress
110      */

111         public <T extends Serializable JavaDoc>
112     DeploymentProgressImpl( final Map JavaDoc<String JavaDoc,T> m )
113     {
114         super( m, DEPLOYMENT_PROGRESS_CLASS_NAME );
115         checkValidType( m, DEPLOYMENT_PROGRESS_CLASS_NAME );
116         
117         validateThrow();
118     }
119     
120         public String JavaDoc
121     getMapClassName()
122     {
123         return( DEPLOYMENT_PROGRESS_CLASS_NAME );
124     }
125     
126         public static String JavaDoc
127     getLocalizedDescriptionKey( final Locale JavaDoc locale )
128     {
129         return( LOCALIZED_DESCRIPTION_KEY_BASE + "_" + locale.toString() );
130     }
131     
132         public byte
133     getProgressPercent()
134     {
135         return( getByte( PROGRESS_PERCENT_KEY ).byteValue() );
136     }
137     
138         public String JavaDoc
139     getDescription()
140     {
141         return( getString( DESCRIPTION_KEY ) );
142     }
143     
144         public String JavaDoc
145     getLocalizedDescription( final Locale JavaDoc locale)
146     {
147         return( getString( getLocalizedDescriptionKey( locale ) ) );
148     }
149 }
150
151
152
153
Popular Tags