Exemplo n.º 1
0
  public DocumentHandlerMapping(DoccoFileFilter fileFilter, DocumentHandler docHandler) {
    if (fileFilter == null) {
      throw new IllegalArgumentException(
          GuiMessages.getString(
              "DocumentHandlerMapping.illegalArgumentMessageFilterMustNotBeNull.text")); //$NON-NLS-1$
    }
    if (docHandler == null) {
      throw new IllegalArgumentException(
          GuiMessages.getString(
              "DocumentHandlerMapping.illegalArgumentMessageDocumentHandlerMustNotBeNull.text")); //$NON-NLS-1$
    }

    this.fileFilter = fileFilter;
    this.docHandler = docHandler;
  }
Exemplo n.º 2
0
 public DocumentHandlerMapping(String serialForm) throws ClassNotFoundException {
   int firstColonIndex = serialForm.indexOf(':');
   int lastColonIndex = serialForm.lastIndexOf(':');
   String fileFilterClassName = serialForm.substring(0, firstColonIndex);
   String filterExpression = serialForm.substring(firstColonIndex + 1, lastColonIndex);
   String docHandlerClassName = serialForm.substring(lastColonIndex + 1);
   FileFilterFactory fileFilterFactory =
       FileFilterFactoryRegistry.getFileFilterFactoryByName(fileFilterClassName);
   if (fileFilterFactory == null) {
     throw new ClassNotFoundException(
         MessageFormat.format(
             GuiMessages.getString("DocumentHandlerMapping.fileFilterTypeNotFoundError.text"),
             new Object[] {fileFilterClassName})); // $NON-NLS-1$
   }
   this.docHandler = DocumentHandlerRegistry.getDocumentHandlerByName(docHandlerClassName);
   if (docHandler == null) {
     throw new ClassNotFoundException(
         MessageFormat.format(
             GuiMessages.getString("DocumentHandlerMapping.documentHandlerNotFoundError.text"),
             new Object[] {docHandlerClassName})); // $NON-NLS-1$
   }
   this.fileFilter = fileFilterFactory.createNewFilter(filterExpression);
 }