Java Code Examples for org.codehaus.groovy.runtime.InvokerHelper#setProperty()
The following examples show how to use
org.codehaus.groovy.runtime.InvokerHelper#setProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Closure.java From groovy with Apache License 2.0 | 6 votes |
private void setPropertyTryThese(String property, Object newValue, Object firstTry, Object secondTry) { try { // let's try setting the property on the first object InvokerHelper.setProperty(firstTry, property, newValue); } catch (GroovyRuntimeException e1) { if (firstTry != null && firstTry != this && firstTry != secondTry) { try { // let's try setting the property on the second object InvokerHelper.setProperty(secondTry, property, newValue); return; } catch (GroovyRuntimeException e2) { // ignore, we'll throw e1 } } throw e1; } }
Example 2
Source File: XmlUtil.java From groovy with Apache License 2.0 | 5 votes |
private static String asString(GPathResult node) { // little bit of hackery to avoid Groovy dependency in this file try { Object builder = Class.forName("groovy.xml.StreamingMarkupBuilder").getDeclaredConstructor().newInstance(); InvokerHelper.setProperty(builder, "encoding", "UTF-8"); Writable w = (Writable) InvokerHelper.invokeMethod(builder, "bindNode", node); return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + w.toString(); } catch (Exception e) { return "Couldn't convert node to string because: " + e.getMessage(); } }
Example 3
Source File: DOMCategory.java From groovy with Apache License 2.0 | 5 votes |
public static void putAt(Element self, String property, Object value) { if (property.startsWith("@")) { String attributeName = property.substring(1); Document doc = self.getOwnerDocument(); Attr newAttr = doc.createAttribute(attributeName); newAttr.setValue(value.toString()); self.setAttributeNode(newAttr); return; } InvokerHelper.setProperty(self, property, value); }
Example 4
Source File: GroovyTypeCheckingExtensionSupport.java From groovy with Apache License 2.0 | 5 votes |
@Override public void setProperty(final String property, final Object newValue) { try { InvokerHelper.setProperty(extension, property, newValue); } catch (Exception e) { super.setProperty(property, newValue); } }
Example 5
Source File: Closure.java From groovy with Apache License 2.0 | 5 votes |
public void setProperty(String property, Object newValue) { if ("delegate".equals(property)) { setDelegate(newValue); } else if ("metaClass".equals(property)) { setMetaClass((MetaClass) newValue); } else if ("resolveStrategy".equals(property)) { setResolveStrategy(((Number) newValue).intValue()); } else if ("directive".equals(property)) { setDirective(((Number) newValue).intValue()); } else { switch(resolveStrategy) { case DELEGATE_FIRST: setPropertyDelegateFirst(property, newValue); break; case DELEGATE_ONLY: InvokerHelper.setProperty(this.delegate, property, newValue); break; case OWNER_ONLY: InvokerHelper.setProperty(this.owner, property, newValue); break; case TO_SELF: super.setProperty(property, newValue); break; default: setPropertyOwnerFirst(property, newValue); } } }
Example 6
Source File: Reference.java From groovy with Apache License 2.0 | 5 votes |
public void setProperty(String property, Object newValue) { Object value = get(); if (value != null) { InvokerHelper.setProperty(value, property, newValue); } else { super.setProperty(property, newValue); } }
Example 7
Source File: FactoryBuilderSupport.java From groovy with Apache License 2.0 | 5 votes |
/** * Maps attributes key/values to properties on node. * * @param node the object from the node * @param attributes the attributes to be set */ protected void setNodeAttributes(Object node, Map attributes) { // set the properties //noinspection unchecked for (Map.Entry entry : (Set<Map.Entry>) attributes.entrySet()) { String property = entry.getKey().toString(); Object value = entry.getValue(); InvokerHelper.setProperty(node, property, value); } }
Example 8
Source File: ObjectGraphBuilder.java From groovy with Apache License 2.0 | 5 votes |
public void setChild(Object parent, Object child, String parentName, String propertyName) { try { Object property = InvokerHelper.getProperty(parent, propertyName); if (property != null && Collection.class.isAssignableFrom(property.getClass())) { ((Collection) property).add(child); } else { InvokerHelper.setProperty(parent, propertyName, child); } } catch (MissingPropertyException mpe) { // ignore } }
Example 9
Source File: GroovyBeanDefinitionReader.java From spring-analysis-note with MIT License | 4 votes |
@Override public void setProperty(String name, Object value) { InvokerHelper.setProperty(this.propertyValue, name, value); }
Example 10
Source File: GroovyBeanDefinitionReader.java From java-technology-stack with MIT License | 4 votes |
@Override public void setProperty(String name, Object value) { InvokerHelper.setProperty(this.propertyValue, name, value); }
Example 11
Source File: GroovyBeanDefinitionReader.java From lams with GNU General Public License v2.0 | 4 votes |
public void setProperty(String name, Object value) { InvokerHelper.setProperty(this.propertyValue, name, value); }
Example 12
Source File: GroovyBeanDefinitionReader.java From blog_demos with Apache License 2.0 | 4 votes |
public void setProperty(String name, Object value) { InvokerHelper.setProperty(this.propertyValue, name, value); }
Example 13
Source File: GroovyBeanDefinitionReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void setProperty(String name, Object value) { InvokerHelper.setProperty(this.propertyValue, name, value); }
Example 14
Source File: EventTriggerBinding.java From groovy with Apache License 2.0 | 4 votes |
public void bind() { InvokerHelper.setProperty(triggerBean, eventName, handler); }
Example 15
Source File: PropertyModel.java From groovy with Apache License 2.0 | 4 votes |
public void setValue(Object value) { Object source = sourceModel.getValue(); if (source != null) { InvokerHelper.setProperty(source, property, value); } }
Example 16
Source File: DefaultPropertyWriter.java From groovy with Apache License 2.0 | 4 votes |
public void write(Object owner, String propertyName, Object value) { InvokerHelper.setProperty(owner, propertyName, value); }