Set indicated external-xacml3 node to be the leaves of the MIDD

@param midd
@param extNode
322902
@SuppressWarnings("rawtypes")
    private void setEffectNode(AbstractNode midd, ExternalNode3 extNode) throws MIDDException {
        // Replace current external nodes in the MIDD with the extNode (XACML 3 external node)

        if (!(midd instanceof InternalNode)) {
            throw new IllegalArgumentException("MIDD argument must not be an ExternalNode");
        }

        InternalNode currentNode = (InternalNode) midd;

        Stack<InternalNode> stackNodes = new Stack<InternalNode>();

        stackNodes.push(currentNode);

        while (!stackNodes.empty()) {
            InternalNode n = stackNodes.pop();

            // Change indeterminate state of the internal node,
            //	- By default is NotApplicable (XACML 3.0, sec 7.3.5, 7.19.3)
            // 	- If the attribute "MustBePresent" is true, then state is "Indeterminate_P" if Effect is "Permit",
            //	  "Indeterminate_D" if Effect is "Deny" - XACML 3.0, section 7.11

            if (n.getStateIN() == DecisionType.Indeterminate) { // this attribute has 'MustBePresent'=true
                if (ruleEffect == DecisionType.Deny) {
                    n.setState(new InternalNodeState(nl.uva.sne.midd.DecisionType.Indeterminate_D));
                } else if (ruleEffect == DecisionType.Permit) {
                    n.setState(new InternalNodeState(nl.uva.sne.midd.DecisionType.Indeterminate_P));
                }
            }
//			else {
//				n.setState(new InternalNodeState(nl.uva.sne.midd.DecisionType.NotApplicable));
//			}

            // search for all children of the poped internal node
            @SuppressWarnings("unchecked")
            Iterator<AbstractEdge> it = n.getEdges().iterator();
            while (it.hasNext()) {
                AbstractEdge edge = it.next();
                AbstractNode child = edge.getSubDiagram();
                if (child instanceof InternalNode) {
                    stackNodes.push((InternalNode) child);
                } else {
                    edge.setSubDiagram(extNode);        // set the final edge pointing to the xacml3 external node.
                }
            }
        }
    }
