Ejemplo n.º 1
0
  private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
    int begin = recipient.indexOf('<');
    int end = recipient.indexOf('>', begin);
    String value = recipient.substring(begin + 1, end);

    if (NumberUtil.isValidSmsOrEmail(value)) return value;
    else throw new RecipientFormattingException("Bracketed value: " + value + " is not valid.");
  }
Ejemplo n.º 2
0
  private static Recipient parseRecipient(Context context, String recipient, boolean asynchronous)
      throws RecipientFormattingException {
    recipient = recipient.trim();

    if (recipient.length() == 0) return null;

    if (hasBracketedNumber(recipient))
      return getRecipientForNumber(context, parseBracketedNumber(recipient), asynchronous);

    if (NumberUtil.isValidSmsOrEmail(recipient))
      return getRecipientForNumber(context, recipient, asynchronous);

    throw new RecipientFormattingException("Recipient: " + recipient + " is badly formatted.");
  }