@Nonnull public static PModeAddressList createFromString (@Nullable final String sAddressString) { final ICommonsList <String> aAddresses = StringHelper.getExploded (ADDRESS_SEPARATOR, sAddressString); return new PModeAddressList (aAddresses); } }
@Nonnull public static AcceptLanguageList getAcceptLanguages (@Nullable final String sAcceptLanguage) { final AcceptLanguageList ret = new AcceptLanguageList (); if (StringHelper.hasNoText (sAcceptLanguage)) { // No definition - access all ret.addLanguage (ANY_LANGUAGE, QValue.MAX_QUALITY); } else { // Languages are separated by "," or ", " for (final String sItem : StringHelper.getExploded (',', sAcceptLanguage)) { // Qualities are separated by ";" final String [] aParts = StringHelper.getExplodedArray (';', sItem.trim (), 2); // Default quality is 1 double dQuality = QValue.MAX_QUALITY; if (aParts.length == 2 && aParts[1].trim ().startsWith ("q=")) dQuality = StringParser.parseDouble (aParts[1].trim ().substring (2), QValue.MAX_QUALITY); ret.addLanguage (aParts[0], dQuality); } } return ret; } }
/** * Set parameters from a string separated by delimiters. * * @param sFormat * Comma separated list of parameters to set, like * <code>msg.sender.as2_id,msg.receiver.as2_id,msg.header.content-type</code> * @param sDelimiters * delimiters in string to parse, like "-." * @param sValue * string to parse, like <code>"NORINCO-WALMART.application/X12"</code> * @throws OpenAS2Exception * In case the string is incorrect */ public void setParameters (@Nullable final String sFormat, @Nullable final String sDelimiters, @Nonnull final String sValue) throws OpenAS2Exception { final ICommonsList <String> aKeys = StringHelper.getExploded (',', sFormat); final StringTokenizer aValueTokens = new StringTokenizer (sValue, sDelimiters, false); for (final String sKey : aKeys) { if (!aValueTokens.hasMoreTokens ()) throw new OpenAS2Exception ("Invalid value: Format=" + sFormat + ", value=" + sValue); if (sKey.length () > 0) setParameter (sKey, aValueTokens.nextToken ()); } }
@Nonnull public static AcceptCharsetList getAcceptCharsets (@Nullable final String sAcceptCharset) { final AcceptCharsetList ret = new AcceptCharsetList (); if (StringHelper.hasNoText (sAcceptCharset)) { // No definition - access all ret.addCharset (ANY_CHARSET, QValue.MAX_QUALITY); } else { // Charsets are separated by "," or ", " for (final String sItem : StringHelper.getExploded (',', sAcceptCharset)) { // Qualities are separated by ";" final String [] aParts = StringHelper.getExplodedArray (';', sItem.trim (), 2); // Default quality is 1 double dQuality = QValue.MAX_QUALITY; if (aParts.length == 2 && aParts[1].trim ().startsWith ("q=")) dQuality = StringParser.parseDouble (aParts[1].trim ().substring (2), QValue.MAX_QUALITY); ret.addCharset (aParts[0], dQuality); } } return ret; } }
/** * Clean the provided path and split it into parts. * * @param sPath * Source path * @return The list with all path parts. Never <code>null</code>. */ @Nonnull @ReturnsMutableCopy public static ICommonsList <String> getCleanPathParts (@Nonnull final String sPath) { // Remove leading and trailing whitespaces and slashes String sRealPath = StringHelper.trimStartAndEnd (sPath.trim (), "/", "/"); // Remove obscure path parts sRealPath = FilenameHelper.getCleanPath (sRealPath); // Split into pieces final ICommonsList <String> aPathParts = StringHelper.getExploded ('/', sRealPath); return aPathParts; } }
for (final String sItem : StringHelper.getExploded (',', sAcceptEncoding))
/** * Create a new identifier from the URI representation. This is the inverse * operation of {@link IIdentifier#getURIEncoded()}. The URI part must have the * layout <code>scheme::value</code>. This method accepts all identifier schemes * and values. * * @param sURIPart * The URI part in the format <code>scheme::value</code>. It must NOT be * percent encoded! May be <code>null</code>. * @param aConverter * Converter function to be used. The first parameter is the scheme, the * second parameter is the value. May not be <code>null</code>. * @return The created {@link IIdentifier} instance or <code>null</code> if the * passed identifier is not a valid URI encoded identifier */ @Nullable default <T extends IIdentifier> T parseURIPartOrNull (@Nullable final String sURIPart, @Nonnull final BiFunction <String, String, T> aConverter) { if (sURIPart == null) return null; // This is quicker than splitting with RegEx! final ICommonsList <String> aSplitted = StringHelper.getExploded (CIdentifier.URL_SCHEME_VALUE_SEPARATOR, sURIPart, 2); if (aSplitted.size () != 2) return null; // Okay, we have exactly 2 parts -> create the identifier return aConverter.apply (aSplitted.get (0), aSplitted.get (1)); }
/** * Check if the passed identifier value is valid in the PEPPOL default * participant identifier scheme (iso6523-actorid-upis). * * @param sValue * The value to be validated. Must not be <code>null</code>. * @return <code>true</code> if the value is valid, <code>false</code> * otherwise. */ static boolean isValidValueWithDefaultScheme (@Nonnull final String sValue) { // Check if the separator between identifier issuing agency and value is // present - can only be done if the default scheme is present final ICommonsList <String> aParts = StringHelper.getExploded (':', sValue, 2); if (aParts.size () != 2) return false; final String sIdentifierIssuingAgencyID = aParts.get (0); if (sIdentifierIssuingAgencyID.length () != 4 || !StringParser.isUnsignedInt (sIdentifierIssuingAgencyID)) return false; final String sIdentifierValue = aParts.get (1).trim (); return sIdentifierValue.length () > 0; } }
/** * Extract the issuing agency ID from the passed participant identifier value. * <br> * Example: extract the <code>0088</code> from the participant identifier * <code>iso6523-actorid-upis::0088:123456</code><br> * Note: this only works for participant identifiers that are using the * default scheme (iso6523-actorid-upis) because for the other schemes, I just * can't tell! * * @return <code>null</code> if the identifier is not of default scheme or if * the identifier is malformed. */ @Nullable default String getIssuingAgencyID () { if (hasDefaultScheme ()) return StringHelper.getExploded (':', getValue (), 2).getAtIndex (0); return null; }
@Nonnull public static VESID parseID (@Nullable final String sVESID) { final ICommonsList <String> aParts = StringHelper.getExploded (ID_SEPARATOR, sVESID); final int nSize = aParts.size (); if (nSize >= 3 && nSize <= 4) return new VESID (aParts.get (0), aParts.get (1), aParts.get (2), nSize >= 4 ? aParts.get (3) : null); throw new IllegalArgumentException ("Invalid VESID '" + sVESID + "' provided!"); }
/** * Extract the local participant ID from the passed participant identifier * value.<br> * Example: extract the <code>123456</code> from the participant identifier * <code>iso6523-actorid-upis::0088:123456</code><br> * Note: this only works for participant identifiers that are using the * default scheme (iso6523-actorid-upis) because for the other schemes, I just * can't tell! * * @return <code>null</code> if the identifier is not of default scheme or if * the identifier is malformed. */ @Nullable default String getLocalParticipantID () { if (hasDefaultScheme ()) return StringHelper.getExploded (':', getValue (), 2).getAtIndex (1); return null; }
if (StringHelper.hasText (sMICAlgs)) final ICommonsList <String> aMICAlgs = StringHelper.getExploded (',', sMICAlgs.trim ()); for (final String sMICAlg : aMICAlgs)
@Nonnull protected PhotonRequestParameters getParametersFromPath (@Nonnull final String sPath, @Nonnull final IMenuTree aMenuTree) { // Use paths for standard menu items final PhotonRequestParameters ret = new PhotonRequestParameters (); for (final String sParamValue : StringHelper.getExploded ('/', StringHelper.trimStartAndEnd (sPath, "/"))) { if (!ret.hasLocale ()) if (ret.setLocaleFromString (GlobalLocaleManager.getInstance (), sParamValue) != null) continue; if (!ret.hasMenuItem ()) if (ret.setMenuItemFromString (aMenuTree, sParamValue) != null) continue; if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Ignoring superfluous parameter '" + sParamValue + "'"); } return ret; }
@Nonnull protected PhotonRequestParameters getParametersFromPath (@Nonnull final String sPath, @Nonnull final IMenuTree aMenuTree) { // Use paths for standard menu items final PhotonRequestParameters ret = new PhotonRequestParameters (); for (final String sPair : StringHelper.getExploded ('/', StringHelper.trimStartAndEnd (sPath, "/"))) { final ICommonsList <String> aElements = StringHelper.getExploded (m_sSeparator, sPair, 2); if (aElements.size () == 2) { final String sParamName = aElements.get (0); final String sParamValue = aElements.get (1); if (sParamName.equals (getRequestParamNameLocale ())) ret.setLocaleFromString (GlobalLocaleManager.getInstance (), sParamValue); else if (sParamName.equals (getRequestParamNameMenuItem ())) ret.setMenuItemFromString (aMenuTree, sParamValue); else if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Ignoring superfluous parameter '" + sParamName + "' with value '" + sParamValue + "'"); } } return ret; }
aParts.addAll (StringHelper.getExploded ('\n', sValue));
final ICommonsList <String> aMsgLines = StringHelper.getExploded (ENewLineMode.DEFAULT.getText (), formatMessage (aSessionLogEntry)); final int nMaxIndex = aMsgLines.size ();
final ICommonsList <String> aMain = StringHelper.getExploded (SUBTYPE_SEPARATOR, sDocTypeID, 2); final ICommonsList <String> aFirst = StringHelper.getExploded (NAMESPACE_SEPARATOR, aMain.get (0), 2); if (aFirst.size () < 2) throw new IllegalArgumentException ("The document identifier '" +
"js,css,png,jpg,jpeg,gif,eot,svg,ttf,woff,woff2,map"); for (final String sItem : StringHelper.getExploded (',', sRealItemList))
for (final String sCharCode : StringHelper.getExploded (',', sLine))
final ICommonsList <String> aParts = StringHelper.getExploded (CDATA_END, sText); final int nParts = aParts.size (); for (int i = 0; i < nParts; ++i)