com.alachisoft.ncache.client.internal.caching.SearchServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.client.internal.caching;
import Alachisoft.NCache.Caching.TagComparisonType;
import com.alachisoft.ncache.client.CacheReader;
import com.alachisoft.ncache.client.QueryCommand;
import com.alachisoft.ncache.client.internal.util.ConversionUtil;
import com.alachisoft.ncache.client.services.SearchService;
import com.alachisoft.ncache.runtime.exceptions.CacheException;
import java.io.IOException;
import java.util.*;
import static tangible.DotNetToJavaStringHelper.isNullOrEmpty;
import static tangible.DotNetToJavaStringHelper.isNull;
class SearchServiceImpl implements SearchService {
protected CacheImpl cacheContainer;
SearchServiceImpl(CacheImpl cache) {
cacheContainer = cache;
}
CacheImpl getCacheContainer() {
return cacheContainer;
}
void setCacheContainer(CacheImpl value) {
cacheContainer = value;
}
//region Execute Reader Operations
@Override
public int executeNonQuery(QueryCommand queryCommand) throws CacheException {
if (queryCommand == null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: queryCommand");
}
if (queryCommand.getQuery()==null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: query");
}
if (queryCommand.getQuery()=="") {
throw new IllegalArgumentException("Value cannot be empty.\nParameter name: query");
}
return cacheContainer.executeNonQuery(queryCommand.getQuery(), queryCommand.getParameters());
}
@Override
public CacheReader executeReader(QueryCommand queryCommand) throws CacheException {
return executeReader(queryCommand, true, -1);
}
@Override
public CacheReader executeReader(QueryCommand queryCommand, boolean getData, int chunkSize) throws CacheException {
if (queryCommand == null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: queryCommand");
}
if (queryCommand.getQuery()==null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: query");
}
if (queryCommand.getQuery()=="") {
throw new IllegalArgumentException("Value cannot be empty.\nParameter name: query");
}
return cacheContainer.executeReader(queryCommand.getQuery(), queryCommand.getParameters(), getData, chunkSize);
}
//endregion
//region Tag Based Operations
@Override
public T executeScalar(QueryCommand queryCommand, Class> cls) throws CacheException {
if (queryCommand == null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: queryCommand");
}
if (queryCommand.getQuery()==null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: query");
}
if (queryCommand.getQuery()=="") {
throw new IllegalArgumentException("Value cannot be empty.\nParameter name: query");
}
Object scalarValue = null;
CacheReader reader = null;
try {
reader = cacheContainer.executeReader(queryCommand.getQuery(), queryCommand.getParameters(), true, -1);
if (reader != null) {
if (reader.read()) {
if (reader.getFieldCount() > 1) {
scalarValue = reader.