Log log = getLog();
if (log.isTraceEnabled())
log.trace(_loc.get("parse-class", _cls.getName()));
MetaDataRepository repos = getRepository();
ClassMetaData meta = repos.getCachedMetaData(_cls);
if (meta != null
&& ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0)
|| (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
{
if(isDuplicateClass(meta)) {
if (log.isWarnEnabled()) {
log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
}
if(log.isTraceEnabled()) {
log.trace(String.format(
"MetaData originally obtained from source: %s under mode: %d with scope: %s, and type: %d",
meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType()));
}
}
_cls = null;
return false;
}
int access = AccessCode.UNKNOWN;
if (meta == null) {
int accessCode = toAccessType(attrs.getValue("access"));
// if access not specified and access was specified at
// the system level, use the system default (which may
// be UNKNOWN)
if (accessCode == AccessCode.UNKNOWN)
accessCode = _access;
meta = repos.addMetaData(_cls, accessCode, metaDataComplete);
FieldMetaData[] fmds = meta.getFields();
if (metaDataComplete) {
for (int i = 0; i < fmds.length; i++) {
fmds[i].setExplicit(true);
}
}
meta.setEnvClassLoader(_envLoader);
meta.setSourceMode(MODE_NONE);
// parse annotations first so XML overrides them
if (_parser != null) {
_parser.parse(_cls);
}
}
access = meta.getAccessType();
boolean mappedSuper = "mapped-superclass".equals(elem);
boolean embeddable = "embeddable".equals(elem);
if (isMetaDataMode()) {
Locator locator = getLocation().getLocator();
meta.setSource(getSourceFile(), SourceTracker.SRC_XML, locator != null ? locator.getSystemId() : "" );
meta.setSourceMode(MODE_META, true);
if (locator != null) {
meta.setLineNumber(locator.getLineNumber());
meta.setColNumber(locator.getColumnNumber());
}
meta.setListingIndex(_clsPos);
String name = attrs.getValue("name");
if (!StringUtils.isEmpty(name))
meta.setTypeAlias(name);
meta.setAbstract(mappedSuper);
meta.setEmbeddedOnly(mappedSuper || embeddable);
if (embeddable) {
meta.setEmbeddable();
setDeferredEmbeddableAccessType(_cls, access);
}
}
if (attrs.getValue("cacheable") != null) {
meta.setCacheEnabled(Boolean.valueOf(attrs.getValue("cacheable")));
}
if (isMappingMode())
meta.setSourceMode(MODE_MAPPING, true);
if (isMappingOverrideMode())
startClassMapping(meta, mappedSuper, attrs);
if (isQueryMode())
meta.setSourceMode(MODE_QUERY, true);
_clsPos++;
_fieldPos = 0;
addComments(meta);
pushElement(meta);