@Override public void setProperty(String name, Object value) { throw new MissingPropertyException("configurations cannot be set directly"); }
/** * @param name the name of the variable to lookup * @return the variable value */ public Object getVariable(String name) { try { return getProxyBuilder().doGetVariable(name); } catch(MissingPropertyException mpe) { if(mpe.getProperty().equals(name) && propertyMissingDelegate != null) { return propertyMissingDelegate.call(new Object[]{name}); } throw mpe; } }
public String getMessageWithoutLocationText() { final Throwable cause = getCause(); if (cause == null) { if (super.getMessageWithoutLocationText() != null) { return super.getMessageWithoutLocationText(); } return "No such property: " + property + " for class: " + type.getName() + MethodRankHelper.getPropertySuggestionString(property, type); } return "No such property: " + property + " for class: " + type.getName() + ". Reason: " + cause; }
private static List getAtIterable(Iterable coll, String property, List<Object> answer) { for (Object item : coll) { if (item == null) continue; Object value; try { value = InvokerHelper.getProperty(item, property); } catch (MissingPropertyExceptionNoStack mpe) { String causeString = new MissingPropertyException(mpe.getProperty(), mpe.getType()).toString(); throw new MissingPropertyException("Exception evaluating property '" + property + "' for " + coll.getClass().getName() + ", Reason: " + causeString); } answer.add(value); } return answer; }
/** * Support the subscript operator for List * * @param coll a Collection * @param property a String * @return a List * @since 1.0 */ public static List getAt(Collection coll, String property) { List answer = new ArrayList(coll.size()); for (Object item : coll) { if (item == null) continue; Object value; try { value = InvokerHelper.getProperty(item, property); } catch (MissingPropertyExceptionNoStack mpe) { String causeString = new MissingPropertyException(mpe.getProperty(), mpe.getType()).toString(); throw new MissingPropertyException("Exception evaluating property '" + property + "' for " + coll.getClass().getName() + ", Reason: " + causeString); } answer.add(value); } return answer; }
private String getPropertyGetterName(String prop) { if (prop == null || prop.length() < 1) { throw new MissingPropertyException(prop, target.getClass()); } return "get" + prop.substring(0, 1).toUpperCase() + prop.substring(1); }
/** * Support the subscript operator for Collection. * <pre class="groovyTestCase">assert [String, Long, Integer] == ["a",5L,2]["class"]</pre> * * @param coll a Collection * @param property a String * @return a List * @since 1.0 */ public static List getAt(Collection coll, String property) { List<Object> answer = new ArrayList<Object>(coll.size()); for (Object item : coll) { if (item == null) continue; Object value; try { value = InvokerHelper.getProperty(item, property); } catch (MissingPropertyExceptionNoStack mpe) { String causeString = new MissingPropertyException(mpe.getProperty(), mpe.getType()).toString(); throw new MissingPropertyException("Exception evaluating property '" + property + "' for " + coll.getClass().getName() + ", Reason: " + causeString); } answer.add(value); } return answer; }
/** * Overloaded to make variables appear as bean properties or via the subscript operator */ public Object getProperty(String property) { try { return getProxyBuilder().doGetProperty(property); } catch (MissingPropertyException mpe) { if ((getContext() != null) && (getContext().containsKey(property))) { return getContext().get(property); } else { try { return getMetaClass().getProperty(this, property); } catch(MissingPropertyException mpe2) { if(mpe2.getProperty().equals(property) && propertyMissingDelegate != null) { return propertyMissingDelegate.call(new Object[]{property}); } throw mpe2; } } } }
public String getMessageWithoutLocationText() { final Throwable cause = getCause(); if (cause == null) { if (super.getMessageWithoutLocationText() != null) { return super.getMessageWithoutLocationText(); } return "No such property: " + property + " for class: " + type.getName(); } return "No such property: " + property + " for class: " + type.getName() + ". Reason: " + cause; }
/** * @param name the name of the variable to lookup * @return the variable value */ public Object getVariable(String name) { if (variables == null) throw new MissingPropertyException(name, this.getClass()); Object result = variables.get(name); if (result == null && !variables.containsKey(name)) { throw new MissingPropertyException(name, this.getClass()); } return result; }
/** * Support the subscript operator for List * * @param coll a Collection * @param property a String * @return a List */ public static List getAt(Collection coll, String property) { List answer = new ArrayList(coll.size()); for (Iterator iter = coll.iterator(); iter.hasNext();) { Object item = iter.next(); Object value; try { value = InvokerHelper.getProperty(item, property); } catch (MissingPropertyExceptionNoStack mpe) { String causeString = new MissingPropertyException(mpe.getProperty(), mpe.getType()).toString(); throw new MissingPropertyException("Exception evaluating property '" + property + "' for " + coll.getClass().getName() + ", Reason: " + causeString); } answer.add(value); } return answer; }
@Override public Object getProperty(final String name) { try { return doGetProperty(name); } catch (MissingFieldException e) { if (e.getField().equals(name) && scope.containsKey(name)) { return scope.get(name); } throw e; } catch (MissingPropertyException e) { if (e.getProperty().equals(name) && scope.containsKey(name)) { return scope.get(name); } throw e; } }
public String getMessageWithoutLocationText() { final Throwable cause = getCause(); if (cause == null) { if (super.getMessageWithoutLocationText() != null) { return super.getMessageWithoutLocationText(); } return "No such property: " + property + " for class: " + type.getName(); } return "No such property: " + property + " for class: " + type.getName() + ". Reason: " + cause; }
/** * Retrieve the value of the property by its (case-insensitive) name. * * @param property is the name of the property to look at * @return the value of the property */ public Object getProperty(String property) { try { Object key = lookupKeyIgnoringCase(property); if (key != null) { return result.get(key); } throw new MissingPropertyException(property, GroovyRowResult.class); } catch (Exception e) { throw new MissingPropertyException(property, GroovyRowResult.class, e); } }
/** * Support the subscript operator for List * * @param coll a Collection * @param property a String * @return a List * @since 1.0 */ public static List getAt(Collection coll, String property) { List answer = new ArrayList(coll.size()); for (Iterator iter = coll.iterator(); iter.hasNext();) { Object item = iter.next(); if (item == null) continue; Object value; try { value = InvokerHelper.getProperty(item, property); } catch (MissingPropertyExceptionNoStack mpe) { String causeString = new MissingPropertyException(mpe.getProperty(), mpe.getType()).toString(); throw new MissingPropertyException("Exception evaluating property '" + property + "' for " + coll.getClass().getName() + ", Reason: " + causeString); } answer.add(value); } return answer; }
/** * @param name the name of the variable to lookup * @return the variable value */ public Object getVariable(String name) { try { return getProxyBuilder().doGetVariable(name); } catch(MissingPropertyException mpe) { if(mpe.getProperty().equals(name) && propertyMissingDelegate != null) { return propertyMissingDelegate.call(new Object[]{name}); } throw mpe; } }
public String getMessageWithoutLocationText() { final Throwable cause = getCause(); if (cause == null) { if (super.getMessageWithoutLocationText() != null) { return super.getMessageWithoutLocationText(); } return "No such property: " + property + " for class: " + type.getName(); } return "No such property: " + property + " for class: " + type.getName() + ". Reason: " + cause; }
@Override public Object getProperty(String name) { Object config = configurationRegistry.getConfigurationByName(name); if (config == null) throw new MissingPropertyException("configuration not found"); return config; }
private static Object evaluateGroovyExpression(final String script, final Binding binding) throws GroovyException { final ClassLoader scriptClassLoader = Thread.currentThread().getContextClassLoader(); final Script groovyScript = GroovyScriptBuilder.getScript(script, scriptClassLoader); groovyScript.setBinding(binding); Object result = null; try { result = groovyScript.run(); } catch (final MissingPropertyException e) { final String lineSeparator = System.getProperty("line.separator", "\n"); final StringBuilder stb = new StringBuilder(); stb.append("Error in Groovy script: unable to use element \"" + e.getProperty() + "\""); stb.append(lineSeparator); stb.append(lineSeparator); stb.append("Possible cause:"); stb.append(lineSeparator); stb.append("- missing import"); stb.append(lineSeparator); stb.append("- variable not found (wrong name, undefined)"); stb.append(lineSeparator); stb.append("- ..."); stb.append(lineSeparator); stb.append(lineSeparator); stb.append("Script:"); stb.append(lineSeparator); stb.append("\"" + script + "\""); stb.append(lineSeparator); throw new GroovyException(stb.toString(), e); } return result; }
public String getMessageWithoutLocationText() { final Throwable cause = getCause(); if (cause == null) { if (super.getMessageWithoutLocationText() != null) { return super.getMessageWithoutLocationText(); } return "No such property: " + property + " for class: " + type.getName() + MethodRankHelper.getPropertySuggestionString(property, type); } return "No such property: " + property + " for class: " + type.getName() + ". Reason: " + cause; }