KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > antsupport > InputHandlerSetter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.antsupport;
12
13
14 import java.text.MessageFormat JavaDoc; // can't use ICU, used by ant
15

16 import org.apache.tools.ant.BuildException;
17 import org.apache.tools.ant.Project;
18 import org.apache.tools.ant.input.DefaultInputHandler;
19 import org.apache.tools.ant.input.InputHandler;
20
21 /**
22  * This class exists so that the Ant integration has backwards compatibility
23  * with Ant releases previous to 1.5. InputHandlers are a new feature of Ant 1.5.
24  */

25 class InputHandlerSetter {
26
27     protected void setInputHandler(Project project, String JavaDoc inputHandlerClassname) {
28         InputHandler handler = null;
29         if (inputHandlerClassname == null) {
30             handler = new DefaultInputHandler();
31         } else {
32             try {
33                 handler = (InputHandler)(Class.forName(inputHandlerClassname).newInstance());
34             } catch (ClassCastException JavaDoc e) {
35                 String JavaDoc msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new String JavaDoc[]{inputHandlerClassname}); //$NON-NLS-1$
36
throw new BuildException(msg, e);
37             } catch (Exception JavaDoc e) {
38                 String JavaDoc msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new String JavaDoc[]{inputHandlerClassname, e.getClass().getName()}); //$NON-NLS-1$
39
throw new BuildException(msg, e);
40             }
41         }
42         project.setInputHandler(handler);
43     }
44 }
45
Popular Tags