org.kde.koala

Class KFileMetaInfo

public class KFileMetaInfo extends Object implements QtSupport

UNKNOWN: Meta Information about a file This is the class for objects that hold meta information about a file. The information is kept in form of a system of key/value pairs. See also KFileMetaInfoItem. This information is retrieved from the file through a plugin system, and this class is the main interface to it. If you want to write your own plugin, have a look at KFilePlugin. There are basically two different kinds of meta information: Fixed ones that the plugin knows about (e.g. an mp3 id3v1 tag has a well defined fixed list of fields), and variable keys that exist in mimetypes that support their own key/value system (comments in png files are of this type). Almost every file has fixed keys, but some also have variable keys. The groups and the What enum are not yet supported, but already added to the interface so that adding support doesn't break compatibility. @brief Meta Information about a file

Field Summary
static intContentInfo
static intDontCare
static intEverything
static intExtenedAttr
static intFastest
This is used to specify what a KFileMetaInfo object should read, so you can specify if you want to read "expensive" items or not.
static intPreferred
static intTechnicalInfo
static intThumbnail
Constructor Summary
protected KFileMetaInfo(Class dummy)
KFileMetaInfo(String path, String mimeType, int what)
The constructor. creating a KFileMetaInfo item through this will autoload the plugin belonging to the mimetype and try to get meta information about the specified file.
KFileMetaInfo(String path, String mimeType)
KFileMetaInfo(String path)
KFileMetaInfo(KURL url, String mimeType, int what)
Another constructor Similar to the above, but takes a URL so that meta-data may be retrieved over other protocols (ftp, etc.)
KFileMetaInfo(KURL url, String mimeType)
KFileMetaInfo(KURL url)
KFileMetaInfo()
Default constructor.
KFileMetaInfo(KFileMetaInfo original)
Copy constructor.
Method Summary
booleanaddGroup(String name)
Try to add the specified group.
protected KFileMetaInfoGroupappendGroup(String name)
booleanapplyChanges()
This method writes all pending changes of the meta info back to the file.
booleancontains(String key)
Checks whether an item with the given key exists.
booleancontainsGroup(String key)
Checks whether a group with the given key exists.
protected voidderef()
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
ArrayListeditableGroups()
Returns the list of groups that you can add or remove from the file.
protected voidfinalize()
Deletes the wrapped C++ instance
KFileMetaInfoGroupgroup(String key)
Returns the KFileMetaInfoGroup with the given key.
ArrayListgroups()
Returns a list of all groups.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisEmpty()
Returns false if the object contains data, true if it's empty.
booleanisValid()
Returns true if the item is valid, i.e. if actually represents the info about a file, false if the object is uninitialized.
KFileMetaInfoItemitem(String key)
Returns the KFileMetaInfoItem with the given key.
StringmimeType()
Returns the mime type of file.
KFileMetaInfoGroupop_at(String key)
Returns the KFileMetaInfoGroup with the given key.
Stringpath()
Returns the path of file - or null if file is non-local
ArrayListpreferredGroups()
Returns a list of the preferred groups.
ArrayListpreferredKeys()
Returns a list of all preferred keys.
protected voidref()
ArrayListremovedGroups()
Returns a list of removed groups.
booleanremoveGroup(String name)
Remove the specified group.
KFileMetaInfoItemsaveItem(String key, String preferredGroup, boolean createGroup)
Saves the item with the given key.
KFileMetaInfoItemsaveItem(String key, String preferredGroup)
KFileMetaInfoItemsaveItem(String key)
ArrayListsupportedGroups()
Returns a list of all supported groups.
ArrayListsupportedKeys()
Returns a list of supported keys.
KURLurl()
Returns the url of file
QVariantvalue(String key)
Returns the value with the given key.

Field Detail

ContentInfo

public static final int ContentInfo

DontCare

public static final int DontCare

Everything

public static final int Everything

ExtenedAttr

public static final int ExtenedAttr

Fastest

public static final int Fastest
This is used to specify what a KFileMetaInfo object should read, so you can specify if you want to read "expensive" items or not.

UNKNOWN: This is used to specify what a KFileMetaInfo object should read, so you can specify if you want to read "expensive" items or not.

Preferred

public static final int Preferred

TechnicalInfo

public static final int TechnicalInfo

Thumbnail

public static final int Thumbnail

Constructor Detail

KFileMetaInfo

protected KFileMetaInfo(Class dummy)

KFileMetaInfo

public KFileMetaInfo(String path, String mimeType, int what)
The constructor. creating a KFileMetaInfo item through this will autoload the plugin belonging to the mimetype and try to get meta information about the specified file. If no info is available, you'll get an empty (not invalid) object. You can test for it with the isEmpty() method.

Parameters: path The file name. This must be the path to a local file. mimeType The name of the file's mimetype. If ommited, the mimetype is autodetected what one or more of the What enum values. It gives some hint to the plugin what information is desired. The plugin may still return more items.

UNKNOWN: This version will nly work for ocal (file:/) files. The constructor.

KFileMetaInfo

public KFileMetaInfo(String path, String mimeType)

KFileMetaInfo

public KFileMetaInfo(String path)

KFileMetaInfo

public KFileMetaInfo(KURL url, String mimeType, int what)
Another constructor Similar to the above, but takes a URL so that meta-data may be retrieved over other protocols (ftp, etc.)

UNKNOWN: Another constructor

KFileMetaInfo

public KFileMetaInfo(KURL url, String mimeType)

KFileMetaInfo

public KFileMetaInfo(KURL url)

KFileMetaInfo

