/** * Returns the price of the given event as a <code>String</code>. * * @param inEvent a <code>QuoteEvent</code> value * @return a <code>String</code> value */ private static String getPriceAsString(QuoteEvent inEvent) { if(inEvent != null) { return inEvent.getPrice().toPlainString(); } return NO_QUANTITY; } /**
@Override public int compare(QuoteEvent inO1, QuoteEvent inO2) { if(inO1 == inO2) { return 0; } // the first key is price, either ascending or descending int result = inO1.getPrice().compareTo(inO2.getPrice()); if(result == 0) { // prices are equal // secondary sort should be on the timestamp long o1time = inO1.getTimeMillis(); long o2time = inO2.getTimeMillis(); if(o1time < o2time) { result = -1; } else if(o1time > o2time) { result = 1; } else { result = 0; } } // invert the result to be returned if necessary to get a descending sort return result * (mIsAscending ? 1 : -1); } }
quote.setInstrument(inQuoteEvent.getInstrument()); quote.setExchange(inQuoteEvent.getExchange()); quote.setPrice(inQuoteEvent.getPrice()); quote.setProcessedTimestamp(inQuoteEvent.getProcessedTimestamp()); quote.setReceivedTimestamp(inQuoteEvent.getReceivedTimestamp());