List of usage examples for com.liferay.portal.kernel.util StringPool TAB
String TAB
To view the source code for com.liferay.portal.kernel.util StringPool TAB.
Click Source Link
From source file:com.liferay.tools.sourceformatter.SQLSourceProcessor.java
License:Open Source License
@Override protected String doFormat(File file, String fileName, String absolutePath, String content) throws Exception { StringBundler sb = new StringBundler(); try (UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader( new UnsyncStringReader(content))) { String line = null;/*from w ww .jav a 2s.c om*/ String previousLineSqlCommand = StringPool.BLANK; while ((line = unsyncBufferedReader.readLine()) != null) { line = trimLine(line, false); if (Validator.isNotNull(line) && !line.startsWith(StringPool.TAB)) { String sqlCommand = StringUtil.split(line, CharPool.SPACE)[0]; if (Validator.isNotNull(previousLineSqlCommand) && !previousLineSqlCommand.equals(sqlCommand)) { sb.append("\n"); } previousLineSqlCommand = sqlCommand; } else { previousLineSqlCommand = StringPool.BLANK; } String strippedQuotesLine = stripQuotes(line, CharPool.APOSTROPHE); if (strippedQuotesLine.contains(StringPool.QUOTE)) { line = StringUtil.replace(line, StringPool.QUOTE, StringPool.APOSTROPHE); } sb.append(line); sb.append("\n"); } } content = sb.toString(); if (content.endsWith("\n")) { content = content.substring(0, content.length() - 1); } return content; }
From source file:com.liferay.tools.sourceformatter.XMLSourceProcessor.java
License:Open Source License
protected String fixPoshiXMLNumberOfTabs(String content) { Matcher matcher = _poshiTabsPattern.matcher(content); int tabCount = 0; boolean ignoredCdataBlock = false; boolean ignoredCommentBlock = false; while (matcher.find()) { String statement = matcher.group(); Matcher quoteWithSlashMatcher = _poshiQuoteWithSlashPattern.matcher(statement); String fixedQuoteStatement = statement; if (quoteWithSlashMatcher.find()) { fixedQuoteStatement = StringUtil.replace(statement, quoteWithSlashMatcher.group(), "\"\""); }/*from w ww . j a v a2s .c om*/ Matcher closingTagMatcher = _poshiClosingTagPattern.matcher(fixedQuoteStatement); Matcher openingTagMatcher = _poshiOpeningTagPattern.matcher(fixedQuoteStatement); Matcher wholeTagMatcher = _poshiWholeTagPattern.matcher(fixedQuoteStatement); if (closingTagMatcher.find() && !openingTagMatcher.find() && !wholeTagMatcher.find() && !statement.contains("<!--") && !statement.contains("-->") && !statement.contains("<![CDATA[") && !statement.contains("]]>")) { tabCount--; } if (statement.contains("]]>")) { ignoredCdataBlock = false; } else if (statement.contains("<![CDATA[")) { ignoredCdataBlock = true; } if (statement.contains("-->")) { ignoredCommentBlock = false; } else if (statement.contains("<!--")) { ignoredCommentBlock = true; } if (!ignoredCommentBlock && !ignoredCdataBlock) { StringBundler sb = new StringBundler(tabCount + 1); for (int i = 0; i < tabCount; i++) { sb.append(StringPool.TAB); } sb.append(StringPool.LESS_THAN); String replacement = sb.toString(); if (!replacement.equals(matcher.group(1))) { String newStatement = StringUtil.replace(statement, matcher.group(1), replacement); return StringUtil.replaceFirst(content, statement, newStatement, matcher.start()); } } if (openingTagMatcher.find() && !closingTagMatcher.find() && !wholeTagMatcher.find() && !statement.contains("<!--") && !statement.contains("-->") && !statement.contains("<![CDATA[") && !statement.contains("]]>")) { tabCount++; } } return content; }
From source file:com.liferay.util.xml.XMLFormatter.java
License:Open Source License
public static String toString(Node node) throws IOException { return toString(node, StringPool.TAB); }
From source file:com.liferay.util.xml.XMLFormatter.java
License:Open Source License
public static String toString(Node node, String indent) throws IOException { return toString(node, StringPool.TAB, false); }
From source file:com.liferay.util.xml.XMLFormatter.java
License:Open Source License
public static String toString(String xml) throws DocumentException, IOException { return toString(xml, StringPool.TAB); }