/** * Increments the connection failure counter by one for the given address. * * @param address the address the connection failure counter should be increased */ private static void incrementConnectionFailures(String address) { Integer count = ADDRESS_BLACKLIST.lookup(address); ADDRESS_BLACKLIST.put(address, count == null ? 1 : count + 1); }
CACHE.put(cacheKey, keys);
throw new IllegalArgumentException("Not a valid combination of localpart, domainpart and resource"); JID_CACHE.put(jidString, jid); return jid;
/** * Perform localprep on the input String. * * @param string the input String. * @return the localpreped String. * @throws XmppStringprepException if the input String can not be transformed. */ public static String localprep(String string) throws XmppStringprepException { if (xmppStringprep == null) { return string; } // Avoid cache lookup if string is the empty string throwIfEmptyString(string); String res = NODEPREP_CACHE.lookup(string); if (res != null) { return res; } res = xmppStringprep.localprep(string); NODEPREP_CACHE.put(string, res); return res; }
/** * Perform domainprep on the input String. * * @param string the input String. * @return the domainprep String. * @throws XmppStringprepException if the input String can not be transformed. */ public static String domainprep(String string) throws XmppStringprepException { if (xmppStringprep == null) { return string; } // Avoid cache lookup if string is the empty string throwIfEmptyString(string); String res = DOMAINPREP_CACHE.lookup(string); if (res != null) { return res; } res = xmppStringprep.domainprep(string); DOMAINPREP_CACHE.put(string, res); return res; }
/** * Perform resourceprep on the input String. * * @param string the input String. * @return the resourceprep String. * @throws XmppStringprepException if the input String can not be transformed. */ public static String resourceprep(String string) throws XmppStringprepException { if (xmppStringprep == null) { return string; } // Avoid cache lookup if string is the empty string throwIfEmptyString(string); String res = RESOURCEPREP_CACHE.lookup(string); if (res != null) { return res; } res = xmppStringprep.resourceprep(string); RESOURCEPREP_CACHE.put(string, res); return res; }
/** * 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; }
/** * Get a {@link BareJid} 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 BareJid bareFrom(String jid) throws XmppStringprepException { BareJid bareJid = BAREJID_CACHE.lookup(jid); if (bareJid != null) { return bareJid; } String localpart = XmppStringUtils.parseLocalpart(jid); String domainpart = XmppStringUtils.parseDomain(jid); try { if (localpart.length() != 0) { bareJid = new LocalAndDomainpartJid(localpart, domainpart); } else { bareJid = new DomainpartJid(domainpart); } } catch (XmppStringprepException e) { throw new XmppStringprepException(jid, e); } BAREJID_CACHE.put(jid, bareJid); return bareJid; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
CACHE.put(cacheKey, keys);
ENTITYJID_CACHE.put(jidString, entityJid); return entityJid;