當前位置: 首頁>>代碼示例>>Java>>正文


Java TextElement類代碼示例

本文整理匯總了Java中org.mybatis.generator.api.dom.xml.TextElement的典型用法代碼示例。如果您正苦於以下問題:Java TextElement類的具體用法?Java TextElement怎麽用?Java TextElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextElement類屬於org.mybatis.generator.api.dom.xml包,在下文中一共展示了TextElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$

    String fqjt = introspectedTable.getExampleType();

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getDeleteByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("delete from "); //$NON-NLS-1$
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getExampleIncludeElement());

    if (context.getPlugins().sqlMapDeleteByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:bandaotixi,項目名稱:generator_mybatis,代碼行數:25,代碼來源:DeleteByExampleElementGenerator.java

示例2: getSelectKey

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * This method should return an XmlElement for the select key used to
 * automatically generate keys.
 * 
 * @param introspectedColumn
 *            the column related to the select key statement
 * @param generatedKey
 *            the generated key for the current table
 * @return the selectKey element
 */
protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn,
        GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn
            .getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", identityColumnType)); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("order", //$NON-NLS-1$
            generatedKey.getMyBatis3Order())); 
    
    answer.addElement(new TextElement(generatedKey
                    .getRuntimeSqlStatement()));

    return answer;
}
 
開發者ID:bandaotixi,項目名稱:generator_mybatis,代碼行數:28,代碼來源:AbstractXmlElementGenerator.java

示例3: getSelectKey

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * This method should return an XmlElement for the select key used to
 * automatically generate keys.
 * 
 * @param introspectedColumn
 *            the column related to the select key statement
 * @param generatedKey
 *            the generated key for the current table
 * @return the selectKey element
 */
protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn,
        GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn
            .getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultClass", identityColumnType)); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
    if (stringHasValue(generatedKey.getType())) {
        answer.addAttribute(new Attribute("type", generatedKey.getType())); //$NON-NLS-1$  
    }
    answer
            .addElement(new TextElement(generatedKey
                    .getRuntimeSqlStatement()));

    return answer;
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:29,代碼來源:AbstractXmlElementGenerator.java

示例4: sqlMapSelectByExampleWithoutBLOBsElementGenerated

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * 為Mapper.xml的selectByExample添加limit,offset
 */
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(XmlElement element,
                                                                 IntrospectedTable introspectedTable) {

	XmlElement ifLimitNotNullElement = new XmlElement("if");
	ifLimitNotNullElement.addAttribute(new Attribute("test", "limit != null"));

	XmlElement ifOffsetNotNullElement = new XmlElement("if");
	ifOffsetNotNullElement.addAttribute(new Attribute("test", "offset != null"));
	ifOffsetNotNullElement.addElement(new TextElement("limit ${offset}, ${limit}"));
	ifLimitNotNullElement.addElement(ifOffsetNotNullElement);

	XmlElement ifOffsetNullElement = new XmlElement("if");
	ifOffsetNullElement.addAttribute(new Attribute("test", "offset == null"));
	ifOffsetNullElement.addElement(new TextElement("limit ${limit}"));
	ifLimitNotNullElement.addElement(ifOffsetNullElement);

	element.addElement(ifLimitNotNullElement);

	return true;
}
 
開發者ID:ChangyiHuang,項目名稱:shuzheng,代碼行數:25,代碼來源:PaginationPlugin.java

