#10 Processing tildes

closed
nobody
None
5
2008-11-29
2008-09-03
Anonymous
No

Greetings. First of all, thanks for this great library! I am using it and found some features that I would have a use for.

One of them is processing tildes: If you generate a barcode with the message "H~101llo world", the tilde and the following three digits are replaced with their ascii code, resulting in "Hello world".

I have already implemented this feature as it's not a lot of work to do and applied the following changes to the source:

AbstractBarcodeBean.java
- Added the variable protected boolean processTilde with the default value false, as well as a getter and a setter.

DefaultCanvasLogicHandler.java
- Added in
public void startBarcode(String msg, String formattedMsg)

if (bcBean.isProcessTilde())
{
formattedMsg = MessagePatternUtil.processTilde(formattedMsg);
}

at the beginning.

MessagePatternUtil.java (Thought it wouldn't be bad to put it here)
- Added the method public static String processTilde( String msg ). (See attachement)

And when already talking about this I've got a question:
In DefaultCanvasLogicHandler - startBarcode(String,String) you make:

//Calculate extents
BarcodeDimension dim = bcBean.calcDimensions(msg);

canvas.establishDimensions(dim);
x = getStartX();

Shouldn't this actually be done with the formatted message (this.formattedMsg)?

Have a nice day,
thomasjost.05@gmail.com

Discussion

  • Method public static String processTilde(String)

     
    Attachments
  • Ulrich Mayring
    Ulrich Mayring
    2008-09-03

    Logged In: YES
    user_id=673053
    Originator: NO

    What is the purpose of this feature? If it does only ASCII, then why not type the character itself?

     
  • Logged In: NO

    Riiiiight.... To be honest I didn't think about that before. That was just one of my requirements. But you can also use it for ascii symbols below 32.

    Anyway, the above implementation has a bug as
    if (bcBean.isProcessTilde())
    {
    formattedMsg = MessagePatternUtil.processTilde(formattedMsg);
    }
    ought to be
    if (isProcessTilde())
    {
    msg = MessagePatternUtil.processTilde(msg);
    }
    and situated in the BarcodeBean itself generateBarcode(CanvasProvider,String).

     
  • Instead of ~, Java's Unicode escape syntax can now be used to encode any Unicode character when using the FOP extension in CVS HEAD.

     
    • status: open --> closed