Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class FileTypeFilter
- Object
- FileTypeFilter
A named group of file types a file dialog offers, such as “PNG Image” or “Text Documents”.
A filter can name the same types three ways, and each platform reads the one it understands: desktop dialogs and the fallback chooser use the extensions, Android and the browser use the MIME types, and iOS and macOS use the Uniform Type Identifiers when given, deriving them from the extensions otherwise. Supplying extensions alone works everywhere.
FileTypeFilter png = new FileTypeFilter("PNG Image")
.extensions("png").mimeTypes("image/png").utTypes("public.png");
Constructors
public FileTypeFilter(String label) | Creates a filter with the label the dialog shows for it. |
Methods
public FileTypeFilter extensions(String... ext) | Adds file extensions, with or without the leading dot. |
public FileTypeFilter mimeTypes(String... types) | Adds MIME types such as "image/png" or "image/*". |
public FileTypeFilter utTypes(String... types) | Adds Apple Uniform Type Identifiers such as "public.png". |
public String getLabel() | The label the dialog shows. |
public String[] getExtensions() | The extensions, without leading dots. |
public String[] getMimeTypes() | The MIME types. |
public String[] getUtTypes() | The Uniform Type Identifiers. |
public boolean acceptsName(String name) | Checks whether a file name ends with one of this filter’s extensions. |
Inherited methods
Constructor details
FileTypeFilter
public FileTypeFilter(String label)Creates a filter with the label the dialog shows for it.
Parameters
labelString- the human readable name of the filter
Method details
extensions
public FileTypeFilter extensions(String... ext)Adds file extensions, with or without the leading dot.
Parameters
extString...- extensions such as
"png"or".jpg"
Returns
this filter
mimeTypes
public FileTypeFilter mimeTypes(String... types)Adds MIME types such as
"image/png" or "image/*".Parameters
typesString...- the MIME types
Returns
this filter
utTypes
public FileTypeFilter utTypes(String... types)Adds Apple Uniform Type Identifiers such as
"public.png". Ignored
outside iOS and macOS.Parameters
typesString...- the type identifiers
Returns
this filter
getLabel
public String getLabel()The label the dialog shows.
Returns
the label
getExtensions
public String[] getExtensions()The extensions, without leading dots.
Returns
a copy of the extension list
getMimeTypes
public String[] getMimeTypes()The MIME types.
Returns
a copy of the MIME type list
getUtTypes
public String[] getUtTypes()The Uniform Type Identifiers.
Returns
a copy of the identifier list
acceptsName
public boolean acceptsName(String name)Checks whether a file name ends with one of this filter’s extensions.
A filter without extensions accepts every name.
Parameters
nameString- the file name or path
Returns
true if the name matches