[OFBiz] SVN: r4997 -
trunk/framework/webapp/src/org/ofbiz/webapp/barcode
jonesde at svn.ofbiz.org
jonesde at svn.ofbiz.org
Sun May 15 05:27:30 EDT 2005
Author: jonesde
Date: 2005-05-15 04:27:27 -0500 (Sun, 15 May 2005)
New Revision: 4997
Modified:
trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeGenerator.java
trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeTransform.java
Log:
Made changes for new barcode library, some changes in class packages and in the generate svg barcode method
Modified: trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeGenerator.java
===================================================================
--- trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeGenerator.java 2005-05-15 09:26:15 UTC (rev 4996)
+++ trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeGenerator.java 2005-05-15 09:27:27 UTC (rev 4997)
@@ -28,14 +28,12 @@
import nu.xom.Nodes;
import nu.xom.converters.DOMConverter;
-import org.ofbiz.base.util.Debug;
-
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.logger.Log4JLogger;
-import org.apache.avalon.framework.logger.Logger;
-import org.krysalis.barcode.BarcodeException;
-import org.krysalis.barcode.BarcodeUtil;
+import org.krysalis.barcode4j.BarcodeException;
+import org.krysalis.barcode4j.BarcodeUtil;
+import org.ofbiz.base.util.Debug;
import org.w3c.dom.DocumentFragment;
/**
@@ -49,7 +47,7 @@
public static final String module = BarcodeGenerator.class.getName();
private Configuration config;
- private Logger log;
+ // removing this because the new version of Barcode4J doesn't have a parameter for it: private Logger log;
private BarcodeUtil barcodeUtil;
public BarcodeGenerator(String barcodeFormat) {
@@ -62,26 +60,25 @@
Debug.logError(e, "Couldn't create config for Barcode Generator", module);
}
- log = new Log4JLogger(Debug.getLogger(module));
+ //log = new Log4JLogger(Debug.getLogger(module));
barcodeUtil = BarcodeUtil.getInstance();
}
- public String generateSvgXml(String message) throws BarcodeException {
- if (config != null && log != null) {
- DocumentFragment fragment = barcodeUtil.generateBarcode(config, log, message);
+ public String generateSvgXml(String message) throws BarcodeException, ConfigurationException {
+ if (config != null) {
+ DocumentFragment fragment = barcodeUtil.generateSVGBarcode(config, message);
Nodes nodes = DOMConverter.convert(fragment);
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
for (int i = 0; i < nodes.size(); i++) {
Node node = nodes.get(i);
buffer.append(node.toXML());
}
return buffer.toString();
- }
- else {
+ } else {
return "";
}
}
Modified: trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeTransform.java
===================================================================
--- trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeTransform.java 2005-05-15 09:26:15 UTC (rev 4996)
+++ trunk/framework/webapp/src/org/ofbiz/webapp/barcode/BarcodeTransform.java 2005-05-15 09:27:27 UTC (rev 4997)
@@ -26,14 +26,14 @@
import java.io.Writer;
import java.util.Map;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.krysalis.barcode4j.BarcodeException;
+import org.ofbiz.base.util.Debug;
+
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;
import freemarker.template.TemplateTransformModel;
-import org.ofbiz.base.util.Debug;
-
-import org.krysalis.barcode.BarcodeException;
-
/**
* BarcodeTransform - Freemarker Transform for Barcodes
*
@@ -84,10 +84,11 @@
try {
out.write(generator.generateSvgXml(buf.toString()));
+ } catch (BarcodeException e) {
+ throw new IOException(e.toString());
+ } catch (ConfigurationException e) {
+ throw new IOException(e.toString());
}
- catch (BarcodeException e) {
- throw new IOException(e.getMessage());
- }
}
};
}
More information about the Svn
mailing list