MetaDataHandler.pm

Contents


1. Description
2. Usage
3. Method Index

1. Description

The perl module MetaDataHandler.pm facilitates the manipulation of meta-data files.

2. Usage

The following examples show the basic usage of the MetaDataHandler module; the first shows the creation of a new meta data file, filling the data and writing it. The second example shows how to access an existing one.

Creating a new meta data file

   use MetaDataHandler;                          # MetaDataHandler has to be in @INC
   
   $meta_data =  new MetaDataHandler;            # creating a new instance 
   $meta_data -> setFileName('/meta/data/file'); # setting the file name
   $meta_data -> setMode('strict');              # setting mode of MetaDataHandle
   $meta_data -> setFieldNames('Name Date');     # space separated list of fields
   $meta_data -> setValueOf('Name','Andreas');   # assigning values
   $meta_data -> setValueOf('Date','1966/14/04');# 
   $meta_data -> writeData;                      # writing Data to File
 

Creating a new meta data file

   use MetaDataHandler;                          # MetaDataHandler has to be in @INC
   
   $meta_data =  new MetaDataHandler;            # creating a new instance 
   $meta_data -> setFileName('/meta/data/file'); # setting the file name
   $meta_data -> setMode('relaxed');             # setting mode of MetaDataHandle
   $meta_data -> readData;                       # reading the Data from the File
   $name = $meta_data -> getValueOf('Name');     # assigning values
 

3. Method Index

new   (['filename']) 
getFileName 
setFileName ('filename')
getMode ( 'strict'|'relaxed'|'sloppy' )
setMode ()
getFieldNames ()
setFieldNames ("field_name1 field_name2 field_name3 ...")
getValueOf ('field_name')
setValueOf ('field_name', 'value')
readData   ()
writeData  ()

new (['filename'])

Creates a new MetaDataHandler object. Obtionally the filename of the MetaDataHandler can be specified.

Example: $meta = new MetaDataHandler;


getFileName ()

Sets the filename of the MetaDataHandler.

Example: $meta->setFileName('filename');


setFileName ('filename')

Method to obtain the filename of the MetaDataHandler.

Example: $actual_filename = $meta->getFileName();


setMode ( 'strict' | 'relaxed' | 'sloppy' )

Sets the mode of the MetaDataHandler to one of the three values:

strict Only fieldnames are accepted which have been defined with setFieldNames
relaxed All fieldnames are accepted when reading a meta data file and when setting or getting the value of fields (setvalueOf, getvalueOf, writeData).
sloppy All fieldnames are accepted and in addition the sysntax of the meta data file doesn't need a blank after the fieldname:

Example: $meta->setMode('relaxed');


getMode ()

Mehtod to obtain the present mode setting of the MetaDataHandler.

Example: $meta->getMode();


setFieldNames ('field_name1 field_name2 field_name3 ...')

Specifies the list of fieldnames (blank separated string).

Example: $meta->setFieldNames('Title Author Date');


getFieldNames

Returns the list of fieldnames either specified with setFieldNames or after reading data from a file (when using mode 'relaxed' or 'sloppy'; see setMode, getMode);

Example: $fields = $meta->getFieldNames();


setValueOf ('field_name', 'value')

Sets the value of field 'field_name' to 'value'. Depending on the setting of the mode (see setMode, getMode) the field has to be in the list of field names (see getFieldName, setFieldName)

Example: $meta->setValueOf('Title','The title of the object');


getValueOf ('field_name')

Returns the value of the field 'field_name'.Depending on the setting of the mode (see setMode, getMode) the field has to be in the list of field names (see getFieldName, setFieldName)

Example: $title = $mata->getValueOf('Title');


readData ()

Reads and parses the file specified. Depending on the setting of the mode (see setMode) the file may only contain field specified with setFieldName.

Example: $meta->readData();


writeData ()

Writes the meta-data to the file specified.

Example: $meta->writeData();