KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > commands > CmdGetLiveVersion


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.commands;
20
21 import org.openharmonise.rm.resources.lifecycle.*;
22
23
24 /**
25  * Gets the live version of the 'command object', if it is
26  * an an instance of <code>Editable</code>.
27  *
28  * @author Michael Bell
29  * @version $Revision: 1.3 $
30  *
31  */

32 public class CmdGetLiveVersion extends AbstractCmd {
33     
34     /**
35      * Creates an instance of the command
36      *
37      */

38     public CmdGetLiveVersion() {
39         super();
40     }
41
42     /* (non-Javadoc)
43      * @see org.openharmonise.rm.commands.AbstractCmd#execute()
44      */

45     public Object JavaDoc execute(Context context) throws CommandException {
46         if((m_commandObj instanceof Editable) == false) {
47             throw new InvalidCommandException("Command is not valid for this object:" + m_commandObj.getClass());
48         }
49
50         if (isAvailable(context) == false) {
51           throw new InvalidCommandException("Command is not available for this object");
52         }
53     
54         Editable eObj = (Editable)getCommandObject(context);
55         Editable rtnObj = null;
56         
57         try {
58             rtnObj = eObj.getLiveVersion();
59         } catch(Exception JavaDoc e) {
60             throw new CommandExecutionException(e.getMessage());
61         }
62         
63         return rtnObj;
64     }
65
66     /* (non-Javadoc)
67      * @see org.openharmonise.rm.commands.AbstractCmd#getName()
68      */

69     public String JavaDoc getName() {
70         return "GetLiveVersion";
71     }
72     
73     /* (non-Javadoc)
74      * @see org.openharmonise.rm.commands.AbstractCmd#isValidCommandObject(java.lang.Object)
75      */

76     public boolean isValidCommandObject(Object JavaDoc obj) {
77         return (obj instanceof Editable);
78     }
79 }
Popular Tags