comparison org.eclipse.core.commands/src/org/eclipse/core/commands/common/NamedHandleObject.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2004, 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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.core.commands.common.NamedHandleObject;
14
15 import org.eclipse.core.commands.common.HandleObject;
16 import org.eclipse.core.commands.common.NotDefinedException;
17 import java.lang.all;
18
19 /**
20 * A handle object that carries with it a name and a description. This type of
21 * handle object is quite common across the commands code base. For example,
22 * <code>Command</code>, <code>Context</code> and <code>Scheme</code>.
23 *
24 * @since 3.1
25 */
26 public abstract class NamedHandleObject : HandleObject {
27
28 /**
29 * The description for this handle. This value may be <code>null</code> if
30 * the handle is undefined or has no description.
31 */
32 protected String description = null;
33
34 /**
35 * The name of this handle. This valud should not be <code>null</code>
36 * unless the handle is undefined.
37 */
38 protected String name = null;
39
40 /**
41 * Constructs a new instance of <code>NamedHandleObject</code>.
42 *
43 * @param id
44 * The identifier for this handle; must not be <code>null</code>.
45 */
46 protected this(String id) {
47 super(id);
48 }
49
50 /**
51 * Returns the description for this handle.
52 *
53 * @return The description; may be <code>null</code> if there is no
54 * description.
55 * @throws NotDefinedException
56 * If the handle is not currently defined.
57 */
58 public String getDescription() {
59 if (!isDefined()) {
60 throw new NotDefinedException(
61 "Cannot get a description from an undefined object. " //$NON-NLS-1$
62 ~ id);
63 }
64
65 return description;
66 }
67
68 /**
69 * Returns the name for this handle.
70 *
71 * @return The name for this handle; never <code>null</code>.
72 * @throws NotDefinedException
73 * If the handle is not currently defined.
74 */
75 public String getName() {
76 if (!isDefined()) {
77 throw new NotDefinedException(
78 "Cannot get the name from an undefined object. " //$NON-NLS-1$
79 ~ id);
80 }
81
82 return name;
83 }
84 }