Java Code Examples for com.helger.commons.string.StringHelper#getImplodedNonEmpty()
The following examples show how to use
com.helger.commons.string.StringHelper#getImplodedNonEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLTransformerFactory.java From ph-commons with Apache License 2.0 | 6 votes |
/** * Set the secure processing feature to a {@link TransformerFactory}. See * https://docs.oracle.com/javase/tutorial/jaxp/properties/properties.html for * details. * * @param aFactory * The factory to secure. May not be <code>null</code>. * @param aAllowedExternalSchemes * Optional external URL schemes that are allowed to be accessed (as in * "file" or "http") * @since 9.1.2 */ public static void makeTransformerFactorySecure (@Nonnull final TransformerFactory aFactory, @Nullable final String... aAllowedExternalSchemes) { ValueEnforcer.notNull (aFactory, "Factory"); try { aFactory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); final String sCombinedSchemes = StringHelper.getImplodedNonEmpty (',', aAllowedExternalSchemes); if (sCombinedSchemes.length () > 0) { aFactory.setAttribute (XMLConstants.ACCESS_EXTERNAL_DTD, sCombinedSchemes); aFactory.setAttribute (XMLConstants.ACCESS_EXTERNAL_STYLESHEET, sCombinedSchemes); // external schema is unknown } } catch (final TransformerConfigurationException ex) { throw new InitializationException ("Failed to secure XML TransformerFactory", ex); } }
Example 2
Source File: PluginErrorListener.java From ph-schematron with Apache License 2.0 | 6 votes |
public static void logIError (@Nonnull final BuildContext aBuildContext, @Nonnull final File aSourceFile, @Nonnull final IError aResError) { final int nLine = aResError.getErrorLocation ().getLineNumber (); final int nColumn = aResError.getErrorLocation ().getColumnNumber (); final String sMessage = StringHelper.getImplodedNonEmpty (" - ", aResError.getErrorText (Locale.US), aResError.getLinkedExceptionMessage ()); // 0 means undefined line/column aBuildContext.addMessage (aSourceFile, nLine <= 0 ? 0 : nLine, nColumn <= 0 ? 0 : nColumn, sMessage, aResError.isError () ? BuildContext.SEVERITY_ERROR : BuildContext.SEVERITY_WARNING, aResError.getLinkedExceptionCause ()); }
Example 3
Source File: FileSystemFolderTree.java From ph-commons with Apache License 2.0 | 5 votes |
public FileSystemFolderTree (@Nonnull final File aStartDir, @Nullable final Predicate <? super File> aDirFilter, @Nullable final Predicate <? super File> aFileFilter) { super (x -> StringHelper.getImplodedNonEmpty ('/', x)); ValueEnforcer.notNull (aStartDir, "StartDirectory"); ValueEnforcer.isTrue (aStartDir.isDirectory (), "Start directory is not a directory!"); final DefaultFolderTreeItem <String, File, ICommonsList <File>> aStart = getRootItem ().createChildItem (aStartDir.getName (), new CommonsArrayList <> ()); _iterate (aStart, aStartDir, aDirFilter, aFileFilter); }
Example 4
Source File: IAggregatorTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testGetStringCombinatorWithSeparatorIgnoreEmptyChar () { final IAggregator <String, String> c = x -> StringHelper.getImplodedNonEmpty (',', x); assertEquals ("a,b", c.apply ("a", "b")); assertEquals ("a", c.apply ("a", null)); assertEquals ("b", c.apply (null, "b")); assertEquals ("", c.apply (null, null)); assertEquals ("", c.apply ("", "")); }
Example 5
Source File: IAggregatorTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testGetStringCombinatorWithSeparatorIgnoreEmptyString () { final IAggregator <String, String> c = x -> StringHelper.getImplodedNonEmpty (";", x); assertEquals ("a;b", c.apply ("a", "b")); assertEquals ("a", c.apply ("a", null)); assertEquals ("b", c.apply (null, "b")); assertEquals ("", c.apply (null, null)); assertEquals ("", c.apply ("", "")); }