Re: [digester] Reading in Enums

2012-07-06 Thread Simone Tripodi
Hi Neil,

apologize for the late reply - the Digester relies on BeanUtils to
perform text to Java object unmarshalling, so for your enumeration(s)
type you have to plug the needed converter.

Have a look at Data Type Conversions[1] to understand how to convert
the extracted XML body text to OneDBarcodeFormat; basically you have
to implement the Converter[2] interface and register it via the
ConvertUtils.html#register()[3] method.
The Digester will do the rest.

HTH and don't hesitate on writing back to the ML if needed!
All the best,
-Simo

[1] 
http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/package-summary.html#conversion
[2] 
http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/Converter.html
[3] 
http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/ConvertUtils.html#register(org.apache.commons.beanutils.Converter,
java.lang.Class)

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/


On Wed, Jul 4, 2012 at 9:30 PM, Neil Benn neil.b...@ziath.com wrote:
 Hello,

   I have a class which holds a set of enums; I'm writing out to the xml
 file the name of the enum and I want to read it back in with Digester.
  However I'm having a hard time working out how to do that - has anyone
 managed to read in the enums.  I'm currently trying:

 Digester digester = new Digester();
 digester.addObjectCreate(barcodeScanner, BarcodeScannerModel.class);
 digester.addSetProperties(barcodeScanner);
 digester.addCallMethod(barcodeScanner/formats/OneDBarcodeFormat,
 addPossibleOneDBarcodeFormat, 1);
 digester.addCallParam(barcodeScanner/formats/OneDBarcodeFormat, 0,
 format);

   This however returns the error message of :

 java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 4;
 columnNumber: 39; Error at line 4 char 39: No such accessible method:
 addPossibleOneDBarcodeFormat() on object:
 com.ziath.datapaq.application.BarcodeScannerModel
 at
 com.ziath.datapaq.application.ConfigureBarcodeScannerPanel$ConfigureFileReader.load(ConfigureBarcodeScannerPanel.java:443)

   The method is question is:

 public void addPossibleOneDBarcodeFormat(OneDBarcodeFormat format){
 this.formats.add(format);
 }

   The method is there so I guess it is just the parameter that is the
 problem in that Digester is trying to pass a String whereas it needs an
 enum.  So, if anyone can help that would be greatly appreciated.

   Thanks.

 Cheers,

 Neil

 --

 Neil Benn MSc
 Ziath Ltd
 Phone: +44 (0) 1223 655577
 http://www.ziath.com

 *Please consider the environment before printing this email.*

 Follow us on Facebook http://www.facebook.com/ziathltd,
 Twitterhttp://www.twitter.com/ziath_ltdor
 LinkedIn http://www.linkedin.com/company/ziath-ltd

 IMPORTANT NOTICE: This message, including any attached documents, is
 intended only for the use of the individual or entity to which it is
 addressed, and may contain information that is privileged, confidential and
 exempt from disclosure under applicable law. If the reader of this message
 is not the intended recipient, or the employee or agent responsible for
 delivering the message to the intended recipient, you are hereby notified
 that any dissemination, distribution or copying of this communication is
 strictly prohibited. If you have received this communication in error,
 please notify Ziath Ltd immediately by email at i...@ziath.com. Thank you.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[digester] Reading in Enums

2012-07-04 Thread Neil Benn
Hello,

  I have a class which holds a set of enums; I'm writing out to the xml
file the name of the enum and I want to read it back in with Digester.
 However I'm having a hard time working out how to do that - has anyone
managed to read in the enums.  I'm currently trying:

Digester digester = new Digester();
digester.addObjectCreate(barcodeScanner, BarcodeScannerModel.class);
digester.addSetProperties(barcodeScanner);
digester.addCallMethod(barcodeScanner/formats/OneDBarcodeFormat,
addPossibleOneDBarcodeFormat, 1);
digester.addCallParam(barcodeScanner/formats/OneDBarcodeFormat, 0,
format);

  This however returns the error message of :

java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 4;
columnNumber: 39; Error at line 4 char 39: No such accessible method:
addPossibleOneDBarcodeFormat() on object:
com.ziath.datapaq.application.BarcodeScannerModel
at
com.ziath.datapaq.application.ConfigureBarcodeScannerPanel$ConfigureFileReader.load(ConfigureBarcodeScannerPanel.java:443)

  The method is question is:

public void addPossibleOneDBarcodeFormat(OneDBarcodeFormat format){
this.formats.add(format);
}

  The method is there so I guess it is just the parameter that is the
problem in that Digester is trying to pass a String whereas it needs an
enum.  So, if anyone can help that would be greatly appreciated.

  Thanks.

Cheers,

Neil

-- 

Neil Benn MSc
Ziath Ltd
Phone: +44 (0) 1223 655577
http://www.ziath.com

*Please consider the environment before printing this email.*

Follow us on Facebook http://www.facebook.com/ziathltd,
Twitterhttp://www.twitter.com/ziath_ltdor
LinkedIn http://www.linkedin.com/company/ziath-ltd

IMPORTANT NOTICE: This message, including any attached documents, is
intended only for the use of the individual or entity to which it is
addressed, and may contain information that is privileged, confidential and
exempt from disclosure under applicable law. If the reader of this message
is not the intended recipient, or the employee or agent responsible for
delivering the message to the intended recipient, you are hereby notified
that any dissemination, distribution or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify Ziath Ltd immediately by email at i...@ziath.com. Thank you.