Class FileValidator

All Implemented Interfaces:
NodeValidator<File>

public class FileValidator extends NameableNodeValidator<File>
Validator implementation for files. Validation rules:
Since:
3.17
Author:
Nicklas
  • Constructor Details

    • FileValidator

      public FileValidator()
  • Method Details

    • preMissingItem

      public boolean preMissingItem(DbControl dc, OverviewContext context, Node parentNode)
      If the parent item has a subtype that is related to a FILE subtype, report the missing item as a Validator.MISSING_FILE failure. Otherwise, ignore the missing file.
      Specified by:
      preMissingItem in interface NodeValidator<File>
      Overrides:
      preMissingItem in class BasicNodeValidator<File>
      Parameters:
      dc - A DbControl to use if the validation needs to access the database
      context - The current overview context
      parentNode - The parent node that is missing the item
      Returns:
      Always false
    • postValidate

      public void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode)
      Checks if the file is of the correct file type.
      Specified by:
      postValidate in interface NodeValidator<File>
      Overrides:
      postValidate in class NameableNodeValidator<File>
      Parameters:
      dc - A DbControl to use if the validation needs to access the database
      context - The current overview context
      node - The node object that represents item
      parentNode - The parent node that is linked with the item
    • getMissingItemFix

      protected Fix getMissingItemFix(DbControl dc, Node parentNode)
      Description copied from class: BasicNodeValidator
      Subclasses should override this method if they have a suggessted fix for a missing item problem. The default implementation does nothing, but the following template may be usable by most subclasses:
                      new Fix("Add item to parent", parentNode.getItem())
                      
      Specified by:
      getMissingItemFix in class BasicNodeValidator<File>
      Returns:
      Suggested fix is to add a file to the parent item
    • getExpectedFileSubtype

      protected ItemSubtype getExpectedFileSubtype(DbControl dc, BasicItem parentItem)
      Get the subtype of the associated file that we expect for the given parent item.