use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class Configuration method toDocument.
/**
* Builds an XML representation of this configuration. This can be used to
* persist a programmatically generated configuration.
*
* @return the XML representation of this configuration
*/
public Document toDocument() {
// note that this method will not reconstruct a properties
// element - that element is only used in XML parsing
Document document = new Document(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID, XmlConstants.MYBATIS_GENERATOR_CONFIG_SYSTEM_ID);
//$NON-NLS-1$
XmlElement rootElement = new XmlElement("generatorConfiguration");
document.setRootElement(rootElement);
for (String classPathEntry : classPathEntries) {
//$NON-NLS-1$
XmlElement cpeElement = new XmlElement("classPathEntry");
//$NON-NLS-1$
cpeElement.addAttribute(new Attribute("location", classPathEntry));
rootElement.addElement(cpeElement);
}
for (Context context : contexts) {
rootElement.addElement(context.toXmlElement());
}
return document;
}
use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class JavaClientGeneratorConfiguration method toXmlElement.
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement answer = new XmlElement("javaClientGenerator");
if (getConfigurationType() != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("type", getConfigurationType()));
}
if (targetPackage != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("targetPackage", targetPackage));
}
if (targetProject != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("targetProject", targetProject));
}
if (implementationPackage != null) {
answer.addAttribute(new Attribute("implementationPackage", //$NON-NLS-1$
targetProject));
}
addPropertyXmlElements(answer);
return answer;
}
use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class JavaModelGeneratorConfiguration method toXmlElement.
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement answer = new XmlElement("javaModelGenerator");
if (targetPackage != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("targetPackage", targetPackage));
}
if (targetProject != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("targetProject", targetProject));
}
addPropertyXmlElements(answer);
return answer;
}
use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class PluginConfiguration method toXmlElement.
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement answer = new XmlElement("plugin");
if (getConfigurationType() != null) {
//$NON-NLS-1$
answer.addAttribute(new Attribute("type", getConfigurationType()));
}
addPropertyXmlElements(answer);
return answer;
}
use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class ResultMapWithBLOBsElementGenerator method addElements.
@Override
public void addElements(XmlElement parentElement) {
//$NON-NLS-1$
XmlElement answer = new XmlElement("resultMap");
answer.addAttribute(new //$NON-NLS-1$
Attribute(//$NON-NLS-1$
"id", introspectedTable.getResultMapWithBLOBsId()));
String returnType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
returnType = introspectedTable.getRecordWithBLOBsType();
} else {
// table has BLOBs, but no BLOB class - BLOB fields must be
// in the base class
returnType = introspectedTable.getBaseRecordType();
}
answer.addAttribute(new //$NON-NLS-1$
Attribute(//$NON-NLS-1$
"type", returnType));
if (!introspectedTable.isConstructorBased()) {
answer.addAttribute(new //$NON-NLS-1$
Attribute(//$NON-NLS-1$
"extends", introspectedTable.getBaseResultMapId()));
}
context.getCommentGenerator().addComment(answer);
if (introspectedTable.isConstructorBased()) {
addResultMapConstructorElements(answer);
} else {
addResultMapElements(answer);
}
if (context.getPlugins().sqlMapResultMapWithBLOBsElementGenerated(answer, introspectedTable)) {
parentElement.addElement(answer);
}
}
Aggregations