Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7692373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:50:17+00:00 2026-05-31T20:50:17+00:00

For a project we have a requirement to create an interfacedefinition that will return

  • 0

For a project we have a requirement to create an interfacedefinition that will return all available filetype extensions that our component can export…

The problem is that we want avoid configuration/properties files. We don’t want to edit our configuration/propertie file when another filetype is added (in the future). The structure of this part of our component is as follows:

public abstract class FileType {
    protected String filetype;

    public FileType(String filetype){
        this.filetype = filetype;
    }

    public abstract void export(String path, Object information);
}


public class PdfExport extends FileType {
    public PdfExport() {
        super("pdf");
    }

    public void export(String path, Object information){
        //pdf specific logic
    }
}

But how do we solve this when another component calls the interfacedefinition getExportTypes()? (How do we get a list of all available filetypes?) Taking into account the requirement to add in the future new classes that extend abstract class filetype (add new filetypes)?

Does anyone has suggestions, maybe another structure of above example? Or any (design) that discuss above issue?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:50:19+00:00Added an answer on May 31, 2026 at 8:50 pm

    This is the exact purpose of the strategy pattern. The strategies here are the FileTypes that encapsulate an algorithm that exports a file.
    In the following example:

    public class Application{
     List<FileType> exporters = new ArrayList<FileType>();
     public void addExporter(FileType fileExporter){
      exporters.add(fileExporter);
     }
     public void exportData(Object information){
       for(FileType exporter : exporters){
        exporter.export("d:\Export", information);
       }
     }
    }
    

    The Application class holds a list of exporters that can be filled out on the go. The Application class does not have to know what type of file exporter is registered nor how the file can be exported. When the data is exported, the Applicaiton class loops through registered exporters and delegates the export task to each one of them.

    EDIT Below is an example of the Application class usage.

    // Define a pdf exporter
    PdfExport pdfExport = new pdfExport();
    Application app = new Application();
    // Register the new exporter
    app.addExporter(pdfExport);
    // Export some data...
    app.export(information);
    

    EDIT How to avoid configuration files and changing the code everytime you have a new FileType?
    You can load the exporters at runtime using reflexion (see this link for details)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our project we have requirement that, after receiving sms message from third party
In our project we have a requirement that when a set of records are
We have a requirement in project to store all the revisions(Change History) for the
I have a requirement on my current project (a Flex app which will be
Hey all, I have something of an interesting requirement for my project. I need
I have a requirement for a project that is hosted in a shared hosting
i have a requirement to build some sort of services that can easily be
The requirement I have to implement is to create special views that look similar
We have an requirement in our project to browse & upload an XML file
Normally I create web application projects and use code-behind, but I have a requirement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.