Java Code Examples for org.mybatis.generator.api.dom.OutputUtilities#newLine()
The following examples show how to use
org.mybatis.generator.api.dom.OutputUtilities#newLine() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Document.java From mybatis-generator-core-fix with Apache License 2.0 | 6 votes |
/** * Gets the formatted content. * * @return the formatted content */ public String getFormattedContent() { StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ if (publicId != null && systemId != null) { OutputUtilities.newLine(sb); sb.append("<!DOCTYPE "); //$NON-NLS-1$ sb.append(rootElement.getName()); sb.append(" PUBLIC \""); //$NON-NLS-1$ sb.append(publicId); sb.append("\" \""); //$NON-NLS-1$ sb.append(systemId); sb.append("\">"); //$NON-NLS-1$ } OutputUtilities.newLine(sb); sb.append(rootElement.getFormattedContent(0)); return sb.toString(); }
Example 2
Source File: Document.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
public String getFormattedContent() { StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); //$NON-NLS-1$ if (publicId != null && systemId != null) { OutputUtilities.newLine(sb); sb.append("<!DOCTYPE "); //$NON-NLS-1$ sb.append(rootElement.getName()); sb.append(" PUBLIC \""); //$NON-NLS-1$ sb.append(publicId); sb.append("\" \""); //$NON-NLS-1$ sb.append(systemId); sb.append("\" >"); //$NON-NLS-1$ } OutputUtilities.newLine(sb); sb.append(rootElement.getFormattedContent(0)); return sb.toString(); }
Example 3
Source File: XmlElement.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
@Override public String getFormattedContent(int indentLevel) { StringBuilder sb = new StringBuilder(); OutputUtilities.xmlIndent(sb, indentLevel); sb.append('<'); sb.append(name); Collections.sort(attributes); for (Attribute att : attributes) { sb.append(' '); sb.append(att.getFormattedContent()); } if (elements.size() > 0) { sb.append(">"); //$NON-NLS-1$ for (Element element : elements) { OutputUtilities.newLine(sb); sb.append(element.getFormattedContent(indentLevel + 1)); } OutputUtilities.newLine(sb); OutputUtilities.xmlIndent(sb, indentLevel); sb.append("</"); //$NON-NLS-1$ sb.append(name); sb.append('>'); } else { sb.append(" />"); //$NON-NLS-1$ } return sb.toString(); }
Example 4
Source File: JavaElement.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
public void addFormattedJavadoc(StringBuilder sb, int indentLevel) { for (String javaDocLine : javaDocLines) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(javaDocLine); OutputUtilities.newLine(sb); } }
Example 5
Source File: JavaElement.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
public void addFormattedAnnotations(StringBuilder sb, int indentLevel) { for (String annotation : annotations) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(annotation); OutputUtilities.newLine(sb); } }
Example 6
Source File: XmlElement.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
@Override public String getFormattedContent(int indentLevel) { StringBuilder sb = new StringBuilder(); OutputUtilities.xmlIndent(sb, indentLevel); sb.append('<'); sb.append(name); for (Attribute att : attributes) { sb.append(' '); sb.append(att.getFormattedContent()); } if (elements.size() > 0) { sb.append(" >"); //$NON-NLS-1$ for (Element element : elements) { OutputUtilities.newLine(sb); sb.append(element.getFormattedContent(indentLevel + 1)); } OutputUtilities.newLine(sb); OutputUtilities.xmlIndent(sb, indentLevel); sb.append("</"); //$NON-NLS-1$ sb.append(name); sb.append('>'); } else { sb.append(" />"); //$NON-NLS-1$ } return sb.toString(); }
Example 7
Source File: PostgisGeoPlugin.java From dolphin with Apache License 2.0 | 5 votes |
protected String getContentWithoutOuterTags(XmlElement xe){ int indentLevel = 0; StringBuilder sb = new StringBuilder(); Iterator<Element> iter = xe.getElements().iterator(); while(iter.hasNext()){ sb.append(iter.next().getFormattedContent(indentLevel)); if(iter.hasNext()){ OutputUtilities.newLine(sb); } } return sb.toString(); }
Example 8
Source File: CommentGenerator.java From dolphin with Apache License 2.0 | 5 votes |
public void addSqlMapFileComment(Document document){ if(suppressAllComments) return; ExtendedDocument ed = null; if(document instanceof ExtendedDocument) { ed = (ExtendedDocument) document; } else return; // if user doesn't supplied the xml source copyright then use the default String copyright = copyrights.getFormatted("XmlSource", startYear, endYear); if(StringUtils.isEmpty(copyright)){ copyright = defaultCopyrights.getFormatted("XmlSource",startYear,endYear); } if(StringUtils.isNotEmpty(copyright)) { String[] array = copyright.split("\\|"); StringBuilder sb = new StringBuilder(); for(String str : array){ if(!str.startsWith("<!--") && !str.startsWith("-->")){ sb.append(" "); } sb.append(str); OutputUtilities.newLine(sb); } ed.setFileComments(sb.toString()); } }
Example 9
Source File: ExtendedDocument.java From dolphin with Apache License 2.0 | 5 votes |
@Override public String getFormattedContent() { StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); //$NON-NLS-1$ if (getPublicId() != null && getSystemId() != null) { OutputUtilities.newLine(sb); sb.append("<!DOCTYPE "); //$NON-NLS-1$ sb.append(getRootElement().getName()); sb.append(" PUBLIC \""); //$NON-NLS-1$ sb.append(getPublicId()); sb.append("\" \""); //$NON-NLS-1$ sb.append(getSystemId()); sb.append("\" >"); //$NON-NLS-1$ } // add file comments to the generated string if(StringUtils.isNotEmpty(fileComments)) { OutputUtilities.newLine(sb); sb.append(fileComments); } OutputUtilities.newLine(sb); sb.append(getRootElement().getFormattedContent(0)); return sb.toString(); }
Example 10
Source File: InitializationBlock.java From mybatis-generator-core-fix with Apache License 2.0 | 4 votes |
public String getFormattedContent(int indentLevel) { StringBuilder sb = new StringBuilder(); for (String javaDocLine : javaDocLines) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(javaDocLine); OutputUtilities.newLine(sb); } OutputUtilities.javaIndent(sb, indentLevel); if (isStatic) { sb.append("static "); //$NON-NLS-1$ } sb.append('{'); indentLevel++; ListIterator<String> listIter = bodyLines.listIterator(); while (listIter.hasNext()) { String line = listIter.next(); if (line.startsWith("}")) { //$NON-NLS-1$ indentLevel--; } OutputUtilities.newLine(sb); OutputUtilities.javaIndent(sb, indentLevel); sb.append(line); if ((line.endsWith("{") && !line.startsWith("switch")) //$NON-NLS-1$ //$NON-NLS-2$ || line.endsWith(":")) { //$NON-NLS-1$ indentLevel++; } if (line.startsWith("break")) { //$NON-NLS-1$ // if the next line is '}', then don't outdent if (listIter.hasNext()) { String nextLine = listIter.next(); if (nextLine.startsWith("}")) { //$NON-NLS-1$ indentLevel++; } // set back to the previous element listIter.previous(); } indentLevel--; } } indentLevel--; OutputUtilities.newLine(sb); OutputUtilities.javaIndent(sb, indentLevel); sb.append('}'); return sb.toString(); }
Example 11
Source File: InitializationBlock.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
public String getFormattedContent(int indentLevel) { StringBuilder sb = new StringBuilder(); for (String javaDocLine : javaDocLines) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(javaDocLine); OutputUtilities.newLine(sb); } OutputUtilities.javaIndent(sb, indentLevel); if (isStatic) { sb.append("static "); //$NON-NLS-1$ } sb.append('{'); indentLevel++; ListIterator<String> listIter = bodyLines.listIterator(); while (listIter.hasNext()) { String line = listIter.next(); if (line.startsWith("}")) { //$NON-NLS-1$ indentLevel--; } OutputUtilities.newLine(sb); OutputUtilities.javaIndent(sb, indentLevel); sb.append(line); if ((line.endsWith("{") && !line.startsWith("switch")) //$NON-NLS-1$ //$NON-NLS-2$ || line.endsWith(":")) { //$NON-NLS-1$ indentLevel++; } if (line.startsWith("break")) { //$NON-NLS-1$ // if the next line is '}', then don't outdent if (listIter.hasNext()) { String nextLine = listIter.next(); if (nextLine.startsWith("}")) { //$NON-NLS-1$ indentLevel++; } // set back to the previous element listIter.previous(); } indentLevel--; } } indentLevel--; OutputUtilities.newLine(sb); OutputUtilities.javaIndent(sb, indentLevel); sb.append('}'); return sb.toString(); }
Example 12
Source File: Interface.java From mybatis-generator-plus with Apache License 2.0 | 4 votes |
public String getFormattedContent() { StringBuilder sb = new StringBuilder(); for (String commentLine : fileCommentLines) { sb.append(commentLine); newLine(sb); } if (stringHasValue(getType().getPackageName())) { sb.append("package "); //$NON-NLS-1$ sb.append(getType().getPackageName()); sb.append(';'); newLine(sb); newLine(sb); } for (String staticImport : staticImports) { sb.append("import static "); //$NON-NLS-1$ sb.append(staticImport); sb.append(';'); newLine(sb); } if (staticImports.size() > 0) { newLine(sb); } Set<String> importStrings = calculateImports(importedTypes); for (String importString : importStrings) { sb.append(importString); newLine(sb); } if (importStrings.size() > 0) { newLine(sb); } int indentLevel = 0; addFormattedJavadoc(sb, indentLevel); addFormattedAnnotations(sb, indentLevel); sb.append(getVisibility().getValue()); if (isStatic()) { sb.append("static "); //$NON-NLS-1$ } if (isFinal()) { sb.append("final "); //$NON-NLS-1$ } sb.append("interface "); //$NON-NLS-1$ sb.append(getType().getShortName()); if (getSuperInterfaceTypes().size() > 0) { sb.append(" extends "); //$NON-NLS-1$ boolean comma = false; for (FullyQualifiedJavaType fqjt : getSuperInterfaceTypes()) { if (comma) { sb.append(", "); //$NON-NLS-1$ } else { comma = true; } sb.append(fqjt.getShortName()); } } sb.append(" {"); //$NON-NLS-1$ indentLevel++; //add by wushuai start Iterator<Field> fldIter = fields.iterator(); while (fldIter.hasNext()) { OutputUtilities.newLine(sb); Field field = fldIter.next(); sb.append(field.getFormattedContent(indentLevel)); OutputUtilities.newLine(sb); } //add by wushuai end Iterator<Method> mtdIter = getMethods().iterator(); while (mtdIter.hasNext()) { newLine(sb); Method method = mtdIter.next(); sb.append(method.getFormattedContent(indentLevel, true)); if (mtdIter.hasNext()) { newLine(sb); } } indentLevel--; newLine(sb); javaIndent(sb, indentLevel); sb.append('}'); return sb.toString(); }
Example 13
Source File: JavaElement.java From mybatis-generator-core-fix with Apache License 2.0 | 3 votes |
/** * Adds the formatted javadoc. * * @param sb * the sb * @param indentLevel * the indent level */ public void addFormattedJavadoc(StringBuilder sb, int indentLevel) { for (String javaDocLine : javaDocLines) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(javaDocLine); OutputUtilities.newLine(sb); } }
Example 14
Source File: JavaElement.java From mybatis-generator-core-fix with Apache License 2.0 | 3 votes |
/** * Adds the formatted annotations. * * @param sb * the sb * @param indentLevel * the indent level */ public void addFormattedAnnotations(StringBuilder sb, int indentLevel) { for (String annotation : annotations) { OutputUtilities.javaIndent(sb, indentLevel); sb.append(annotation); OutputUtilities.newLine(sb); } }