<commit_before>/**
 * 
 */
package com.thoughtworks.automation.orchestrion;

/**
 * Base class for all the containers
 * 
 */
public abstract class UIItemContainer extends UIItem {

	public UIItemContainer(int refId) {
		super(refId);
	}

	/**
	 * Gets the keyboard instance
	 * 
	 * @return keyboard
	 * @throws Exception
	 * @see Keyboard
	 */
	public Keyboard getKeyBoard() throws Exception {
		try {
			int id = RemoteServer.instance().executeAndGetId("getkeyboard",
					getRefId());
			return new Keyboard(id);
		} catch (RefIdNotAvailableException e) {
			return null;
		}
	}

	/**
	 * Gets the mouse instance
	 * 
	 * @return
	 * @throws Exception
	 */
	public Mouse getMouse() throws Exception {
		try {
			int id = RemoteServer.instance().executeAndGetId("getmouse",
					getRefId());
			return new Mouse(id);
		} catch (RefIdNotAvailableException e) {
			return null;
		}
	}

	/**
	 * Gets a Button by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 */
	public Button getButton(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getbutton",
				getRefId(), by, by.getValue());
		return new Button(id, getRefId());
	}

	/**
	 * Gets a CheckBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 */
	public CheckBox getCheckBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getcheckbox",
				getRefId(), by, by.getValue());
		return new CheckBox(id, getRefId());
	}

	/**
	 * Gets a RadioButton by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see RadioButton
	 */
	public RadioButton getRadioButton(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getradiobutton",
				getRefId(), by, by.getValue());
		return new RadioButton(id, getRefId());
	}

	/**
	 * Gets a ComboBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see ComboBox
	 */
	public Combobox getComboBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getcombobox",
				getRefId(), by, by.getValue());
		return new Combobox(id, getRefId());
	}

	/**
	 * Gets a ListBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see ListBox
	 */
	public ListBox getListBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getlistbox",
				getRefId(), by, by.getValue());
		return new ListBox(id, getRefId());
	}
	
	
	/**
	 * Gets a TextBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see TextBox
	 */
	public TextBox getTextBox(By by) throws Exception{
		return getTextBox(by, false);
	}
	
	public TextBox getMultiLineTextBox(By by) throws Exception{
		return getTextBox(by, true);
	}

	private TextBox getTextBox(By by, boolean multiline) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id;
		if (multiline) {
			id = RemoteServer.instance().executeAndGetId("getmultilinetextbox",
					getRefId(), by, by.getValue());
		} else {
			id = RemoteServer.instance().executeAndGetId("gettextbox",
					getRefId(), by, by.getValue());
		}

		return new TextBox(id, getRefId());
	}

	/**
	 * Gets a Label by the search criteria
	 * 
	 * @param by
	 *            condition to locate element<commit_msg>Caching the Keyboard and Mouse instance in UIItemContainer<commit_after>/**
 * 
 */
package com.thoughtworks.automation.orchestrion;

/**
 * Base class for all the containers
 * 
 */
public abstract class UIItemContainer extends UIItem {

	private Keyboard keyboard;
	private Mouse mouse;

	public UIItemContainer(int refId) {
		super(refId);
	}

	/**
	 * Gets the keyboard instance.
	 * 
	 * @return keyboard
	 * @throws Exception
	 * @see Keyboard
	 */
	public Keyboard getKeyBoard() throws Exception {
		if (keyboard == null) {
			try {
				int id = RemoteServer.instance().executeAndGetId("getkeyboard",
						getRefId());
				keyboard = new Keyboard(id);
			} catch (RefIdNotAvailableException e) {
				keyboard = null;
			}
		}

		return keyboard;
	}

	/**
	 * Gets the mouse instance
	 * 
	 * @return
	 * @throws Exception
	 */
	public Mouse getMouse() throws Exception {
		if (mouse == null) {
			try {
				int id = RemoteServer.instance().executeAndGetId("getmouse",
						getRefId());
				mouse = new Mouse(id);
			} catch (RefIdNotAvailableException e) {
				mouse = null;
			}
		}

		return mouse;
	}

	/**
	 * Gets a Button by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 */
	public Button getButton(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getbutton",
				getRefId(), by, by.getValue());
		return new Button(id, getRefId());
	}

	/**
	 * Gets a CheckBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 */
	public CheckBox getCheckBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getcheckbox",
				getRefId(), by, by.getValue());
		return new CheckBox(id, getRefId());
	}

	/**
	 * Gets a RadioButton by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see RadioButton
	 */
	public RadioButton getRadioButton(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getradiobutton",
				getRefId(), by, by.getValue());
		return new RadioButton(id, getRefId());
	}

	/**
	 * Gets a ComboBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see ComboBox
	 */
	public Combobox getComboBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getcombobox",
				getRefId(), by, by.getValue());
		return new Combobox(id, getRefId());
	}

	/**
	 * Gets a ListBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see ListBox
	 */
	public ListBox getListBox(By by) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id = RemoteServer.instance().executeAndGetId("getlistbox",
				getRefId(), by, by.getValue());
		return new ListBox(id, getRefId());
	}

	/**
	 * Gets a TextBox by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
	 * @return
	 * @throws Exception
	 * @see TextBox
	 */
	public TextBox getTextBox(By by) throws Exception {
		return getTextBox(by, false);
	}

	public TextBox getMultiLineTextBox(By by) throws Exception {
		return getTextBox(by, true);
	}

	private TextBox getTextBox(By by, boolean multiline) throws Exception {
		if (by == null) {
			throw new IllegalArgumentException("by");
		}

		int id;
		if (multiline) {
			id = RemoteServer.instance().executeAndGetId("getmultilinetextbox",
					getRefId(), by, by.getValue());
		} else {
			id = RemoteServer.instance().executeAndGetId("gettextbox",
					getRefId(), by, by.getValue());
		}

		return new TextBox(id, getRefId());
	}

	/**
	 * Gets a Label by the search criteria
	 * 
	 * @param by
	 *            condition to locate element
{'fraction_non_alphanumeric': 0.121529919802591, 'fraction_numerical': 0.0, 'mean_word_length': 3.0939393939393938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1791949', 'n_tokens_mistral': 2790, 'n_tokens_neox': 2377, 'n_words': 722}