/** * {@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; }
/** * Constructor * * @param attributeName attribute name * @param type the expeceted type for values evaluated by this criteria */ public ComparableValue(String attributeName, AttributeType type) { this.attributeName = attributeName; this.type = type; if (!this.type.isComparable()) { throw new SearchException("Illegal (non-comparable) type for comparsion (" + type + ")"); } }
/** * Construct a "like" criteria for the given expression * * @param attributeName attribute name * @param regex expression */ public ILike(String attributeName, String regex) { if ((attributeName == null) || (regex == null)) { throw new SearchException("Both the attribute name and regex must be non null."); } this.attributeName = attributeName; this.regex = regex; this.pattern = convertRegex(regex.trim()); }
private Query createQuery(Ehcache cache, String statement) throws SearchException { EhcacheSearchParser parser = new EhcacheSearchParser(new StringReader(statement)); ParseModel model; try { model = parser.QueryStatement(); } catch (ParseException p) { throw new SearchException(p); } catch (TokenMgrError e) { throw new SearchException(e); } return model.getQuery(cache); }
private AttributeType verifyCommonType() { if (values.isEmpty()) { throw new AssertionError(); } AttributeType rv = null; for (Object value : values) { if (value == null) { throw new NullPointerException("null element in set"); } AttributeType at = AttributeType.typeFor(attributeName, value); if (rv == null) { rv = at; } else if (at != rv) { throw new SearchException("Multiple types detected in collection: " + at + " and " + rv); } } return rv; }
@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); } }