Ejemplo n.º 1
0
 /** Insert an object into this variable at a position. */
 @Override
 public void insertAt(Variable v, Variable index) throws ScriptException {
   if (v == null) throw new ScriptException(composeMessage("Can't insert a null object"));
   if (index == null)
     configurationNode.addChild(configurationNode.getChildCount(), v.getConfigurationNodeValue());
   else {
     int indexValue = index.getIntValue();
     if (indexValue < 0 || indexValue > configurationNode.getChildCount())
       throw new ScriptException(composeMessage("Insert out of bounds: " + indexValue));
     configurationNode.addChild(indexValue, v.getConfigurationNodeValue());
   }
 }
Ejemplo n.º 2
0
 @Override
 public VariableReference plus(Variable v) throws ScriptException {
   if (v == null) throw new ScriptException(composeMessage("Can't add a null object"));
   ConfigurationNode node = v.getConfigurationNodeValue();
   ConfigurationNode cn = new ConfigurationNode(configurationNode.getType());
   cn.setValue(configurationNode.getValue());
   Iterator<String> attIter = configurationNode.getAttributes();
   while (attIter.hasNext()) {
     String attrName = attIter.next();
     String attrValue = configurationNode.getAttributeValue(attrName);
     cn.setAttribute(attrName, attrValue);
   }
   int i = 0;
   while (i < configurationNode.getChildCount()) {
     ConfigurationNode child = configurationNode.findChild(i++);
     cn.addChild(cn.getChildCount(), child);
   }
   cn.addChild(cn.getChildCount(), node);
   return new VariableConfigurationNode(cn);
 }