Corrected naming conventions, corrected payload decoding

Signed-off-by: Lenard Nagy <lenard.nagy@ericsson.com>
diff --git a/user_provided/org/eclipse/titan/user_provided/CoAP__Types_externalfunctions.java b/user_provided/org/eclipse/titan/user_provided/CoAP__Types_externalfunctions.java
index 1e26668..84ca4a5 100644
--- a/user_provided/org/eclipse/titan/user_provided/CoAP__Types_externalfunctions.java
+++ b/user_provided/org/eclipse/titan/user_provided/CoAP__Types_externalfunctions.java
@@ -35,53 +35,53 @@
 		}
 		//HEADER
 		//version
-		if(msg.get_field_msg().get_field_header().get_field_version().isGreaterThanOrEqual(0) && msg.get_field_msg().get_field_header().get_field_version().isLessThanOrEqual(3)){
-			chr = msg.get_field_msg().get_field_header().get_field_version().getInt() << 6;
+		if(msg.get_field_msg().get_field_header().get_field_version().is_greater_than_or_equal(0) && msg.get_field_msg().get_field_header().get_field_version().is_less_than_or_equal(3)){
+			chr = msg.get_field_msg().get_field_header().get_field_version().get_int() << 6;
 		}else{
 			return 1;
 		}
 		//message type
-		chr += msg.get_field_msg().get_field_header().get_field_msg__type().asInt() << 4;
+		chr += msg.get_field_msg().get_field_header().get_field_msg__type().as_int() << 4;
 		//token length
-		if(msg.get_field_msg().get_field_token().lengthof().isGreaterThanOrEqual(0) && msg.get_field_msg().get_field_token().lengthof().isLessThanOrEqual(8)){
-			chr += msg.get_field_msg().get_field_token().lengthof().getInt();
+		if(msg.get_field_msg().get_field_token().lengthof().is_greater_than_or_equal(0) && msg.get_field_msg().get_field_token().lengthof().is_less_than_or_equal(8)){
+			chr += msg.get_field_msg().get_field_token().lengthof().get_int();
 		}else{
 			return 1;
 		}
 
 		stream.put_c(Character.toChars(chr)[0]);
 		//code
-		if(msg.get_field_msg().get_field_header().get_field_code().get_field_class_().isGreaterThanOrEqual(0) && msg.get_field_msg().get_field_header().get_field_code().get_field_class_().isLessThanOrEqual(7)){
-			chr = msg.get_field_msg().get_field_header().get_field_code().get_field_class_().getInt() << 5;
+		if(msg.get_field_msg().get_field_header().get_field_code().get_field_class_().is_greater_than_or_equal(0) && msg.get_field_msg().get_field_header().get_field_code().get_field_class_().is_less_than_or_equal(7)){
+			chr = msg.get_field_msg().get_field_header().get_field_code().get_field_class_().get_int() << 5;
 		}else{
 			return 1;
 		}
-		if(msg.get_field_msg().get_field_header().get_field_code().get_field_detail().isGreaterThanOrEqual(0) && msg.get_field_msg().get_field_header().get_field_code().get_field_detail().isLessThanOrEqual(31)){
-			chr += msg.get_field_msg().get_field_header().get_field_code().get_field_detail().getInt();
+		if(msg.get_field_msg().get_field_header().get_field_code().get_field_detail().is_greater_than_or_equal(0) && msg.get_field_msg().get_field_header().get_field_code().get_field_detail().is_less_than_or_equal(31)){
+			chr += msg.get_field_msg().get_field_header().get_field_code().get_field_detail().get_int();
 		}else{
 			return 1;
 		}
 		stream.put_c(Character.toChars(chr)[0]);
 		//message ID
-		if(msg.get_field_msg().get_field_header().get_field_message__id().isGreaterThanOrEqual(0) && msg.get_field_msg().get_field_header().get_field_message__id().isLessThanOrEqual(65535)){
-			encodeInteger(stream, msg.get_field_msg().get_field_header().get_field_message__id().getInt(), 2);
+		if(msg.get_field_msg().get_field_header().get_field_message__id().is_greater_than_or_equal(0) && msg.get_field_msg().get_field_header().get_field_message__id().is_less_than_or_equal(65535)){
+			encodeInteger(stream, msg.get_field_msg().get_field_header().get_field_message__id().get_int(), 2);
 		}else{
 			return 1;
 		}
 		//TOKEN
 		stream.put_os(msg.get_field_msg().get_field_token());
 		//OPTIONS
-		if(msg.get_field_msg().get_field_options().ispresent() && msg.get_field_msg().get_field_options().get().size_of().isGreaterThan(0)){
-			int[] optionOrder = new int[msg.get_field_msg().get_field_options().get().size_of().getInt()];
+		if(msg.get_field_msg().get_field_options().ispresent() && msg.get_field_msg().get_field_options().get().size_of().is_greater_than(0)){
+			int[] optionOrder = new int[msg.get_field_msg().get_field_options().get().size_of().get_int()];
 			int temp;
-			for(int i = 0; i < msg.get_field_msg().get_field_options().get().size_of().getInt(); i++){
+			for(int i = 0; i < msg.get_field_msg().get_field_options().get().size_of().get_int(); i++){
 				optionOrder[i] = i;
 			}
 			//determine the order of options
-			for(int j = 0; j < msg.get_field_msg().get_field_options().get().size_of().getInt() - 1; j++){
+			for(int j = 0; j < msg.get_field_msg().get_field_options().get().size_of().get_int() - 1; j++){
 				int minOptionCode = getOptionCode(msg.get_field_msg().get_field_options().get().get_at(optionOrder[j]));
 				int minOptionIndex = j;
-				for(int i = j+1; i < msg.get_field_msg().get_field_options().get().size_of().getInt(); i++){
+				for(int i = j+1; i < msg.get_field_msg().get_field_options().get().size_of().get_int(); i++){
 					if(getOptionCode(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i])) < minOptionCode){
 						minOptionCode = getOptionCode(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]));
 						minOptionIndex = i;
@@ -93,7 +93,7 @@
 			}
 			//encode options
 			int previousOptionCode = 0;
-			for(int i = 0; i < msg.get_field_msg().get_field_options().get().size_of().getInt(); i++){
+			for(int i = 0; i < msg.get_field_msg().get_field_options().get().size_of().get_int(); i++){
 				int delta = getOptionCode(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i])) - previousOptionCode;
 				int length = getOptionLength(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]));
 				previousOptionCode += delta;
@@ -153,10 +153,10 @@
 						stream.put_os(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_if__none__match());
 						break;
 					case ALT_observe:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_observe().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_observe().get_int(), length);
 						break;
 					case ALT_uri__port:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_uri__port().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_uri__port().get_int(), length);
 						break;
 					case ALT_location__path:
 						msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_location__path().encode_utf8(stream, false);
@@ -165,16 +165,16 @@
 						msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_uri__path().encode_utf8(stream, false);
 						break;
 					case ALT_content__format:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_content__format().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_content__format().get_int(), length);
 						break;
 					case ALT_max__age:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_max__age().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_max__age().get_int(), length);
 						break;
 					case ALT_uri__query:
 						msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_uri__query().encode_utf8(stream, false);
 						break;
 					case ALT_accept:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_accept().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_accept().get_int(), length);
 						break;
 					case ALT_location__query:
 						msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_location__query().encode_utf8(stream, false);
@@ -192,7 +192,7 @@
 						msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_proxy__scheme().encode_utf8(stream, false);
 						break;
 					case ALT_size1:
-						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_size1().getInt(), length);
+						encodeInteger(stream, msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_size1().get_int(), length);
 						break;
 					case ALT_unknown__option:
 						stream.put_os(msg.get_field_msg().get_field_options().get().get_at(optionOrder[i]).get_field_unknown__option().get_field_option__value());
