Changeset 11378 for trunk/gli


Ignore:
Timestamp:
2006-03-16T14:42:37+13:00 (18 years ago)
Author:
mdewsnip
Message:

Now looks at a plugin's block_exp as well as its process_exp to determine if it will "process" a file.

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/Plugin.java

    r11282 r11378  
    171171
    172172
     173    /** Checks whether this plugin instance will process the specified file (given its block_exp). */
     174    public boolean doesBlockFile(File file)
     175    {
     176    // Check the filename against the plugin's block_exp value
     177    ArrayList arguments = getArguments(true, true);
     178    for (int i = 0; i < arguments.size(); i++) {
     179        Argument argument = (Argument) arguments.get(i);
     180        if (argument.getName().equals("block_exp")) {
     181        // Try the assigned value first, for when the user has manually set the value
     182        String regular_expression = argument.getValue();
     183        if (regular_expression == null || regular_expression.equals("")) {
     184            // Not set, so use the default value
     185            regular_expression = argument.getDefaultValue();
     186            if (regular_expression.equals("")) {
     187            continue;
     188            }
     189        }
     190
     191        // The $ at the end doesn't seem to work in Java, so need to add ".*" at the start
     192        if (regular_expression.startsWith("(?i)")) {
     193            // Don't mess up case-insensitive matching though
     194            regular_expression = "(?i)" + ".*" + regular_expression.substring("(?i)".length());
     195        }
     196        else {
     197            regular_expression = ".*" + regular_expression;
     198        }
     199
     200        // If the filename matches the regular expression, this plugin will deal with the file in some way
     201        if (file.getName().matches(regular_expression)) {
     202            return true;
     203        }
     204        }
     205    }
     206
     207    // This plugin will (probably) not deal with the specified file
     208    return false;
     209    }
     210
     211
    173212    /** Checks whether this plugin instance will process the specified file (given its process_exp). */
    174213    public boolean doesProcessFile(File file)
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r11130 r11378  
    140140    for (int i = 0; i < super.getSize(); i++) {
    141141        Plugin assigned_plugin = (Plugin) getElementAt(i);
    142         if (assigned_plugin.isSeparator() == false && assigned_plugin.doesProcessFile(file) == true) {
     142        if (assigned_plugin.isSeparator() == false && (assigned_plugin.doesProcessFile(file) == true || assigned_plugin.doesBlockFile(file) == true)) {
    143143        // This file will be processed by an assigned plugin, so no suggestion is necessary
    144144        DebugStream.println("Processed by assigned plugin: " + assigned_plugin);
Note: See TracChangeset for help on using the changeset viewer.