Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

You could change the factory above to allow for processing a specific combination of files by using MapEntry and SimpleEntry instances. See this answerthis answer for details. Whichever implementation is required, you'd need to define:

You could change the factory above to allow for processing a specific combination of files by using MapEntry and SimpleEntry instances. See this answer for details. Whichever implementation is required, you'd need to define:

You could change the factory above to allow for processing a specific combination of files by using MapEntry and SimpleEntry instances. See this answer for details. Whichever implementation is required, you'd need to define:

added 69 characters in body
Source Link
Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
  public ImageType getImageType() {
    // Make sure getExtension never returns null!
    return ImageType.valueOf( FilenameUtils.getExtension( getName() ).toUpperCase() );
  }

At the risk of evoking ire, you could encapsulate the processor mechanismcreation and execution mechanisms. In theory, you could make getImageType() a private method, then re-write main:

  public ImageType getImageType() {
    return ImageType.valueOf( FilenameUtils.getExtension( getName() ) );
  }

At the risk of evoking ire, you could encapsulate the processor mechanism. In theory, you could make getImageType() a private method, then re-write main:

  public ImageType getImageType() {
    // Make sure getExtension never returns null!
    return ImageType.valueOf( FilenameUtils.getExtension( getName() ).toUpperCase() );
  }

At the risk of evoking ire, you could encapsulate the processor creation and execution mechanisms. In theory, you could make getImageType() a private method, then re-write main:

added 148 characters in body
Source Link
Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
public abstract class AbstractImageFileProcessor implements ImageFileProcessor {
  private ImageFile primary;

  public void setPrimaryFile( ImageFile ifprimary ) { this.primary = if;primary; }
  protected ImageFile getPrimaryFile() { return this.primary; }
}
  public static void main( String args... ) {
    ImageFileProcessor ifp = ImageFileProcessorFactory.createProcessor( args[1] );
    ifp.process( args[2] );
    System.out.println( "Done" );
  }

The Factory would need a method to refresh itself, which could then be tied to a file monitor process that kicks off the refresh event automatically when the file has changed. So many possibilities.

At the risk of evoking ire, you could encapsulate the processor mechanism. In theory, you could make getImageType() a private method, then re-write main:

  public static void main( String args... ) {
    (new ImageFile( args[1] )).process( args[2] );
    System.out.println( "Done" );
  }

That is an exercise for the reader.

public abstract class AbstractImageFileProcessor implements ImageFileProcessor {
  private ImageFile primary;

  public void setPrimaryFile( ImageFile if ) { this.primary = if; }
}
  public void main( String args... ) {
    ImageFileProcessor ifp = ImageFileProcessorFactory.createProcessor( args[1] );
    ifp.process( args[2] );
    System.out.println( "Done" );
  }

The Factory would need a method to refresh itself, which could then be tied to a file monitor process that kicks off the refresh event automatically when the file has changed. So many possibilities.

public abstract class AbstractImageFileProcessor implements ImageFileProcessor {
  private ImageFile primary;

  public void setPrimaryFile( ImageFile primary ) { this.primary = primary; }
  protected ImageFile getPrimaryFile() { return this.primary; }
}
  public static void main( String args... ) {
    ImageFileProcessor ifp = ImageFileProcessorFactory.createProcessor( args[1] );
    ifp.process( args[2] );
    System.out.println( "Done" );
  }

The Factory would need a method to refresh itself, which could then be tied to a file monitor process that kicks off the refresh event automatically when the file has changed. So many possibilities.

At the risk of evoking ire, you could encapsulate the processor mechanism. In theory, you could make getImageType() a private method, then re-write main:

  public static void main( String args... ) {
    (new ImageFile( args[1] )).process( args[2] );
    System.out.println( "Done" );
  }

That is an exercise for the reader.

added 148 characters in body
Source Link
Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
Loading
added 148 characters in body
Source Link
Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
Loading
Source Link
Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
Loading