com.alachisoft.ncache.client.internal.messaging.MessageEventItem Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.messaging;
import Alachisoft.NCache.Common.BitSet;
import Alachisoft.NCache.Util.MiscUtil;
import com.alachisoft.ncache.client.CacheItemVersion;
import com.alachisoft.ncache.client.EventCacheItem;
import com.alachisoft.ncache.client.EventCacheItemWrapperInternal;
import com.alachisoft.ncache.client.internal.caching.CacheItemRemovedReason;
import com.alachisoft.ncache.client.internal.caching.QueryChangeType;
import com.alachisoft.ncache.common.protobuf.EventCacheItemCommandProtocol;
import com.alachisoft.ncache.runtime.CacheItemPriority;
import com.alachisoft.ncache.runtime.events.EventDataFilter;
import Alachisoft.NCache.Common.Caching.UserBinaryObject;
import com.google.protobuf.ByteString;
import java.util.List;
public class MessageEventItem extends MessageEventItemBase {
private String cqId;
private EventCacheItem item;
private EventCacheItem oldItem;
private EventDataFilter eventDataFilter;
private QueryChangeType queryChangeType;
private CacheItemRemovedReason reason;
public String getCQId() {
return cqId;
}
public void setCQId(String value) {
cqId = value;
}
public EventCacheItem getItem() {
return item;
}
public void setItem(EventCacheItem value) {
item = value;
}
public EventCacheItem getOldItem() {
return oldItem;
}
public void setOldItem(EventCacheItem value) {
oldItem = value;
}
public EventDataFilter getDataFilter() {
return eventDataFilter;
}
public void setDataFilter(EventDataFilter value) {
eventDataFilter = value;
}
public QueryChangeType getChangeType() {
return queryChangeType;
}
public void setChangeType(QueryChangeType value) {
queryChangeType = value;
}
public CacheItemRemovedReason getReason() {
return reason;
}
public void setReason(CacheItemRemovedReason value) {
reason = value;
}
public EventCacheItem convertToEventCacheItem(EventCacheItemCommandProtocol.EventCacheItem entry, boolean isGeneraEvent) {
EventCacheItem eventCacheItem = EventCacheItemWrapperInternal.createEventCacheItem();
eventCacheItem.setGroup(entry.getGroup());
eventCacheItem.setCacheItemVersion(new CacheItemVersion());
eventCacheItem.getCacheItemVersion().setVersion(entry.getItemVersion());
eventCacheItem.setCacheItemPriority(CacheItemPriority.forValue(entry.getPriority()));
EventCacheItemWrapperInternal.setFlagMap(eventCacheItem,new BitSet((byte) entry.getFlagMap()));
if (isGeneraEvent || eventDataFilter == EventDataFilter.DataWithMetadata) {
if (entry.getValueCount() > 0) {
List val = (List) entry.getValueList();
UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(entry.getValueList());
if (ubObject != null) {
EventCacheItemWrapperInternal.setValue(eventCacheItem,ubObject.getFullObject());
}
}
}
eventCacheItem.setEntryType(MiscUtil.protoItemTypeToEntryType(entry.getItemType()));
return eventCacheItem;
}
}