
com.draagon.meta.loader.xml.XMLFileMetaDataLoader Maven / Gradle / Ivy
/*
* Copyright 2003 Draagon Software LLC. All Rights Reserved.
*
* This software is the proprietary information of Draagon Software LLC.
* Use is subject to license terms.
*/
package com.draagon.meta.loader.xml;
import com.draagon.meta.loader.file.FileMetaDataLoader;
import com.draagon.meta.loader.file.LocalMetaDataSources;
import com.draagon.meta.loader.file.FileLoaderOptions;
import com.draagon.meta.loader.file.xml.XMLMetaDataParser;
/**
* Meta Class loader for XML files
*/
public class XMLFileMetaDataLoader extends FileMetaDataLoader {
private String typesRef = null;
private String sourceDir = null;
public XMLFileMetaDataLoader() {
this( "file-" + System.currentTimeMillis());
}
public XMLFileMetaDataLoader( String name ) {
super( new FileLoaderOptions()
.addParser( "*.xml", XMLMetaDataParser.class )
.setShouldRegister( false )
.setAllowAutoAttrs( true )
.setStrict( false )
.setVerbose( false ),
name );
}
public String getDefaultTypesRef() {
return "com/draagon/meta/loader/xml/metaobjects.types.xml";
}
public void setSourceDir( String dir ) {
sourceDir = dir;
if ( !sourceDir.endsWith( "/" )) sourceDir += "/";
}
public String getSourceDir() {
return sourceDir;
}
public void addSources( MetaDataSources sources ) {
getLoaderOptions().addSources( sources );
}
/*public void setTypesRef(String types) {
if ( types.isEmpty() ) types = null;
typesRef = types;
}
public String getTypesRef() {
return typesRef;
}*/
/** Initialize with the metadata source being set */
public XMLFileMetaDataLoader init( MetaDataSources sources ) {
return init( sources, false );
}
/** Initialize with the metadata source being set */
public XMLFileMetaDataLoader init( MetaDataSources sources, boolean shouldRegister ) {
FileLoaderOptions config = getLoaderOptions();
config.setShouldRegister( shouldRegister );
// Prepend the Types XML to load using the default behavior of the original XMLFileMetaDataLoader
if ( getDefaultTypesRef() != null ) {
config.addSources( new LocalMetaDataSources( getDefaultTypesRef()) );
}
return (XMLFileMetaDataLoader) super.init( sources );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy