Search in sources :

Example 1 with DTDElement

use of org.eclipse.wst.dtd.core.internal.emf.DTDElement 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 DTDElement

use of org.eclipse.wst.dtd.core.internal.emf.DTDElement 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 DTDElement

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

the class DTDMetrics method getLeastReferencedElement.

public DTDElement getLeastReferencedElement() {
    DTDElement result = null;
    int lowestReferenceCount = Integer.MAX_VALUE;
    Collection elements = dtdFile.listDTDElement();
    for (Iterator i = elements.iterator(); i.hasNext(); ) {
        DTDElement element = (DTDElement) i.next();
        int count = getElementReferenceCount(element);
        if (count < lowestReferenceCount) {
            result = element;
            lowestReferenceCount = count;
        }
    }
    return result;
}
Also used : Iterator(java.util.Iterator) Collection(java.util.Collection) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement)

Example 4 with DTDElement

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

the class DTDElementContentImpl method isFirstElementContent.

public boolean isFirstElementContent() {
    DTDElement element = getElement();
    if (element != null) {
        // This means this is the only element content in the element
        return true;
    }
    // end of if ()
    DTDGroupContent group = getGroup();
    int pos = group.getContentPosition(this);
    if (pos == 0) {
        // now recurse and ensure this group is the first group
        return group.isFirstElementContent();
    } else // end of if ()
    {
        return false;
    }
}
Also used : DTDGroupContent(org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement)

Example 5 with DTDElement

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

the class DTDVisitor method visitDTDFileGen.

/**
 * @generated
 */
protected void visitDTDFileGen(DTDFile file) {
    Collection notations = file.listDTDNotation();
    for (Iterator i = notations.iterator(); i.hasNext(); ) {
        visitDTDNotation((DTDNotation) i.next());
    }
    Collection entities = file.listDTDEntity();
    for (Iterator i = entities.iterator(); i.hasNext(); ) {
        visitDTDEntity((DTDEntity) i.next());
    }
    Collection objects = file.listDTDElementAndDTDParameterEntityReference();
    for (Iterator i = objects.iterator(); i.hasNext(); ) {
        DTDObject object = (DTDObject) i.next();
        if (object instanceof DTDElement) {
            visitDTDElement((DTDElement) object);
        } else // end of if ()
        {
            visitDTDParameterEntityReference((DTDParameterEntityReference) object);
        }
    // end of if ()
    }
}
Also used : Iterator(java.util.Iterator) Collection(java.util.Collection) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) DTDObject(org.eclipse.wst.dtd.core.internal.emf.DTDObject)

Aggregations

DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)16 Iterator (java.util.Iterator)5 Collection (java.util.Collection)4 DTDElementReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent)4 DTDEntity (org.eclipse.wst.dtd.core.internal.emf.DTDEntity)3 DTDGroupContent (org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent)3 Enumeration (java.util.Enumeration)2 Hashtable (java.util.Hashtable)2 Vector (java.util.Vector)2 DTDEmptyContent (org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent)2 DTDEntityReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent)2 DTDFactory (org.eclipse.wst.dtd.core.internal.emf.DTDFactory)2 DTDGroupKind (org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind)2 DTDObject (org.eclipse.wst.dtd.core.internal.emf.DTDObject)2 DTDOccurrenceType (org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType)2 DTDPCDataContent (org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent)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