Metadata Selector (.^someMetadata)

Metadata Selector (.^someMetadata)

Returns the value of specified metadata for a Mule payload, variable, or attribute. The selector can return the following metadata:

  • Content length metadata: .^contentLength returns the content length of the value, if the value is present. For an example, see Content Length Metadata Selector (.^contentLength).
  • Class metadata: .^class returns the class of the Plain Old Java Object (POJO). For example, { “string” : payload.string.^class } might return { “string”: “java.lang.String” } if the input payload defines a Java string, such as simplePojo.string = “myString”, in a simple POJO, and { “date” : payload.date.^class } might return { “date”: “java.util.Date” }. For an example, see Class Metadata Selector (.^class).
  • Encoding metadata: .^encoding returns the encoding of a value. For example, { “myEncoding” : payload.^encoding } might return {“myEncoding”: “UTF-8”} for an input POJO. For an example, see Encoding Metadata Selector (.^encoding).
  • Media Type Selector: .^mediaType returns the MIME type of a value that includes parameters, for example, application/json;charset=UTF-16, and the expression in the value of { “myMediaType” : payload.^mediaType } might return “myMediaType”: “/; charset=UTF-8″ for an input POJO. For an example, see Media Type Metadata Selector (.^mediaType).
  • MIME Type metadata: .^mimeType returns the MIME type (without parameters) of a value, for example, application/json, and { “myMimeType” : payload.^mimeType } might return { “myMediaType”: “/” } for an input POJO. For an example, see MIME Type Metadata Selector (.^mimeType).
  • Raw metadata: .^raw returns the underlying data (typically, a binary value) of a plain old Java object (POJO). This selector is sometimes used when calculating an MD5 for hashes when checking for man-in-the-middle attacks. For examples, see Raw Metadata Selector (.^raw).

Custom metadata: .^myCustomMetadata returns the value of custom metadata. For examples, see Custom Metadata Selector (.^myCustomMetadata).

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

Instagram

Facebook

Recent Posts

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

2 days ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

3 weeks ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

3 weeks ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

4 weeks ago

Autocomplete System Implementation

Build an autocomplete system that, given a query string s and a set of possible…

4 weeks ago

Job Scheduler Implementation

Design a job scheduler that accepts a function f and an integer n. The scheduler…

4 weeks ago