/** * Gets the value of the variable, or if it's not defined, return the given default value object. */ public Object getVariableWithDefaultValue(String name, Object defaultValue) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; value = defaultValue; if (isInherit()) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariableWithDefaultValue(name, defaultValue); } } return value; }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
/** * Populate a context with variables, including parent variables if inheritance is enabled. * * @param destContext the destination context * @param sourceContext the source context */ public static void populateVariables( JellyContext destContext, JellyContext sourceContext ) { if ( sourceContext != null ) { if ( !"false".equals( sourceContext.getVariable( "maven.property.inheritance" ) ) && ( !"false".equals( destContext.getVariable( "maven.property.inheritance" ) ) ) ) { populateVariables( destContext, sourceContext.isInherit() ? sourceContext.getParent() : null ); } destContext.getVariables().putAll( sourceContext.getVariables() ); } destContext.setVariable( "context", destContext ); } }