/*
 * Copyright 2012 Kulikov Dmitriy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package javax.microedition.lcdui;

public class Command {
	public static final int SCREEN = 1;
	public static final int BACK = 2;
	public static final int CANCEL = 3;
	public static final int OK = 4;
	public static final int HELP = 5;
	public static final int STOP = 6;
	public static final int EXIT = 7;
	public static final int ITEM = 8;

	private String shortLabel;
	private String longLabel;
	private int commandType;
	private int priority;

	public Command(String label, int commandType, int priority) {
		this(label, null, commandType, priority);
	}

	public Command(String shortLabel, String longLabel, int commandType, int priority) {
		this.shortLabel = shortLabel;
		this.longLabel = longLabel;
		this.commandType = commandType;
		this.priority = priority;
	}

	public String getLabel() {
		return shortLabel;
	}

	public String getLongLabel() {
		return longLabel;
	}

	public String getAndroidLabel() {
		if (shortLabel.length() > 0) {
			return shortLabel;
		} else {
			String label;
			switch (commandType) {
				case BACK:
					label = "Back";
					break;
				case OK:
					label = "OK";
					break;
				default:
					label = shortLabel;
					break;
			}
			return label;
		}
	}

	public int getCommandType() {
		return commandType;
	}

	public int getPriority() {
		return priority;
	}

	public int hashCode() {
		int hash = 3;

		hash = 97 * hash + (shortLabel != null ? shortLabel.hashCode() : 0);
		hash = 97 * hash + (longLabel != null ? longLabel.hashCode() : 0);
		hash = 97 * hash + commandType;
		hash = 97 * hash + priority;

		return hash;
	}
}
@@ -648,16 +648,47 @@
  Command
+ implements Comparable%3CCommand%3E
  %7B%0A%09publ
@@ -1661,76 +1661,372 @@
 ase 
-BACK:%0A%09%09%09%09%09label = %22Back%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case OK:%0A%09%09%09%09%09label = %22OK
+SCREEN:%0A%09%09%09%09%09label = %22Screen%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case BACK:%0A%09%09%09%09%09label = %22Back%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case CANCEL:%0A%09%09%09%09%09label = %22Cancel%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case OK:%0A%09%09%09%09%09label = %22OK%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case HELP:%0A%09%09%09%09%09label = %22Help%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case STOP:%0A%09%09%09%09%09label = %22Stop%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case EXIT:%0A%09%09%09%09%09label = %22Exit%22;%0A%09%09%09%09%09break;%0A%09%09%09%09case ITEM:%0A%09%09%09%09%09label = %22Item
 %22;%0A%09
@@ -2489,10 +2489,101 @@
 hash;%0A%09%7D
+%0A%0A%09@Override%0A%09public int compareTo(Command cmd) %7B%0A%09%09return cmd.getPriority() - priority;%0A%09%7D
 %0A%7D

Update Command