public void addReplaceActions(CMValidator.MatchModelNode matchModelNode, CMGroup group, int startIndex, int endIndex) { CMNode excludeCMNode = null; if (matchModelNode.children.size() > 0) { CMValidator.MatchModelNode child = (CMValidator.MatchModelNode)matchModelNode.children.get(0); excludeCMNode = child.cmNode; } CMNodeList nodeList = group.getChildNodes(); int size = nodeList.getLength(); for (int i = 0; i < size; i++) { CMNode alternative = nodeList.item(i); if (alternative != excludeCMNode) { Action action = new Action(ModelQueryAction.REPLACE, parent, alternative, startIndex, endIndex); actionList.add(action); } } } }
int min = Math.max(e.getMinOccur(), forcedMin); if (e.getMaxOccur() == -1) // unbounded max = getNumOfRepeatableElements(); else max = Math.min(e.getMaxOccur(), getNumOfRepeatableElements()); if (e.getOperator() == CMGroup.CHOICE && buildFirstChoice(buildPolicy)) { CMNode hintNode = null; CMNodeList nodeList = e.getChildNodes(); int nodeListLength = nodeList.getLength(); for (int j = 0; j < nodeListLength; j++) { CMNodeList nodeList = e.getChildNodes(); if (nodeList.getLength() > 0) { cmNode = nodeList.item(0); else if (e.getOperator() == CMGroup.ALL // ALL || e.getOperator() == CMGroup.SEQUENCE) // SEQUENCE
public void visitCMGroup(CMGroup group) { if (includeSequenceGroups) { if (group.getOperator() == CMGroup.SEQUENCE && group.getChildNodes().getLength() > 1 && includesRequiredContent(group)) { childNodeTable.put(group, group); } } super.visitCMGroup(group); }
public void visitCMGroup(CMGroup group) { if (group == root || group.getMinOccur() > 0) { int op = group.getOperator(); if (op == CMGroup.SEQUENCE) { super.visitCMGroup(group); } else if (op == CMGroup.CHOICE) { CMNodeList nodeList = group.getChildNodes(); if (nodeList.getLength() > 0) { visitCMNode(nodeList.item(0)); } } } } }
protected boolean isSimpleChoiceGroupContentModel(CMElementDeclaration ed) { boolean result = false; CMNode cmNode = ed.getContent(); if (cmNode != null && cmNode.getNodeType() == CMNode.GROUP) { CMGroup cmGroup = (CMGroup)cmNode; if (cmGroup.getOperator() == CMGroup.CHOICE && cmGroup.getMaxOccur() == -1) { result = true; CMNodeList list = cmGroup.getChildNodes(); for (int i = list.getLength() - 1; i >= 0; i--) { if (list.item(i).getNodeType() != CMNode.ELEMENT_DECLARATION) { result = false; break; } } } } return result; }
/** * getOperation method * @return int * * Returns one of : * ALONE (a), SEQUENCE (a,b), CHOICE (a|b), ALL (a&b). */ public int getOperator() { return fGroup.getOperator(); }
int gmin = group.getMinOccur(); if (gmin == 0) if (buildOptionalElements(buildPolicy)) {
public void visitCMGroup(CMGroup e) { int forcedMin = (buildPolicy == BUILD_ALL_CONTENT || alwaysVisit) ? 1 : 0; int min = Math.max(e.getMinOccur(), forcedMin); alwaysVisit = false; for (int i = 1; i <= min; i++) { if (e.getOperator() == CMGroup.CHOICE) { // add only 1 element from the group // todo... perhaps add something other than the first one CMNodeList nodeList = e.getChildNodes(); if (nodeList.getLength() > 0) { visitCMNode(nodeList.item(0)); } } else // SEQUENCE, ALL { // visit all of the content super.visitCMGroup(e); } } }
public void visitCMGroup(CMGroup group) { int op = group.getOperator(); if (op == CMGroup.ALL) { sb.append("all"); //$NON-NLS-1$ } sb.append("("); //$NON-NLS-1$ String separator = ", "; //$NON-NLS-1$ if (op == CMGroup.CHOICE) { separator = " | "; //$NON-NLS-1$ } CMNodeList nodeList = group.getChildNodes(); int size = nodeList.getLength(); for (int i = 0; i < size; i++) { visitCMNode(nodeList.item(i)); if (i < size - 1) { sb.append(separator); } } sb.append(")"); //$NON-NLS-1$ addOccurenceSymbol(group); }
public void visitMatchModelNode(CMValidator.MatchModelNode matchModelNode) { int startIndex = indexOfNextElement(elementIndex); //String cmNodeName = matchModelNode.cmNode != null ? matchModelNode.cmNode.getNodeName() : "null"; //printIndented(indent, "+MatchModelNode : " + cmNodeName + " " + startIndex); indent += 2; for (Iterator iterator = matchModelNode.children.iterator(); iterator.hasNext(); ) { CMValidator.MatchModelNode child = (CMValidator.MatchModelNode)iterator.next(); visitMatchModelNode(child); } indent -= 2; if (matchModelNode.cmNode != null) { int nodeType = matchModelNode.cmNode.getNodeType(); if (nodeType == CMNode.GROUP) { CMGroup group = (CMGroup)matchModelNode.cmNode; if (group.getOperator() == CMGroup.CHOICE) { addReplaceActions(matchModelNode, group, startIndex, elementIndex - 1); } } else if (nodeType == CMNode.ELEMENT_DECLARATION) { elementIndex = startIndex + 1; } //printIndented(indent, "-MatchModelNode : " + cmNodeName + " " + (elementIndex - 1)); } }
public void visitCMGroup(CMGroup group) { CMNodeList nodeList = group.getChildNodes(); int size = nodeList.getLength(); for (int i = 0; i < size; i++) { visitCMNode(nodeList.item(i)); } }
if (group.getOperator() == CMGroup.ALL)
private static void extractDeclarations(Hashtable availables, CMGroup group) { CMNodeList content = group.getChildNodes(); for (int i = 0; i < content.getLength(); i++) { CMNode cmn = content.item(i); if (cmn == null || cmn.getNodeType() != CMNode.ELEMENT_DECLARATION) continue; addInclusion(availables, (CMElementDeclaration) cmn); } } }
public void visitCMGroup(CMGroup group) { Context prevContext = context; GraphNode in = new GraphNode("(" + getGraphNodeName()); //$NON-NLS-1$ GraphNode out = new GraphNode(")" + getGraphNodeName()); //$NON-NLS-1$ int groupOperator = group.getOperator(); if (groupOperator == CMGroup.SEQUENCE) { context = new Context(in, null); super.visitCMGroup(group); context.from.addArc(new Arc(Arc.LINK, out, group)); } else if (groupOperator == CMGroup.CHOICE || groupOperator == CMGroup.ALL) { context = new Context(in, out); super.visitCMGroup(group); } context = prevContext; createArcs(in, out, group, groupOperator == CMGroup.ALL); }
CMNodeList children = ((CMGroup) content).getChildNodes(); if (children == null) { return;
if (content instanceof CMGroup) { CMGroup cmGroup = (CMGroup) content; CMNodeList children = cmGroup.getChildNodes(); CMNode cmNode = null; for (int i = 0; i < children.getLength(); i++) {
boolean isPartiallyValid = true; HashMap map = new HashMap(); CMNodeList list = allGroup.getChildNodes(); for (int j = list.getLength() - 1; j >= 0; j--)
/** */ private static boolean isChild(CMContent content, CMElementDeclaration target) { switch (content.getNodeType()) { case CMNode.ELEMENT_DECLARATION : return isSameDeclaration((CMElementDeclaration) content, target); case CMNode.GROUP : CMNodeList children = ((CMGroup) content).getChildNodes(); for (int i = 0; i < children.getLength(); i++) { CMNode child = children.item(i); switch (child.getNodeType()) { case CMNode.ELEMENT_DECLARATION : if (isSameDeclaration((CMElementDeclaration) child, target)) return true; continue; // Go next child. case CMNode.GROUP : if (isChild((CMContent) child, target)) return true; continue; // Go next child. default : continue; // Go next child. } } } return false; }
/** * getChildNodes method * @return CMNodeList * * Returns child CMNodeList, which includes ElementDefinition or CMElement. */ public CMNodeList getChildNodes() { if (fChildNodes == null) { CMNodeListImpl childNodes = new CMNodeListImpl(); CMNodeList children = fGroup.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { CMNode child = children.item(i); if (child instanceof CMGroup) childNodes.appendItem(new CMGroupWrapperImpl(fPrefix, (CMGroup) child)); else if (child instanceof CMElementDeclaration) childNodes.appendItem(new CMElementDeclarationWrapperImpl(fPrefix, (CMElementDeclaration) child)); else // error? childNodes.appendItem(new CMNodeWrapperImpl(fPrefix, child)); } fChildNodes = childNodes; } return fChildNodes; }
return isSameDeclaration((CMElementDeclaration) content, target); case CMNode.GROUP : CMNodeList children = ((CMGroup) content).getChildNodes(); for (int i = 0; i < children.getLength(); i++) { CMNode child = children.item(i);