• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programming for Dynamic String Patterns

 
Ranch Hand
Posts: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my java web app I have a part number validator class.
The purpose is to insure that a particular video monitor is assembled to the correct aircraft seat.
A bar code reader is used for the following steps.
Process is the seat assembly serial number is scanned, creating an indented bill list.
Then the part number on the monitor is scanned. The app looks for the part number in the indented bill.
If it exists the user is prompted to scan the serial number of the monitor.
This will cause a validation label to be printed out which is attached to seat assembly.

All was well when the monitors presented 1D barcodes, one for the part number and one for the serial number.
Then the monitors started having a QR code. I adjusted my app to break the code down using identifiers. Example QR Code: PNR RD-FD2802-01/SER J248628/CAG SZ437
However, the latest monitors have a QR code that has no identifiers. Example QR code: 00-5120-02-F,134009,090618,3FGZ1

Is there some way to use a pattern solution so I do not have to do hard code changes to try and manage this.  
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve,

Your description is pretty succint so I am not sure I understand you problem fully but did you already consider having a list of regexps with named capture groups coming from your configuration?

Based on the example you gave this could be something like this:

Your program would try them sequenatially until it finds one that matches.

Hope this helps.
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could write a plugin mechanism that allows you just drop JARs on the classpath and it will recognize new kinds of codes.

First write a model and a service provider interface (SPI):

Now, in a separate library, you implement your SPI:

If you're on Java 9+, add a module-info.java to the root package of your plugin:

If you're on Java 8-, add a META-INF/services/aircraft.seat.monitor.scanning.spi.MonitorCodeScannerProvider file (without extension) to the root package of your plugin:

Now, as long as the plugin JAR is on the module path of your main application (or on the class path if you're on Java 8-) you can load it like this:

You can use it like this:
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic