/******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.ui.keys; import org.eclipse.jface.bindings.keys.IKeyLookup; import org.eclipse.jface.bindings.keys.KeyLookupFactory; import org.eclipse.ui.internal.util.Util; /** *

* Key is the abstract base class for all objects representing * keys on the keyboard. *

*

* All Key objects have a formal string representation, called * the 'name' of the key, available via the toString() method. *

*

* All Key objects, via the format() method, * provide a version of their formal string representation translated by * platform and locale, suitable for display to a user. *

*

* Key objects are immutable. Clients are not permitted to extend * this class. *

* * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and * org.eclipse.jface.bindings.keys.KeyLookupFactory * @since 3.0 * @noextend This class is not intended to be subclassed by clients. */ @Deprecated public abstract class Key implements Comparable { /** * The key from which this key was constructed. This value is defined by * KeyLookupFactory.getDefault(). */ protected final int key; /** * Constructs an instance of Key given its formal string * representation. * * @param key * the integer representation of this key, as defined by * KeyLookupFactory.getDefault(). */ Key(final int key) { this.key = key; } /** * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override public final int compareTo(final Object object) { return Util.compare(key, ((Key) object).key); } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public final boolean equals(final Object object) { if (!(object instanceof Key)) { return false; } return key == ((Key) object).key; } /** * @see java.lang.Object#hashCode() */ @Override public final int hashCode() { return Util.hashCode(key); } /** * Returns the formal string representation for this key. * * @return The formal string representation for this key. Guaranteed not to * be null. * @see java.lang.Object#toString() */ @Override public final String toString() { final IKeyLookup lookup = KeyLookupFactory.getDefault(); return lookup.formalNameLookup(key); } }