/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Double)) { throw new SearchException("Expecting a Double value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Integer)) { throw new SearchException("Expecting an Integer value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Short)) { throw new SearchException("Expecting a Short value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Boolean)) { throw new SearchException("Expecting a Boolean value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Byte)) { throw new SearchException("Expecting a Byte value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Float)) { throw new SearchException("Expecting a Float value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Long)) { throw new SearchException("Expecting a Long value for attribute [" + name + "] but was " + type(value)); } } },
private void checkFrozen() { if (frozen) { throw new SearchException("Query is frozen and cannot be mutated"); } }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Enum)) { throw new SearchException("Expecting a enum value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Character)) { throw new SearchException("Expecting a Character value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof String)) { throw new SearchException("Expecting a String value for attribute [" + name + "] but was " + type(value)); } } };
public void setCacheName(String cacheName) { String[] tokens = cacheName.split("\\."); if (tokens.length > 2) { throw new SearchException("Cache manager name not specified."); } else if (tokens.length == 2) { this.cacheManagerName = tokens[0]; this.cacheName = tokens[1]; this.cacheManagerNameWasAttempted = true; } else { this.cacheName = cacheName; } }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (value == null || value.getClass() != java.util.Date.class) { throw new SearchException("Expecting a java.util.Date value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (value == null || value.getClass() != java.sql.Date.class) { throw new SearchException("Expecting a java.sql.Date value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ public List<Object> getAggregatorResults() throws SearchException { if (this.aggregateResults.isEmpty()) { throw new SearchException("No aggregators present in query"); } return this.aggregateResults; }
@Override public Query createQuery(String statement) throws SearchException { Map<String, String> cacheManagerCacheNameMap = extractSearchCacheName(statement); String cacheManagerName = cacheManagerCacheNameMap.values().iterator().next(); String cacheName = cacheManagerCacheNameMap.keySet().iterator().next(); if (cacheManagerCacheNameMap.size() == 0) { throw new SearchException("Please specify the cache's name with the FROM clause."); } else { return createQuery(getCache(cacheName, cacheManagerName), statement); } }
private static AttributeType computeType(String attributeName, Object min, Object max) { if ((min == null) || (max == null)) { throw new NullPointerException(); } AttributeType minType = AttributeType.typeFor(attributeName, min); AttributeType maxType = AttributeType.typeFor(attributeName, max); if (minType != maxType) { throw new SearchException("Different types for min (" + minType + ") and max (" + maxType + ")"); } return minType; }
/** * {@inheritDoc} */ public Object getKey() { if (query.requestsKeys()) { return basicGetKey(); } throw new SearchException("keys not included in query. Use includeKeys() to add keys to results."); }
/** * {@inheritDoc} */ public Object getValue() throws SearchException { if (query.requestsValues()) { return basicGetValue(); } throw new SearchException("values not included in query. Use includeValues() to add values to results."); }
/** * {@inheritDoc} */ public <T> T getAttribute(Attribute<T> attribute) { String name = attribute.getAttributeName(); if (!query.requestedAttributes().contains(attribute)) { throw new SearchException("Attribute [" + name + "] not included in query"); } return (T) basicGetAttribute(name); }