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

  • Home
  • SEARCH
  • 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 6759153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:01+00:00 2026-05-26T13:54:01+00:00

FilenameFilter has an accept method that I can implement to tell system how I

  • 0

FilenameFilter has an accept method that I can implement to tell system how I want to filter files. I want to implement something this similar. Here is my scenario:

I am writing a generic API that run on top of iText that adding Barcode to pdf documents. I have a generic custom Barcode.

public class MyCustomBarcode{

/**
 * This variable holds the type of barcode
 * com.itextpdf.text.pdf.Barcode
 */
private Barcode barcode;

/**
 * The X position of the barcode. (0, 0) is at the bottom left
 */
private float x;

/**
 * The Y position of the barcode. (0, 0) is at the bottom left
 */
private float y;

/**
 * 
 */
private int rotation;

...
}

So when the user use this API, they just need pass in a List<MyCustomBarcode> to a method from my API, then API will insert barcode on to every pdf page. The problem is every barcode has different code format. For example, BarcodeInter25 might use code like 000001, 000002 ... where Barcode39 might use something else. So I want to allow the user to write their own implementation of how to generate the value of the barcode. Something like this

MyCustomBarcode barcode = new MyCustomBarcode(x, y, z){
    public String getSeqNum(int i){
       //The user own implementation of how they want integer i to look like.
       //E.g if i==1, I might return 000001
    }
);

And since I allow user to have multiples type of barcode, I want to allow them to write their own implementation for every barcode that they have.

  • 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-26T13:54:02+00:00Added an answer on May 26, 2026 at 1:54 pm

    In the parent class, make the method abstract, and then have each subclass provide their own concrete implementation.


    Example

    Parent class

    public abstract class Barcode{
        .
        .
        .
        public abstract String getSeqNum(int i);
    }
    

    Subclass

    public final class FooBarcode extends Barcode{
        .
        .
        .
        public final String getSeqNum(int i){
            // provide own implementation
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Java Docs for the method String[] java.io.File.list(FilenameFilter filter) includes this in the returns
How to make a filter for .txt files? I wrote something like this but
I found a library called JVST that can load VST files and filter the
I am trying to implement a Filter/Pipeline pattern so that I can take an
So I have this method that get executed repeatedly public static boolean isReady(String dirPath,
I have this code that lists all the files in a dir: File d
One-Liner to list TXT-files. import java.io.File; import java.io.FilenameFilter; ... files = dir.listFiles(new FilenameFilter() {
I need to implement File[] files = getFiles( String folderName, String ptrn ); Where
I would like to implement something equivalent to the unix command 'rm foo*' using
I have a method which reads the content from files located in a directory.

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.