use of com.swiftmq.impl.streams.comp.message.Property in project swiftmq-ce by iitsoftware.
the class Memory method group.
/**
* Groups all Messages over a Property and returns a Group Result.
*
* @param propName Property Name
* @return GroupResult
* @throws Exception
*/
public GroupResult group(String propName) throws Exception {
Map<Object, Memory> map = new HashMap<Object, Memory>();
for (int i = 0; i < size(); i++) {
Message message = at(i);
Property property = message.property(propName);
Object value = property.value().toObject();
Memory mem = map.get(value);
if (mem == null) {
mem = create(ctx);
map.put(value, mem);
}
mem.add(message);
}
return new GroupResult(ctx, propName, map.values().toArray(new Memory[map.size()]));
}
use of com.swiftmq.impl.streams.comp.message.Property in project swiftmq-ce by iitsoftware.
the class Memory method max.
/**
* Returns the Message with the maximum value of a Property.
*
* @param propName Property Name
* @return Message
* @throws Exception
*/
public Message max(String propName) throws Exception {
Comparable value = null;
Message selected = null;
for (int i = 0; i < size(); i++) {
Message message = at(i);
Property property = message.property(propName);
Comparable val = (Comparable) property.value().toObject();
if (value == null || val.compareTo(value) > 0) {
value = val;
selected = message;
}
}
return selected;
}
use of com.swiftmq.impl.streams.comp.message.Property in project swiftmq-ce by iitsoftware.
the class Memory method min.
/**
* Returns the Message with the minimum value of a Property.
*
* @param propName Property Name
* @return Message
* @throws Exception
*/
public Message min(String propName) throws Exception {
Comparable value = null;
Message selected = null;
for (int i = 0; i < size(); i++) {
Message message = at(i);
Property property = message.property(propName);
Comparable val = (Comparable) property.value().toObject();
if (value == null || val.compareTo(value) < 0) {
value = val;
selected = message;
}
}
return selected;
}
use of com.swiftmq.impl.streams.comp.message.Property in project swiftmq-ce by iitsoftware.
the class Memory method values.
/**
* Returns all values of a Property in the Message order.
*
* @param propName Property Name
* @return List of values
* @throws Exception
*/
public List<Object> values(String propName) throws Exception {
List<Object> list = new ArrayList<Object>(size());
for (int i = 0; i < size(); i++) {
Message message = at(i);
Property property = message.property(propName);
list.add(property.value().toObject());
}
return list;
}