Java Code Examples for com.helger.commons.io.file.FilenameHelper#getExtension()

The following examples show how to use com.helger.commons.io.file.FilenameHelper#getExtension() . 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: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableCopy
public ICommonsList <MimeTypeInfo> getAllInfosOfFilename (@Nullable final File aFile)
{
  if (aFile == null)
    return null;

  final String sExtension = FilenameHelper.getExtension (aFile);
  return getAllInfosOfExtension (sExtension);
}
 
Example 2
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableCopy
public ICommonsList <MimeTypeInfo> getAllInfosOfFilename (@Nullable final String sFilename)
{
  if (StringHelper.hasNoText (sFilename))
    return null;

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return getAllInfosOfExtension (sExtension);
}
 
Example 3
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get all mime types that are associated to the extension of the specified
 * filename.
 *
 * @param sFilename
 *        The filename to search. May neither be <code>null</code> nor empty.
 * @return Never <code>null</code> but maybe empty set if no mime type is
 *         associated with the extension of the passed filename.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <IMimeType> getAllMimeTypesForFilename (@Nonnull @Nonempty final String sFilename)
{
  ValueEnforcer.notEmpty (sFilename, "Filename");

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return getAllMimeTypesForExtension (sExtension);
}
 
Example 4
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get all mime types that are associated to the extension of the specified
 * filename.
 *
 * @param sFilename
 *        The filename to search. May neither be <code>null</code> nor empty.
 * @return Never <code>null</code> but maybe empty set if no mime type is
 *         associated with the extension of the passed filename.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <String> getAllMimeTypeStringsForFilename (@Nonnull @Nonempty final String sFilename)
{
  ValueEnforcer.notEmpty (sFilename, "Filename");

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return getAllMimeTypeStringsForExtension (sExtension);
}
 
Example 5
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Check if any mime type is registered for the extension of the specified
 * filename.
 *
 * @param sFilename
 *        The filename to search. May neither be <code>null</code> nor empty.
 * @return <code>true</code> if at least one mime type is associated with the
 *         extension of the passed filename, <code>false</code> otherwise.
 */
public boolean containsMimeTypeForFilename (@Nonnull @Nonempty final String sFilename)
{
  ValueEnforcer.notEmpty (sFilename, "Filename");

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return containsMimeTypeForExtension (sExtension);
}
 
Example 6
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Get the primary (=first) mime type associated with the specified filename.
 *
 * @param sFilename
 *        The filename to retrieve the primary mime type from. May neither be
 *        <code>null</code> nor empty.
 * @return <code>null</code> if no mime type is associated with the extension
 *         of the passed filename
 */
@Nullable
public IMimeType getPrimaryMimeTypeForFilename (@Nonnull @Nonempty final String sFilename)
{
  ValueEnforcer.notEmpty (sFilename, "Filename");

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return getPrimaryMimeTypeForExtension (sExtension);
}
 
Example 7
Source File: MimeTypeInfoManager.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Get the primary (=first) mime type associated with the specified filename.
 *
 * @param sFilename
 *        The filename to retrieve the primary mime type from. May neither be
 *        <code>null</code> nor empty.
 * @return <code>null</code> if no mime type is associated with the extension
 *         of the passed filename
 */
@Nullable
public String getPrimaryMimeTypeStringForFilename (@Nonnull @Nonempty final String sFilename)
{
  ValueEnforcer.notEmpty (sFilename, "Filename");

  final String sExtension = FilenameHelper.getExtension (sFilename);
  return getPrimaryMimeTypeStringForExtension (sExtension);
}