Package com.trafficparrot.sdk.messaging
Class MessageBodyType
java.lang.Object
com.trafficparrot.sdk.messaging.MessageBodyType
- Direct Known Subclasses:
MessageBodyType
Describes the body type of a messaging request or response.
This is the canonical location for MessageBodyType.
The deprecated MessageBodyType remains available for backward compatibility.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MessageBodyTypeA binary body held as Base64: the response's text is the Base64 of the bytes to send.static final MessageBodyTypeA binary body held in the printable-characters encoding, which keeps the ASCII characters in it readable: the response's text is that encoding of the bytes to send.static final MessageBodyTypeA text body: the response's text is the body.static final MessageBodyTypeStands in where a body type is not known or does not apply.final StringThe body type as a mapping file writes it:TEXT,BYTES,PRINTABLE_CHARACTERS,proto/<message type>,protoBase64Bytes/<message type>,javaProto/<Java class>,javaProto/<Java class>:<message type>, or the name of a Java class for a Java object body. -
Constructor Summary
ConstructorsConstructorDescriptionMessageBodyType(String value) Creates a body type from its text in a mapping file. -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageBodyTypeThe body typejava.lang.Object, which stands for a Java object of any class.static MessageBodyTypeThe body typejavaProto/*, which stands for a protobuf message of any type with a Java class.booleancanRepresent(MessageBodyType bodyType) Whether a body of this type can stand for a body of another type.booleaninthashCode()booleanWhether the body is a Java object.booleanWhether this is ajavaProto/body type.booleanWhether this is aprotoBase64Bytes/body type.booleanWhether this is aproto/body type.Class<?>The class of a Java object body.static MessageBodyTypejavaClassType(Object object) The type of a body that is this Java object.NOTE: this is encoded as either: - javaProto/com.example.JavaType:com.example.ProtoType - javaProto/com.example.ProtoAndJavaTypeNOTE: this is encoded as either: - javaProto/com.example.JavaType:com.example.ProtoType - javaProto/com.example.ProtoAndJavaTypestatic MessageBodyTypejavaProtoMessageType(String javaAndProtoTypeName) The type of a body that is a protobuf message with a Java class, when the class and the message type have one name.static MessageBodyTypejavaProtoMessageType(String javaTypeName, String protoTypeName) The type of a body that is a protobuf message with a Java class.The protobuf message type of aprotoBase64Bytes/body type.The protobuf message type of aproto/body type.static MessageBodyTypeprotoMessageType(String typeName) The type of a body that is a protobuf message.toString()
-
Field Details
-
TEXT
A text body: the response's text is the body. -
BYTES
A binary body held as Base64: the response's text is the Base64 of the bytes to send. -
PRINTABLE_CHARACTERS
A binary body held in the printable-characters encoding, which keeps the ASCII characters in it readable: the response's text is that encoding of the bytes to send. -
UNKNOWN_BODY_TYPE
Stands in where a body type is not known or does not apply. Not a type to give a response. -
value
The body type as a mapping file writes it:TEXT,BYTES,PRINTABLE_CHARACTERS,proto/<message type>,protoBase64Bytes/<message type>,javaProto/<Java class>,javaProto/<Java class>:<message type>, or the name of a Java class for a Java object body.
-
-
Constructor Details
-
MessageBodyType
Creates a body type from its text in a mapping file. Use the constants for the fixed types and the static methods for the others.- Parameters:
value- the body type as a mapping file writes it, asvaluedescribes
-
-
Method Details
-
protoMessageType
The type of a body that is a protobuf message.- Parameters:
typeName- the protobuf message type's name- Returns:
- the body type
proto/<typeName>
-
anyJavaProtoMessageType
The body typejavaProto/*, which stands for a protobuf message of any type with a Java class.- Returns:
- the body type
-
anyJavaClassType
The body typejava.lang.Object, which stands for a Java object of any class.- Returns:
- the body type
-
javaProtoMessageType
The type of a body that is a protobuf message with a Java class, when the class and the message type have one name.- Parameters:
javaAndProtoTypeName- the name the Java class and the protobuf message type share- Returns:
- the body type
javaProto/<javaAndProtoTypeName>
-
javaProtoMessageType
The type of a body that is a protobuf message with a Java class.- Parameters:
javaTypeName- the Java class's nameprotoTypeName- the protobuf message type's name- Returns:
- the body type
javaProto/<javaTypeName>:<protoTypeName>, orjavaProto/<javaTypeName>when the two names are the same
-
javaClassType
The type of a body that is this Java object.- Parameters:
object- the object- Returns:
- a body type that names the object's class, or for a dynamic proxy its invocation handler's class
-
toString
-
equals
-
hashCode
public int hashCode() -
protoMessageType
The protobuf message type of aproto/body type.- Returns:
valuewithout itsproto/prefix; the whole value for any other body type
-
protoBase64BytesMessageType
The protobuf message type of aprotoBase64Bytes/body type.- Returns:
valuewithout itsprotoBase64Bytes/prefix; the whole value for any other body type
-
javaProtoJavaType
NOTE: this is encoded as either: - javaProto/com.example.JavaType:com.example.ProtoType - javaProto/com.example.ProtoAndJavaType- Returns:
- the Java class name of a
javaProto/body type
-
javaProtoMessageType
NOTE: this is encoded as either: - javaProto/com.example.JavaType:com.example.ProtoType - javaProto/com.example.ProtoAndJavaType- Returns:
- the protobuf message type name of a
javaProto/body type
-
isProtoMessageType
public boolean isProtoMessageType()Whether this is aproto/body type.- Returns:
- true if
valuestarts withproto/
-
isProtoBase64BytesMessageType
public boolean isProtoBase64BytesMessageType()Whether this is aprotoBase64Bytes/body type.- Returns:
- true if
valuestarts withprotoBase64Bytes/
-
isJavaProtoMessageType
public boolean isJavaProtoMessageType()Whether this is ajavaProto/body type.- Returns:
- true if
valuestarts withjavaProto/
-
canRepresent
Whether a body of this type can stand for a body of another type.- Parameters:
bodyType- the other body type- Returns:
- true if the two are equal, or each is one of
TEXT,BYTESandPRINTABLE_CHARACTERS
-
isJavaObject
public boolean isJavaObject()Whether the body is a Java object.- Returns:
- true if
valueis none of the other forms and names a class on Traffic Parrot's classpath
-
javaClass
The class of a Java object body.- Returns:
- the class
valuenames - Throws:
IllegalStateException- if no such class is on Traffic Parrot's classpath
-