<commit_before>package fortiss.gui.listeners.textfield;

import fortiss.gui.listeners.helper.InsertionVerifier;

public class BPortListener extends TextFieldListener {

	public BPortListener() {
		super("Error. Invalid port number. Only numbers between 1024 and 49151, and 0 are valid.");
	}
	
	@Override
	boolean isValidField(String text) {
		boolean valid = false;
		if (!text.isEmpty()) {
			int num = Integer.parseUnsignedInt(text);
			if (num == 0 || (num > 1024 && num < 49151))
				valid = true;
		}
		return valid;
	}
	
	@Override
	boolean isValidCharacter(char c, String text) {
		InsertionVerifier v = new InsertionVerifier();
		return v.isNumber(c, text);
	}
	
	@Override
	void update(String text) {
		building.setPort(Integer.parseUnsignedInt(text));
	}

	@Override
	boolean isValidLength(String text) {
		return text.length() < 5;<commit_msg>Handle number format exception: building port<commit_after>package fortiss.gui.listeners.textfield;

import fortiss.gui.DesignerPanel;
import fortiss.gui.listeners.helper.InsertionVerifier;
import fortiss.simulation.helper.Logger;

public class BPortListener extends TextFieldListener {

	public BPortListener() {
		super("Error. Invalid port number. Only numbers between 1024 and 49151, and 0 are valid.");
	}
	
	@Override
	boolean isValidField(String text) {
		boolean valid = false;
		if (!text.isEmpty()) {
			try {
				int num = Integer.parseUnsignedInt(text);	
				if (num == 0 || (num > 1024 && num < 49151))
					valid = true;
			} catch (NumberFormatException e) {
				Logger.getInstance().writeError("Number format exception. Expected an integer and received " + text);
			}
		}
		return valid;
	}
	
	@Override
	boolean isValidCharacter(char c, String text) {
		InsertionVerifier v = new InsertionVerifier();
		return v.isNumber(c, text);
	}
	
	@Override
	void update(String text) {
		try {
			building.setPort(Integer.parseUnsignedInt(text));
		} catch (NumberFormatException e) {
			Logger.getInstance().writeError("Number format exception. Expected an integer and received " + text);
			DesignerPanel.pl_ems_detail.update();
		}
	}

	@Override
	boolean isValidLength(String text) {
		return text.length() < 5;
{'fraction_non_alphanumeric': 0.11070280202112999, 'fraction_numerical': 0.01929260450160772, 'mean_word_length': 4.260869565217392, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1377182', 'n_tokens_mistral': 769, 'n_tokens_neox': 661, 'n_words': 181}