Example usage for java.nio.charset Charset contains

List of usage examples for java.nio.charset Charset contains

Introduction

In this page you can find the example usage for java.nio.charset Charset contains.

Prototype

public abstract boolean contains(Charset cs);

Source Link

Document

Tells whether or not this charset contains the given charset.

Usage

From source file:org.ebayopensource.turmeric.runtime.tests.common.util.TestUtils.java

public static MyMessage encodeMessage(MyMessage msg, Charset charset) throws Exception {
    if (null == msg) {
        return null;
    }//from w  ww.java  2 s  .co m
    MyMessage encodedMsg = new MyMessage();
    String body = msg.getBody();
    if (!charset.contains(UTF8) && !charset.contains(UTF16)) {
        body = usAsciiEncodeString(body);
    }
    encodedMsg.setBody(body);
    encodedMsg.setCreateTime(msg.getCreateTime());
    encodedMsg.setRecipients(msg.getRecipients());
    encodedMsg.setSubject(msg.getSubject());
    encodedMsg.setSomething(msg.getSomething());
    return encodedMsg;
}