Optional<URI> moduleNs = Optional.fromNullable(firstAttributeOf(stmt.declaredSubstatements(),
NamespaceStatement.class));
if (!moduleNs.isPresent()) {
- throw new IllegalArgumentException("Namespace of the module [" + stmt.getStatementArgument()
- + "] is missing.");
+ throw new SourceException(String.format("Namespace of the module [%s] is missing",
+ stmt.getStatementArgument()), stmt.getStatementSourceReference());
}
Optional<Date> revisionDate = Optional.fromNullable(Utils.getLatestRevision(stmt.declaredSubstatements()));
revisionDate = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_REV);
}
- QNameModule qNameModule = QNameModule.cachedReference(QNameModule.create(moduleNs.get(), revisionDate.orNull()));
+ QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orNull()).intern();
ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(stmt.getStatementArgument(),
Optional.<URI> absent(), revisionDate);
String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
if (modulePrefix == null) {
- throw new IllegalArgumentException("Prefix of the module [" + stmt.getStatementArgument() + "] is missing.");
+ throw new SourceException(String.format("Prefix of the module [%s] is missing",
+ stmt.getStatementArgument()), stmt.getStatementSourceReference());
}
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
super.onFullDefinitionDeclared(stmt);
SUBSTATEMENT_VALIDATOR.validate(stmt);
}
-}
\ No newline at end of file
+}