List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_BRACKET
String OPEN_BRACKET
To view the source code for com.liferay.portal.kernel.util StringPool OPEN_BRACKET.
Click Source Link
From source file:au.com.permeance.liferay.portlet.documentlibrary.service.impl.DLFolderExportZipHelper.java
License:Open Source License
/** * Returns a ZIP entry name for the file entry. * /* w w w .j a v a2 s. c om*/ * @param fileEntry file entry * @param folderPath file path * @param zipWriter ZIP writer * * @return ZIP entry name * * @throws SystemException * @throws PortalException */ public static String buildZipEntryName(FileEntry fileEntry, String folderPath, ZipWriter zipWriter) throws SystemException, PortalException { // Use file entry title as file name String fileEntryBaseName = fileEntry.getTitle(); // normalize base name by stripping extension and replacing non-alphanum chars with underscore fileEntryBaseName = FilenameUtils.getBaseName(fileEntryBaseName); fileEntryBaseName = fileEntryBaseName.replaceAll("\\W+", "_"); // build zip entry name String zipEntryName = folderPath + fileEntryBaseName + FilenameUtils.EXTENSION_SEPARATOR_STR + fileEntry.getExtension(); if (zipWriter.hasAllocatedPath(zipEntryName)) { String oldZipEntryName = zipEntryName; int counter = 1; while (true) { zipEntryName = folderPath + fileEntryBaseName + StringPool.OPEN_BRACKET + counter + StringPool.CLOSE_BRACKET + FilenameUtils.EXTENSION_SEPARATOR_STR + fileEntry.getExtension(); if (!zipWriter.hasAllocatedPath(zipEntryName)) { break; } counter++; } if (s_log.isDebugEnabled()) { s_log.debug(oldZipEntryName + " already exists in ZIP file, renaming to " + zipEntryName); } } return zipEntryName; }
From source file:com.liferay.alloy.util.DefaultValueUtil.java
License:Open Source License
public static String getDefaultValue(String className, String value) { String defaultValue = StringPool.BLANK; if (className.equals(ArrayList.class.getName()) || className.equals(HashMap.class.getName()) || className.equals(Object.class.getName()) || className.equals(String.class.getName())) { if (!isValidStringValue(value)) { return defaultValue; }//from ww w. j a va 2 s .c om if (_EMPTY_STRINGS.contains(value)) { value = StringPool.BLANK; } else if (className.equals(ArrayList.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_BRACKET)) { value = "[]"; } else if (className.equals(HashMap.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_CURLY_BRACE)) { value = "{}"; } defaultValue = StringUtil.unquote(value); } else if (className.equals(boolean.class.getName()) || className.equals(Boolean.class.getName())) { defaultValue = String.valueOf(GetterUtil.getBoolean(value)); } else if (className.equals(int.class.getName()) || className.equals(Integer.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getInteger(value)); } else if (className.equals(double.class.getName()) || className.equals(Double.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Double.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getDouble(value)); } else if (className.equals(float.class.getName()) || className.equals(Float.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Float.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getFloat(value)); } else if (className.equals(long.class.getName()) || className.equals(Long.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Long.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getLong(value)); } else if (className.equals(short.class.getName()) || className.equals(Short.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Short.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getShort(value)); } else if (className.equals(Number.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getNumber(value)); } return defaultValue; }
From source file:com.liferay.portlet.documentlibrary.util.LiferayVideoConverter.java
License:Open Source License
protected void initVideoFrameRateMap(Properties videoProperties) { _videoFrameRateMap = new HashMap<String, IRational>(); for (String previewVideoContainer : _previewVideoContainers) { int numerator = GetterUtil.getInteger( videoProperties.getProperty(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_FRAME_RATE_NUMERATOR + "[" + previewVideoContainer + "]")); int denominator = GetterUtil.getInteger( videoProperties.getProperty(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_FRAME_RATE_DENOMINATOR + StringPool.OPEN_BRACKET + previewVideoContainer + StringPool.CLOSE_BRACKET)); if ((numerator > 0) && (denominator > 0)) { IRational iRational = IRational.make(numerator, denominator); _videoFrameRateMap.put(previewVideoContainer, iRational); if (_log.isInfoEnabled()) { _log.info("Frame rate for " + previewVideoContainer + " set to " + iRational.getNumerator() + "/" + iRational.getDenominator()); }//w w w . j av a2s. co m } } }
From source file:com.liferay.portlet.dynamicdatamapping.storage.XMLStorageAdapter.java
License:Open Source License
private XPath _parseCondition(Condition condition) { StringBundler sb = new StringBundler(4); sb.append("//dynamic-element"); sb.append(StringPool.OPEN_BRACKET); sb.append(_toXPath(condition));/*from w w w . j a v a 2 s .c o m*/ sb.append(StringPool.CLOSE_BRACKET); return SAXReaderUtil.createXPath(sb.toString()); }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected void checkLanguageKeys(String fileName, String content, Pattern pattern) throws IOException { String fileExtension = fileUtil.getExtension(fileName); if (!portalSource || fileExtension.equals("vm")) { return;/* w w w .j a v a 2 s.c om*/ } if (_portalLanguageProperties == null) { _portalLanguageProperties = new Properties(); ClassLoader classLoader = BaseSourceProcessor.class.getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream("content/Language.properties"); _portalLanguageProperties.load(inputStream); } Matcher matcher = pattern.matcher(content); while (matcher.find()) { String[] languageKeys = getLanguageKeys(matcher); for (String languageKey : languageKeys) { if (Validator.isNumber(languageKey) || languageKey.endsWith(StringPool.DASH) || languageKey.endsWith(StringPool.OPEN_BRACKET) || languageKey.endsWith(StringPool.PERIOD) || languageKey.endsWith(StringPool.UNDERLINE) || languageKey.startsWith(StringPool.DASH) || languageKey.startsWith(StringPool.OPEN_BRACKET) || languageKey.startsWith(StringPool.OPEN_CURLY_BRACE) || languageKey.startsWith(StringPool.PERIOD) || languageKey.startsWith(StringPool.UNDERLINE) || _portalLanguageProperties.containsKey(languageKey)) { continue; } Properties languageProperties = getLanguageProperties(fileName); if ((languageProperties == null) || !languageProperties.containsKey(languageKey)) { processErrorMessage(fileName, "missing language key: " + languageKey + StringPool.SPACE + fileName); } } } }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected boolean hasMissingParentheses(String s) { if (Validator.isNull(s)) { return false; }/* ww w . j a v a 2 s . co m*/ boolean containsAndOperator = s.contains("&&"); boolean containsOrOperator = s.contains("||"); if (containsAndOperator && containsOrOperator) { return true; } boolean containsCompareOperator = (s.contains(" == ") || s.contains(" != ") || s.contains(" < ") || s.contains(" > ") || s.contains(" =< ") || s.contains(" => ") || s.contains(" <= ") || s.contains(" >= ")); boolean containsMathOperator = (s.contains(" = ") || s.contains(" - ") || s.contains(" + ") || s.contains(" & ") || s.contains(" % ") || s.contains(" * ") || s.contains(" / ")); if (containsCompareOperator && (containsAndOperator || containsOrOperator || (containsMathOperator && !s.contains(StringPool.OPEN_BRACKET)))) { return true; } return false; }
From source file:com.liferay.tools.sourceformatter.JavaSourceProcessor.java
License:Open Source License
protected String getCombinedLinesContent(String content, String fileName, String absolutePath, String line, String trimmedLine, int lineLength, int lineCount, String previousLine, int lineTabCount, int previousLineTabCount) { if (Validator.isNull(line) || Validator.isNull(previousLine) || isExcluded(_fitOnSingleLineExclusions, absolutePath, lineCount)) { return null; }/* w w w . j av a 2 s.co m*/ String trimmedPreviousLine = StringUtil.trimLeading(previousLine); if (line.contains("// ") || line.contains("*/") || line.contains("*/") || previousLine.contains("// ") || previousLine.contains("*/") || previousLine.contains("*/")) { return null; } int tabDiff = lineTabCount - previousLineTabCount; if (previousLine.endsWith(" extends")) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, "extends", tabDiff, false, false, false); } if (previousLine.endsWith(" implements")) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, "implements ", tabDiff, false, false, false); } if (trimmedLine.startsWith("+ ") || trimmedLine.startsWith("- ") || trimmedLine.startsWith("|| ") || trimmedLine.startsWith("&& ")) { int pos = trimmedLine.indexOf(StringPool.SPACE); String linePart = trimmedLine.substring(0, pos); return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, linePart, tabDiff, true, true, false); } int previousLineLength = getLineLength(previousLine); if ((trimmedLine.length() + previousLineLength) < _MAX_LINE_LENGTH) { if (trimmedPreviousLine.startsWith("for ") && previousLine.endsWith(StringPool.COLON) && line.endsWith(StringPool.OPEN_CURLY_BRACE)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } if (line.endsWith(StringPool.SEMICOLON) && !previousLine.endsWith(StringPool.COLON) && !previousLine.endsWith(StringPool.OPEN_BRACKET) && !previousLine.endsWith(StringPool.OPEN_CURLY_BRACE) && !previousLine.endsWith(StringPool.OPEN_PARENTHESIS) && !previousLine.endsWith(StringPool.PERIOD) && (lineTabCount == (previousLineTabCount + 1))) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } if ((trimmedPreviousLine.startsWith("if ") || trimmedPreviousLine.startsWith("else ")) && (previousLine.endsWith("||") || previousLine.endsWith("&&")) && line.endsWith(StringPool.OPEN_CURLY_BRACE)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } if ((trimmedLine.startsWith("extends ") || trimmedLine.startsWith("implements ") || trimmedLine.startsWith("throws")) && (line.endsWith(StringPool.OPEN_CURLY_BRACE) || line.endsWith(StringPool.SEMICOLON)) && (lineTabCount == (previousLineTabCount + 1))) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } if (previousLine.endsWith(StringPool.EQUAL) && line.endsWith(StringPool.OPEN_PARENTHESIS)) { String nextLine = getNextLine(content, lineCount); if (nextLine.endsWith(StringPool.SEMICOLON)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, true); } } } if (((trimmedLine.length() + previousLineLength) <= _MAX_LINE_LENGTH) && (previousLine.endsWith(StringPool.OPEN_BRACKET) || previousLine.endsWith(StringPool.OPEN_PARENTHESIS) || previousLine.endsWith(StringPool.PERIOD)) && line.endsWith(StringPool.SEMICOLON)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, false, false); } if (previousLine.endsWith(StringPool.EQUAL) && line.endsWith(StringPool.SEMICOLON)) { String tempLine = trimmedLine; for (int pos = 0;;) { pos = tempLine.indexOf(StringPool.DASH); if (pos == -1) { pos = tempLine.indexOf(StringPool.PLUS); } if (pos == -1) { pos = tempLine.indexOf(StringPool.SLASH); } if (pos == -1) { pos = tempLine.indexOf(StringPool.STAR); } if (pos == -1) { pos = tempLine.indexOf("||"); } if (pos == -1) { pos = tempLine.indexOf("&&"); } if (pos == -1) { break; } String linePart = tempLine.substring(0, pos); int openParenthesisCount = StringUtil.count(linePart, StringPool.OPEN_PARENTHESIS); int closeParenthesisCount = StringUtil.count(linePart, StringPool.CLOSE_PARENTHESIS); if (openParenthesisCount == closeParenthesisCount) { return null; } tempLine = tempLine.substring(0, pos) + tempLine.substring(pos + 1); } int x = trimmedLine.indexOf(StringPool.OPEN_PARENTHESIS); if (x == 0) { x = trimmedLine.indexOf(StringPool.OPEN_PARENTHESIS, 1); } if (x != -1) { int y = trimmedLine.indexOf(StringPool.CLOSE_PARENTHESIS, x); int z = trimmedLine.indexOf(StringPool.QUOTE); if (((x + 1) != y) && ((z == -1) || (z > x))) { char previousChar = trimmedLine.charAt(x - 1); if ((previousChar != CharPool.CLOSE_PARENTHESIS) && (previousChar != CharPool.OPEN_PARENTHESIS) && (previousChar != CharPool.SPACE) && (previousLineLength + 1 + x) < _MAX_LINE_LENGTH) { String linePart = trimmedLine.substring(0, x + 1); if (linePart.startsWith(StringPool.OPEN_PARENTHESIS) && !linePart.contains(StringPool.CLOSE_PARENTHESIS)) { return null; } return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, linePart, tabDiff, true, true, false); } } } } if (previousLine.endsWith(StringPool.COMMA) && (previousLineTabCount == lineTabCount) && !previousLine.contains(StringPool.CLOSE_CURLY_BRACE) && (line.endsWith(") {") || !line.endsWith(StringPool.OPEN_CURLY_BRACE))) { int x = trimmedLine.indexOf(StringPool.COMMA); if (x != -1) { while ((previousLineLength + 1 + x) < _MAX_LINE_LENGTH) { String linePart = trimmedLine.substring(0, x + 1); if (isValidJavaParameter(linePart)) { if (trimmedLine.equals(linePart)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } else { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, linePart + StringPool.SPACE, tabDiff, true, true, false); } } String partAfterComma = trimmedLine.substring(x + 1); int pos = partAfterComma.indexOf(StringPool.COMMA); if (pos == -1) { break; } x = x + pos + 1; } } else if (!line.endsWith(StringPool.OPEN_PARENTHESIS) && !line.endsWith(StringPool.PLUS) && !line.endsWith(StringPool.PERIOD) && (!trimmedLine.startsWith("new ") || !line.endsWith(StringPool.OPEN_CURLY_BRACE)) && ((trimmedLine.length() + previousLineLength) < _MAX_LINE_LENGTH)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, true, false); } } if (!previousLine.endsWith(StringPool.OPEN_PARENTHESIS)) { return null; } if (StringUtil.count(previousLine, StringPool.OPEN_PARENTHESIS) > 1) { int pos = trimmedPreviousLine.lastIndexOf(StringPool.OPEN_PARENTHESIS, trimmedPreviousLine.length() - 2); if ((pos > 0) && Character.isLetterOrDigit(trimmedPreviousLine.charAt(pos - 1))) { String filePart = trimmedPreviousLine.substring(pos + 1); if (!filePart.contains(StringPool.CLOSE_PARENTHESIS) && !filePart.contains(StringPool.QUOTE)) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, filePart, tabDiff, false, false, false); } } } if ((trimmedLine.length() + previousLineLength) > _MAX_LINE_LENGTH) { return null; } if (line.endsWith(StringPool.COMMA)) { String strippedQuotesLine = stripQuotes(trimmedLine, CharPool.QUOTE); int openParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.OPEN_PARENTHESIS); int closeParenthesisCount = StringUtil.count(strippedQuotesLine, StringPool.CLOSE_PARENTHESIS); if (closeParenthesisCount > openParenthesisCount) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, false, false); } } if (((line.endsWith(StringPool.OPEN_CURLY_BRACE) && !trimmedLine.startsWith("new ")) || line.endsWith(StringPool.CLOSE_PARENTHESIS)) && (trimmedPreviousLine.startsWith("else ") || trimmedPreviousLine.startsWith("if ") || trimmedPreviousLine.startsWith("private ") || trimmedPreviousLine.startsWith("protected ") || trimmedPreviousLine.startsWith("public "))) { return getCombinedLinesContent(content, fileName, line, trimmedLine, lineLength, lineCount, previousLine, null, tabDiff, false, false, false); } return null; }
From source file:com.liferay.util.JS.java
License:Open Source License
public static String toScript(String[] array) { StringBundler sb = new StringBundler(array.length * 4 + 2); sb.append(StringPool.OPEN_BRACKET); for (int i = 0; i < array.length; i++) { sb.append(StringPool.APOSTROPHE); sb.append(UnicodeFormatter.toString(array[i])); sb.append(StringPool.APOSTROPHE); if (i + 1 < array.length) { sb.append(StringPool.COMMA); }//from w w w . j av a 2 s. c om } sb.append(StringPool.CLOSE_BRACKET); return sb.toString(); }
From source file:com.rivetlogic.portal.search.elasticsearch.util.ElasticsearchHelper.java
License:Open Source License
/** * Builds the range term.// w w w . j a v a2s.co m * * @param entry the entry * @return the string */ private String buildRangeTerm(org.elasticsearch.search.facet.range.RangeFacet.Entry entry) { StringBuilder termBuilder = new StringBuilder(); termBuilder.append(StringPool.OPEN_BRACKET); termBuilder.append(entry.getFromAsString()); termBuilder.append(StringPool.SPACE); termBuilder.append(ElasticsearchIndexerConstants.ELASTIC_SEARCH_TO); termBuilder.append(StringPool.SPACE); termBuilder.append(entry.getToAsString()); termBuilder.append(StringPool.CLOSE_BRACKET); return termBuilder.toString(); }