use of com.ibm.j9tools.om.Owner in project openj9 by eclipse.
the class BuildSpecParser 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("spec")) {
// $NON-NLS-1$
/* Reset all lists */
_owners = new Vector<Owner>();
_features = new Vector<Feature>();
_flags = new Vector<Flag>();
_sources = new Vector<Source>();
_properties = new Vector<Property>();
/* Set the build spec id */
// $NON-NLS-1$
_buildSpec.setId(attributes.getValue("id"));
/* Remember where this build spec was defined */
_buildSpec.setLocation(_documentLocatorFile, _documentLocator);
} else /* Parse owners of the build spec */
if (qName.equalsIgnoreCase("owners")) {
// $NON-NLS-1$
_owners = new Vector<Owner>();
} else /* Parse flags of the build spec */
if (qName.equalsIgnoreCase("flags")) {
// $NON-NLS-1$
_flags = new Vector<Flag>();
} else if (qName.equalsIgnoreCase("flag") && _flags != null) {
// $NON-NLS-1$
// $NON-NLS-1$
String flagName = attributes.getValue("id");
// $NON-NLS-1$
Boolean flagState = Boolean.valueOf(attributes.getValue("value"));
FlagDefinition flagDefinition = flagDefinitions.getFlagDefinition(flagName);
Flag flag = new Flag(flagName, flagState);
flag.setLocation(_documentLocatorFile, _documentLocator);
if (flagDefinition != null) {
flag.setDefinition(flagDefinition);
}
_flags.add(flag);
} else /* Parse features of the build spec */
if (qName.equalsIgnoreCase("features")) {
// $NON-NLS-1$
_features = new Vector<Feature>();
} else if (qName.equalsIgnoreCase("feature") && _features != null) {
// $NON-NLS-1$
// $NON-NLS-1$
String featureId = attributes.getValue("id");
FeatureDefinition featureDefinition = featureDefinitions.get(featureId);
Feature feature = new Feature(featureId);
feature.setLocation(_documentLocatorFile, _documentLocator);
if (featureDefinition != null) {
feature.setDefinition(featureDefinition);
}
_features.add(feature);
} else /* Parse sources of the build spec */
if (qName.equalsIgnoreCase("source")) {
// $NON-NLS-1$
_sources = new Vector<Source>();
} else if (qName.equalsIgnoreCase("project") && _sources != null) {
// $NON-NLS-1$
// $NON-NLS-1$
Source source = new Source(attributes.getValue("id"));
source.setLocation(_documentLocatorFile, _documentLocator);
_sources.add(source);
} else /* Parse properties of the build spec */
if (qName.equalsIgnoreCase("properties")) {
// $NON-NLS-1$
_properties = new Vector<Property>();
} else if (qName.equalsIgnoreCase("property") && _properties != null) {
// $NON-NLS-1$
// $NON-NLS-1$ //$NON-NLS-2$
Property property = new Property(attributes.getValue("name"), attributes.getValue("value"));
property.setLocation(_documentLocatorFile, _documentLocator);
_properties.add(property);
}
}
use of com.ibm.j9tools.om.Owner in project openj9 by eclipse.
the class BuildSpecParser method endElement.
/**
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) {
if (qName.equalsIgnoreCase("name")) {
// $NON-NLS-1$
_buildSpec.setName(_parsedValue);
} else if (qName.equalsIgnoreCase("asmBuilderName")) {
// $NON-NLS-1$
AsmBuilder asmBuilder = new AsmBuilder(_parsedValue);
asmBuilder.setLocation(_documentLocatorFile, _documentLocator);
_buildSpec.setAsmBuilder(asmBuilder);
} else if (qName.equalsIgnoreCase("cpuArchitecture")) {
// $NON-NLS-1$
_buildSpec.setCpuArchitecture(_parsedValue);
} else if (qName.equalsIgnoreCase("os")) {
// $NON-NLS-1$
_buildSpec.setOs(_parsedValue);
} else if (qName.equalsIgnoreCase("defaultJCL")) {
// $NON-NLS-1$
JclConfiguration jclConfiguration = new JclConfiguration(_parsedValue);
jclConfiguration.setLocation(_documentLocatorFile, _documentLocator);
_buildSpec.setDefaultJCL(jclConfiguration);
} else if (qName.equalsIgnoreCase("defaultSizes")) {
// $NON-NLS-1$
DefaultSizes defaultSizes = new DefaultSizes(_parsedValue);
defaultSizes.setLocation(_documentLocatorFile, _documentLocator);
_buildSpec.setDefaultSizes(defaultSizes);
} else if (qName.equalsIgnoreCase("priority")) {
// $NON-NLS-1$
try {
_buildSpec.setPriority(Integer.parseInt(_parsedValue));
} catch (NumberFormatException e) {
// $NON-NLS-1$
error(new SAXParseException("Invalid priority value, not a valid integer.", _documentLocator));
}
} else if (qName.equalsIgnoreCase("owner")) {
// $NON-NLS-1$
/* Parsed a single owner, add it to the list of Owners */
Owner owner = new Owner(_parsedValue);
owner.setLocation(_documentLocatorFile, _documentLocator);
_buildSpec.addOwner(owner);
} else if (qName.equalsIgnoreCase("owners")) {
// $NON-NLS-1$
/* Parsed all owners, add it to the BuildSpec */
_owners.add(new Owner(_parsedValue));
} else /* The <flags> element is being closed. Add all parsed flags to the buildSpec */
if (qName.equalsIgnoreCase("flags")) {
// $NON-NLS-1$
for (Flag f : _flags) {
_buildSpec.addFlag(f);
}
// flags set to a default value of FALSE
for (FlagDefinition flagDefinition : flagDefinitions.getFlagDefinitions().values()) {
if (!_buildSpec.hasFlag(flagDefinition.getId())) {
_buildSpec.addFlag(new Flag(flagDefinition));
}
}
} else /* The <features> element is being closed. Add all parsed features to the buildSpec */
if (qName.equalsIgnoreCase("features")) {
// $NON-NLS-1$
for (Feature f : _features) {
/* Save the feature id, it is not our responsibility to load the actual feature here */
_buildSpec.addFeature(f);
}
} else /* The <sources> element is being closed. Add all parsed sources to the buildSpec */
if (qName.equalsIgnoreCase("source")) {
// $NON-NLS-1$
for (Source s : _sources) {
_buildSpec.addSource(s);
}
} else /* The <properties> element is being closed. Add all parsed properties to the buildSpec */
if (qName.equalsIgnoreCase("properties")) {
// $NON-NLS-1$
for (Property p : _properties) {
_buildSpec.addProperty(p);
}
}
}
Aggregations