Fields Summary |
---|
static final int | RESERVEDStatus of Transaction - Reserved |
static final int | MISSEDStatus of Transaction - Missed |
static final int | PASSEDStatus of Transaction - Passed |
private int | transactionIDTransaction ID |
private int | applicationIDApplication ID |
private String | applicationNameApplication Name |
private int | featureIDFeature ID |
private String | featureTitleFeature Title |
private double | priceprice |
private String | currencycurrency |
private int | statestate of Transaction |
private long | timestampTimestamp of Transaction |
private int | statusTransaction status - Reserved/Missed/Passed |
private boolean | fakeFake Transaction |
private int | recordIDrecord ID |
private static final String | EMPTY_CURRENCYempty currency |
private static final String | TEMPLATE_CURRENCYUSD currency |
Methods Summary |
---|
int | add2list(java.util.Vector v)Adds Transaction Record into the list
int count = v.size();
if (count == 0) {
v.addElement(this);
} else {
do {
if (((CldcTransactionRecordImpl)v.elementAt(count-1)).
getFinishedTimestamp() <= this.timestamp) {
v.insertElementAt(this, count);
break;
}
count--;
} while (count > 0);
if (count == 0) {
v.insertElementAt(this, count);
}
}
return count;
|
static int | calculateSize(java.lang.String applicationName, java.lang.String featureTitle)Calculates the size in bytes which will be needed to store a transaction
record with the specified application name and feature title.
// calculate the required space
int size;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(bos);
try {
os.writeUTF(applicationName);
os.writeUTF(featureTitle);
os.writeUTF(TEMPLATE_CURRENCY);
size = bos.size();
} finally {
os.close();
}
size += 4 + // transactionID
4 + // applicationID
4 + // featureID
8 + // price
4 + // state
8 + // timestamp
4; // status
return size;
|
com.sun.j2me.payment.CldcTransactionRecordImpl | createDuplicateRecord()Returns the exact duplicate of this transaction record except of the
wasMissed flag which is set to the value of the input
parameter.
CldcTransactionRecordImpl newRecord = new CldcTransactionRecordImpl();
newRecord.transactionID = transactionID;
newRecord.applicationID = applicationID;
newRecord.applicationName = applicationName;
newRecord.featureID = featureID;
newRecord.featureTitle = featureTitle;
newRecord.price = price;
newRecord.currency = currency;
newRecord.state = state;
newRecord.timestamp = timestamp;
newRecord.fake = fake;
newRecord.recordID = recordID;
newRecord.status = PASSED;
return newRecord;
|
static com.sun.j2me.payment.CldcTransactionRecordImpl | createFakeRecord(int transactionID, int applicationID, java.lang.String applicationName, int featureID, java.lang.String featureTitle, double price, java.lang.String currency, int state, long timestamp)Creates a fake transaction record from the given information. It's
used in the debug mode.
CldcTransactionRecordImpl record = new CldcTransactionRecordImpl();
record.transactionID = transactionID;
record.applicationID = applicationID;
record.applicationName = applicationName;
record.featureID = featureID;
record.featureTitle = featureTitle;
record.price = price;
record.currency = currency;
record.state = state;
record.timestamp = timestamp;
record.status = RESERVED;
record.fake = true;
record.recordID = 0;
return record;
|
public int | getApplicationID()Returns the appplication ID of the application (MIDlet) which initiated
the transaction.
return applicationID;
|
public java.lang.String | getApplicationName()Returns the name of the application (MIDlet) which initiated the
transaction.
return applicationName;
|
public java.lang.String | getCurrency()Returns the currency of the price or an empty string if it hasn't been
set when the transaction ended.
return currency;
|
public int | getFeatureID()Returns the feature ID.
return featureID;
|
public java.lang.String | getFeatureTitle()Returns the title of the feature.
return featureTitle;
|
public long | getFinishedTimestamp()Returns the timestamp when the transaction was finished.
return timestamp;
|
public double | getPrice()Returns the price of the feature or 0 if it hasn't been
set when the transaction ended.
return price;
|
int | getRecordID()Returns Record ID of the transaction
return recordID;
|
int | getSerializedSize()Returns the size (in bytes) which is needed to serialize the transaction
record.
if (fake) {
return 0;
}
int size = 0;
try {
size = calculateSize(applicationName, featureTitle);
} catch (IOException e) {
}
return size;
|
public int | getState()Returns the final state of the transaction. It can be one of
TRANSACTION_SUCCESSFUL , TRANSACTION_FAILED ,
TRANSACTION_REJECTED .
return state;
|
public int | getStatus()Indicates status of Transaction:
RESERVED/MISSED/PASSED
return status;
|
public int | getTransactionID()Returns the transaction ID of the transaction.
return transactionID;
|
public boolean | isFake()Indicates if the current transaction record is fake. A fake record isn't
permanently stored into the transaction store file. Fake records are
produced in the debug mode and by MIDlet suites which are run without
beeing installed.
return fake;
|
static com.sun.j2me.payment.CldcTransactionRecordImpl | read(java.io.DataInputStream is)Creates a new transaction record from the data read from the given input
stream.
CldcTransactionRecordImpl newRecord = new CldcTransactionRecordImpl();
newRecord.transactionID = is.readInt();
newRecord.applicationID = is.readInt();
newRecord.applicationName = is.readUTF();
newRecord.featureID = is.readInt();
newRecord.featureTitle = is.readUTF();
newRecord.price = is.readDouble();
newRecord.currency = is.readUTF();
newRecord.state = is.readInt();
newRecord.timestamp = is.readLong();
newRecord.status = is.readInt();
return newRecord;
|
void | setRecordID(int recordID)Stores Record ID for internal usage
this.recordID = recordID;
|
void | setStatus(int status)Change status of Transaction:
RESERVED/MISSED/PASSED
if ((status == MISSED) || (status == PASSED))
{
this.status = status;
}
|
void | update(com.sun.j2me.payment.Transaction transaction)Sets the state of the transaction. It can be one of
TRANSACTION_SUCCESSFUL , TRANSACTION_FAILED ,
TRANSACTION_REJECTED .
timestamp = System.currentTimeMillis();
switch (transaction.getState()) {
case Transaction.SUCCESSFUL:
state = TransactionRecord.TRANSACTION_SUCCESSFUL;
break;
case Transaction.REJECTED:
state = TransactionRecord.TRANSACTION_REJECTED;
break;
case Transaction.FAILED:
state = TransactionRecord.TRANSACTION_FAILED;
break;
}
|
public boolean | wasMissed()Indicates if the MIDlet have or haven't been notified about the final
state of the transaction.
return (status != PASSED);
|
void | write(java.io.DataOutputStream os)Stores the transaction record into the given output stream.
os.writeInt(transactionID);
os.writeInt(applicationID);
os.writeUTF(applicationName);
os.writeInt(featureID);
os.writeUTF(featureTitle);
os.writeDouble(price);
os.writeUTF(currency);
os.writeInt(state);
os.writeLong(timestamp);
os.writeInt(status);
|