示例5: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("select"); //$NON-NLS-1$

    String fqjt = introspectedTable.getExampleType();

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getCountByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", "java.lang.Long")); //$NON-NLS-1$ //$NON-NLS-2$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("select count(*) from "); //$NON-NLS-1$
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getExampleIncludeElement());

    if (context.getPlugins().sqlMapCountByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:26,代碼來源:CountByExampleElementGenerator.java

示例6: generatedWithSelective

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * 有Selective代碼生成
 * @param element
 */
private void generatedWithSelective(XmlElement element, IntrospectedTable introspectedTable, boolean hasPrefix) {
    if (incTools.support()) {
        // 查找 set->if->text
        List<XmlElement> sets = XmlElementGeneratorTools.findXmlElements(element, "set");
        if (sets.size() > 0) {
            List<XmlElement> ifs = XmlElementGeneratorTools.findXmlElements(sets.get(0), "if");
            if (ifs.size() > 0) {
                for (XmlElement xmlElement : ifs) {
                    // 下麵為if的text節點
                    List<Element> textEles = xmlElement.getElements();
                    TextElement textEle = (TextElement) textEles.get(0);
                    String[] strs = textEle.getContent().split("=");
                    String columnName = strs[0].trim();
                    IntrospectedColumn introspectedColumn = IntrospectedTableTools.safeGetColumn(introspectedTable, columnName);
                    // 查找是否需要進行增量操作
                    if (incTools.supportColumn(introspectedColumn)) {
                        xmlElement.getElements().clear();
                        xmlElement.getElements().addAll(incTools.generatedIncrementsElement(introspectedColumn, hasPrefix, true));
                    }
                }
            }
        }
    }
}
 
開發者ID:itfsw,項目名稱:mybatis-generator-plugin,代碼行數:29,代碼來源:IncrementsPlugin.java

示例7: generateSqlBaseColumns

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * 生成包含全部列的 sql 元素
 */
private void generateSqlBaseColumns(Document document, IntrospectedTable introspectedTable) {
    // 新建 sql 元素標簽
    XmlElement sqlElement = new XmlElement("sql");
    // 新建 sql 元素屬性
    Attribute attr = new Attribute("id", id);
    sqlElement.addAttribute(attr);
    // 新建 sql 元素內容,填寫注釋
    sqlElement.addElement(new TextElement(Constants.WARNING));
    // 獲取全部列名稱
    StringBuilder columnsBuilder = new StringBuilder();
    List<IntrospectedColumn> columnList = introspectedTable.getAllColumns();
    for (IntrospectedColumn column : columnList) {
        columnsBuilder.append(MyBatis3FormattingUtilities.getSelectListPhrase(column)).append(", ");
    }
    // 刪除最後一個逗號
    String columns = columnsBuilder.substring(0, columnsBuilder.length() - 2);
    // 新建 sql 元素內容,填寫列名稱
    sqlElement.addElement(new TextElement(columns));
    // 將 sql 元素放到根元素下
    XmlElement rootElement = document.getRootElement();
    rootElement.addElement(new TextElement(""));
    rootElement.addElement(sqlElement);
    rootElement.addElement(new TextElement(""));
}
 
開發者ID:drtrang,項目名稱:mybatis-generator-extension,代碼行數:28,代碼來源:MapperSqlMapConfigPlugin.java

示例8: sqlMapSelectByExampleWithoutBLOBsElementGenerated

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
	XmlElement isNotNullElement = new XmlElement("if");
	isNotNullElement.addAttribute(new Attribute("test", "limitStart != null and limitStart >=0"));
	isNotNullElement.addElement(new TextElement("limit ${limitStart} , ${pageSize}"));
	element.addElement(isNotNullElement);
	return super.sqlMapSelectByExampleWithoutBLOBsElementGenerated(element, introspectedTable);
}
 
開發者ID:dianbaer,項目名稱:epay,代碼行數:9,代碼來源:PaginationPlugin.java

示例9: contextGenerateAdditionalXmlFiles

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles() {
	Document document = new Document("-//mybatis.org//DTD Config 3.0//EN", "http://mybatis" +
			".org/dtd/mybatis-3-config.dtd");
	XmlElement root = new XmlElement("configuration");
	document.setRootElement(root);
	root.addElement(new TextElement("<!--"));
	root.addElement(new TextElement("  This file is generated by MyBatis Generator."));
	root.addElement(new TextElement("-->"));
	XmlElement mappers = new XmlElement("mappers");
	root.addElement(mappers);
	Iterator var6 = this.mapperFiles.iterator();

	while (var6.hasNext()) {
		String mapperFile = (String) var6.next();
		XmlElement mapper = new XmlElement("mapper");
		mapper.addAttribute(new Attribute("resource", mapperFile));
		mappers.addElement(mapper);
	}

	GeneratedXmlFile gxf = new GeneratedXmlFile(document, this.properties.getProperty("fileName", "MapperConfig" +
			".xml"), this.properties.getProperty("targetPackage"), this.properties.getProperty("targetProject"),
			false, this.context.getXmlFormatter());
	List<GeneratedXmlFile> answer = new ArrayList(1);
	answer.add(gxf);
	return answer;
}
 
開發者ID:ychaoyang,項目名稱:autotest,代碼行數:28,代碼來源:MapperConfigPlugin.java