@@ -227,7 +227,7 @@
 			v__enc.log();
 			TTCN_Logger.end_event();
 		}
-		if(v__enc.lengthof().isGreaterThanOrEqual(4)){
+		if(v__enc.lengthof().is_greater_than_or_equal(4)){
 			int chr;
 			int position = 0;
 			int token_length = 0;
@@ -235,25 +235,25 @@
 			int count_of_options = 0;
 			boolean payload_marker = false;
 			//version, message type and token length
-			chr = v__enc.getValue()[0];
+			chr = v__enc.get_value()[0];
 			v__dec.get_field_msg().get_field_header().get_field_version().operator_assign(chr >> 6);
 			v__dec.get_field_msg().get_field_header().get_field_msg__type().operator_assign((chr >> 4) & 3);
 			token_length = chr & 15;
 			//code
-			chr = v__enc.getValue()[1];
+			chr = v__enc.get_value()[1];
 			v__dec.get_field_msg().get_field_header().get_field_code().get_field_class_().operator_assign((chr >> 5) & 7);
 			v__dec.get_field_msg().get_field_header().get_field_code().get_field_detail().operator_assign(chr & 31);
 			//message ID
-			v__dec.get_field_msg().get_field_header().get_field_message__id().operator_assign(v__enc.getValue()[2] * 256 + v__enc.getValue()[3]);
-			if(v__enc.lengthof().isGreaterThan(4) && v__dec.get_field_msg().get_field_header().get_field_code().get_field_class_().operator_equals(0) && v__dec.get_field_msg().get_field_header().get_field_code().get_field_detail().operator_equals(0)) {
+			v__dec.get_field_msg().get_field_header().get_field_message__id().operator_assign(v__enc.get_value()[2] * 256 + v__enc.get_value()[3]);
+			if(v__enc.lengthof().is_greater_than(4) && v__dec.get_field_msg().get_field_header().get_field_code().get_field_class_().operator_equals(0) && v__dec.get_field_msg().get_field_header().get_field_code().get_field_detail().operator_equals(0)) {
 				v__dec.get_field_raw__message().operator_assign(v__enc);
 				return 1;
 			}
 			position = 4;
 			//token
 			if(token_length > 0){
-				if(v__enc.lengthof().isGreaterThanOrEqual(position + token_length)) {
-					v__dec.get_field_msg().get_field_token().operator_assign(new TitanOctetString(v__enc.getValue()[position]));
+				if(v__enc.lengthof().is_greater_than_or_equal(position + token_length)) {
+					v__dec.get_field_msg().get_field_token().operator_assign(new TitanOctetString(v__enc.get_value()[position]));
 					position += token_length;
 				}else{
 					v__dec.get_field_raw__message().operator_assign(v__enc);
@@ -264,8 +264,8 @@
 			}
 			//options
 			v__dec.get_field_msg().get_field_options().operator_assign(template_sel.OMIT_VALUE);
-			if(v__enc.lengthof().isGreaterThan(4)) {
-				while(!payload_marker && v__enc.lengthof().isGreaterThan(position)) {
+			if(v__enc.lengthof().is_greater_than(4)) {
+				while(!payload_marker && v__enc.lengthof().is_greater_than(position)) {
 					int delta = v__enc.get_nibble(position) >> 4;
 			int length = v__enc.get_nibble(position) & 15;
 			if(delta == 15 && length != 15){
@@ -363,8 +363,13 @@
 				}
 			}
 			//payload
-			if(v__enc.lengthof().isGreaterThan(position)) {
-				v__dec.get_field_msg().get_field_payload().operator_assign(new TitanOctetString(v__enc.get_nibble(position)));
+			if(v__enc.lengthof().is_greater_than(position)) {
+				char[] enc = v__enc.get_value();
+				char[] pl = new char[enc.length-position];
+				
+				System.arraycopy(enc, position, pl, 0, enc.length-position);
+				
+				v__dec.get_field_msg().get_field_payload().operator_assign(new TitanOctetString(pl));
 				if(v__dec.get_field_msg().get_field_payload().get().lengthof().operator_equals(0)) { 
 					v__dec.get_field_raw__message().operator_assign(v__enc);
 					return 1;
@@ -466,7 +471,7 @@
 		case ALT_size1:
 			return 60;
 		case ALT_unknown__option:
-			return option.get_field_unknown__option().get_field_option__code().getInt();
+			return option.get_field_unknown__option().get_field_option__code().get_int();
 		case UNBOUND_VALUE:
 		default:
 			throw new TtcnError("CoAP: Error at getOptionCode!");
@@ -475,49 +480,49 @@
 	private static int getOptionLength(CoAP__Options option){
 		switch(option.get_selection()){
 		case ALT_if__match:
-			return option.get_field_if__match().lengthof().getInt();
+			return option.get_field_if__match().lengthof().get_int();
 		case ALT_uri__host:
-			return option.get_field_uri__host().lengthof().getInt();
+			return option.get_field_uri__host().lengthof().get_int();
 		case ALT_etag:
-			return option.get_field_etag().lengthof().getInt();
+			return option.get_field_etag().lengthof().get_int();
 		case ALT_if__none__match:
-			return option.get_field_if__none__match().lengthof().getInt();
+			return option.get_field_if__none__match().lengthof().get_int();
 		case ALT_observe:
-			return getIntegerLength(option.get_field_observe().getLong(), 3);
+			return get_integerLength(option.get_field_observe().get_long(), 3);
 		case ALT_uri__port:
-			return getIntegerLength(option.get_field_uri__port().getLong(), 2);
+			return get_integerLength(option.get_field_uri__port().get_long(), 2);
 		case ALT_location__path:
-			return option.get_field_location__path().lengthof().getInt();
+			return option.get_field_location__path().lengthof().get_int();
 		case ALT_uri__path:
-			return option.get_field_uri__path().lengthof().getInt();
+			return option.get_field_uri__path().lengthof().get_int();
 		case ALT_content__format:
-			return getIntegerLength(option.get_field_content__format().getLong(), 2);
+			return get_integerLength(option.get_field_content__format().get_long(), 2);
 		case ALT_max__age:
-			return getIntegerLength(option.get_field_max__age().getLong(), 4);
+			return get_integerLength(option.get_field_max__age().get_long(), 4);
 		case ALT_uri__query:
-			return option.get_field_uri__query().lengthof().getInt();
+			return option.get_field_uri__query().lengthof().get_int();
 		case ALT_accept:
-			return getIntegerLength(option.get_field_accept().getLong(), 2);
+			return get_integerLength(option.get_field_accept().get_long(), 2);
 		case ALT_location__query:
-			return option.get_field_location__query().lengthof().getInt();
+			return option.get_field_location__query().lengthof().get_int();
 		case ALT_block1:
-			return getBlockLengthForNum(option.get_field_block1().get_field_num().getLong());
+			return getBlockLengthForNum(option.get_field_block1().get_field_num().get_long());
 		case ALT_block2:
-			return getBlockLengthForNum(option.get_field_block2().get_field_num().getLong());
+			return getBlockLengthForNum(option.get_field_block2().get_field_num().get_long());
 		case ALT_proxy__uri:
-			return option.get_field_proxy__uri().lengthof().getInt();
+			return option.get_field_proxy__uri().lengthof().get_int();
 		case ALT_proxy__scheme:
-			return option.get_field_proxy__scheme().lengthof().getInt();
+			return option.get_field_proxy__scheme().lengthof().get_int();
 		case ALT_size1:
-			return getIntegerLength(option.get_field_size1().getLong(), 4);
+			return get_integerLength(option.get_field_size1().get_long(), 4);
 		case ALT_unknown__option:
-			return option.get_field_unknown__option().get_field_option__value().lengthof().getInt();
+			return option.get_field_unknown__option().get_field_option__value().lengthof().get_int();
 		case UNBOUND_VALUE:
 		default:
 			throw new TtcnError("CoAP: Error at getOptionLength!");
 		}
 	}
-	private static int getIntegerLength(final long value, int mode){
+	private static int get_integerLength(final long value, int mode){
 		if(value == 0){
 			return 0;
 		}else if(value / 269.0 == 0){
@@ -529,7 +534,7 @@
 		}else if(mode == 4 && value / 4294967296L == 0){
 			return 4;
 		}else{
-			throw new TtcnError("CoAP: Error at getIntegerLength!");
+			throw new TtcnError("CoAP: Error at get_integerLength!");
 		}
 	}
 
@@ -551,11 +556,11 @@
 	// RFC 7959
 	private static void encodeBlock(TTCN_Buffer stream, final BlockOption option, final int length) {
 		int chr;
-		int num_val = option.get_field_num().getInt();
+		int num_val = option.get_field_num().get_int();
 		int szx;
-		szx = option.get_field_szx().getInt() & 0x07; // szx_val & 00000111b
+		szx = option.get_field_szx().get_int() & 0x07; // szx_val & 00000111b
 		char m;
-		if (option.get_field_m().getValue())
+		if (option.get_field_m().get_value())
 			m = 0x08; // 00001000b
 		else
 			m = 0x00; // 00000000b