public KFileMetaInfo()
Default constructor. This will create an invalid object (see isValid().

UNKNOWN: Default constructor.

KFileMetaInfo

public KFileMetaInfo(KFileMetaInfo original)
Copy constructor. This creates a copy of the original object, but that copy will point to the same data, so if you change the original, the copy will be changed, too. After all, they are referring to the same file.

UNKNOWN: Copy constructor.

Method Detail

addGroup

public boolean addGroup(String name)
Try to add the specified group. This will only succeed if it is in the list of editableGroups().

Parameters: name the name of the group to add

Returns: true if successful, false if not

UNKNOWN: that all non-variable items that belong to this group are automatically added as empty item. Try to add the specified group.

appendGroup

protected KFileMetaInfoGroup appendGroup(String name)

applyChanges

public boolean applyChanges()
This method writes all pending changes of the meta info back to the file. If any items are marked as removed, they are really removed from the list. The info object as well as all items are updated.

Returns: true if successful, false if not

UNKNOWN: This method writes all pending changes of the meta info back to the file.

contains

public boolean contains(String key)
Checks whether an item with the given key exists.

Parameters: key the key to check

Returns: whether an item for this key exists.

UNKNOWN: Checks whether an item with the given key exists.

containsGroup

public boolean containsGroup(String key)
Checks whether a group with the given key exists.

Parameters: key the key to check

Returns: whether a group with this name exists.

UNKNOWN: Checks whether a group with the given key exists.

deref

protected void deref()

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

editableGroups

public ArrayList editableGroups()
Returns the list of groups that you can add or remove from the file.

Returns: the groups can be added or removed

UNKNOWN: Returns the list of groups that you can add or remove from the file.

finalize

protected void finalize()
Deletes the wrapped C++ instance

group

public KFileMetaInfoGroup group(String key)
Returns the KFileMetaInfoGroup with the given key.

Parameters: key the key of the item

Returns: the group. Invalid if there is no group with the given key.

UNKNOWN: Returns the KFileMetaInfoGroup with the given key.

groups

public ArrayList groups()
Returns a list of all groups.

Returns: the keys of the groups that the file has.

UNKNOWN: Returns a list of all groups.

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

isEmpty

public boolean isEmpty()
Returns false if the object contains data, true if it's empty. You'll get an empty object if no plugin for the file could be found.

Returns: true if empty, false otherwise

UNKNOWN: Returns false if the object contains data, true if it's empty.

isValid

public boolean isValid()
Returns true if the item is valid, i.e. if actually represents the info about a file, false if the object is uninitialized.

Returns: true if valid, false otherwise

UNKNOWN: Returns true if the item is valid, i.

item

public KFileMetaInfoItem item(String key)
Returns the KFileMetaInfoItem with the given key.

Parameters: key the key of the item

Returns: the item. Invalid if there is no item with the given key.

UNKNOWN: Returns the KFileMetaInfoItem with the given key.

mimeType

public String mimeType()
Returns the mime type of file.

Returns: the file's mime type

UNKNOWN: Returns the mime type of file.

op_at

public KFileMetaInfoGroup op_at(String key)
Returns the KFileMetaInfoGroup with the given key.

Parameters: key the key of the item

Returns: the group. Invalid if there is no group with the given key.

UNKNOWN: Returns the KFileMetaInfoGroup with the given key.

path

public String path()
Returns the path of file - or null if file is non-local

Returns: the file's path - or null if file is non-local

UNKNOWN: Returns the path of file - or String.null if file is non-local

preferredGroups

public ArrayList preferredGroups()
Returns a list of the preferred groups.

Returns: the keys of the preferred groups that the file has.

UNKNOWN: Returns a list of the preferred groups.

preferredKeys

public ArrayList preferredKeys()
Returns a list of all preferred keys.

Returns: a list of all preferred keys.

UNKNOWN: Returns a list of all preferred keys.

ref

protected void ref()

Returns: a pointer to the plugin that belogs to this object's mimetype. It will be auto-loaded if it's currently not loaded

UNKNOWN:

removedGroups

public ArrayList removedGroups()
Returns a list of removed groups.

Returns: a list of removed groups.

UNKNOWN: Returns a list of removed groups.

removeGroup

public boolean removeGroup(String name)
Remove the specified group. This will only succeed if it is in the list of editableGroups(). Beware that this also removes all the items in that group, so always ask the user before removing it!

Parameters: name the name of the group to remove

Returns: true if successful, false if not

UNKNOWN: Remove the specified group.

saveItem

public KFileMetaInfoItem saveItem(String key, String preferredGroup, boolean createGroup)
Saves the item with the given key.

Parameters: key the key of the item preferredGroup the preferred group, or null createGroup true to create the group if necessary

Returns: the saved item

UNKNOWN: Saves the item with the given key.

saveItem

public KFileMetaInfoItem saveItem(String key, String preferredGroup)

saveItem

public KFileMetaInfoItem saveItem(String key)

supportedGroups

public ArrayList supportedGroups()
Returns a list of all supported groups.

Returns: the supported keys of the groups that the file has.

UNKNOWN: Returns a list of all supported groups.

supportedKeys

public ArrayList supportedKeys()
Returns a list of supported keys.

Returns: a list of supported keys

UNKNOWN: Returns a list of supported keys.

url

public KURL url()
Returns the url of file

Returns: the file's url

UNKNOWN: Returns the url of file

value

public QVariant value(String key)
Returns the value with the given key.

Parameters: key the key to retrieve

Returns: the value. Invalid if it does not exist

UNKNOWN: Returns the value with the given key.