<commit_before>package models;

import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.JsonNode;

import akka.actor.dsl.Creators.Act;

import play.Logger;
import play.libs.Json;

/**
 * represents a message send from us to us with xmpp
 */
public class Message {

	public enum Action {
		SEND_SMS("send-sms-action"), RECEIVE_SMS("receive-sms-action");

		private final String text;

		private Action(String text) {
			this.text = text;
		}

		public String getText() {
			return text;
		}

		public static Action fromString(String text) {
			if (text != null) {
				for (Action action : Action.values()) {
					if (text.equals(action.text))
						return action;
				}
			}
			return null;
		}
	}

	private JsonNode jsonMsg = null;

	private String authorPhoneNumber;
	private String recipient;
	private String content;
	private Action action;

	/**
	 * retrieve the content to json format
	 */
	public Message(org.jivesoftware.smack.packet.Message xmppMsg) {
		jsonMsg = Json.parse(xmppMsg.getBody());

		if (jsonMsg != null) {
			authorPhoneNumber = jsonMsg.findValue("authorPhoneNumber").toString();
			recipient = jsonMsg.findValue("recipient").toString();
			content = jsonMsg.findValue("content").toString();

			String action = jsonMsg.findValue("action").getTextValue();
			Logger.info(action);
			if (action != null) {
				this.action = Action.fromString("receive-sms-action");
			}
		}
	}

	public Message(Action action, String authorPhoneNumber, String recipient, String content) {
		this.action = action;
		this.authorPhoneNumber = authorPhoneNumber;
		this.recipient = recipient;
		this.content = content;
	}

	/**
	 * check wether the xmpp message is wrapping an sms
	 */
	public boolean isNewIncomingSMS() {
		if (jsonMsg != null) {
			if (action == models.Message.Action.RECEIVE_SMS) {
				return true;
			}
		}
		return false;<commit_msg>keep only value, not the json string<commit_after>package models;

import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.JsonNode;

import akka.actor.dsl.Creators.Act;

import play.Logger;
import play.libs.Json;

/**
 * represents a message send from us to us with xmpp
 */
public class Message {

	public enum Action {
		SEND_SMS("send-sms-action"), RECEIVE_SMS("receive-sms-action");

		private final String text;

		private Action(String text) {
			this.text = text;
		}

		public String getText() {
			return text;
		}

		public static Action fromString(String text) {
			if (text != null) {
				for (Action action : Action.values()) {
					if (text.equals(action.text))
						return action;
				}
			}
			return null;
		}
	}

	private JsonNode jsonMsg = null;

	private String authorPhoneNumber;
	private String recipient;
	private String content;
	private Action action;

	/**
	 * retrieve the content to json format
	 */
	public Message(org.jivesoftware.smack.packet.Message xmppMsg) {
		jsonMsg = Json.parse(xmppMsg.getBody());

		if (jsonMsg != null) {
			authorPhoneNumber = jsonMsg.findValue("authorPhoneNumber").getTextValue();
			recipient = jsonMsg.findValue("recipient").getTextValue();
			content = jsonMsg.findValue("content").getTextValue();

			String action = jsonMsg.findValue("action").getTextValue();
			Logger.info(action);
			if (action != null) {
				this.action = Action.fromString("receive-sms-action");
			}
		}
	}

	public Message(Action action, String authorPhoneNumber, String recipient, String content) {
		this.action = action;
		this.authorPhoneNumber = authorPhoneNumber;
		this.recipient = recipient;
		this.content = content;
	}

	/**
	 * check wether the xmpp message is wrapping an sms
	 */
	public boolean isNewIncomingSMS() {
		if (jsonMsg != null) {
			if (action == models.Message.Action.RECEIVE_SMS) {
				return true;
			}
		}
		return false;
{'fraction_non_alphanumeric': 0.11881450119079122, 'fraction_numerical': 0.0, 'mean_word_length': 3.7191011235955056, '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': '5359502', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1177, 'n_words': 297}