當前位置: 首頁>>代碼示例>>Java>>正文


Java Binding.getVariable方法代碼示例

本文整理匯總了Java中groovy.lang.Binding.getVariable方法的典型用法代碼示例。如果您正苦於以下問題:Java Binding.getVariable方法的具體用法?Java Binding.getVariable怎麽用?Java Binding.getVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在groovy.lang.Binding的用法示例。


在下文中一共展示了Binding.getVariable方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValue

import groovy.lang.Binding; //導入方法依賴的package包/類
@Nonnull
@Override
public Object getValue(@Nonnull CpsScript script) throws Exception {
    Binding binding = script.getBinding();
    script.println();
    Object openshift;
    if (binding.hasVariable(getName())) {
        openshift = binding.getVariable(getName());
    } else {
        // Note that if this were a method rather than a constructor, we
        // would need to mark it @NonCPS lest it throw
        // CpsCallableInvocation.
        openshift = script.getClass().getClassLoader()
                .loadClass("com.openshift.jenkins.plugins.OpenShiftDSL")
                .getConstructor(CpsScript.class).newInstance(script);
        binding.setVariable(getName(), openshift);
    }
    return openshift;

}
 
開發者ID:openshift,項目名稱:jenkins-client-plugin,代碼行數:21,代碼來源:OpenShiftGlobalVariable.java

示例2: execute

import groovy.lang.Binding; //導入方法依賴的package包/類
/**
 * Evaluates this condition on the supplied object and with the supplied parameters.
 * 
 * The supplied parameters can contain special keys (see the PARAM_
 * constants in this class).
 * 
 * If such parameters are provided and this condition has a targetObject
 * param specified, one of these will be used when evaluating instead of
 * whatever was passed in as the object.
 * 
 * @param object
 *            - on which object his should be executed. Depending on the
 *            parameters passed, this might not actually be used
 * @param parameters
 * @return true if the condition evaluated as true, false otherwise
 */