示例10: addComment

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
public void addComment(XmlElement xmlElement) {
    if (!this.suppressAllComments) {
        xmlElement.addElement(new TextElement("<!--"));
        StringBuilder sb = new StringBuilder();
        sb.append("  WARNING - ");
        sb.append("@mbg.generated");
        xmlElement.addElement(new TextElement(sb.toString()));
        xmlElement.addElement(new TextElement("  This element is automatically generated by MyBatis Generator, do not modify."));
        xmlElement.addElement(new TextElement("-->"));
    }
}
 
開發者ID:ychaoyang,項目名稱:autotest,代碼行數:12,代碼來源:DefaultCommentGenerator.java

示例11: addComment

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
/**
 * Adds a suitable comment to warn users that the element was generated, and when it was generated.
 *
 * @param xmlElement
 *            the xml element
 */
public void addComment(XmlElement xmlElement) {
    if (suppressAllComments) {
        return;
    }

    xmlElement.addElement(new TextElement("<!--")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    sb.append("  WARNING - "); //$NON-NLS-1$
    sb.append(MergeConstants.NEW_ELEMENT_TAG);
    xmlElement.addElement(new TextElement(sb.toString()));
    xmlElement
            .addElement(new TextElement(
                    "  This element is automatically generated by MyBatis Generator, do not modify.")); //$NON-NLS-1$

    String s = getDateString();
    if (s != null) {
        sb.setLength(0);
        sb.append("  This element was generated on "); //$NON-NLS-1$
        sb.append(s);
        sb.append('.');
        xmlElement.addElement(new TextElement(sb.toString()));
    }

    xmlElement.addElement(new TextElement("-->")); //$NON-NLS-1$
}
 
開發者ID:bandaotixi,項目名稱:generator_mybatis,代碼行數:33,代碼來源:DefaultCommentGenerator.java

示例12: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getDeleteByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("delete from "); //$NON-NLS-1$
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    sb.setLength(0);
    sb.append(introspectedTable.getIbatis2SqlMapNamespace());
    sb.append('.');
    sb.append(introspectedTable.getExampleWhereClauseId());
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
            sb.toString()));

    answer.addElement(includeElement);

    if (context.getPlugins().sqlMapDeleteByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:bandaotixi,項目名稱:generator_mybatis,代碼行數:33,代碼來源:DeleteByExampleElementGenerator.java

示例13: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
            introspectedTable.getBlobColumnListId()));

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();

    Iterator<IntrospectedColumn> iter = introspectedTable.getBLOBColumns()
            .iterator();
    while (iter.hasNext()) {
        sb.append(MyBatis3FormattingUtilities.getSelectListPhrase(iter
                .next()));

        if (iter.hasNext()) {
            sb.append(", "); //$NON-NLS-1$
        }

        if (sb.length() > 80) {
            answer.addElement(new TextElement(sb.toString()));
            sb.setLength(0);
        }
    }

    if (sb.length() > 0) {
        answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapBlobColumnListElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:nextyu,項目名稱:summer-mybatis-generator,代碼行數:37,代碼來源:BlobColumnListElementGenerator.java

示例14: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("select"); //$NON-NLS-1$

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getCountByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultClass", "java.lang.Long")); //$NON-NLS-1$ //$NON-NLS-2$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("select count(*) from "); //$NON-NLS-1$
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    sb.setLength(0);
    sb.append(introspectedTable.getIbatis2SqlMapNamespace());
    sb.append('.');
    sb.append(introspectedTable.getExampleWhereClauseId());
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
            sb.toString()));

    answer.addElement(includeElement);

    if (context.getPlugins().sqlMapCountByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:bandaotixi,項目名稱:generator_mybatis,代碼行數:34,代碼來源:CountByExampleElementGenerator.java

示例15: addElements

import org.mybatis.generator.api.dom.xml.TextElement; //導入依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
            introspectedTable.getBlobColumnListId()));

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();

    Iterator<IntrospectedColumn> iter = introspectedTable.getBLOBColumns()
            .iterator();
    while (iter.hasNext()) {
        sb.append(Ibatis2FormattingUtilities.getSelectListPhrase(iter
                .next()));

        if (iter.hasNext()) {
            sb.append(", "); //$NON-NLS-1$
        }

        if (sb.length() > 80) {
            answer.addElement(new TextElement(sb.toString()));
            sb.setLength(0);
        }
    }

    if (sb.length() > 0) {
        answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapBlobColumnListElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:37,代碼來源:BlobColumnListElementGenerator.java


注:本文中的org.mybatis.generator.api.dom.xml.TextElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。