Java Code Examples for com.helger.commons.string.StringHelper#startsWith()

The following examples show how to use com.helger.commons.string.StringHelper#startsWith() . 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: FilenameHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Concatenate a base URL and a sub path incl. the path cleansing. More or
 * less the same as calling <code>getCleanPath (sURL + "/" + sPath)</code>
 *
 * @param sURL
 *        The base URL. May not be <code>null</code>.
 * @param sPath
 *        The path to append. May not be <code>null</code>.
 * @return The combined, cleaned path.
 * @see #getCleanPath(String)
 */
@Nonnull
public static String getCleanConcatenatedUrlPath (@Nonnull final String sURL, @Nonnull final String sPath)
{
  ValueEnforcer.notNull (sURL, "URL");
  ValueEnforcer.notNull (sPath, "Path");

  // If nothing is to be appended, just clean the base URL
  if (StringHelper.hasNoText (sPath))
    return getCleanPath (sURL);

  final String sRealURL = StringHelper.endsWith (sURL, UNIX_SEPARATOR) ? sURL : sURL + UNIX_SEPARATOR;
  final String sRealPath = StringHelper.startsWith (sPath, UNIX_SEPARATOR) ? sPath.substring (1) : sPath;
  return getCleanPath (sRealURL + sRealPath);
}
 
Example 2
Source File: DefaultResourceResolver.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public static boolean isExplicitJarFileResource (@Nullable final String sName)
{
  // jar:file - regular JDK
  // wsjar:file - Websphere
  return StringHelper.startsWith (sName, "jar:file:") ||
         StringHelper.startsWith (sName, "wsjar:file:") ||
         StringHelper.startsWith (sName, "zip:file:");
}
 
Example 3
Source File: CSSViewportRule.java    From ph-css with Apache License 2.0 4 votes vote down vote up
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration)
{
  return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "viewport");
}
 
Example 4
Source File: CSSFontFaceRule.java    From ph-css with Apache License 2.0 4 votes vote down vote up
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration)
{
  return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "font-face");
}
 
Example 5
Source File: CSSKeyframesRule.java    From ph-css with Apache License 2.0 4 votes vote down vote up
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration)
{
  return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "keyframes");
}
 
Example 6
Source File: CSSUnknownRule.java    From ph-css with Apache License 2.0 4 votes vote down vote up
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration)
{
  return StringHelper.startsWith (sDeclaration, '@');
}
 
Example 7
Source File: ClassPathResource.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Remove any leading explicit classpath resource prefixes.
 *
 * @param sPath
 *        The source path to strip the class path prefixes from. May be
 *        <code>null</code>.
 * @return <code>null</code> if the parameter was <code>null</code>.
 * @see #CLASSPATH_PREFIX_LONG
 * @see #CLASSPATH_PREFIX_SHORT
 */
@Nullable
public static String getWithoutClassPathPrefix (@Nullable final String sPath)
{
  if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_LONG))
    return sPath.substring (CLASSPATH_PREFIX_LONG.length ());
  if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_SHORT))
    return sPath.substring (CLASSPATH_PREFIX_SHORT.length ());
  return sPath;
}
 
Example 8
Source File: ScopeManager.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Check if the passed attribute name is an internal attribute.
 *
 * @param sAttributeName
 *        The name of the attribute to check. May be <code>null</code>.
 * @return <code>true</code> if the passed attribute name is not
 *         <code>null</code> and starts with the
 *         {@link #SCOPE_ATTRIBUTE_PREFIX_INTERNAL} prefix.
 */
public static boolean isInternalAttribute (@Nullable final String sAttributeName)
{
  return StringHelper.startsWith (sAttributeName, SCOPE_ATTRIBUTE_PREFIX_INTERNAL);
}
 
Example 9
Source File: ClassPathResource.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Check if the passed resource name is an explicit classpath resource. This
 * is the case, if the name starts either with {@link #CLASSPATH_PREFIX_LONG}
 * or {@link #CLASSPATH_PREFIX_SHORT}.
 *
 * @param sName
 *        The name to check. May be <code>null</code>.
 * @return <code>true</code> if the passed name is not <code>null</code> and
 *         an explicit classpath resource.
 */
public static boolean isExplicitClassPathResource (@Nullable final String sName)
{
  return StringHelper.startsWith (sName, CLASSPATH_PREFIX_LONG) ||
         StringHelper.startsWith (sName, CLASSPATH_PREFIX_SHORT);
}