public void error(String message, Location location, Throwable cause) { _errorHandler.error(_log, message, location, cause); }
/** * Checks that each service has at service constructor. */ private void checkForMissingServices() { Iterator i = _servicePoints.values().iterator(); while (i.hasNext()) { ServicePointImpl point = (ServicePointImpl) i.next(); if (point.getServiceConstructor() != null) continue; _errorHandler.error(_log, ImplMessages.missingService(point), null, null); } }
/** * Invoked from the constructor to read the properties file that defines certain aspects of the * operation of the parser. */ private void initializeFromPropertiesFile() { Properties p = new Properties(); try { InputStream propertiesIn = getClass() .getResourceAsStream("DescriptorParser.properties"); InputStream bufferedIn = new BufferedInputStream(propertiesIn); p.load(bufferedIn); bufferedIn.close(); } catch (IOException ex) { _errorHandler.error(LOG, ParseMessages.unableToInitialize(ex), null, ex); } initializeFromProperties(p); }
private String expandSymbol(String name, Location location) { String value = _source.valueForSymbol(name); if (value != null) return value; _errorHandler.error(LOG, ImplMessages.noSuchSymbol(name), location, null); return "${" + name + "}"; }
private Schema getSchema(String schemaId, String referencingModule, Location reference) { Schema schema = (Schema) _schemas.get(schemaId); if (schema == null) _errorHandler .error(_log, ImplMessages.unableToResolveSchema(schemaId), reference, null); else if (!schema.visibleToModule(referencingModule)) { _errorHandler.error( _log, ImplMessages.schemaNotVisible(schemaId, referencingModule), reference, null); schema = null; } return schema; }
private void processResource(Resource resource) { try { ModuleDescriptor md = _processor.processResource(resource); _moduleDescriptors.add(md); // After parsing a module, parse any additional modules identified // within the module (using the <sub-module> element) recursively. processSubModules(md); } catch (RuntimeException ex) { _errorHandler.error(LOG, ex.getMessage(), HiveMind.getLocation(ex), ex); } }
/** * Adds a mapping for an attribute; these come from <map> elements nested within the * <conversion> element. A check for duplicate attribute mappings (that is, duplicated * attribute name), and an error is logged (and the duplicate ignored). */ public void addAttributeMapping(AttributeMappingDescriptor descriptor) { String attributeName = descriptor.getAttributeName(); AttributeMappingDescriptor existing = (AttributeMappingDescriptor) _attributeNameMappingMap .get(attributeName); if (existing != null) { _errorHandler.error( LOG, ParseMessages.dupeAttributeMapping(descriptor, existing), descriptor.getLocation(), null); return; } _attributeNameMappingMap.put(attributeName, descriptor); _attributeMappings.add(descriptor); }
private void enterService30() { _errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null); push(_elementName, null, STATE_NO_CONTENT); }
private void enterService30() { _errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null); push(_elementName, null, STATE_NO_CONTENT); }
/** * Checks that each configuration extension point has the right number of contributions. */ private void checkContributionCounts() { Iterator i = _configurationPoints.values().iterator(); while (i.hasNext()) { ConfigurationPointImpl point = (ConfigurationPointImpl) i.next(); Occurances expected = point.getExpectedCount(); int actual = point.getContributionCount(); if (expected.inRange(actual)) continue; _errorHandler.error(_log, ImplMessages.wrongNumberOfContributions( point, actual, expected), point.getLocation(), null); } }
private boolean getBooleanAttribute(String name, boolean defaultValue) { String value = getAttribute(name); if (value == null) return defaultValue; if (value.equals("true")) return true; if (value.equals("false")) return false; _errorHandler.error( LOG, ParseMessages.booleanAttribute(value, name, getElementPath()), getLocation(), null); return defaultValue; }
/** * Adds a schema to this module descriptor. If a schema with the same id already has been added, * an error is reported and the given schema is ignored. * * @since 1.1 */ public void addSchema(SchemaImpl schema) { if (_schemas == null) _schemas = new HashMap(); String schemaId = schema.getId(); Schema existing = getSchema(schemaId); if (existing != null) { _errorHandler.error(LOG, ParseMessages.duplicateSchema( _moduleId + '.' + schemaId, existing), schema.getLocation(), null); return; } _schemas.put(schemaId, schema); }
/** * Gets the value for the attribute and uses the Map to translate it to an object value. Returns * the object value if succesfully translated. Returns null if unsuccesful. If a value is * provided that isn't a key of the map, and error is logged and null is returned. */ private Object getEnumAttribute(String name, Map translations) { String value = getAttribute(name); if (value == null) return null; Object result = translations.get(value); if (result == null) _errorHandler.error(LOG, ParseMessages.invalidAttributeValue( value, name, getElementPath()), getLocation(), null); return result; }
private int getIntAttribute(String name) { String value = getAttribute(name); try { return Integer.parseInt(value); } catch (NumberFormatException ex) { _errorHandler.error(LOG, ParseMessages.invalidNumericValue( value, name, getElementPath()), getLocation(), ex); return 0; } }
private void addAttributeRules() { Iterator i = _elementModel.getAttributeModels().iterator(); while (i.hasNext()) { AttributeModel am = (AttributeModel) i.next(); String attributeName = am.getName(); AttributeMappingDescriptor amd = (AttributeMappingDescriptor) _attributeNameMappingMap .get(attributeName); if (amd == null) { _rules.add(new ReadAttributeRule(attributeName, constructPropertyName(attributeName), null, getLocation())); } else { String propertyName = amd.getPropertyName(); if (propertyName == null) propertyName = constructPropertyName(attributeName); _rules.add(new ReadAttributeRule(attributeName, propertyName, null, amd .getLocation())); _attributeNameMappingMap.remove(attributeName); } } if (!_attributeNameMappingMap.isEmpty()) _errorHandler.error(LOG, ParseMessages.extraMappings( _attributeNameMappingMap.keySet(), _elementModel), _elementModel.getLocation(), null); }
private void checkDependency(DependencyDescriptor dependency) { ModuleDescriptor requiredModule = (ModuleDescriptor) _moduleDescriptors.get(dependency .getModuleId()); if (requiredModule == null) { _errorHandler.error( _log, ImplMessages.dependencyOnUnknownModule(dependency), dependency.getLocation(), null); return; } if (dependency.getVersion() != null && !dependency.getVersion().equals(requiredModule.getVersion())) { _errorHandler.error( _log, ImplMessages.dependencyVersionMismatch(dependency), dependency.getLocation(), null); return; } } }
private void processSubModules(ModuleDescriptor moduleDescriptor) { List subModules = moduleDescriptor.getSubModules(); if (subModules == null) return; for (Iterator i = subModules.iterator(); i.hasNext();) { SubModuleDescriptor smd = (SubModuleDescriptor) i.next(); Resource descriptorResource = smd.getDescriptor(); if (descriptorResource.getResourceURL() == null) { _errorHandler.error( LOG, ImplMessages.subModuleDoesNotExist(descriptorResource), smd.getLocation(), null); continue; } processResource(smd.getDescriptor()); } }
_errorHandler.error( LOG, ParseMessages.unknownAttribute(name, getElementPath()),
private String getValidatedAttribute(String name, String pattern, String formatKey) { String result = getAttribute(name); if (!validateFormat(result, pattern)) _errorHandler.error(LOG, ParseMessages.invalidAttributeFormat( name, result, getElementPath(), formatKey), getLocation(), null); return result; }