public void addOccurenceSymbol(CMContent content) { int min = content.getMinOccur(); int max = content.getMaxOccur(); if (min == 0) { if (max > 1 || max == -1) { sb.append("*"); //$NON-NLS-1$ } else { sb.append("?"); //$NON-NLS-1$ } } else if (max > 1 || max == -1) { sb.append("+"); //$NON-NLS-1$ } } }
public static Collection getInclusions(Element target) { if (target == null) return nullVector; Collection inclusions = gatherInclusions(getAncestorDeclarations(target)); Hashtable availables = new Hashtable(); Iterator iter = inclusions.iterator(); while (iter.hasNext()) { CMContent inclusion = (CMContent) iter.next(); switch (inclusion.getNodeType()) { case CMNode.GROUP : extractDeclarations(availables, (CMGroup) inclusion); break; case CMNode.ELEMENT_DECLARATION : addInclusion(availables, (CMElementDeclaration) inclusion); break; } } return availables.values(); }
/** * getMinOccur method * @return int * * If 0, it's OPTIONAL. * If 1, it's REQUIRED. */ public int getMinOccur() { return fCMContent.getMinOccur(); }
/** * getMaxOccur method * @return int * * If -1, it's UNBOUNDED. */ public int getMaxOccur() { return fCMContent.getMaxOccur(); }
public void visitCMElementDeclaration(CMElementDeclaration ed) { if (ed == root && !isRootVisited) { isRootVisited = true; CMContent content = ed.getContent(); if (content != null) { if (content.getNodeType() != CMNode.GROUP) { sb.append("("); //$NON-NLS-1$ visitCMNode(content); sb.append(")"); //$NON-NLS-1$ } else { visitCMNode(content); } } } else { sb.append(ed.getElementName()); addOccurenceSymbol(ed); } }
if (cmNode.getMinOccur() == 0)
if (content.getMaxOccur() > 1) if (itemCount.count + 1 >= content.getMaxOccur())
protected void createArcs(GraphNode in, GraphNode out, CMContent cmContent, boolean isAllGroup) { //println("+createArcs() " + ed.getDescription() + " " + ed.getMinOccur()); GraphNode prev = context.from; GraphNode next = new GraphNode(getGraphNodeName()); prev.addArc(new Arc(Arc.PREV_IN, in, cmContent)); out.addArc(new Arc(Arc.OUT_NEXT, next, cmContent)); if (context.to != null) { next.addArc(new Arc(Arc.LINK, context.to, cmContent)); } else { context.from = next; } if (cmContent.getMinOccur() == 0) { // todo... should we see if an optional arc has already been added? prev.addArc(new Arc(Arc.OPTIONAL, next, cmContent)); } if (cmContent.getMaxOccur() == -1 || cmContent.getMaxOccur() > 1 || isAllGroup) { out.addArc(new Arc(Arc.REPEAT, in, cmContent)); } }
if (content.getNodeType() == CMNode.GROUP)
ItemCount itemCount = (ItemCount)map.get(node); if (itemCount.count < content.getMinOccur())
/** */ 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; }
switch (content.getNodeType()) { case CMNode.ELEMENT_DECLARATION : if (isWholeTagOmissible((CMElementDeclaration) content))