Search in sources :

Example 1 with DTDType

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

the class DTDModelBuilder method hasIDAttribute.

public boolean hasIDAttribute(DTDAttribute dtdattr) {
    boolean hasID = false;
    DTDElement element = dtdattr.getDTDElement();
    EList attrs = element.getDTDAttribute();
    Iterator i = attrs.iterator();
    while (i.hasNext()) {
        DTDAttribute attr = (DTDAttribute) i.next();
        DTDType dType = attr.getDTDType();
        if (dType instanceof DTDBasicType) {
            if (((DTDBasicType) dType).getKind().getValue() == DTDBasicTypeKind.ID) {
                hasID = true;
                break;
            }
        }
    }
    return hasID;
}
Also used : EList(org.eclipse.emf.common.util.EList) DTDBasicType(org.eclipse.wst.dtd.core.internal.emf.DTDBasicType) Iterator(java.util.Iterator) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) DTDType(org.eclipse.wst.dtd.core.internal.emf.DTDType) DTDAttribute(org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)

Example 2 with DTDType

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

the class DTDAttributeImpl method unparse.

public String unparse() {
    StringBuffer result = new StringBuffer(128);
    result.append(getName());
    StringBuffer value = new StringBuffer();
    switch(getDefaultKind().getValue()) {
        case DTDDefaultKind.IMPLIED:
            // $NON-NLS-1$
            value.append("#IMPLIED");
            break;
        case DTDDefaultKind.REQUIRED:
            // $NON-NLS-1$
            value.append("#REQUIRED");
            break;
        case DTDDefaultKind.FIXED:
            String type = getDTDType().toString();
            if (!(type.equals(DTDType.ID) || type.equals(DTDType.IDREF) || type.equals(DTDType.ENUM_NAME_TOKEN_GROUP) || type.equals(DTDType.IDREFS))) {
                // $NON-NLS-1$ //$NON-NLS-2$
                value.append("#FIXED \"").append(getDefaultValueString()).append("\"");
            }
            break;
        case DTDDefaultKind.NOFIXED:
            String defaultValue = getDefaultValueString();
            if (defaultValue != null)
                // $NON-NLS-1$ //$NON-NLS-2$
                value.append("\"").append(defaultValue).append("\"");
            break;
    }
    // Get the attribute type
    DTDEntity typeEnt = getAttributeTypeReferencedEntity();
    if (typeEnt != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result.append(" %" + typeEnt.getName() + "; ").append(value);
    } else {
        DTDType dtdType = getDTDType();
        if (dtdType instanceof DTDBasicType) {
            switch(((DTDBasicType) dtdType).getKind().getValue()) {
                case DTDBasicTypeKind.CDATA:
                    // $NON-NLS-1$
                    result.append(" CDATA ").append(value);
                    break;
                case DTDBasicTypeKind.ID:
                    // $NON-NLS-1$
                    result.append(" ID ").append(value);
                    break;
                case DTDBasicTypeKind.IDREF:
                    // $NON-NLS-1$
                    result.append(" IDREF ").append(value);
                    break;
                case DTDBasicTypeKind.IDREFS:
                    // $NON-NLS-1$
                    result.append(" IDREFS ").append(value);
                    break;
                case DTDBasicTypeKind.ENTITY:
                    // $NON-NLS-1$
                    result.append(" ENTITY ").append(value);
                    break;
                case DTDBasicTypeKind.ENTITIES:
                    // $NON-NLS-1$
                    result.append(" ENTITIES ").append(value);
                    break;
                case DTDBasicTypeKind.NMTOKEN:
                    // $NON-NLS-1$
                    result.append(" NMTOKEN ").append(value);
                    break;
                case DTDBasicTypeKind.NMTOKENS:
                    // $NON-NLS-1$
                    result.append(" NMTOKENS ").append(value);
                    break;
            }
        } else if (dtdType instanceof DTDEnumerationType) {
            // $NON-NLS-1$
            result.append(" ").append(buildEnumString((DTDEnumerationType) dtdType)).append(value);
        }
    }
    return result.toString();
}
Also used : DTDBasicType(org.eclipse.wst.dtd.core.internal.emf.DTDBasicType) DTDEnumerationType(org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType) DTDType(org.eclipse.wst.dtd.core.internal.emf.DTDType) DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity)

Example 3 with DTDType

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

the class DTDAttributeImpl method getEnumeratedValues.

public Collection getEnumeratedValues() {
    Collection result = new ArrayList();
    DTDType type = getDTDType();
    if (type instanceof DTDEnumerationType) {
        DTDEnumerationType enumType = (DTDEnumerationType) type;
        Iterator i = enumType.getEnumLiterals().iterator();
        while (i.hasNext()) {
            result.add(((EEnumLiteral) i.next()).toString());
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DTDEnumerationType(org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType) Iterator(java.util.Iterator) Collection(java.util.Collection) DTDType(org.eclipse.wst.dtd.core.internal.emf.DTDType)

Aggregations

DTDType (org.eclipse.wst.dtd.core.internal.emf.DTDType)3 Iterator (java.util.Iterator)2 DTDBasicType (org.eclipse.wst.dtd.core.internal.emf.DTDBasicType)2 DTDEnumerationType (org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 EList (org.eclipse.emf.common.util.EList)1 DTDAttribute (org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)1 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)1 DTDEntity (org.eclipse.wst.dtd.core.internal.emf.DTDEntity)1