578180
public void updateNode(CmsSitemapTreeNode node) {

        CmsSitemapTreeNodeData data = (CmsSitemapTreeNodeData)node.getData();
        try {
            CmsSitemapTreeNodeData changedData = m_treeDataProvider.getData(
                A_CmsUI.getCmsObject().readResource(
                    data.getClientEntry().getId(),
                    CmsResourceFilter.IGNORE_EXPIRATION));
            CmsSitemapTreeNode changedNode = createNode(changedData);
            initEventHandlers(changedNode);
            ComponentContainer parent = (ComponentContainer)(node.getParent());
            parent.replaceComponent(node, changedNode);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
279790
public void transformSelectedNodes(TransformerImpl transformer)
          throws TransformerException
  {

    final XPathContext xctxt = transformer.getXPathContext();
    final int sourceNode = xctxt.getCurrentNode();
    DTMIterator sourceNodes = m_selectExpression.asIterator(xctxt,
            sourceNode);

    try
    {

      final Vector keys = (m_sortElems == null)
              ? null
              : transformer.processSortKeys(this, sourceNode);

      // Sort if we need to.
      if (null != keys)
        sourceNodes = sortNodes(xctxt, keys, sourceNodes);

      xctxt.pushCurrentNode(DTM.NULL);

      IntStack currentNodes = xctxt.getCurrentNodeStack();

      xctxt.pushCurrentExpressionNode(DTM.NULL);

      IntStack currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();

      xctxt.pushSAXLocatorNull();
      xctxt.pushContextNodeList(sourceNodes);
      transformer.pushElemTemplateElement(null);

      // pushParams(transformer, xctxt);
      // Should be able to get this from the iterator but there must be a bug.
      DTM dtm = xctxt.getDTM(sourceNode);
      int docID = sourceNode & DTMManager.IDENT_DTM_DEFAULT;
      int child;

      while (DTM.NULL != (child = sourceNodes.nextNode()))
      {
        currentNodes.setTop(child);
        currentExpressionNodes.setTop(child);

        if ((child & DTMManager.IDENT_DTM_DEFAULT) != docID)
        {
          dtm = xctxt.getDTM(child);
          docID = child & DTMManager.IDENT_DTM_DEFAULT;
        }

        //final int exNodeType = dtm.getExpandedTypeID(child);
        final int nodeType = dtm.getNodeType(child); 

        // And execute the child templates.
        // Loop through the children of the template, calling execute on 
        // each of them.
        for (ElemTemplateElement t = this.m_firstChild; t != null;
             t = t.m_nextSibling)
        {
          xctxt.setSAXLocator(t);
          transformer.setCurrentElement(t);
          t.execute(transformer);
        }

        // KLUGE: Implement <?xalan:doc_cache_off?>
	 	// ASSUMPTION: This will be set only when the XPath was indeed
	 	// a call to the Document() function. Calling it in other
	 	// situations is likely to fry Xalan.
	 	//
	 	// %REVIEW% We need a MUCH cleaner solution -- one that will
	 	// handle cleaning up after document() and getDTM() in other
		// contexts. The whole SourceTreeManager mechanism should probably
	 	// be moved into DTMManager rather than being explicitly invoked in
	 	// FuncDocument and here.
	 	if(m_doc_cache_off)
		{
	 	  if(DEBUG)
	 	    System.out.println("JJK***** CACHE RELEASE *****\n"+
				       "\tdtm="+dtm.getDocumentBaseURI());
	  	// NOTE: This will work because this is _NOT_ a shared DTM, and thus has
	  	// only a single Document node. If it could ever be an RTF or other
	 	// shared DTM, this would require substantial rework.
	 	  xctxt.getSourceTreeManager().removeDocumentFromCache(dtm.getDocument());
	 	  xctxt.release(dtm,false);
	 	}
      }
    }
    finally
    {
      xctxt.popSAXLocator();
      xctxt.popContextNodeList();
      transformer.popElemTemplateElement();
      xctxt.popCurrentExpressionNode();
      xctxt.popCurrentNode();
      sourceNodes.detach();
    }
  }
1307016
private void pushNode(int node) {
    // Expand buffers if needed.
    if (position == arcs.length) {
      arcs = Arrays.copyOf(arcs, arcs.length + EXPECTED_MAX_STATES);
    }

    arcs[position++] = fsa.getFirstArc(node);
  }
1055593
function setPartial(fs, path, nodeCount, callback) {
  fs.setxattr(path, constants.attributes.partial, nodeCount, callback);
}
984591
private void adaptForInsert(final ITreeData paramNewNode, final boolean addAsFirstChild) throws TTException {
        assert paramNewNode != null;

        if (paramNewNode instanceof ITreeStructData) {
            final ITreeStructData strucNode = (ITreeStructData)paramNewNode;
            final ITreeStructData parent = (ITreeStructData)getPtx().getData(paramNewNode.getParentKey());
            parent.incrementChildCount();
            if (addAsFirstChild) {
                parent.setFirstChildKey(paramNewNode.getDataKey());
            }
            getPtx().setData(parent);

            if (strucNode.hasRightSibling()) {
                final ITreeStructData rightSiblingNode =
                    (ITreeStructData)getPtx().getData(strucNode.getRightSiblingKey());
                rightSiblingNode.setLeftSiblingKey(paramNewNode.getDataKey());
                getPtx().setData(rightSiblingNode);
            }
            if (strucNode.hasLeftSibling()) {
                final ITreeStructData leftSiblingNode =
                    (ITreeStructData)getPtx().getData(strucNode.getLeftSiblingKey());
                leftSiblingNode.setRightSiblingKey(paramNewNode.getDataKey());
                getPtx().setData(leftSiblingNode);
            }
        }

    }
424480
private Node buildNode(int begin, int end) {
        int d = keys[0].length;

        // Allocate the node
        Node node = new Node();

        // Fill in basic info
        node.count = end - begin;
        node.index = begin;

        // Calculate the bounding box
        double[] lowerBound = new double[d];
        double[] upperBound = new double[d];

        for (int i = 0; i < d; i++) {
            lowerBound[i] = keys[index[begin]][i];
            upperBound[i] = keys[index[begin]][i];
        }

        for (int i = begin + 1; i < end; i++) {
            for (int j = 0; j < d; j++) {
                double c = keys[index[i]][j];
                if (lowerBound[j] > c) {
                    lowerBound[j] = c;
                }
                if (upperBound[j] < c) {
                    upperBound[j] = c;
                }
            }
        }

        // Calculate bounding box stats
        double maxRadius = -1;
        for (int i = 0; i < d; i++) {
            double radius = (upperBound[i] - lowerBound[i]) / 2;
            if (radius > maxRadius) {
                maxRadius = radius;
                node.split = i;
                node.cutoff = (upperBound[i] + lowerBound[i]) / 2;
            }
        }

        // If the max spread is 0, make this a leaf node
        if (maxRadius == 0) {
            node.lower = node.upper = null;
            return node;
        }

        // Partition the dataset around the midpoint in this dimension. The
        // partitioning is done in-place by iterating from left-to-right and
        // right-to-left in the same way that partioning is done in quicksort.
        int i1 = begin, i2 = end - 1, size = 0;
        while (i1 <= i2) {
            boolean i1Good = (keys[index[i1]][node.split] < node.cutoff);
            boolean i2Good = (keys[index[i2]][node.split] >= node.cutoff);

            if (!i1Good && !i2Good) {
                int temp = index[i1];
                index[i1] = index[i2];
                index[i2] = temp;
                i1Good = i2Good = true;
            }

            if (i1Good) {
                i1++;
                size++;
            }

            if (i2Good) {
                i2--;
            }
        }

        // Create the child nodes
        node.lower = buildNode(begin, begin + size);
        node.upper = buildNode(begin + size, end);

        return node;
    }
486808
public static void generateExplorerTypesXml(
        Element startNode,
        List<CmsExplorerTypeSettings> explorerTypes,
        boolean module) {

        // we need the default access node later to check if the explorer type is an individual setting
        CmsExplorerTypeAccess defaultAccess = null;
        if (OpenCms.getWorkplaceManager() != null) {
            defaultAccess = OpenCms.getWorkplaceManager().getDefaultAccess();
        }
        // get the menu rule translator to eliminate eventual legacy menu rules
        Iterator<CmsExplorerTypeSettings> i = explorerTypes.iterator();
        while (i.hasNext()) {
            // create an explorer type node
            CmsExplorerTypeSettings settings = i.next();

            if (settings.isAddititionalModuleExplorerType() == module) {
                Element explorerTypeElement = startNode.addElement(N_EXPLORERTYPE);
                explorerTypeElement.addAttribute(A_NAME, settings.getName());
                explorerTypeElement.addAttribute(A_KEY, settings.getKey());
                String originalIcon = settings.getOriginalIcon();
                if (CmsStringUtil.isNotEmpty(originalIcon)) {
                    explorerTypeElement.addAttribute(A_ICON, settings.getOriginalIcon());
                }
                if (CmsStringUtil.isNotEmpty(settings.getBigIcon())) {
                    explorerTypeElement.addAttribute(A_BIGICON, settings.getBigIcon());
                }
                if (CmsStringUtil.isNotEmpty(settings.getSmallIconStyle())) {
                    explorerTypeElement.addAttribute(A_SMALLICONSTYLE, settings.getSmallIconStyle());
                }
                if (CmsStringUtil.isNotEmpty(settings.getBigIconStyle())) {
                    explorerTypeElement.addAttribute(A_BIGICONSTYLE, settings.getBigIconStyle());
                }

                if (settings.getReference() != null) {
                    explorerTypeElement.addAttribute(A_REFERENCE, settings.getReference());
                }

                if (settings.getElementView() != null) {
                    explorerTypeElement.addAttribute(A_ELEMENTVIEW, settings.getElementView());
                }

                if (settings.isView()) {
                    explorerTypeElement.addAttribute(A_ISVIEW, "true");
                }

                if (settings.getNamePattern() != null) {
                    explorerTypeElement.addAttribute(A_NAME_PATTERN, settings.getNamePattern());
                }

                if (settings.getViewOrder(false) != null) {
                    explorerTypeElement.addAttribute(A_VIEW_ORDER, "" + settings.getViewOrder(false));
                }

                // create subnode <newresource>
                Element newResElement = explorerTypeElement.addElement(N_NEWRESOURCE);
                newResElement.addAttribute(A_CREATABLE, String.valueOf(settings.isCreatable()));
                newResElement.addAttribute(A_ORDER, settings.getNewResourceOrder());
                newResElement.addAttribute(A_AUTOSETNAVIGATION, String.valueOf(settings.isAutoSetNavigation()));
                newResElement.addAttribute(A_AUTOSETTITLE, String.valueOf(settings.isAutoSetTitle()));
                newResElement.addAttribute(A_INFO, settings.getInfo());
                newResElement.addAttribute(A_KEY, settings.getTitleKey());
                // create subnode <accesscontrol>
                CmsExplorerTypeAccess access = settings.getAccess();
                if (access != defaultAccess) {
                    // don't output the node if this is in fact the default access settings
                    List<String> accessEntries = new ArrayList<String>(access.getAccessEntries().keySet());
                    // sort accessEntries
                    Collections.sort(accessEntries);
                    if (accessEntries.size() > 0) {
                        Element accessControlElement = explorerTypeElement.addElement(N_ACCESSCONTROL);
                        Iterator<String> k = accessEntries.iterator();
                        while (k.hasNext()) {
                            String key = k.next();
                            String value = settings.getAccess().getAccessEntries().get(key);
                            Element accessEntryElement = accessControlElement.addElement(N_ACCESSENTRY);
                            accessEntryElement.addAttribute(A_PRINCIPAL, key);
                            accessEntryElement.addAttribute(A_PERMISSIONS, value);
                        }
                    }
                }
                // create subnode <editoptions>
                if (settings.hasEditOptions()) {
                    Element editOptionsElement = explorerTypeElement.addElement(N_EDITOPTIONS);
                    Element defaultPropertiesElement = editOptionsElement.addElement(N_DEFAULTPROPERTIES);
                    defaultPropertiesElement.addAttribute(A_ENABLED, String.valueOf(settings.isPropertiesEnabled()));
                    defaultPropertiesElement.addAttribute(
                        A_SHOWNAVIGATION,
                        String.valueOf(settings.isShowNavigation()));
                    Iterator<String> m = settings.getProperties().iterator();
                    while (m.hasNext()) {
                        defaultPropertiesElement.addElement(N_DEFAULTPROPERTY).addAttribute(A_NAME, m.next());
                    }
                }

                Map<String, CmsIconRule> iconRules = settings.getIconRules();
                if ((iconRules != null) && !iconRules.isEmpty()) {
                    Element iconRulesElem = explorerTypeElement.addElement(N_ICONRULES);
                    for (Map.Entry<String, CmsIconRule> entry : iconRules.entrySet()) {
                        CmsIconRule rule = entry.getValue();
                        Element ruleElem = iconRulesElem.addElement(N_ICONRULE);
                        String icon = rule.getIcon();
                        String bigIcon = rule.getBigIcon();
                        String extension = rule.getExtension();
                        ruleElem.addAttribute(A_EXTENSION, extension);
                        if (icon != null) {
                            ruleElem.addAttribute(A_ICON, icon);
                        }
                        if (bigIcon != null) {
                            ruleElem.addAttribute(A_BIGICON, bigIcon);
                        }
                        if (rule.getSmallIconStyle() != null) {
                            ruleElem.addAttribute(A_SMALLICONSTYLE, rule.getSmallIconStyle());
                        }
                        if (rule.getBigIconStyle() != null) {
                            ruleElem.addAttribute(A_BIGICONSTYLE, rule.getBigIconStyle());
                        }
                    }
                }

            }
        }
    }
155508
public void setEscapingDirectives(
      SoyNode node, Context context, List<EscapingMode> escapingModes) {
    Preconditions.checkArgument(
        (node instanceof PrintNode)
            || (node instanceof CallNode)
            || (node instanceof MsgFallbackGroupNode),
        "Escaping directives may only be set for {print}, {msg}, or {call} nodes");
    if (escapingModes != null) {
      nodeToEscapingModes.put(node, ImmutableList.copyOf(escapingModes));
    }
    nodeToContext.put(node, context);
  }
282648
function (node, m, M) {

        var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
            compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
            xMargin = this._allDistMargin(node, m, M, compareMinX),
            yMargin = this._allDistMargin(node, m, M, compareMinY);

        // if total distributions margin value is minimal for x, sort by minX,
        // otherwise it's already sorted by minY
        if (xMargin < yMargin) node.children.sort(compareMinX);
    }
223549
function (node) {
            return this.setEnd(node, node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length);
        }
919324
private void setNodeDirty(final Node<K, V> node) {
		final int nodeid = node.id;
		final int index = nodeid < 0 ? -nodeid : nodeid;
		(node.isLeaf() ? dirtyLeafNodes : dirtyInternalNodes).put(nodeid, node);
		(node.isLeaf() ? cacheLeafNodes : cacheInternalNodes).remove(nodeid);
		if (enableIOStats) {
			getIOStat(nodeid).incCacheWrite();
		}
		if (enableDirtyCheck) {
			dirtyCheck.set(index);
		}
	}
450074
protected void endNode(int node) throws org.xml.sax.SAXException
  {
    super.endNode(node);
    if(DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
    {
      m_transformer.getXPathContext().popCurrentNode();
    }
  }
1111868
public int asNode(XPathContext xctxt)
          throws javax.xml.transform.TransformerException
  {
  	DTMIterator iter = execute(xctxt).iter();
    return iter.nextNode();
  }
1137561
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
	protected void _createNode(DocumentRootNode parentNode, XtendTypeDeclaration modelElement) {
		//
		// The text region is set to the model element, not to the model element's name as in the
		// default implementation of createStructuralFeatureNode().
		// The text region computation is overridden in order to have a correct link to the editor.
		//
		final boolean isFeatureSet = modelElement.eIsSet(XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME);
		final EStructuralFeatureNode elementNode = new EStructuralFeatureNode(
				modelElement,
				XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME,
				parentNode,
				this.imageDispatcher.invoke(modelElement),
				this.textDispatcher.invoke(modelElement),
				modelElement.getMembers().isEmpty() || !isFeatureSet);
		final EObject primarySourceElement = this.associations.getPrimarySourceElement(modelElement);
		final ICompositeNode parserNode = NodeModelUtils.getNode(
				(primarySourceElement == null) ? modelElement : primarySourceElement);
		elementNode.setTextRegion(parserNode.getTextRegion());
		//
		boolean hasConstructor = false;
		if (!modelElement.getMembers().isEmpty()) {
			EObjectNode capacityUseNode = null;
			EObjectNode capacityRequirementNode = null;

			for (final EObject feature : modelElement.getMembers()) {
				if (feature instanceof SarlConstructor) {
					hasConstructor = true;
					createNode(elementNode, feature);
				} else if (feature instanceof SarlField) {
					final SarlField field = (SarlField) feature;
					createNode(elementNode, field);
					createAutomaticAccessors(elementNode, field);
				} else if (feature instanceof SarlAction
						|| feature instanceof SarlBehaviorUnit
						|| feature instanceof XtendTypeDeclaration) {
					createNode(elementNode, feature);
				} else if (feature instanceof SarlCapacityUses) {
					capacityUseNode = createCapacityUseNode(elementNode, (SarlCapacityUses) feature, capacityUseNode);
				} else if (feature instanceof SarlRequiredCapacity) {
					capacityRequirementNode = createRequiredCapacityNode(elementNode,
							(SarlRequiredCapacity) feature, capacityRequirementNode);
				}
			}
		}
		if (!hasConstructor && modelElement instanceof XtendClass) {
			createInheritedConstructors(elementNode, (XtendClass) modelElement);
		}
	}
367516
public void setNodeType(int nodeType) {
        if (nodeType != Token.COLON
            && nodeType != Token.GET
            && nodeType != Token.SET
            && nodeType != Token.METHOD)
            throw new IllegalArgumentException("invalid node type: "
                                               + nodeType);
        setType(nodeType);
    }
201340
public void visit(final ElementNode pNode) throws TTIOException {
        final long nodeKey = pNode.getDataKey();
        mRtx.moveTo(nodeKey);
        for (int i = 0; i < pNode.getAttributeCount(); i++) {
            mRtx.moveToAttribute(i);
            addLeafLabel();
            mRtx.moveTo(nodeKey);
        }
        for (int i = 0; i < pNode.getNamespaceCount(); i++) {
            mRtx.moveToNamespace(i);
            addLeafLabel();
            mRtx.moveTo(nodeKey);
        }
        if (pNode.hasFirstChild() || pNode.getAttributeCount() > 0 || pNode.getNamespaceCount() > 0) {
            if (!mLabels.containsKey(pNode.getKind())) {
                mLabels.put(pNode.getKind(), new ArrayList<ITreeData>());
            }
            mLabels.get(pNode.getKind()).add(pNode);
        }
    }