Search in sources :

Example 1 with DTDElementReferenceContent

use of org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent in project webtools.sourceediting by eclipse.

the class DTDMetrics method getElementReferences.

public Hashtable getElementReferences() {
    if (elementReferenceMap == null) {
        elementReferenceMap = new Hashtable();
        new DTDVisitor() {

            public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
                DTDElement dtdElement = elementReferenceContent.getReferencedElement();
                Object visitation = elementReferenceMap.get(dtdElement);
                if (visitation == null) {
                    elementReferenceMap.put(dtdElement, visitation = new Vector());
                }
                ((Vector) visitation).addElement(elementReferenceContent);
            }
        }.visitDTDFile(dtdFile);
    }
    return elementReferenceMap;
}
Also used : DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) Hashtable(java.util.Hashtable) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) Vector(java.util.Vector)

Example 2 with DTDElementReferenceContent

use of org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent in project webtools.sourceediting by eclipse.

the class DTDMetrics method getElementReferencesGen.

/**
 * @generated
 */
protected Hashtable getElementReferencesGen() {
    if (elementReferenceMap == null) {
        elementReferenceMap = new Hashtable();
        new DTDVisitor() {

            public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
                DTDElement dtdElement = elementReferenceContent.getReferencedElement();
                Object visitation = elementReferenceMap.get(dtdElement);
                if (visitation == null) {
                    elementReferenceMap.put(dtdElement, visitation = new Vector());
                }
                ((Vector) visitation).addElement(elementReferenceContent);
            }
        }.visitDTDFile(dtdFile);
    }
    return elementReferenceMap;
}
Also used : DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) Hashtable(java.util.Hashtable) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) Vector(java.util.Vector)

Example 3 with DTDElementReferenceContent

use of org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent in project webtools.sourceediting by eclipse.

the class DTDElementContentImpl method getPathname.

public String getPathname() {
    int cnt = 0;
    DTDObject parent = getGroup();
    if (parent == null) {
        parent = getElement();
    } else {
        DTDGroupContent group = (DTDGroupContent) parent;
        Iterator i = group.getContent().iterator();
        while (i.hasNext()) {
            DTDElementContent content = (DTDElementContent) i.next();
            if (content == this) {
                break;
            }
            if ((content instanceof DTDElementReferenceContent) || (content instanceof DTDEntityReferenceContent)) {
                continue;
            }
            cnt++;
        }
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    return DTDPathnameUtil.makePath(((parent == null) ? "NULL_PARENT" : parent.getPathname()), "Content", null, cnt);
}
Also used : DTDElementContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementContent) DTDGroupContent(org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent) DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) DTDEntityReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent) Iterator(java.util.Iterator) DTDObject(org.eclipse.wst.dtd.core.internal.emf.DTDObject)

Example 4 with DTDElementReferenceContent

use of org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent in project webtools.sourceediting by eclipse.

the class DTDPrinter method visitDTDElement.

public void visitDTDElement(DTDElement element) {
    generateComment(element);
    updateStartOffset(element, sb.length());
    // $NON-NLS-1$
    sb.append("<!ELEMENT " + element.getName());
    DTDElementContent content = element.getContent();
    if (content instanceof DTDPCDataContent || content instanceof DTDElementReferenceContent) {
        // $NON-NLS-1$
        sb.append(" (");
        super.visitDTDElement(element);
        // $NON-NLS-1$
        sb.append(")");
    } else // end of if ()
    {
        // $NON-NLS-1$
        sb.append(" ");
        super.visitDTDElement(element);
    }
    // end of else
    endTag();
    // -1 for the newline char
    updateEndOffset(element, sb.length() - 1);
    visitAttributes(element);
}
Also used : DTDElementContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementContent) DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) DTDPCDataContent(org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent)

Example 5 with DTDElementReferenceContent

use of org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent in project webtools.sourceediting by eclipse.

the class DTDPrinter method visitDTDElementContent.

public void visitDTDElementContent(DTDElementContent content) {
    updateStartOffset(content, sb.length());
    // $NON-NLS-1$
    String trailingChars = "";
    if (content instanceof DTDRepeatableContent) {
        DTDRepeatableContent repeatContent = (DTDRepeatableContent) content;
        DTDOccurrenceType occurrenceType = repeatContent.getOccurrence();
        // Integer occurrence = repeatContent.getOccurrence();
        if (occurrenceType != null) {
            int occurType = occurrenceType.getValue();
            if (occurType != DTDOccurrenceType.ONE) {
                if (repeatContent instanceof DTDEntityReferenceContent) {
                    // $NON-NLS-1$
                    sb.append("(");
                    // $NON-NLS-1$
                    trailingChars = ")";
                }
                trailingChars += (char) occurType;
            }
        }
    // end of if ()
    }
    if (content instanceof DTDGroupContent) {
        super.visitDTDElementContent(content);
    } else // end of if ()
    if (content instanceof DTDElementReferenceContent || content instanceof DTDEntityReferenceContent) {
        sb.append(((DTDRepeatableContent) content).unparseRepeatableContent());
    } else // end of if ()
    {
        // handle DTDPCDataContent, DTDAnyContent and DTDEmptyContent here
        sb.append(content.getContentName());
    }
    // end of else
    sb.append(trailingChars);
    updateEndOffset(content, sb.length());
}
Also used : DTDGroupContent(org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent) DTDEntityReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent) DTDElementReferenceContent(org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent) DTDRepeatableContent(org.eclipse.wst.dtd.core.internal.emf.DTDRepeatableContent) DTDOccurrenceType(org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType)

Aggregations

DTDElementReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent)8 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)4 DTDEntityReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent)4 DTDGroupContent (org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent)4 DTDOccurrenceType (org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType)3 DTDPCDataContent (org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent)3 Hashtable (java.util.Hashtable)2 Vector (java.util.Vector)2 DTDElementContent (org.eclipse.wst.dtd.core.internal.emf.DTDElementContent)2 DTDEntity (org.eclipse.wst.dtd.core.internal.emf.DTDEntity)2 DTDGroupKind (org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind)2 CMBasicNode (org.eclipse.wst.dtd.core.internal.saxparser.CMBasicNode)2 CMGroupNode (org.eclipse.wst.dtd.core.internal.saxparser.CMGroupNode)2 CMNode (org.eclipse.wst.dtd.core.internal.saxparser.CMNode)2 CMReferenceNode (org.eclipse.wst.dtd.core.internal.saxparser.CMReferenceNode)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Enumeration (java.util.Enumeration)1 Iterator (java.util.Iterator)1 DTDAnyContent (org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent)1