List of usage examples for com.liferay.portal.kernel.util StringPool SEMICOLON
String SEMICOLON
To view the source code for com.liferay.portal.kernel.util StringPool SEMICOLON.
Click Source Link
From source file:com.fingence.slayer.service.impl.RatingServiceImpl.java
License:Open Source License
public String getRatings(String description) { List<Rating> ratings = null; try {/*from w w w . j a v a 2s. c o m*/ ratings = ratingPersistence.findByDescription(description); } catch (SystemException e) { e.printStackTrace(); } if (Validator.isNull(ratings) || ratings.size() == 0) return IConstants.UN_SPECIFIED; StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); for (Rating rating : ratings) { String sandp = rating.getSandp(); String moodys = rating.getMoodys(); if (Validator.isNotNull(moodys)) { if (Validator.isNull(sb1.toString())) { sb1.append("Moody's:"); } else { sb1.append(StringPool.SLASH); } sb1.append(moodys); } if (Validator.isNotNull(sandp)) { if (Validator.isNull(sb2.toString())) { sb2.append("S&P:"); } else { sb2.append(StringPool.SLASH); } sb2.append(sandp); } } return (Validator.isNotNull(sb1.toString()) ? sb1.toString() : StringPool.BLANK) + (Validator.isNotNull(sb1.toString()) ? StringPool.SEMICOLON + StringPool.SPACE : StringPool.BLANK) + (Validator.isNotNull(sb2.toString()) ? sb2.toString() : StringPool.BLANK); }
From source file:com.liferay.adaptive.media.image.internal.configuration.AdaptiveMediaImageConfigurationEntryParser.java
License:Open Source License
public String getConfigurationString(AdaptiveMediaImageConfigurationEntry configurationEntry) { StringBundler sb = new StringBundler(); sb.append(_http.encodeURL(configurationEntry.getName())); sb.append(StringPool.COLON);//from www.ja v a 2 s . c om sb.append(_http.encodeURL(configurationEntry.getDescription())); sb.append(StringPool.COLON); sb.append(configurationEntry.getUUID()); sb.append(StringPool.COLON); Map<String, String> properties = configurationEntry.getProperties(); if (properties.get("max-height") != null) { int height = GetterUtil.getInteger(properties.get("max-height")); sb.append("max-height="); sb.append(height); if (properties.get("max-width") != null) { sb.append(StringPool.SEMICOLON); } } if (properties.get("max-width") != null) { int width = GetterUtil.getInteger(properties.get("max-width")); sb.append("max-width="); sb.append(width); } sb.append(StringPool.COLON); sb.append("enabled="); sb.append(String.valueOf(configurationEntry.isEnabled())); return sb.toString(); }
From source file:com.liferay.contacts.util.ContactsUtil.java
License:Open Source License
private static String _getAddresses(User user) throws Exception { List<Address> addresses = AddressLocalServiceUtil.getAddresses(user.getCompanyId(), Contact.class.getName(), user.getContactId());//from ww w . jav a2 s. com StringBundler sb = new StringBundler(addresses.size() * 19); for (Address address : addresses) { sb.append("ADR;TYPE="); ListType listType = address.getType(); sb.append(StringUtil.toUpperCase(_getVCardListTypeName(listType))); sb.append(StringPool.COLON); sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON); if (Validator.isNotNull(address.getStreet1())) { sb.append(address.getStreet1()); } if (Validator.isNotNull(address.getStreet2())) { sb.append("\\n"); sb.append(address.getStreet2()); } if (Validator.isNotNull(address.getStreet3())) { sb.append("\\n"); sb.append(address.getStreet3()); } sb.append(StringPool.SEMICOLON); if (Validator.isNotNull(address.getCity())) { sb.append(address.getCity()); } sb.append(StringPool.SEMICOLON); long regionId = address.getRegionId(); if (regionId > 0) { Region region = RegionServiceUtil.getRegion(regionId); sb.append(region.getName()); } sb.append(StringPool.SEMICOLON); if (Validator.isNotNull(address.getZip())) { sb.append(address.getZip()); } sb.append(StringPool.SEMICOLON); long countryId = address.getCountryId(); if (countryId > 0) { Country country = CountryServiceUtil.getCountry(countryId); sb.append(country.getName()); } sb.append(StringPool.NEW_LINE); } return sb.toString(); }
From source file:com.liferay.contacts.util.ContactsUtil.java
License:Open Source License
private static String _getName(User user, Contact contact) throws Exception { StringBundler sb = new StringBundler(14); sb.append("N:"); sb.append(user.getLastName());//from w w w . j a va 2 s. c o m sb.append(StringPool.SEMICOLON); sb.append(user.getFirstName()); sb.append(StringPool.SEMICOLON); sb.append(user.getMiddleName()); sb.append(StringPool.SEMICOLON); int prefixId = contact.getPrefixId(); if (prefixId > 0) { ListType listType = ListTypeServiceUtil.getListType(prefixId); sb.append(listType.getName()); } sb.append(StringPool.SEMICOLON); int suffixId = contact.getSuffixId(); if (suffixId > 0) { ListType listType = ListTypeServiceUtil.getListType(suffixId); sb.append(listType.getName()); } sb.append(StringPool.NEW_LINE); sb.append("FN:"); sb.append(user.getFullName()); sb.append(StringPool.NEW_LINE); return sb.toString(); }
From source file:com.liferay.localization.servlet.LocalizationServletContextListener.java
License:Open Source License
protected void importSQL() throws Exception { Class<?> clazz = getClass(); ClassLoader classLoader = clazz.getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream("/resources/data/sql.xml"); String xml = new String(FileUtil.getBytes(inputStream)); Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); List<Element> batchElements = rootElement.elements("batch"); for (Element batchElement : batchElements) { String testSQL = batchElement.elementText("test-sql"); int count = getCount(testSQL); if (count > 0) { continue; }//from w w w .j a v a 2s .co m String[] importSQLs = StringUtil.split(batchElement.elementText("import-sql"), StringPool.SEMICOLON); runSQL(importSQLs); } }
From source file:com.liferay.message.boards.parser.bbcode.internal.HtmlBBCodeTranslatorImpl.java
License:Open Source License
protected String escapeQuote(String quote) { StringBuilder sb = new StringBuilder(); int index = 0; Matcher matcher = _bbCodePattern.matcher(quote); Collection<String> values = _bbCodeCharacters.values(); while (matcher.find()) { String match = matcher.group(); int matchStartIndex = matcher.start(); int nextSemicolonIndex = quote.indexOf(StringPool.SEMICOLON, matchStartIndex); sb.append(quote.substring(index, matchStartIndex)); boolean entityFound = false; if (nextSemicolonIndex >= 0) { String value = quote.substring(matchStartIndex, nextSemicolonIndex + 1); if (values.contains(value)) { sb.append(value);/* ww w . j av a 2s .c o m*/ index = matchStartIndex + value.length(); entityFound = true; } } if (!entityFound) { String escapedValue = _bbCodeCharacters.get(match); sb.append(escapedValue); index = matchStartIndex + match.length(); } } if (index < quote.length()) { sb.append(quote.substring(index, quote.length())); } return sb.toString(); }
From source file:com.liferay.tools.sourceformatter.JavaClass.java
License:Open Source License
protected Tuple getJavaTermTuple(String line, String content, int index) { int posStartNextLine = index; while (!line.endsWith(StringPool.OPEN_CURLY_BRACE) && !line.endsWith(StringPool.SEMICOLON)) { posStartNextLine = content.indexOf(StringPool.NEW_LINE, posStartNextLine) + 1; int posEndNextline = content.indexOf(StringPool.NEW_LINE, posStartNextLine); String nextLine = content.substring(posStartNextLine, posEndNextline); nextLine = StringUtil.trimLeading(nextLine); if (line.endsWith(StringPool.OPEN_PARENTHESIS)) { line += nextLine;/*www . j av a 2 s . com*/ } else { line += StringPool.SPACE + nextLine; } } line = StringUtil.replace(line, " synchronized ", StringPool.SPACE); int pos = line.indexOf(StringPool.OPEN_PARENTHESIS); if (line.startsWith(_indent + "public static ")) { if (line.contains(" class ") || line.contains(" enum ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PUBLIC_STATIC); } if (line.contains(StringPool.EQUAL) || (line.endsWith(StringPool.SEMICOLON) && (pos == -1))) { return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PUBLIC_STATIC); } if (pos != -1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PUBLIC_STATIC); } } else if (line.startsWith(_indent + "public ")) { if (line.contains(" @interface ") || line.contains(" class ") || line.contains(" enum ") || line.contains(" interface ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PUBLIC); } if (line.contains(StringPool.EQUAL) || (line.endsWith(StringPool.SEMICOLON) && (pos == -1))) { return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PUBLIC); } if (pos != -1) { int spaceCount = StringUtil.count(line.substring(0, pos), StringPool.SPACE); if (spaceCount == 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_CONSTRUCTOR_PUBLIC); } if (spaceCount > 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PUBLIC); } } } else if (line.startsWith(_indent + "protected static ")) { if (line.contains(" class ") || line.contains(" enum ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PROTECTED_STATIC); } if (line.contains(StringPool.EQUAL) || (line.endsWith(StringPool.SEMICOLON) && (pos == -1))) { return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PROTECTED_STATIC); } if (pos != -1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PROTECTED_STATIC); } } else if (line.startsWith(_indent + "protected ")) { if (line.contains(" @interface ") || line.contains(" class ") || line.contains(" enum ") || line.contains(" interface ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PROTECTED); } if (pos != -1) { if (!line.contains(StringPool.EQUAL)) { int spaceCount = StringUtil.count(line.substring(0, pos), StringPool.SPACE); if (spaceCount == 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_CONSTRUCTOR_PROTECTED); } if (spaceCount > 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PROTECTED); } } } return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PROTECTED); } else if (line.startsWith(_indent + "private static ")) { if (line.contains(" class ") || line.contains(" enum ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PRIVATE_STATIC); } if (line.contains(StringPool.EQUAL) || (line.endsWith(StringPool.SEMICOLON) && (pos == -1))) { return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PRIVATE_STATIC); } if (pos != -1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PRIVATE_STATIC); } } else if (line.startsWith(_indent + "private ")) { if (line.contains(" @interface ") || line.contains(" class ") || line.contains(" enum ") || line.contains(" interface ")) { return new Tuple(getClassName(line), JavaTerm.TYPE_CLASS_PRIVATE); } if (line.contains(StringPool.EQUAL) || (line.endsWith(StringPool.SEMICOLON) && (pos == -1))) { return new Tuple(getVariableName(line), JavaTerm.TYPE_VARIABLE_PRIVATE); } if (pos != -1) { int spaceCount = StringUtil.count(line.substring(0, pos), StringPool.SPACE); if (spaceCount == 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_CONSTRUCTOR_PRIVATE); } if (spaceCount > 1) { return new Tuple(getConstructorOrMethodName(line, pos), JavaTerm.TYPE_METHOD_PRIVATE); } } } else if (line.startsWith(_indent + "static {")) { return new Tuple("static", JavaTerm.TYPE_STATIC_BLOCK); } return null; }
From source file:com.liferay.tools.sourceformatter.JavaClass.java
License:Open Source License
protected String getVariableName(String line) { int x = line.indexOf(StringPool.EQUAL); int y = line.lastIndexOf(StringPool.SPACE); if (x != -1) { line = line.substring(0, x);/* w ww . j av a2 s .c o m*/ line = StringUtil.trim(line); y = line.lastIndexOf(StringPool.SPACE); return line.substring(y + 1); } if (line.endsWith(StringPool.SEMICOLON)) { return line.substring(y + 1, line.length() - 1); } return StringPool.BLANK; }
From source file:com.liferay.tools.sourceformatter.JavaClass.java
License:Open Source License
protected boolean isValidJavaTerm(String content) { if (content.startsWith(_indent + "static {")) { return true; }/* w w w .j a v a2 s. c o m*/ while (!content.startsWith(_indent + "private") && !content.startsWith(_indent + "protected") && !content.startsWith(_indent + "public")) { content = content.substring(content.indexOf("\n") + 1); } int indentLinesCount = StringUtil.count(content, "\n" + _indent) - StringUtil.count(content, "\n" + _indent + StringPool.TAB); content = StringUtil.trim(content); if (content.endsWith(StringPool.CLOSE_CURLY_BRACE) && ((indentLinesCount == 1) || (((indentLinesCount == 2) || (indentLinesCount == 3)) && content.contains("\n" + _indent + "static {")))) { return true; } else if ((content.endsWith("};") && (indentLinesCount == 1)) || (content.endsWith(StringPool.SEMICOLON) && (indentLinesCount == 0))) { return true; } return false; }
From source file:com.liferay.tools.sourceformatter.JavaSourceProcessor.java
License:Open Source License
protected String formatJava(String fileName, String absolutePath, String content) throws Exception { StringBundler sb = new StringBundler(); try (UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader( new UnsyncStringReader(content))) { String line = null;//from ww w. j a v a 2s . c o m String previousLine = StringPool.BLANK; int lineCount = 0; String ifClause = StringPool.BLANK; String packageName = StringPool.BLANK; String regexPattern = StringPool.BLANK; while ((line = unsyncBufferedReader.readLine()) != null) { lineCount++; line = trimLine(line, false); if (line.startsWith("package ")) { packageName = line.substring(8, line.length() - 1); } if (line.startsWith("import ")) { if (line.endsWith(".*;")) { processErrorMessage(fileName, "import: " + fileName + " " + lineCount); } int pos = line.lastIndexOf(StringPool.PERIOD); if (pos != -1) { String importPackageName = line.substring(7, pos); if (importPackageName.equals(packageName)) { continue; } } } if (line.contains(StringPool.TAB + "for (") && line.contains(":") && !line.contains(" :")) { line = StringUtil.replace(line, ":", " :"); } // LPS-42924 if (line.contains("PortalUtil.getClassNameId(") && fileName.endsWith("ServiceImpl.java")) { processErrorMessage(fileName, "Use classNameLocalService.getClassNameId: " + fileName + " " + lineCount); } // LPS-42599 if (!isExcluded(_hibernateSQLQueryExclusions, absolutePath) && line.contains("= session.createSQLQuery(") && content.contains("com.liferay.portal.kernel.dao.orm.Session")) { line = StringUtil.replace(line, "createSQLQuery", "createSynchronizedSQLQuery"); } line = replacePrimitiveWrapperInstantiation(fileName, line, lineCount); String trimmedLine = StringUtil.trimLeading(line); // LPS-45649 if (trimmedLine.startsWith("throw new IOException(") && line.contains("e.getMessage()")) { line = StringUtil.replace(line, ".getMessage()", StringPool.BLANK); } // LPS-45492 if (trimmedLine.contains("StopWatch stopWatch = null;")) { processErrorMessage(fileName, "Do not set stopwatch to null: " + fileName + " " + lineCount); } checkStringBundler(trimmedLine, fileName, lineCount); checkEmptyCollection(trimmedLine, fileName, lineCount); if (trimmedLine.startsWith("* @deprecated") && _addMissingDeprecationReleaseVersion) { if (!trimmedLine.startsWith("* @deprecated As of ")) { line = StringUtil.replace(line, "* @deprecated", "* @deprecated As of " + getMainReleaseVersion()); } else { String version = trimmedLine.substring(20); version = StringUtil.split(version, StringPool.SPACE)[0]; version = StringUtil.replace(version, StringPool.COMMA, StringPool.BLANK); if (StringUtil.count(version, StringPool.PERIOD) == 1) { line = StringUtil.replaceFirst(line, version, version + ".0"); } } } if (trimmedLine.startsWith("* @see ") && (StringUtil.count(trimmedLine, StringPool.AT) > 1)) { processErrorMessage(fileName, "Do not use @see with another annotation: " + fileName + " " + lineCount); } checkInefficientStringMethods(line, fileName, absolutePath, lineCount); if (trimmedLine.startsWith(StringPool.EQUAL)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (line.contains("ActionForm form")) { processErrorMessage(fileName, "Rename form to actionForm: " + fileName + " " + lineCount); } if (line.contains("ActionMapping mapping")) { processErrorMessage(fileName, "Rename mapping to ActionMapping: " + fileName + " " + lineCount); } if (fileName.contains("/upgrade/") && line.contains("rs.getDate(")) { processErrorMessage(fileName, "Use rs.getTimeStamp: " + fileName + " " + lineCount); } if (!trimmedLine.equals("{") && line.endsWith("{") && !line.endsWith(" {")) { line = StringUtil.replaceLast(line, "{", " {"); } line = sortExceptions(line); if (trimmedLine.startsWith("if (") || trimmedLine.startsWith("else if (") || trimmedLine.startsWith("while (") || Validator.isNotNull(ifClause)) { ifClause = ifClause + line + StringPool.NEW_LINE; if (line.endsWith(") {")) { String newIfClause = checkIfClause(ifClause, fileName, lineCount); if (!ifClause.equals(newIfClause) && content.contains(ifClause)) { return StringUtil.replace(content, ifClause, newIfClause); } ifClause = StringPool.BLANK; } else if (line.endsWith(StringPool.SEMICOLON)) { ifClause = StringPool.BLANK; } } if (trimmedLine.startsWith("Pattern ") || Validator.isNotNull(regexPattern)) { regexPattern = regexPattern + trimmedLine; if (trimmedLine.endsWith(");")) { // LPS-41084 checkRegexPattern(regexPattern, fileName, lineCount); regexPattern = StringPool.BLANK; } } if (!trimmedLine.contains(StringPool.DOUBLE_SLASH) && !trimmedLine.startsWith(StringPool.STAR)) { String strippedQuotesLine = stripQuotes(trimmedLine, CharPool.QUOTE); for (int x = 0;;) { x = strippedQuotesLine.indexOf(StringPool.EQUAL, x + 1); if (x == -1) { break; } char c = strippedQuotesLine.charAt(x - 1); if (Character.isLetterOrDigit(c)) { line = StringUtil.replace(line, c + "=", c + " ="); break; } if (x == (strippedQuotesLine.length() - 1)) { break; } c = strippedQuotesLine.charAt(x + 1); if (Character.isLetterOrDigit(c)) { line = StringUtil.replace(line, "=" + c, "= " + c); break; } } while (trimmedLine.contains(StringPool.TAB)) { line = StringUtil.replaceLast(line, StringPool.TAB, StringPool.SPACE); trimmedLine = StringUtil.replaceLast(trimmedLine, StringPool.TAB, StringPool.SPACE); } if (line.contains(StringPool.TAB + StringPool.SPACE) && !previousLine.endsWith("&&") && !previousLine.endsWith("||") && !previousLine.contains(StringPool.TAB + "((") && !previousLine.contains(StringPool.TAB + StringPool.LESS_THAN) && !previousLine.contains(StringPool.TAB + StringPool.SPACE) && !previousLine.contains(StringPool.TAB + "for (") && !previousLine.contains(StringPool.TAB + "implements ") && !previousLine.contains(StringPool.TAB + "throws ")) { line = StringUtil.replace(line, StringPool.TAB + StringPool.SPACE, StringPool.TAB); } while (trimmedLine.contains(StringPool.DOUBLE_SPACE) && !trimmedLine.contains(StringPool.QUOTE + StringPool.DOUBLE_SPACE) && !fileName.contains("Test")) { line = StringUtil.replaceLast(line, StringPool.DOUBLE_SPACE, StringPool.SPACE); trimmedLine = StringUtil.replaceLast(trimmedLine, StringPool.DOUBLE_SPACE, StringPool.SPACE); } if (!line.contains(StringPool.QUOTE)) { int pos = line.indexOf(") "); if (pos != -1) { String linePart = line.substring(pos + 2); if (Character.isLetter(linePart.charAt(0)) && !linePart.startsWith("default") && !linePart.startsWith("instanceof") && !linePart.startsWith("throws")) { line = StringUtil.replaceLast(line, StringPool.SPACE + linePart, linePart); } } if ((trimmedLine.startsWith("private ") || trimmedLine.startsWith("protected ") || trimmedLine.startsWith("public ")) && !line.contains(StringPool.EQUAL) && line.contains(" (")) { line = StringUtil.replace(line, " (", "("); } if (line.contains(" [")) { line = StringUtil.replace(line, " [", "["); } for (int x = -1;;) { int posComma = line.indexOf(StringPool.COMMA, x + 1); int posSemicolon = line.indexOf(StringPool.SEMICOLON, x + 1); if ((posComma == -1) && (posSemicolon == -1)) { break; } x = Math.min(posComma, posSemicolon); if (x == -1) { x = Math.max(posComma, posSemicolon); } if (line.length() > (x + 1)) { char nextChar = line.charAt(x + 1); if ((nextChar != CharPool.APOSTROPHE) && (nextChar != CharPool.CLOSE_PARENTHESIS) && (nextChar != CharPool.SPACE) && (nextChar != CharPool.STAR)) { line = StringUtil.insert(line, StringPool.SPACE, x + 1); } } if (x > 0) { char previousChar = line.charAt(x - 1); if (previousChar == CharPool.SPACE) { line = line.substring(0, x - 1).concat(line.substring(x)); } } } } if ((line.contains(" && ") || line.contains(" || ")) && line.endsWith(StringPool.OPEN_PARENTHESIS)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (trimmedLine.endsWith(StringPool.PLUS) && !trimmedLine.startsWith(StringPool.OPEN_PARENTHESIS)) { int closeParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.CLOSE_PARENTHESIS); int openParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.OPEN_PARENTHESIS); if (openParenthesisCount > closeParenthesisCount) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } int x = strippedQuotesLine.indexOf(", "); if (x != -1) { String linePart = strippedQuotesLine.substring(0, x); int closeParenthesisCount = StringUtil.count(linePart, StringPool.CLOSE_PARENTHESIS); int openParenthesisCount = StringUtil.count(linePart, StringPool.OPEN_PARENTHESIS); if (closeParenthesisCount > openParenthesisCount) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } else if (trimmedLine.endsWith(StringPool.COMMA) && !trimmedLine.startsWith("for (")) { int closeParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.CLOSE_PARENTHESIS); int openParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.OPEN_PARENTHESIS); if (closeParenthesisCount < openParenthesisCount) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } if (line.contains(StringPool.COMMA) && !line.contains(StringPool.CLOSE_PARENTHESIS) && !line.contains(StringPool.GREATER_THAN) && !line.contains(StringPool.QUOTE) && line.endsWith(StringPool.OPEN_PARENTHESIS)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (line.endsWith(" +") || line.endsWith(" -") || line.endsWith(" *") || line.endsWith(" /")) { x = line.indexOf(" = "); if (x != -1) { int y = line.indexOf(StringPool.QUOTE); if ((y == -1) || (x < y)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } } if (line.endsWith(" throws") || (previousLine.endsWith(StringPool.OPEN_PARENTHESIS) && line.contains(" throws ") && line.endsWith(StringPool.OPEN_CURLY_BRACE))) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (trimmedLine.startsWith(StringPool.PERIOD) || (line.endsWith(StringPool.PERIOD) && line.contains(StringPool.EQUAL))) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (trimmedLine.startsWith(StringPool.CLOSE_CURLY_BRACE) && line.endsWith(StringPool.OPEN_CURLY_BRACE)) { Matcher matcher = _lineBreakPattern.matcher(trimmedLine); if (!matcher.find()) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } } if (line.contains(" ") && !line.matches("\\s*\\*.*")) { if (!fileName.endsWith("StringPool.java")) { processErrorMessage(fileName, "tab: " + fileName + " " + lineCount); } } if (line.contains(" {") && !line.matches("\\s*\\*.*")) { processErrorMessage(fileName, "{:" + fileName + " " + lineCount); } int lineLength = getLineLength(line); if (!line.startsWith("import ") && !line.startsWith("package ") && !line.matches("\\s*\\*.*")) { if (fileName.endsWith("Table.java") && line.contains("String TABLE_SQL_CREATE = ")) { } else if (fileName.endsWith("Table.java") && line.contains("String TABLE_SQL_DROP = ")) { } else if (fileName.endsWith("Table.java") && line.contains(" index IX_")) { } else if (lineLength > _MAX_LINE_LENGTH) { if (!isExcluded(_lineLengthExclusions, absolutePath, lineCount) && !isAnnotationParameter(content, trimmedLine)) { String truncateLongLinesContent = getTruncateLongLinesContent(content, line, trimmedLine, lineCount); if (truncateLongLinesContent != null) { return truncateLongLinesContent; } processErrorMessage(fileName, "> 80: " + fileName + " " + lineCount); } } else { int lineLeadingTabCount = getLeadingTabCount(line); int previousLineLeadingTabCount = getLeadingTabCount(previousLine); if (!trimmedLine.startsWith("//")) { if (previousLine.endsWith(StringPool.COMMA) && previousLine.contains(StringPool.OPEN_PARENTHESIS) && !previousLine.contains("for (") && (lineLeadingTabCount > previousLineLeadingTabCount)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if ((lineLeadingTabCount == previousLineLeadingTabCount) && (previousLine.endsWith(StringPool.EQUAL) || previousLine.endsWith(StringPool.OPEN_PARENTHESIS))) { processErrorMessage(fileName, "tab: " + fileName + " " + lineCount); } if (Validator.isNotNull(trimmedLine)) { if (((previousLine.endsWith(StringPool.COLON) && previousLine.contains(StringPool.TAB + "for ")) || (previousLine.endsWith(StringPool.OPEN_PARENTHESIS) && previousLine.contains(StringPool.TAB + "if "))) && ((previousLineLeadingTabCount + 2) != lineLeadingTabCount)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } if (previousLine.endsWith(StringPool.OPEN_CURLY_BRACE) && !trimmedLine.startsWith(StringPool.CLOSE_CURLY_BRACE) && ((previousLineLeadingTabCount + 1) != lineLeadingTabCount)) { processErrorMessage(fileName, "tab: " + fileName + " " + lineCount); } } if (previousLine.endsWith(StringPool.PERIOD)) { int x = trimmedLine.indexOf(StringPool.OPEN_PARENTHESIS); if ((x != -1) && ((getLineLength(previousLine) + x) < _MAX_LINE_LENGTH) && (trimmedLine.endsWith(StringPool.OPEN_PARENTHESIS) || (trimmedLine.charAt(x + 1) != CharPool.CLOSE_PARENTHESIS))) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } int diff = lineLeadingTabCount - previousLineLeadingTabCount; if (trimmedLine.startsWith("throws ") && ((diff == 0) || (diff > 1))) { processErrorMessage(fileName, "tab: " + fileName + " " + lineCount); } if ((diff == 2) && (previousLineLeadingTabCount > 0) && line.endsWith(StringPool.SEMICOLON) && !previousLine.contains(StringPool.TAB + "try (")) { line = StringUtil.replaceFirst(line, StringPool.TAB, StringPool.BLANK); } if ((previousLine.contains(" class ") || previousLine.contains(" enum ")) && previousLine.endsWith(StringPool.OPEN_CURLY_BRACE) && Validator.isNotNull(line) && !trimmedLine.startsWith(StringPool.CLOSE_CURLY_BRACE)) { processErrorMessage(fileName, "line break: " + fileName + " " + lineCount); } } String combinedLinesContent = getCombinedLinesContent(content, fileName, absolutePath, line, trimmedLine, lineLength, lineCount, previousLine, lineLeadingTabCount, previousLineLeadingTabCount); if (combinedLinesContent != null) { return combinedLinesContent; } } } if (lineCount > 1) { sb.append(previousLine); if (Validator.isNotNull(previousLine) && Validator.isNotNull(trimmedLine) && !previousLine.contains("/*") && !previousLine.endsWith("*/")) { String trimmedPreviousLine = StringUtil.trimLeading(previousLine); if ((trimmedPreviousLine.startsWith("// ") && !trimmedLine.startsWith("// ")) || (!trimmedPreviousLine.startsWith("// ") && trimmedLine.startsWith("// "))) { sb.append("\n"); } else if (!trimmedPreviousLine.endsWith(StringPool.OPEN_CURLY_BRACE) && !trimmedPreviousLine.endsWith(StringPool.COLON) && (trimmedLine.startsWith("for (") || trimmedLine.startsWith("if ("))) { sb.append("\n"); } else if (previousLine.endsWith(StringPool.TAB + StringPool.CLOSE_CURLY_BRACE) && !trimmedLine.startsWith(StringPool.CLOSE_CURLY_BRACE) && !trimmedLine.startsWith(StringPool.CLOSE_PARENTHESIS) && !trimmedLine.startsWith(StringPool.DOUBLE_SLASH) && !trimmedLine.equals("*/") && !trimmedLine.startsWith("catch ") && !trimmedLine.startsWith("else ") && !trimmedLine.startsWith("finally ") && !trimmedLine.startsWith("while ")) { sb.append("\n"); } } sb.append("\n"); } previousLine = line; } sb.append(previousLine); } String newContent = sb.toString(); if (newContent.endsWith("\n")) { newContent = newContent.substring(0, newContent.length() - 1); } return newContent; }