当前位置: 首页>>代码示例>>Java>>正文


Java CharacterSets类代码示例

本文整理汇总了Java中ws.com.google.android.mms.pdu.CharacterSets的典型用法代码示例。如果您正苦于以下问题:Java CharacterSets类的具体用法?Java CharacterSets怎么用?Java CharacterSets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CharacterSets类属于ws.com.google.android.mms.pdu包,在下文中一共展示了CharacterSets类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMessageText

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static String getMessageText(PduBody body) {
  String bodyText = null;

  for (int i=0;i<body.getPartsNum();i++) {
    if (ContentType.isTextType(Util.toIsoString(body.getPart(i).getContentType()))) {
      String partText;

      try {
        String characterSet = CharacterSets.getMimeName(body.getPart(i).getCharset());

        if (characterSet.equals(CharacterSets.MIMENAME_ANY_CHARSET))
          characterSet = CharacterSets.MIMENAME_ISO_8859_1;

        partText = new String(body.getPart(i).getData(), characterSet);
      } catch (UnsupportedEncodingException e) {
        Log.w("PartParser", e);
        partText = "Unsupported Encoding!";
      }

      bodyText = (bodyText == null) ? partText : bodyText + " " + partText;
    }
  }

  return bodyText;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:26,代码来源:PartParser.java

示例2: SlideDeck

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public SlideDeck(Context context, MasterSecret masterSecret, PduBody body) {
  try {
    for (int i=0;i<body.getPartsNum();i++) {
      String contentType = new String(body.getPart(i).getContentType(), CharacterSets.MIMENAME_ISO_8859_1);
      if (ContentType.isImageType(contentType))
        slides.add(new ImageSlide(context, masterSecret, body.getPart(i)));
      else if (ContentType.isVideoType(contentType))
        slides.add(new VideoSlide(context, body.getPart(i)));
      else if (ContentType.isAudioType(contentType))
        slides.add(new AudioSlide(context, body.getPart(i)));
      else if (ContentType.isTextType(contentType))
        slides.add(new TextSlide(context, masterSecret, body.getPart(i)));
    }
  } catch (UnsupportedEncodingException uee) {
    throw new AssertionError(uee);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:SlideDeck.java

示例3: getText

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
@Override
public String getText() {
  try {
    SoftReference<String> reference = textCache.get(part.getDataUri());

    if (reference != null) {
      String cachedText = reference.get();

      if (cachedText != null) {
        return cachedText;
      }
    }


    String text = new String(getPartData(), CharacterSets.getMimeName(part.getCharset()));
    textCache.put(part.getDataUri(), new SoftReference<String>(text));

    return text;
  } catch (UnsupportedEncodingException uee) {
    Log.w("TextSlide", uee);
    return new String(getPartData());
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:24,代码来源:TextSlide.java

示例4: getPartForMessage

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
private static PduPart getPartForMessage(String message) {
  PduPart part = new PduPart();

  try {
    part.setData(message.getBytes(CharacterSets.MIMENAME_UTF_8));

    if (part.getData().length == 0)
      throw new AssertionError("Part data should not be zero!");
          
  } catch (UnsupportedEncodingException e) {
    Log.w("TextSlide", "ISO_8859_1 must be supported!", e);
    part.setData("Unsupported character set!".getBytes());
  }

  part.setCharset(CharacterSets.UTF_8);
  part.setContentType(ContentType.TEXT_PLAIN.getBytes());
  part.setContentId((System.currentTimeMillis()+"").getBytes());
  part.setName(("Text"+System.currentTimeMillis()).getBytes());
      
  return part;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:22,代码来源:TextSlide.java

示例5: SlideDeck

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public SlideDeck(Context context, MasterSecret masterSecret, PduBody body) {
  try {
    for (int i=0;i<body.getPartsNum();i++) {
      String contentType = new String(body.getPart(i).getContentType(), CharacterSets.MIMENAME_ISO_8859_1);
      if (ContentType.isImageType(contentType))
        slides.add(new ImageSlide(context, masterSecret, body.getPart(i)));
      else if (ContentType.isVideoType(contentType))
        slides.add(new VideoSlide(context, body.getPart(i)));
      else if (ContentType.isAudioType(contentType))
        slides.add(new AudioSlide(context, body.getPart(i)));
      else if (ContentType.isTextType(contentType))
        slides.add(new TextSlide(context, masterSecret, body.getPart(i)));
      else if (ContentType.isOtherType(contentType))
        slides.add(new OtherSlide(context, body.getPart(i)));
    }
  } catch (UnsupportedEncodingException uee) {
    throw new AssertionError(uee);
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:20,代码来源:SlideDeck.java

示例6: getText

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
@Override
public String getText() {
  try {
    SoftReference<String> reference = textCache.get(part.getDataUri());

    if (reference != null) {
      String cachedText = reference.get();

      if (cachedText != null) {
        return cachedText;
      }
    }


    String text = new String(getPartData(), CharacterSets.getMimeName(part.getCharset()));			
    textCache.put(part.getDataUri(), new SoftReference<String>(text));
	
    return text;
  } catch (UnsupportedEncodingException uee) {
    Log.w("TextSlide", uee);
    return new String(getPartData());
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:24,代码来源:TextSlide.java

示例7: SlideDeck

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public SlideDeck(Context context, MasterSecret masterSecret, PduBody body) {
  try {
    for (int i=0;i<body.getPartsNum();i++) {
      String contentType = new String(body.getPart(i).getContentType(), CharacterSets.MIMENAME_ISO_8859_1);
      if (ContentType.isImageType(contentType))
        slides.add(new ImageSlide(context, masterSecret, body.getPart(i)));
      else if (ContentType.isVideoType(contentType))
        slides.add(new VideoSlide(context, body.getPart(i)));
      else if (ContentType.isAudioType(contentType))
        slides.add(new AudioSlide(context, body.getPart(i)));
      else if (ContentType.isTextType(contentType))
        slides.add(new TextSlide(context, masterSecret, body.getPart(i)));
    }	
  } catch (UnsupportedEncodingException uee) {
    throw new AssertionError(uee);
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Text,代码行数:18,代码来源:SlideDeck.java

示例8: getBytes

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
private byte[] getBytes(String data) {
  try {
    return data.getBytes(CharacterSets.MIMENAME_ISO_8859_1);
  } catch (UnsupportedEncodingException e) {
    Log.e("PduHeadersBuilder", "ISO_8859_1 must be supported!", e);
    return new byte[0];
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:PduHeadersBuilder.java

示例9: getMessageText

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static String getMessageText(PduBody body) {
  String bodyText = null;

  for (int i=0;i<body.getPartsNum();i++) {
    if (ContentType.isTextType(Util.toIsoString(body.getPart(i).getContentType()))) {
      String partText;

      try {
        String characterSet = CharacterSets.getMimeName(body.getPart(i).getCharset());

        if (characterSet.equals(CharacterSets.MIMENAME_ANY_CHARSET))
          characterSet = CharacterSets.MIMENAME_ISO_8859_1;

        if (body.getPart(i).getData() != null) {
          partText = new String(body.getPart(i).getData(), characterSet);
        } else {
          partText = "";
        }
      } catch (UnsupportedEncodingException e) {
        Log.w("PartParser", e);
        partText = "Unsupported Encoding!";
      }

      bodyText = (bodyText == null) ? partText : bodyText + " " + partText;
    }
  }

  return bodyText;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:30,代码来源:PartParser.java

示例10: toIsoString

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static @NonNull String toIsoString(byte[] bytes) {
  try {
    return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError("ISO_8859_1 must be supported!");
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:Util.java

示例11: toIsoBytes

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static byte[] toIsoBytes(String isoString) {
  try {
    return isoString.getBytes(CharacterSets.MIMENAME_ISO_8859_1);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError("ISO_8859_1 must be supported!");
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:Util.java

示例12: toUtf8Bytes

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static byte[] toUtf8Bytes(String utf8String) {
  try {
    return utf8String.getBytes(CharacterSets.MIMENAME_UTF_8);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError("UTF_8 must be supported!");
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:Util.java

示例13: getThreadIdFor

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
private long getThreadIdFor(NotificationInd notification) throws RecipientFormattingException {
  try {
    EncodedStringValue encodedString = notification.getFrom();
    String fromString                = new String(encodedString.getTextString(), CharacterSets.MIMENAME_ISO_8859_1);
    Recipients recipients            = RecipientFactory.getRecipientsFromString(context, fromString, false);
    return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:11,代码来源:MmsDatabase.java

示例14: toIsoString

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
private String toIsoString(byte[] bytes) {
  try {
    return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
  } catch (UnsupportedEncodingException e) {
    Log.e("MmsDatabase", "ISO_8859_1 must be supported!", e);
    return "";
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:9,代码来源:MmsAddressDatabase.java

示例15: toIsoString

import ws.com.google.android.mms.pdu.CharacterSets; //导入依赖的package包/类
public static String toIsoString(byte[] bytes) {
  try {
    return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError("ISO_8859_1 must be supported!");
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:8,代码来源:Util.java


注:本文中的ws.com.google.android.mms.pdu.CharacterSets类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。