Allows to specify matches, action parameters as strings in PI

Some PI elements can encode in their value a string (e.g., when
a P4Runtime translation is used), for this reason we allow users
to specify matches and action parameters as strings.
From southbound, during decode, we interpret the elements as
string if the P4 model suggests that.

Change-Id: I5884de1500437ab647abc200d65de442e23bd1a8
diff --git a/protocols/p4runtime/utils/src/main/java/org/onosproject/p4runtime/ctl/codec/FieldMatchCodec.java b/protocols/p4runtime/utils/src/main/java/org/onosproject/p4runtime/ctl/codec/FieldMatchCodec.java
index d42e6b9..6b01546 100644
--- a/protocols/p4runtime/utils/src/main/java/org/onosproject/p4runtime/ctl/codec/FieldMatchCodec.java
+++ b/protocols/p4runtime/utils/src/main/java/org/onosproject/p4runtime/ctl/codec/FieldMatchCodec.java
@@ -152,16 +152,23 @@
             PiPipeconf pipeconf, P4InfoBrowser browser)
             throws CodecException, P4InfoBrowser.NotFoundException {
 
-        String fieldMatchName = browser.matchFields(tablePreamble.getId())
-                .getById(message.getFieldId()).getName();
-        PiMatchFieldId headerFieldId = PiMatchFieldId.of(fieldMatchName);
+        final P4InfoOuterClass.MatchField matchField =
+                browser.matchFields(tablePreamble.getId())
+                        .getById(message.getFieldId());
+        final PiMatchFieldId headerFieldId = PiMatchFieldId.of(matchField.getName());
+        final boolean isSdnString = browser.isTypeString(matchField.getTypeName());
 
         P4RuntimeOuterClass.FieldMatch.FieldMatchTypeCase typeCase = message.getFieldMatchTypeCase();
 
         switch (typeCase) {
             case EXACT:
                 P4RuntimeOuterClass.FieldMatch.Exact exactFieldMatch = message.getExact();
-                ImmutableByteSequence exactValue = copyFrom(exactFieldMatch.getValue().asReadOnlyByteBuffer());
+                ImmutableByteSequence exactValue;
+                if (isSdnString) {
+                    exactValue = copyFrom(new String(exactFieldMatch.getValue().toByteArray()));
+                } else {
+                    exactValue = copyFrom(exactFieldMatch.getValue().asReadOnlyByteBuffer());
+                }
                 return new PiExactFieldMatch(headerFieldId, exactValue);
             case TERNARY:
                 P4RuntimeOuterClass.FieldMatch.Ternary ternaryFieldMatch = message.getTernary();
@@ -180,7 +187,12 @@
                 return new PiRangeFieldMatch(headerFieldId, rangeLowValue, rangeHighValue);
             case OPTIONAL:
                 P4RuntimeOuterClass.FieldMatch.Optional optionalFieldMatch = message.getOptional();
-                ImmutableByteSequence optionalValue = copyFrom(optionalFieldMatch.getValue().asReadOnlyByteBuffer());
+                ImmutableByteSequence optionalValue;
+                if (isSdnString) {
+                    optionalValue = copyFrom(new String(optionalFieldMatch.getValue().toByteArray()));
+                } else {
+                    optionalValue = copyFrom(optionalFieldMatch.getValue().asReadOnlyByteBuffer());
+                }
                 return new PiOptionalFieldMatch(headerFieldId, optionalValue);
             default:
                 throw new CodecException(format(