Results 1 to 4 of 4
Thread: what is wrong?
- 07-15-2009, 11:40 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
what is wrong?
when I compile the following code I get 2 errors, one on line which has
'pe;' and the other 'e;'
The error during compilation says 'not a statment'....I am not sure what is wrong?
Could you help?
-----------------------------------------------------------------------------
package uk.co.thehub.kiosk.nel.integration.printouts;
import java.awt.*;
import java.awt.print.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.print.PrintService;
import javax.print.attribute.standard.PrinterIsAcceptingJ obs;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.Logger;
import uk.co.thehub.kiosk.nel.payment.constants.Constants ;
import uk.co.thehub.kiosk.nel.utils.Utils;
public class AcceptedCardReceipt extends Component
implements Printable
{
public AcceptedCardReceipt()
{
strImagePath = "";
strMerchantNumber = "";
strTransactionType = "";
strCardNo = "";
strCardType = "";
strStartDate = "";
strExpiryDate = "";
strIssueNo = "";
strTransactionSoure = "";
strTIDAndSeqNo = "";
strAuthCode = "";
strAmount = "";
strVerificationStatement = "";
strAIDAndSequenceNo = "";
strReceiptNo = "";
strAgentID = "";
strCryptoTransType = "";
strCryptValue = "";
strTicketNo = "";
}
public boolean doPrintAcceptedReceipt(HttpServlet pServlet)
{
PrinterJob printerJob;
PrinterIsAcceptingJobs acceptingJobs;
printerJob = PrinterJob.getPrinterJob();
PageFormat pf = printerJob.defaultPage();
Paper newPaper = new Paper();
newPaper.setImageableArea(36D, 36D, newPaper.getWidth() - 72D, newPaper.getHeight());
pf.setPaper(newPaper);
printerJob.setPrintable(this, pf);
acceptingJobs = (PrinterIsAcceptingJobs)printerJob.getPrintService ().getAttribute(javax.print.attribute.standard.Pri nterIsAcceptingJobs.class);
if(acceptingJobs.getValue() != PrinterIsAcceptingJobs.ACCEPTING_JOBS.getValue())
_LOGGER.warn(_LOGGING_STRING + " | Printer is not accepting jobs");
String strPrinterStatus = Utils.getPrinterStatus(pServlet);
if(!strPrinterStatus.equals("printer ok") && !strPrinterStatus.equals("paper low"))
break MISSING_BLOCK_LABEL_174;
printerJob.print();
return true;
return false;
PrinterException pe;
pe;
_LOGGER.error(Utils.getStackTrace(pe));
break MISSING_BLOCK_LABEL_205;
Exception e;
e;
_LOGGER.error(Utils.getStackTrace(e));
return false;
}
public int print(Graphics pGraphics, PageFormat pPageFormat, int pPage)
{
if(pPage > 0)
return 1;
SimpleDateFormat sdf = new SimpleDateFormat("dd / MM / yyyy HH:mm:ss");
Graphics2D graphics2D = (Graphics2D)pGraphics;
graphics2D.translate(pPageFormat.getImageableX(), pPageFormat.getImageableY());
Font textFont = new Font("Arial", 0, 9);
graphics2D.setFont(textFont);
FontMetrics textFontMetrics = graphics2D.getFontMetrics(textFont);
int fontMaxAscend = textFontMetrics.getMaxAscent();
int fontMaxDescend = textFontMetrics.getMaxDescent();
int fontLeading = textFontMetrics.getLeading();
int xIndent = 10;
int currentY = 0;
Image img = loadImage(this);
int imageWidth = 190;
int imageHeight = 50;
double pageWidth = pPageFormat.getImageableWidth();
graphics2D.drawImage(img, imageWidth / 4, currentY, imageWidth, imageHeight, this);
currentY += imageHeight + 10 + fontLeading + fontMaxAscend;
graphics2D.drawString("National Express Limited", getXCentrePosition("National Express Limited", pageWidth, textFontMetrics), currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("4 Vicarage Road, Edgbaston,", getXCentrePosition("4 Vicarage Road, Edgbaston,", pageWidth, textFontMetrics), currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("Birmingham, B15 3ES", getXCentrePosition("Birmingham, B15 3ES", pageWidth, textFontMetrics), currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("VAT No. 487 038714", getXCentrePosition("VAT No. 487 038714", pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
String strTransactionDateTime = "**** " + sdf.format(new Date()) + " ****";
graphics2D.drawString(strTransactionDateTime, getXCentrePosition(strTransactionDateTime, pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("NOT VALID FOR TRAVEL", getXCentrePosition("NOT VALID FOR TRAVEL", pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString(strTransactionType, xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("MERCHANT NO: " + strMerchantNumber, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("TID: " + strTIDAndSeqNo, xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString(strCardType, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("PAN: " + strCardNo, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
if(Utils.isEmpty(strStartDate))
graphics2D.drawString("EXPIRY: " + strExpiryDate, xIndent, currentY);
else
graphics2D.drawString("EXPIRY: " + strExpiryDate + " START: " + strStartDate, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
if(!Utils.isEmpty(strIssueNo))
{
graphics2D.drawString("ISSUE NO: " + strIssueNo, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
}
graphics2D.drawString(strVerificationStatement, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString(strTransactionSoure, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("AUTH CODE: " + strAuthCode, xIndent, currentY);
currentY += fontMaxDescend + fontLeading + fontMaxAscend;
graphics2D.drawString("AID: " + strAIDAndSequenceNo, xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("CRYPT: " + strCryptValue + " " + strCryptoTransType, xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("=========================== =======================", xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
String strItemsString = " 1 ITEM - Ticket Number " + strTicketNo;
graphics2D.drawString(strItemsString, xIndent, currentY);
String strItemsString2 = "\243" + strAmount;
graphics2D.drawString(strItemsString2, xIndent + 194, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
String strTotalString = " TOTAL";
graphics2D.drawString(strTotalString, xIndent, currentY);
String strTotalString2 = "\243" + strAmount;
graphics2D.drawString(strTotalString2, xIndent + 194, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("=========================== =======================", xIndent, currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("Your account will be debited with above amount", getXCentrePosition("Your account will be debited with above amount", pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
graphics2D.drawString("Please retain this receipt for your records", getXCentrePosition("Please retain this receipt for your records", pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
String receiptInfo = "RECEIPT NO: " + strReceiptNo + " AGENT ID: " + strAgentID;
graphics2D.drawString(receiptInfo, getXCentrePosition(receiptInfo, pageWidth, textFontMetrics), currentY);
currentY += (fontMaxDescend + fontLeading + fontMaxAscend) * 2;
return 0;
}
private int getXCentrePosition(String pString, double pPaperWidth, FontMetrics pFontMetrics)
{
int length = pFontMetrics.stringWidth(pString);
return (int)((pPaperWidth - (double)length) / 2D);
}
private Image loadImage(Component pComponent)
{
MediaTracker mt = new MediaTracker(pComponent);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image img = toolkit.createImage(strImagePath);
mt.addImage(img, 1);
try
{
mt.waitForID(1);
}
catch(InterruptedException ie)
{
_LOGGER.error(Utils.getStackTrace(ie));
}
return img;
}
public void setMerchantNumber(String pMerchantNo)
{
strMerchantNumber = pMerchantNo != null ? pMerchantNo : "";
}
public void setTransactionType(String pTransactionType)
{
strTransactionType = pTransactionType != null ? pTransactionType : "";
}
public void setCardNumber(String pCardNo)
{
strCardNo = pCardNo != null ? pCardNo : "";
}
public void setCardType(String pCardType)
{
strCardType = pCardType != null ? pCardType : "";
}
public void setExpiryDate(String pExpiryDate)
{
strExpiryDate = pExpiryDate != null ? pExpiryDate : "";
}
public void setStartDate(String pStartDate)
{
strStartDate = pStartDate != null ? pStartDate : "";
}
public void setIssueNumber(String pIssueNo)
{
strIssueNo = pIssueNo != null ? pIssueNo : "";
}
public void setTransactionSource(String pTransactionSource)
{
strTransactionSoure = pTransactionSource != null ? pTransactionSource : "";
}
public void setTIDAndSequenceNo(String pTIDAndSeqNo)
{
strTIDAndSeqNo = pTIDAndSeqNo != null ? pTIDAndSeqNo : "";
}
public void setAuthCode(String pAuthCode)
{
strAuthCode = pAuthCode != null ? pAuthCode : "";
}
public void setAmount(String pAmount)
{
strAmount = pAmount != null ? pAmount : "";
}
public void setVerificationStatement(String pVerificationStatement)
{
strVerificationStatement = pVerificationStatement != null ? pVerificationStatement : "";
}
public void setAIDAndSequenceNo(String pAIDAndSequenceNo)
{
strAIDAndSequenceNo = pAIDAndSequenceNo != null ? pAIDAndSequenceNo : "";
}
public void setReceiptNo(String pReceiptNo)
{
strReceiptNo = pReceiptNo != null ? pReceiptNo : "";
}
public void setAgentID(String pAgentID)
{
strAgentID = pAgentID != null ? pAgentID : "";
}
public void setCryptoTransType(String pCryptoTransType)
{
strCryptoTransType = pCryptoTransType != null ? pCryptoTransType : "";
}
public void setCryptValue(String pCryptValue)
{
strCryptValue = pCryptValue != null ? pCryptValue : "";
}
public void setImagePath(String pPath)
{
strImagePath = pPath != null ? pPath : "";
}
public void setTicketNo(String pTicketNumber)
{
strTicketNo = pTicketNumber != null ? pTicketNumber : "";
}
private static final Logger _LOGGER;
private static final String _LOGGING_STRING;
private static final String RETENSION_STATEMENT = "Please retain this receipt for your records";
private static final String DEBIT_STATEMENT = "Your account will be debited with above amount";
private static final String ADDRESS_1 = "National Express Limited";
private static final String ADDRESS_2 = "4 Vicarage Road, Edgbaston,";
private static final String ADDRESS_3 = "Birmingham, B15 3ES";
private static final String VAT_NO = "VAT No. 487 038714";
private static final String DISCLAIMER = "NOT VALID FOR TRAVEL";
private static final String SPACER_STRING = "================================================= =";
private String strImagePath;
private String strMerchantNumber;
private String strTransactionType;
private String strCardNo;
private String strCardType;
private String strStartDate;
private String strExpiryDate;
private String strIssueNo;
private String strTransactionSoure;
private String strTIDAndSeqNo;
private String strAuthCode;
private String strAmount;
private String strVerificationStatement;
private String strAIDAndSequenceNo;
private String strReceiptNo;
private String strAgentID;
private String strCryptoTransType;
private String strCryptValue;
private String strTicketNo;
static
{
_LOGGER = Logger.getLogger(uk.co.thehub.kiosk.nel.integratio n.printouts.AcceptedCardReceipt.class);
_LOGGING_STRING = "ACCEPTED_TRANSACTION_RECEIPT | " + Constants.KIOSK_NAME;
}
}
- 07-15-2009, 11:56 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
How on earth do you expect us to find your compilation bug in all that unformatted code?
So, first format it by using CODE tags (there's a '#' button above the message box, place the formatted code in between the resulting tags).
Second, rather than pasting such a huge amount of code, how about simply pasting the code where the error occurs, or at least pointing it out to us.
ETA: Oh, and it'll probably help to paste the full error message you're getting.
- 07-15-2009, 12:09 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
The error occurs on pe; and e;public boolean doPrintAcceptedReceipt(HttpServlet pServlet)
{
PrinterJob printerJob;
PrinterIsAcceptingJobs acceptingJobs;
printerJob = PrinterJob.getPrinterJob();
PageFormat pf = printerJob.defaultPage();
Paper newPaper = new Paper();
newPaper.setImageableArea(36D, 36D, newPaper.getWidth() - 72D, newPaper.getHeight());
pf.setPaper(newPaper);
printerJob.setPrintable(this, pf);
acceptingJobs = (PrinterIsAcceptingJobs)printerJob.getPrintService ().getAttribute(javax.print.attribute.standard.Pri nterIsAcceptingJobs.class);
if(acceptingJobs.getValue() != PrinterIsAcceptingJobs.ACCEPTING_JOBS.getValue())
_LOGGER.warn(_LOGGING_STRING + " | Printer is not accepting jobs");
String strPrinterStatus = Utils.getPrinterStatus(pServlet);
if(!strPrinterStatus.equals("printer ok") && !strPrinterStatus.equals("paper low"))
break MISSING_BLOCK_LABEL_174;
printerJob.print();
return true;
return false;
PrinterException pe;
pe;
_LOGGER.error(Utils.getStackTrace(pe));
break MISSING_BLOCK_LABEL_205;
Exception e;
e;
_LOGGER.error(Utils.getStackTrace(e));
return false;
}
The error says 'not a statement', thats all.
- 07-15-2009, 12:33 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Blimey, if you want something done, you have to do it yourself...
Right...formatted code:
That method is simply riddled with errors...how many returns, one after the other, do you need?Java Code:public boolean doPrintAcceptedReceipt(HttpServlet pServlet) { PrinterJob printerJob; PrinterIsAcceptingJobs acceptingJobs; printerJob = PrinterJob.getPrinterJob(); PageFormat pf = printerJob.defaultPage(); Paper newPaper = new Paper(); newPaper.setImageableArea(36D, 36D, newPaper.getWidth() - 72D, newPaper .getHeight()); pf.setPaper(newPaper); printerJob.setPrintable((Printable) this, pf); acceptingJobs = (PrinterIsAcceptingJobs) printerJob .getPrintService() .getAttribute( javax.print.attribute.standard.PrinterIsAcceptingJobs.class); if (acceptingJobs.getValue() != PrinterIsAcceptingJobs.ACCEPTING_JOBS.getValue()) _LOGGER.warn(_LOGGING_STRING + " | Printer is not accepting jobs"); String strPrinterStatus = Utils.getPrinterStatus(pServlet); if (!strPrinterStatus.equals("printer ok") && !strPrinterStatus.equals("paper low")) break MISSING_BLOCK_LABEL_174; printerJob.print(); return true; return false; PrinterException pe; [B] pe; // Error in here[/B] _LOGGER.error(Utils.getStackTrace(pe)); break MISSING_BLOCK_LABEL_205; Exception e; [B]e; // and here[/B] _LOGGER.error(Utils.getStackTrace(e)); return false; }
For the two errors marked above, I get:
Syntax error, insert "AssignmentOperator Expression" to complete Expression.
I have no idea what you're trying to do, but what I can say is you need to learn what Java code looks like...
Similar Threads
-
what's wrong?
By rayda in forum New To JavaReplies: 3Last Post: 04-14-2009, 09:07 PM -
What did i do wrong
By jpnym15 in forum New To JavaReplies: 8Last Post: 11-17-2008, 10:07 AM -
what's wrong in here!!!
By Annatar in forum New To JavaReplies: 8Last Post: 11-14-2008, 02:55 AM -
So, what am I doing wrong?
By Charles_Smith in forum New To JavaReplies: 0Last Post: 10-29-2008, 02:50 PM -
I am Doing Something Wrong But Don't Know What?
By BHCluster in forum New To JavaReplies: 3Last Post: 04-16-2008, 01:16 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks