/** * Take a concatenated String and return a sorted {@link TreeSet} of all * elements in the passed string, using specified separator string. * * @param sSep * The separator to use. May not be <code>null</code>. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The sorted {@link Set} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static SortedSet <String> getExplodedToSortedSet (@Nonnull final String sSep, @Nullable final String sElements) { return getExploded (sSep, sElements, -1, new TreeSet <String> ()); }
/** * Take a concatenated String and return a {@link List} of all elements in the * passed string, using specified separator string. * * @param cSep * The separator character to use. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The {@link List} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static List <String> getExploded (final char cSep, @Nullable final String sElements) { return getExploded (cSep, sElements, -1); }
/** * Take a concatenated String and return a {@link List} of all elements in the * passed string, using specified separator string. * * @param sSep * The separator to use. May not be <code>null</code>. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The {@link List} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static List <String> getExploded (@Nonnull final String sSep, @Nullable final String sElements) { return getExploded (sSep, sElements, -1); }
/** * Take a concatenated String and return an ordered {@link LinkedHashSet} of * all elements in the passed string, using specified separator string. * * @param sSep * The separator to use. May not be <code>null</code>. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The ordered {@link Set} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static Set <String> getExplodedToOrderedSet (@Nonnull final String sSep, @Nullable final String sElements) { return getExploded (sSep, sElements, -1, new LinkedHashSet <String> ()); }
public Enum <?> convert (@Nonnull final Object aSource) { // Split class name and enum value name final List <String> aParts = StringHelper.getExploded (':', (String) aSource, 2); try { // Resolve any enum class // Note: The explicit EChange is just here, because an explicit enum // type is needed. It must of course not only be EChange :) final Class <EChange> aClass = GenericReflection.getClassFromName (aParts.get (0)); // And look up the element by name return Enum.valueOf (aClass, aParts.get (1)); } catch (final ClassNotFoundException ex) { return null; } } });
/** * Take a concatenated String and return a {@link Set} of all elements in the * passed string, using specified separator string. * * @param sSep * The separator to use. May not be <code>null</code>. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The {@link Set} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static Set <String> getExplodedToSet (@Nonnull final String sSep, @Nullable final String sElements) { return getExploded (sSep, sElements, -1, new HashSet <String> ()); }
/** * @return A non-<code>null</code> list of all directories and files currently * in the class path. */ @Nonnull public static List <String> getAllClassPathEntries () { return StringHelper.getExploded (SystemProperties.getPathSeparator (), SystemProperties.getJavaClassPath ()); }
/** * Take a concatenated String and return a {@link List} of all elements in the * passed string, using specified separator string. * * @param sSep * The separator to use. May not be <code>null</code>. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @param nMaxItems * The maximum number of items to explode. If the passed value is <= 0 * all items are used. If max items is 1, than the result string is * returned as is. If max items is larger than the number of elements * found, it has no effect. * @return The {@link List} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static List <String> getExploded (@Nonnull final String sSep, @Nullable final String sElements, final int nMaxItems) { return getExploded (sSep, sElements, nMaxItems, nMaxItems >= 1 ? new ArrayList <String> (nMaxItems) : new ArrayList <String> ()); }
/** * Take a concatenated String and return a {@link List} of all elements in the * passed string, using specified separator string. * * @param cSep * The separator character to use. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @param nMaxItems * The maximum number of items to explode. If the passed value is <= 0 * all items are used. If max items is 1, than the result string is * returned as is. If max items is larger than the number of elements * found, it has no effect. * @return The {@link List} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static List <String> getExploded (final char cSep, @Nullable final String sElements, final int nMaxItems) { return getExploded (cSep, sElements, nMaxItems, nMaxItems >= 1 ? new ArrayList <String> (nMaxItems) : new ArrayList <String> ()); }
@Nonnull @ReturnsMutableCopy private static Map <String, String> _getQueryStringAsMap (@Nullable final String sQueryString, @Nonnull final IDecoder <String> aParameterDecoder) { final Map <String, String> aMap = new LinkedHashMap <String, String> (); if (StringHelper.hasText (sQueryString)) { for (final String sKeyValuePair : StringHelper.getExploded (AMPERSAND, sQueryString)) if (sKeyValuePair.length () > 0) { final List <String> aParts = StringHelper.getExploded (EQUALS, sKeyValuePair, 2); final String sKey = aParts.get (0); // Maybe empty when passing something like "url?=value" if (StringHelper.hasText (sKey)) { final String sValue = aParts.size () == 2 ? aParts.get (1) : ""; if (sValue == null) throw new NullPointerException ("parameter value may not be null"); // Now decode the name and the value aMap.put (aParameterDecoder.decode (sKey), aParameterDecoder.decode (sValue)); } } } return aMap; }
for (final String sPart : StringHelper.getExploded (',', sLayout))
final List <String> aMsgLines = StringHelper.getExploded (CGlobal.LINE_SEPARATOR, formatMessage (aSessionLogEntry)); final int nMaxIndex = aMsgLines.size (); for (int i = 0; i < nMaxIndex; ++i)
return getExploded (sSep.charAt (0), sElements, nMaxItems, aCollection);
aParts.addAll (StringHelper.getExploded ('\n', sValue));
for (final String sLine : StringHelper.getExploded ("\n", m_sHeaderText)) aWriter.write (" * " + sLine + "\n"); aWriter.write (" */\n"); for (final String sLine : StringHelper.getExploded ("\n", m_sFooterText)) aWriter.write (" * " + sLine + "\n"); aWriter.write (" */\n");
for (final String sLine : StringHelper.getExploded ("\n", m_sHeaderText)) aWriter.write (" * " + sLine + "\n"); aWriter.write (" */\n"); for (final String sLine : StringHelper.getExploded ("\n", m_sFooterText)) aWriter.write (" * " + sLine + "\n"); aWriter.write (" */\n");
@Override public void onCDATA (@Nullable final String sText) { if (StringHelper.hasText (sText)) { if (sText.indexOf (CDATA_END) >= 0) { // Split CDATA sections if they contain the illegal "]]>" marker final List <String> aParts = StringHelper.getExploded (CDATA_END, sText); final int nParts = aParts.size (); for (int i = 0; i < nParts; ++i) { _append (CDATA_START); if (i > 0) _append ('>'); _appendMasked (EXMLCharMode.CDATA, aParts.get (i)); if (i < nParts - 1) _append ("]]"); _append (CDATA_END); } } else { // No special handling required _append (CDATA_START)._appendMasked (EXMLCharMode.CDATA, sText)._append (CDATA_END); } } }
for (final String sPart : StringHelper.getExploded (SystemProperties.getPathSeparator (), sDir))