gpt4 book ai didi

org.jxmpp.stringprep.XmppStringprepException.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 22:17:05 28 4
gpt4 key购买 nike

本文整理了Java中org.jxmpp.stringprep.XmppStringprepException.<init>()方法的一些代码示例,展示了XmppStringprepException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmppStringprepException.<init>()方法的具体详情如下:
包路径:org.jxmpp.stringprep.XmppStringprepException
类名称:XmppStringprepException
方法名:<init>

XmppStringprepException.<init>介绍

[英]Construct a new XMPP Stringprep exception with the given causing String and exception.
[中]用给定的引发字符串和异常构造一个新的XMPP Stringprep异常。

代码示例

代码示例来源:origin: org.jxmpp/jxmpp-jid

protected static void assertNotLongerThan1023BytesOrEmpty(String string) throws XmppStringprepException {
  char[] bytes = string.toCharArray();
  // Better throw XmppStringprepException instead of IllegalArgumentException here, because users don't expect an
  // IAE and it also makes the error handling for users easier.
  if (bytes.length > 1023) {
    throw new XmppStringprepException(string, "Given string is longer then 1023 bytes");
  } else if (bytes.length == 0) {
    throw new XmppStringprepException(string, "Argument can't be the empty string");
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-core

/**
   * Throws a XMPP Stringprep exception if string is the empty string.
   *
   * @param string
   * @throws XmppStringprepException
   */
  private static void throwIfEmptyString(String string) throws XmppStringprepException {
    // TODO replace with string.isEmpty() once Smack's min Android SDK level is > 8
    if (string.length() == 0) {
      throw new XmppStringprepException(string, "Argument can't be the empty string");
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
public String domainprep(String string) throws XmppStringprepException {
  try {
    // Don't allow unassigned because this is a "stored string". See
    // RFC3453 7, RFC3490 4 1) and RFC6122 2.2
    return Stringprep.nameprep(string);
  } catch (StringprepException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-core

@Override
public String localprep(String string) throws XmppStringprepException {
  string = simpleStringprep(string);
  for (char charFromString : string.toCharArray()) {
    for (char forbiddenChar : LOCALPART_FURTHER_EXCLUDED_CHARACTERS) {
      if (charFromString == forbiddenChar) {
        throw new XmppStringprepException(string, "Localpart must not contain '" + forbiddenChar + "'");
      }
    }
  }
  return string;
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
public String localprep(String string) throws XmppStringprepException {
  try {
    // Allow unassigned codepoints as of RFC6122 A.2
    return Stringprep.nodeprep(string, true);
  } catch (StringprepException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
  public String resourceprep(String string) throws XmppStringprepException {
    try {
      return RESOURCEPREP.prepare(string, StringPrep.DEFAULT);
    } catch (StringPrepParseException e) {
      throw new XmppStringprepException(string, e);
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
  public String resourceprep(String string) throws XmppStringprepException {
    try {
      // Allow unassigned codepoints as of RFC6122 B.2
      return Stringprep.resourceprep(string, true);
    } catch (StringprepException e) {
      throw new XmppStringprepException(string, e);
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
public String localprep(String string) throws XmppStringprepException {
  try {
    return NODEPREP.prepare(string, StringPrep.DEFAULT);
  } catch (StringPrepParseException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
public String domainprep(String string) throws XmppStringprepException {
  try {
    return DOMAINPREP.prepare(string, StringPrep.DEFAULT);
  } catch (StringPrepParseException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityFullJid} constructed from the given parts.
 *
 * @param localpart a localpart.
 * @param domainpart a domainpart.
 * @param resource a resourcepart.
 * @return a full JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityFullJid entityFullFrom(String localpart, String domainpart, String resource) throws XmppStringprepException {
  EntityFullJid fullJid;
  try {
    fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(localpart + '@' + domainpart + '/' + resource, e);
  }
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link FullJid} constructed from the given parts.
 *
 * @param localpart a optional localpart.
 * @param domainpart a domainpart.
 * @param resource a resourcepart.
 * @return a full JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static FullJid fullFrom(String localpart, String domainpart, String resource) throws XmppStringprepException {
  FullJid fullJid;
  try {
    if (localpart == null || localpart.length() == 0) {
      fullJid = new DomainAndResourcepartJid(domainpart, resource);
    } else {
      fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
    }
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(localpart + '@' + domainpart + '/' + resource, e);
  }
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link Jid} from the given String.
 *
 * @param jidString the input String.
 * @return the Jid represented by the input String.
 * @throws XmppStringprepException if an error occurs.
 * @see #from(CharSequence)
 */
public static Jid from(String jidString) throws XmppStringprepException {
  String localpart = XmppStringUtils.parseLocalpart(jidString);
  String domainpart = XmppStringUtils.parseDomain(jidString);
  String resource = XmppStringUtils.parseResource(jidString);
  try {
    return from(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jidString, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a domain bare JID.
 *
 * @param jid the JID String.
 * @return a domain bare JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static DomainBareJid domainBareFrom(String jid) throws XmppStringprepException {
  DomainBareJid domainJid = DOMAINJID_CACHE.lookup(jid);
  if (domainJid != null) {
    return domainJid;
  }
  String domain = XmppStringUtils.parseDomain(jid);
  try {
    domainJid = new DomainpartJid(domain);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jid, e);
  }
  DOMAINJID_CACHE.put(jid, domainJid);
  return domainJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link Jid} from the given unescaped String.
 *
 * @param unescapedJidString a unescaped String representing a JID.
 * @return a JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static Jid fromUnescaped(String unescapedJidString) throws XmppStringprepException {
  String localpart = XmppStringUtils.parseLocalpart(unescapedJidString);
  // Some as from(String), but we escape the localpart
  localpart = XmppStringUtils.escapeLocalpart(localpart);
  String domainpart = XmppStringUtils.parseDomain(unescapedJidString);
  String resource = XmppStringUtils.parseResource(unescapedJidString);
  try {
    return from(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(unescapedJidString, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a domain full JID from the given String.
 *
 * @param jid the JID.
 * @return a DomainFullJid.
 * @throws XmppStringprepException if an error happens.
 */
public static DomainFullJid domainFullFrom(String jid) throws XmppStringprepException {
  DomainFullJid domainResourceJid = DOMAINRESOURCEJID_CACHE.lookup(jid);
  if (domainResourceJid != null) {
    return domainResourceJid;
  }
  String domain = XmppStringUtils.parseDomain(jid);
  String resource = XmppStringUtils.parseResource(jid);
  try {
    domainResourceJid = new DomainAndResourcepartJid(domain, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jid, e);
  }
  DOMAINRESOURCEJID_CACHE.put(jid, domainResourceJid);
  return domainResourceJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityBareJid} representing the given String.
 *
 * @param jid the input String.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFrom(String jid) throws XmppStringprepException {
  EntityBareJid bareJid = ENTITY_BAREJID_CACHE.lookup(jid);
  if (bareJid != null) {
    return bareJid;
  }
  String localpart = XmppStringUtils.parseLocalpart(jid);
  String domainpart = XmppStringUtils.parseDomain(jid);
  try {
    bareJid = new LocalAndDomainpartJid(localpart, domainpart);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jid, e);
  }
  ENTITY_BAREJID_CACHE.put(jid, bareJid);
  return bareJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link FullJid} representing the given String.
 *
 * @param jid the JID's String.
 * @return a full JID representing the input String.
 * @throws XmppStringprepException if an error occurs.
 */
public static FullJid fullFrom(String jid) throws XmppStringprepException {
  FullJid fullJid = FULLJID_CACHE.lookup(jid);
  if (fullJid != null) {
    return fullJid;
  }
  String localpart = XmppStringUtils.parseLocalpart(jid);
  String domainpart = XmppStringUtils.parseDomain(jid);
  String resource = XmppStringUtils.parseResource(jid);
  try {
    fullJid = fullFrom(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jid, e);
  }
  FULLJID_CACHE.put(jid, fullJid);
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityFullJid} representing the given String.
 *
 * @param jid the JID's String.
 * @return a full JID representing the input String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityFullJid entityFullFrom(String jid) throws XmppStringprepException {
  EntityFullJid fullJid = ENTITY_FULLJID_CACHE.lookup(jid);
  if (fullJid != null) {
    return fullJid;
  }
  String localpart = XmppStringUtils.parseLocalpart(jid);
  String domainpart = XmppStringUtils.parseDomain(jid);
  String resource = XmppStringUtils.parseResource(jid);
  try {
    fullJid = entityFullFrom(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jid, e);
  }
  ENTITY_FULLJID_CACHE.put(jid, fullJid);
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityBareJid} representing the given unescaped String.
 *
 * @param unescapedJidString the input String.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFromUnescaped(String unescapedJidString) throws XmppStringprepException {
  EntityBareJid bareJid = ENTITY_BAREJID_CACHE.lookup(unescapedJidString);
  if (bareJid != null) {
    return bareJid;
  }
  String localpart = XmppStringUtils.parseLocalpart(unescapedJidString);
  // Some as from(String), but we escape the localpart
  localpart = XmppStringUtils.escapeLocalpart(localpart);
  String domainpart = XmppStringUtils.parseDomain(unescapedJidString);
  try {
    bareJid = new LocalAndDomainpartJid(localpart, domainpart);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(unescapedJidString, e);
  }
  ENTITY_BAREJID_CACHE.put(unescapedJidString, bareJid);
  return bareJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityFullJid} representing the given unescaped String.
 *
 * @param unescapedJidString the JID's String.
 * @return a full JID representing the input String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityFullJid entityFullFromUnescaped(String unescapedJidString) throws XmppStringprepException {
  EntityFullJid fullJid = ENTITY_FULLJID_CACHE.lookup(unescapedJidString);
  if (fullJid != null) {
    return fullJid;
  }
  String localpart = XmppStringUtils.parseLocalpart(unescapedJidString);
  // Some as from(String), but we escape the localpart
  localpart = XmppStringUtils.escapeLocalpart(localpart);
  String domainpart = XmppStringUtils.parseDomain(unescapedJidString);
  String resource = XmppStringUtils.parseResource(unescapedJidString);
  try {
    fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(unescapedJidString, e);
  }
  ENTITY_FULLJID_CACHE.put(unescapedJidString, fullJid);
  return fullJid;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com