public final boolean execute(Object object, Binding parameters) {
	if (getParameter(PARAM_TARGET_OBJECT) != null) {
		String testObject = getParameter(PARAM_TARGET_OBJECT);
		if (PARAM_PC_AT_DIALOGUE.equals(testObject)) {
			object = parameters.getVariable(testObject);
		} else if (PARAM_NPC_AT_DIALOGUE.equals(testObject)) {
			object = parameters.getVariable(testObject);
		} else if (PARAM_ENTERING_CHARACTER.equals(testObject)) {
			object = parameters.getVariable(testObject);
		} else if (PARAM_USER.equals(testObject)) {
			object = parameters.getVariable(testObject);
		} else if (PARAM_PLAYER.equals(testObject)) {
			object = GameState.getPlayerCharacterGroup();
		} else if (PARAM_GLOBAL.equals(testObject)) {
			object = gameState.variables();
		} else {
			object = GameState.getGameObjectById(testObject);
		}
	}
	boolean returnValue = evaluate(object, parameters);
	Log.log("Evaluated {0} with parameters {1} on object {2}, condition returned {3}", Log.LogType.CONDITION, this.getClass().getName(), Arrays.toString(conditionParameters), object, returnValue);
	return returnValue;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:40,代碼來源:Condition.java

示例3: run

import groovy.lang.Binding; //導入方法依賴的package包/類
@Override
protected void run(Object object, Binding parameters) {
	GameCharacter targetCharacter, sourceCharacter;
	GameCharacter npc = (GameCharacter) parameters.getVariable(PARAM_NPC_AT_DIALOGUE);
	GameCharacter pc = (GameCharacter) parameters.getVariable(PARAM_PC_AT_DIALOGUE);
	
	if (CoreUtil.equals(object, pc)) {
		targetCharacter = npc;
		sourceCharacter = pc;
	} else {
		targetCharacter = pc;
		sourceCharacter = npc;
	}
	
	String itemId = getParameter(XML_ITEM);
	InventoryItem item = sourceCharacter != null ? sourceCharacter.getInventory().getItem(itemId) : null;
	if (item == null) {
		item = InventoryItem.getItem(itemId);
	}
	
	targetCharacter.getInventory().addItem(item);
	Log.logLocalized("itemReceived", LogType.INVENTORY, item.getName(), targetCharacter.getName());
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:24,代碼來源:GiveItem.java

示例4: getValue

import groovy.lang.Binding; //導入方法依賴的package包/類
@Override public Object getValue(CpsScript script) throws Exception {
    Binding binding = script.getBinding();
    Object gerrit;
    if (binding.hasVariable(getName())) {
        gerrit = binding.getVariable(getName());
    } else {
        // Note that if this were a method rather than a constructor, we would need to mark it @NonCPS lest it throw CpsCallableInvocation.
        gerrit = script.getClass().getClassLoader().loadClass("jenkins.plugins.gerrit.workflow.Gerrit").getConstructor(CpsScript.class).newInstance(script);
        binding.setVariable(getName(), gerrit);
    }
    return gerrit;
}
 
開發者ID:GerritForge,項目名稱:gerrit-plugin,代碼行數:13,代碼來源:GerritDSL.java

示例5: getGroovyRenderer

import groovy.lang.Binding; //導入方法依賴的package包/類
private PrimitiveRenderer getGroovyRenderer() throws IOException, ResourceException, ScriptException {
  if (this.groovyRenderer == null) {
    GroovyScriptEngine gse = this.getGroovyScriptEngine();
    Binding binding = this.getBinding();
    gse.run(this.groovyFile.getName(), binding);
    this.groovyRenderer = (PrimitiveRenderer) binding.getVariable("renderer");
  }
  return this.groovyRenderer;
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:10,代碼來源:GroovyPrimitiveRenderer.java

示例6: executeGPath

import groovy.lang.Binding; //導入方法依賴的package包/類
private void executeGPath() throws ActivityException {
    String transform = (String) getAttributeValue(RULE);
    if (StringHelper.isEmpty(transform)) {
        logger.info("No transform defined for activity: " + getActivityName());
        return;
    }

    GroovyShell shell = new GroovyShell(getClass().getClassLoader());
    Script script = shell.parse(transform);
    Binding binding = new Binding();

    Variable inputVar = getMainProcessDefinition().getVariable(inputDocument);
    if (inputVar == null)
      throw new ActivityException("Input document variable not found: " + inputDocument);
    String inputVarName = inputVar.getName();
    Object inputVarValue = getGPathParamValue(inputVarName, inputVar.getType());
    binding.setVariable(inputVarName, inputVarValue);

    Variable outputVar = getMainProcessDefinition().getVariable(getOutputDocuments()[0]);
    String outputVarName = outputVar.getName();
    Object outputVarValue = getGPathParamValue(outputVarName, outputVar.getType());
    binding.setVariable(outputVarName, outputVarValue);

    script.setBinding(binding);

    script.run();

    Object groovyVarValue = binding.getVariable(outputVarName);
    setGPathParamValue(outputVarName, outputVar.getType(), groovyVarValue);
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:31,代碼來源:TransformActivity.java

示例7: run

import groovy.lang.Binding; //導入方法依賴的package包/類
@Override
protected void run(Object object, Binding parameters) {
	GameCharacter pc = (GameCharacter) parameters.getVariable(PARAM_PC_AT_DIALOGUE);
	GameCharacter npc = (GameCharacter) parameters.getVariable(PARAM_NPC_AT_DIALOGUE);
	
	if (npc.canTradeWith(Faction.PLAYER_FACTION)) {
		UIManager.displayTradingInventory(pc, npc);
	} else {
		UIManager.displayMessage(npc.getName(), Strings.getString(Faction.STRING_TABLE,"CannotTrade"));
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:12,代碼來源:StartTrading.java

示例8: run

import groovy.lang.Binding; //導入方法依賴的package包/類
@Override
protected void run(Object object, Binding parameters) {
	if (object instanceof AbstractGameCharacter) {
		String talkerId = getParameter(XML_DIALOGUE_NPC);
		String dialogueId = getParameter(XML_DIALOGUE_ID);
		if (dialogueId == null) {
			Object initialObject = parameters.getVariable(PARAM_INITIAL_OBJECT);
			if (initialObject instanceof ThingWithId) {
				dialogueId = ((ThingWithId)initialObject).getId();
			}
		}
		if (dialogueId == null) {
			Log.log("No dialogue id found for object .", LogType.ERROR, object);
			return;
		}
		if (talkerId != null && talkerId.startsWith("__")) {
			Object talkerIdObject = parameters.getVariable(talkerId);
			if (talkerIdObject instanceof ThingWithId) {
				talkerId = ((ThingWithId)talkerIdObject).getId();
			}
		}
		final GameCharacter talker = talkerId != null ? (GameCharacter) GameState.getGameObjectById(talkerId, GameCharacter.class)
				: null;
		UIManager.displayDialogue(((AbstractGameCharacter) object).getRepresentative(), talker, dialogueId,
				new DialogueCallback() {
					@Override
					public void onDialogueEnd(PCTalk dialogueStopper) {
						if (talker != null) {
							talker.setMetNPCBefore(true);
						}

					}
				}, null);
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:36,代碼來源:DisplayDialogue.java

示例9: getProperty

import groovy.lang.Binding; //導入方法依賴的package包/類
/**
 * This method overrides property retrieval in the scope of the
 * GroovyBeanDefinitionReader to either:
 * <ul>
 * <li>Retrieve a variable from the bean builder's binding if it exists
 * <li>Retrieve a RuntimeBeanReference for a specific bean if it exists
 * <li>Otherwise just delegate to MetaClass.getProperty which will resolve
 * properties from the GroovyBeanDefinitionReader itself
 * </ul>
 */
public Object getProperty(String name) {
	Binding binding = getBinding();
	if (binding != null && binding.hasVariable(name)) {
		return binding.getVariable(name);
	}
	else {
		if (this.namespaces.containsKey(name)) {
			return createDynamicElementReader(name);
		}
		if (getRegistry().containsBeanDefinition(name)) {
			GroovyBeanDefinitionWrapper beanDefinition = (GroovyBeanDefinitionWrapper)
					getRegistry().getBeanDefinition(name).getAttribute(GroovyBeanDefinitionWrapper.class.getName());
			if (beanDefinition != null) {
				return new GroovyRuntimeBeanReference(name, beanDefinition, false);
			}
			else {
				return new RuntimeBeanReference(name, false);
			}
		}
		// This is to deal with the case where the property setter is the last
		// statement in a closure (hence the return value)
		else if (this.currentBeanDefinition != null) {
			MutablePropertyValues pvs = this.currentBeanDefinition.getBeanDefinition().getPropertyValues();
			if (pvs.contains(name)) {
				return pvs.get(name);
			}
			else {
				DeferredProperty dp = this.deferredProperties.get(this.currentBeanDefinition.getBeanName() + name);
				if (dp != null) {
					return dp.value;
				}
				else {
					return getMetaClass().getProperty(this, name);
				}
			}
		}
		else {
			return getMetaClass().getProperty(this, name);
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:52,代碼來源:GroovyBeanDefinitionReader.java

示例10: getProperty

import groovy.lang.Binding; //導入方法依賴的package包/類
/**
 * This method overrides property retrieval in the scope of the
 * {@code GroovyBeanDefinitionReader} to either:
 * <ul>
 * <li>Retrieve a variable from the bean builder's binding if it exists
 * <li>Retrieve a RuntimeBeanReference for a specific bean if it exists
 * <li>Otherwise just delegate to MetaClass.getProperty which will resolve
 * properties from the {@code GroovyBeanDefinitionReader} itself
 * </ul>
 */
public Object getProperty(String name) {
	Binding binding = getBinding();
	if (binding != null && binding.hasVariable(name)) {
		return binding.getVariable(name);
	}
	else {
		if (this.namespaces.containsKey(name)) {
			return createDynamicElementReader(name);
		}
		if (getRegistry().containsBeanDefinition(name)) {
			GroovyBeanDefinitionWrapper beanDefinition = (GroovyBeanDefinitionWrapper)
					getRegistry().getBeanDefinition(name).getAttribute(GroovyBeanDefinitionWrapper.class.getName());
			if (beanDefinition != null) {
				return new GroovyRuntimeBeanReference(name, beanDefinition, false);
			}
			else {
				return new RuntimeBeanReference(name, false);
			}
		}
		// This is to deal with the case where the property setter is the last
		// statement in a closure (hence the return value)
		else if (this.currentBeanDefinition != null) {
			MutablePropertyValues pvs = this.currentBeanDefinition.getBeanDefinition().getPropertyValues();
			if (pvs.contains(name)) {
				return pvs.get(name);
			}
			else {
				DeferredProperty dp = this.deferredProperties.get(this.currentBeanDefinition.getBeanName() + name);
				if (dp != null) {
					return dp.value;
				}
				else {
					return getMetaClass().getProperty(this, name);
				}
			}
		}
		else {
			return getMetaClass().getProperty(this, name);
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:52,代碼來源:GroovyBeanDefinitionReader.java


注:本文中的groovy.lang.Binding.getVariable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。