Search in sources :

Example 1 with InvalidFlagException

use of com.ibm.j9tools.om.InvalidFlagException in project openj9 by eclipse.

the class FlagDefinitionParser method startElement.

/**
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
@Override
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes) {
    /* We are starting to parse a new element, reset the parsed value */
    // $NON-NLS-1$
    _parsedValue = "";
    if (qName.equalsIgnoreCase("flags")) {
        // $NON-NLS-1$
        /* Remember where this build spec was defined */
        _flags.setLocation(_documentLocatorFile, _documentLocator);
    }
    if (qName.equalsIgnoreCase("flag") && _flags != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String id = attributes.getValue("id");
        _flag = _flags.getFlagDefinition(id);
        if (_flag == null) {
            // $NON-NLS-1$ //$NON-NLS-2$
            _flag = new FlagDefinition(id, "", "");
            _flag.setLocation(_documentLocatorFile, _documentLocator);
        } else if (_flag.isComplete()) {
            // $NON-NLS-1$
            InvalidFlagException error = new InvalidFlagException("Flag definition has already been defined.", _flag);
            error.setLineNumber(_documentLocator.getLineNumber());
            error.setColumn(_documentLocator.getColumnNumber());
            if (_documentLocatorFile != null) {
                error.setFileName(_documentLocatorFile.getAbsolutePath());
            }
            flagErrors.add(error);
            _flag = null;
        }
    } else /* Parse the required flags list */
    if (qName.equalsIgnoreCase("require") && _flag != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String flagId = attributes.getValue("flag");
        if (flagId.equalsIgnoreCase(_flag.getId())) {
            _flag.addRequires(_flag);
        } else {
            FlagDefinition flagDef = _flags.getFlagDefinition(flagId);
            if (flagDef == null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                flagDef = new FlagDefinition(flagId, "", "");
                _flags.addFlagDefinition(flagDef);
            }
            _flag.addRequires(flagDef);
        }
    } else /* Parse the precludes flag list */
    if (qName.equalsIgnoreCase("preclude") && _flag != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String flagId = attributes.getValue("flag");
        if (flagId.equalsIgnoreCase(_flag.getId())) {
            _flag.addPrecludes(_flag);
        } else {
            FlagDefinition flagDef = _flags.getFlagDefinition(flagId);
            if (flagDef == null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                flagDef = new FlagDefinition(flagId, "", "");
                _flags.addFlagDefinition(flagDef);
            }
            _flag.addPrecludes(flagDef);
        }
    }
    return;
}
Also used : InvalidFlagException(com.ibm.j9tools.om.InvalidFlagException) FlagDefinition(com.ibm.j9tools.om.FlagDefinition)

Aggregations

FlagDefinition (com.ibm.j9tools.om.FlagDefinition)1 InvalidFlagException (com.ibm.j9tools.om.InvalidFlagException)1