本文整理汇总了Java中com.liferay.portal.kernel.util.StringUtil.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.replace方法的具体用法?Java StringUtil.replace怎么用?Java StringUtil.replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMappingTables
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
public List<String> getMappingTables() {
List<String> mappingTablesFields =
ReflectionUtil.getLiferayModelImplMappingTablesFields(
getLiferayModelImplClass());
List<String> mappingTables = new ArrayList<String>(
mappingTablesFields.size());
for (String mappingTablesField : mappingTablesFields) {
String mappingTable = StringUtil.replaceFirst(
mappingTablesField, "MAPPING_TABLE_", StringPool.BLANK);
mappingTable = StringUtil.replace(
mappingTable, "_NAME", StringPool.BLANK);
mappingTable = StringUtil.toLowerCase(mappingTable);
mappingTables.add(mappingTable);
}
return mappingTables;
}
示例2: main
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
String regex = "(\\w+)\\.trim\\(\\)";
String str = "sd sdfeb sampleStr.trim();";
Pattern pattern = Pattern.compile(regex);
System.out.println(pattern.pattern());
Matcher mather = pattern.matcher(str);
String newStr = str;
while (mather.find()) {
String firstGroup = mather.group(1);
newStr = StringUtil.replace(newStr, firstGroup, "StringUtil", mather.start());
newStr = StringUtil.replace(newStr, "trim()", "trim(" + firstGroup + ")");
System.out.print(newStr);
}
}
示例3: getQuery
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
/**
* This method get string query
*
* Version: OEP 2.0
*
* History:
* DATE AUTHOR DESCRIPTION
* -------------------------------------------------
* 20-September-2015 ThongDV Create new
* @param action
* @param fromDate
* @param toDate
* @return String
*/
private String getQuery(String strQuery,String action, Date fromDate, Date toDate){
String query= strQuery;
if(action !=null && !"".equals(action)){
query = StringUtil.replace(query, "[$ACTION$]", "AND action=?");
} else {
query = StringUtil.replace(query, "[$ACTION$]", StringPool.BLANK);
}
if(fromDate != null){
query = StringUtil.replace(query, "[$CREATEDATE_BEGIN$]", " AND createDate>=?");
} else {
query = StringUtil.replace(query, "[$CREATEDATE_BEGIN$]", StringPool.BLANK);
}
if(toDate != null){
query = StringUtil.replace(query, "[$CREATEDATE_END$]", " AND createDate<=?");
} else{
query = StringUtil.replace(query, "[$CREATEDATE_END$]", StringPool.BLANK);
}
return query;
}
示例4: getCategoriesByListStr
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHCategories> getCategoriesByListStr(String categoryIds)
throws SystemException {
List<AHCategories> result = null;
Session session = null;
try {
session = openSession();
String sql = StringUtil.replace(getCategoriesByIdList, "[$ITEM_IDS$]", categoryIds);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHCategories", AHCategoriesImpl.class);
result = (List<AHCategories>) query.list();
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例5: getCategoriesByInverseListStr
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHCategories> getCategoriesByInverseListStr(String categoryIds)
throws SystemException {
List<AHCategories> result = null;
Session session = null;
try {
session = openSession();
String sql = StringUtil.replace(getInverseCategoriesByIdList, "[$ITEM_IDS$]", categoryIds);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHCategories", AHCategoriesImpl.class);
result = (List<AHCategories>) query.list();
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例6: doGetDocument
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
protected Document doGetDocument(DossierLog object) throws Exception {
Document document = getBaseModelDocument(CLASS_NAME, object);
// Indexer of audit fields
document.addNumberSortable(Field.COMPANY_ID, object.getCompanyId());
document.addNumberSortable(Field.GROUP_ID, object.getGroupId());
document.addDateSortable(Field.MODIFIED_DATE, object.getCreateDate());
document.addDateSortable(Field.CREATE_DATE, object.getModifiedDate());
document.addNumberSortable(Field.USER_ID, object.getUserId());
document.addKeywordSortable(Field.USER_NAME, String.valueOf(object.getUserName()));
document.addKeywordSortable(Field.ENTRY_CLASS_NAME, CLASS_NAME);
document.addNumberSortable(Field.ENTRY_CLASS_PK, object.getPrimaryKey());
// add number fields
document.addNumberSortable(DossierLogTerm.DOSSIER_ID, object.getDossierId());
// add text fields
String notifyType = object.getNotificationType();
notifyType = StringUtil.replace(notifyType, StringPool.DASH, StringPool.BLANK);
document.addTextSortable(DossierLogTerm.AUTHOR, object.getAuthor());
document.addTextSortable(DossierLogTerm.CONTENT, object.getContent());
document.addTextSortable(DossierLogTerm.NOTIFICATION_TYPE, notifyType);
document.addTextSortable(DossierLogTerm.PAYLOAD, object.getPayload());
try {
Dossier dossier = DossierLocalServiceUtil.getDossier(object.getDossierId());
document.addTextSortable(DossierLogTerm.SERVICE_CODE, dossier.getServiceCode());
document.addTextSortable(DossierLogTerm.SERVICE_NAME, dossier.getServiceName());
document.addTextSortable(DossierLogTerm.GOVAGENCYCODE, dossier.getGovAgencyCode());
document.addTextSortable(DossierLogTerm.GOVAGENCYNAME, dossier.getGovAgencyName());
document.addNumberSortable(DossierLogTerm.COUNTER, dossier.getCounter());
} catch (Exception e) {
e.printStackTrace();
}
return document;
}
示例7: getQuery
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
/**
* This is method get string query
*
* Version: OEP 2.0
*
* History:
* DATE AUTHOR DESCRIPTION
* -------------------------------------------------
* 20-September-2015 ThongDV Create new
* @return String
* @param keyWord
* @param isUsername
* @param isEmail
* @param fromDate
* @param toDate
*/
private String getQuery(String strQuery,String keyWord, boolean isUsername, boolean isEmail, Date fromDate, Date toDate){
String query = strQuery;
if(fromDate != null){
query = StringUtil.replace(query, "[$CREATEDATE_BEGIN$]", "AND createDate >=? ");
}else{
query = StringUtil.replace(query, "[$CREATEDATE_BEGIN$]", StringPool.BLANK);
}
if(toDate != null){
query = StringUtil.replace(query, "[$CREATEDATE_END$]", "AND createDate<=?");
}else{
query = StringUtil.replace(query, "[$CREATEDATE_END$]", StringPool.BLANK);
}
String cond="AND";
if(!"".equals(keyWord)) {
if(isUsername){
query = StringUtil.replace(query,"[$IS_USERNAME$]", "AND userName LIKE ?");
cond = " OR ";
}else{
query = StringUtil.replace(query,"[$IS_USERNAME$]", StringPool.BLANK);
}
if(isEmail){
query = StringUtil.replace(query,"[$IS_EMAIL$]", cond+" email LIKE ?");
}else{
query = StringUtil.replace(query,"[$IS_EMAIL$]", StringPool.BLANK);
}
} else {
query = StringUtil.replace(query,"[$IS_USERNAME$]", StringPool.BLANK);
query = StringUtil.replace(query,"[$IS_EMAIL$]", StringPool.BLANK);
}
return query;
}
示例8: getSubscriptionMailsByCategoryitems
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHSubscription> getSubscriptionMailsByCategoryitems(int status, String categoryItems)
throws SystemException {
List<AHSubscription> result = null;
Session session = null;
try {
session = openSession();
//String sql = CustomSQLUtil.get(getSubscriptionCategories);
String sql = StringUtil.replace(getSubscriptionsByItemIds, "[$ITEM_IDS$]", categoryItems);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHSubscription", AHSubscriptionImpl.class);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
result = (List<AHSubscription>) query.list();
m_objLog.debug("Search for subscription emails for categoryItems "+categoryItems+" results in "+result.size()+" values");
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例9: getSubscriptionsByCategoryitems
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHSubscription> getSubscriptionsByCategoryitems(int status, String[] categoryItems, int from, int to)
throws SystemException {
List<AHSubscription> result = null;
Session session = null;
try {
session = openSession();
//String sql = CustomSQLUtil.get(getSubscriptionCategories);
String catItemStr = arrToStr(categoryItems);
String sql = StringUtil.replace(getSubscriptionCategories, "[$ITEM_IDS$]", catItemStr);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHSubscription", AHSubscriptionImpl.class);
query.setFirstResult(from);
query.setMaxResults(to-from);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
result = (List<AHSubscription>) query.list();
m_objLog.debug("Search for categoryItems "+catItemStr+" results in "+result.size()+" values");
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例10: countOfferByCategoryitems
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public Integer countOfferByCategoryitems(int status, String[] categoryItems)
throws SystemException {
Integer result = 0;
Session session = null;
try {
long currentTime = CustomServiceUtils.time();
//String currentTimeStr = CustomServiceHandler.formatZoneDateTime(currentTime);
session = openSession();
//String sql = CustomSQLUtil.get(getOfferByCategories);
String sql = StringUtil.replace(getOfferByCategoryItems, "[$ITEM_IDS$]", arrToStr(categoryItems));
//sql = sql.replace("offer.*", "COUNT(*) AS COUNT_VALUE");
sql = "select count(*) as COUNT_VALUE from ("+sql+") x";
//m_objLog.trace("Counting from "+currentTimeStr+" ("+currentTime+") with query "+sql);
SQLQuery query = session.createSQLQuery(sql);
query.addScalar("COUNT_VALUE", Type.INTEGER);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
qPos.add(currentTime);
qPos.add(currentTime);
Iterator<Integer> itr = query.list().iterator();
if (itr.hasNext()) {
result = itr.next();
}
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例11: getOfferByCategoryitems
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHOffer> getOfferByCategoryitems(int status, String[] categoryItems, int from, int to)
throws SystemException {
List<AHOffer> result = null;
Session session = null;
try {
long currentTime = CustomServiceUtils.time();
// String currentTimeStr = CustomServiceHandler.formatZoneDateTime(currentTime);
session = openSession();
//String sql = CustomSQLUtil.get(getOfferByCategories);
String sql = StringUtil.replace(getOfferByCategoryItems, "[$ITEM_IDS$]", arrToStr(categoryItems));
//m_objLog.trace("Listing offers from "+currentTimeStr+" ("+currentTime+") with sql "+sql);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHOffer", AHOfferImpl.class);
query.setFirstResult(from);
query.setMaxResults(to-from);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
qPos.add(currentTime);
qPos.add(currentTime);
result = (List<AHOffer>) query.list();
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例12: getOfferByOfferTypes
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHOffer> getOfferByOfferTypes(int status, String types, int from, int to)
throws SystemException {
List<AHOffer> result = null;
Session session = null;
try {
long currentTime = CustomServiceUtils.time();
//String currentTimeStr = CustomServiceHandler.formatZoneDateTime(currentTime);
session = openSession();
//String sql = CustomSQLUtil.get(getOfferByCategories);
String sql = StringUtil.replace(getOfferByTypes, "[$TYPE_IDS$]", types);
//m_objLog.info("SQL: "+sql);
//m_objLog.trace("Listing offers from "+currentTimeStr+" ("+currentTime+") with sql "+sql);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHOffer", AHOfferImpl.class);
query.setFirstResult(from);
query.setMaxResults(to-from);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
qPos.add(currentTime);
qPos.add(currentTime);
result = (List<AHOffer>) query.list();
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例13: getOfferByCategories
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
@Override
public List<AHOffer> getOfferByCategories(int status, String categories, int from, int to)
throws SystemException {
List<AHOffer> result = null;
Session session = null;
try {
long currentTime = CustomServiceUtils.time();
//String currentTimeStr = CustomServiceHandler.formatZoneDateTime(currentTime);
session = openSession();
//String sql = CustomSQLUtil.get(getOfferByCategories);
String sql = StringUtil.replace(getOfferByCategory, "[$ITEM_IDS$]", categories);
//m_objLog.info("SQL: "+sql);
//m_objLog.trace("Listing offers from "+currentTimeStr+" ("+currentTime+") with sql "+sql);
SQLQuery query = session.createSQLQuery(sql);
query.addEntity("AHOffer", AHOfferImpl.class);
query.setFirstResult(from);
query.setMaxResults(to-from);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add(status);
qPos.add(currentTime);
qPos.add(currentTime);
result = (List<AHOffer>) query.list();
} catch (Exception e) {
throw new SystemException(e);
} finally {
closeSession(session);
}
return result;
}
示例14: getEmailBody
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
private static String getEmailBody(Notificationtemplate notificationtemplate, JSONObject object) {
try {
String emailBody = notificationtemplate.getEmailBody();
String[] oldSubs = buildOldSubs(object);
String[] newSubs = buildNewSubs(object);
return StringUtil.replace(emailBody, oldSubs, newSubs);
} catch (Exception e) {
_log.error(e);
return StringPool.BLANK;
}
}
示例15: replateContent
import com.liferay.portal.kernel.util.StringUtil; //导入方法依赖的package包/类
private static String replateContent(String strSource, String[] keys, String[] values) {
return StringUtil.replace(strSource, keys, values);
}