public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) {
      if (source == null) return null;
      if (sourceType == null) throw new NullPointerException("MediaType cannot be null!");
      if (!sourceType.match(MediaType.TEXT_PLAIN))
         throw CONTAINER.invalidMediaType(TEXT_PLAIN_TYPE, sourceType.toString());

      boolean asString = destinationType.hasStringType();

      Charset sourceCharset = sourceType.getCharset();
      Charset destinationCharset = destinationType.getCharset();
      if (sourceCharset.equals(destinationCharset)) return convertTextClass(source, destinationType, asString);
      byte[] byteContent = source instanceof byte[] ? (byte[]) source : source.toString().getBytes(sourceCharset);
      return convertTextClass(convertCharset(byteContent, sourceCharset, destinationCharset), destinationType, asString);
   }
@Test
   public void textToTextConversion() {
      String source = "All those moments will be lost in time, like tears in rain.";
      byte[] sourceAs8859 = source.getBytes(ISO_8859_1);
      byte[] sourceAsASCII = source.getBytes(US_ASCII);

      Object result = StandardConversions.convertTextToText(sourceAs8859,
            TEXT_PLAIN.withCharset(ISO_8859_1),
            TEXT_PLAIN.withCharset(US_ASCII));

      assertArrayEquals(sourceAsASCII, (byte[]) result);
   }