本文整理汇总了Java中jodd.util.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于jodd.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classifySentence
import jodd.util.StringUtil; //导入依赖的package包/类
private static String classifySentence(Sentence sentence, String type) {
type = StringUtil.cutToIndexOf(type, ':');
if (!TYPES.contains(type)) {
throw new RuntimeException("Unknown type: " + type);
}
QuestionTypeClassifier questionTypeClassifier = new QuestionTypeClassifier();
try {
QuestionTypeClassifier.Features features = questionTypeClassifier.classifyFeatures(sentence);
if (features.getPosOfNext().equals("``")) {
return "";
}
return features.toString() + "," + type;
}
catch (Exception ignore) {
return "";
}
}
示例2: allArea
import jodd.util.StringUtil; //导入依赖的package包/类
public EArea allArea(WMap query) {
//处理查询条件
Criteria cnd = Cnd.cri();
cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
if (query.get("extId") != null && StringUtil.isNotBlank(query.get("extId").toString())) {
cnd.where().andNotIn("id", query.get("extId").toString());
cnd.where().andNotLike("parent_ids", "%," + query.get("extId").toString() + ",%");
}
cnd.getOrderBy().asc("sort");
List<EArea> allAreas = query(cnd);
List<ITreeNode<EArea>> allNodes = new ArrayList<>();
EArea root = new EArea();
root.setId(0L);
allNodes.add(root);
if (allAreas != null && !allAreas.isEmpty()) {
allNodes.addAll(allAreas);
}
return (EArea) root.buildTree(allNodes);
}
示例3: getUser
import jodd.util.StringUtil; //导入依赖的package包/类
@RequestMapping(value = "/currInfo", method = RequestMethod.GET)
public ActionResultObj getUser() {
ActionResultObj result = new ActionResultObj();
// 获取当前用户
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (StringUtil.isNotBlank(userDetails.getUsername())) {
EUser currentUser = userDao.fetchByName(userDetails.getUsername());
EAccount account = accountDao.fetch(currentUser);
EOrg org = orgDao.fetch(currentUser.getOrgId());
WMap map = new WMap();
map.put("userName", account != null ? account.getFullName() : currentUser.getUsername());
map.put("accountId", account != null ? account.getId() : "");
map.put("orgName", org.getName());
result.ok(map);
} else {
result.errorMsg("获取失败");
}
return result;
}
示例4: save
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* 新增一个用户,同时增加account和user
*
* @param account
* @return
*/
@RequestMapping(value = "/save")
public ActionResultObj save(@RequestBody EAccount account) {
ActionResultObj result = new ActionResultObj();
try {
account = userDetailsService.saveUser(account);
if (account.getId() != null && account.getId() != 0) {
result.okMsg("保存成功!");
} else {
result.errorMsg("保存失败!");
}
} catch (Exception e) {
LOG.error("保存失败,原因:" + e.getMessage());
result.error(e);
EUser user = account.getUser();
if (user.getUsername() != null && StringUtil.isNotBlank(user.getUsername())) {
if (userDetailsService.isUserExisted(user.getUsername())) {
result.errorMsg("用户 " + user.getUsername() + " 已存在!");
}
}
}
return result;
}
示例5: findByType
import jodd.util.StringUtil; //导入依赖的package包/类
@RequestMapping(value="type/{type}")
public ActionResultObj findByType(@PathVariable String type){
ActionResultObj result = new ActionResultObj();
try{
if(StringUtil.isNotBlank(type)){
List<EDict> dictList = dictDao.query(Cnd.where("type", "=", type).and("del_flag", "=", Constans.POS_NEG.NEG).orderBy("sort", "asc"));
//处理返回值
WMap map = new WMap();
map.put("type", type);
map.put("data", dictList);
result.ok(map);
result.okMsg("查询成功!");
}else{
result.errorMsg("查询失败,字典类型不存在!");
}
}catch(Exception e){
e.printStackTrace();
LOG.error("查询失败,原因:"+e.getMessage());
result.error(e);
}
return result;
}
示例6: findAllmenu
import jodd.util.StringUtil; //导入依赖的package包/类
@RequestMapping(value = "/allMenu", method = RequestMethod.POST)
public ActionResultObj findAllmenu(@RequestBody SearchQueryJS queryJs) {
ActionResultObj result = new ActionResultObj();
try {
WMap query = queryJs.getQuery();
//处理查询条件
Criteria cnd = Cnd.cri();
cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
if (query.get("extId") != null && StringUtil.isNotBlank(query.get("extId").toString())) {
cnd.where().andNotIn("id", query.get("extId").toString());
cnd.where().andNotLike("parent_ids", "%," + query.get("extId").toString() + ",%");
}
cnd.getOrderBy().asc("sort");
List<EMenu> allMenus = menuDao.query(cnd);
EMenu menu = menuDao.buildMenuTree(allMenus);
WMap map = new WMap();
map.put("data", menu.getItems());
result.setData(map);
result.okMsg("查询成功!");
} catch (Exception e) {
e.printStackTrace();
LOG.error("查询失败,原因:" + e.getMessage());
result.error(e);
}
return result;
}
示例7: testFetchUserAuthoritiesPrincipal
import jodd.util.StringUtil; //导入依赖的package包/类
@Test
public void testFetchUserAuthoritiesPrincipal() {
//principal==null时获取到guest权限信息
Set<String> authorities = userDetailsService.principalAuthorities(null);
notNull(authorities, "");
isTrue(authorities.size() == 1, "");
isTrue("guest".equals(StringUtil.join(authorities, ",")), "");
//admin user时获取全部权限
UserPrincipal up = new UserPrincipal("watano");
authorities = userDetailsService.principalAuthorities(up);
notNull(authorities, "");
isTrue(authorities.size() > 0, "");
isTrue(authorities.contains("pro_list"), "");
List<EAuthority> allAuthorities = authorityDao.query();
assertEquals(authorities.size(), allAuthorities.size());
}
示例8: generateJSTree
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* 生成jstree要求的数据结构
* @param resourceList
* @return
*/
public List<JSTreeEntity> generateJSTree(List<ResourceEntity> resourceList)
{
List<JSTreeEntity> jstreeList = new ArrayList<JSTreeEntity>();
for (ResourceEntity resourceEntity : resourceList) {
JSTreeEntity jstree = new JSTreeEntity();
jstree.setId(resourceEntity.getId().toString());
jstree.setParent(resourceEntity.getParentId()==null ? "#" : resourceEntity.getParentId().toString());
jstree.setText(resourceEntity.getName());
jstree.setIcon(StringUtil.isBlank(resourceEntity.getIcon()) ? "fa fa-cog" : resourceEntity.getIcon());
JSTreeEntity.State state = new JSTreeEntity().new State();
state.setDisabled(false);
state.setSelected(resourceEntity.getSelected());
state.setOpened(true/*resourceEntity.getParentId()==null ? true : false*/);
jstree.setState(state);
jstreeList.add(jstree);
}
return jstreeList;
}
示例9: getDruidPlugin
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* ��ȡDruid���ӳ�
*
* @param druidConfig
* @return
*/
public static DruidPlugin getDruidPlugin(Properties druidConfig) {
DruidPlugin druidPlugin = new DruidPlugin(druidConfig.getProperty("jdbc.url"), druidConfig.getProperty("jdbc.username"), druidConfig.getProperty("jdbc.password"), druidConfig.getProperty("jdbc.driverClass"));
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.MaxActive"))) {
druidPlugin = druidPlugin.setMaxActive(Integer.parseInt(druidConfig.getProperty("jdbc.MaxActive")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.MinIdle"))) {
druidPlugin = druidPlugin.setMinIdle(Integer.parseInt(druidConfig.getProperty("jdbc.MinIdle")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.MaxActive"))) {
druidPlugin = druidPlugin.setInitialSize(Integer.parseInt(druidConfig.getProperty("jdbc.InitialSize")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.MinEvictableIdleTimeMillis"))) {
druidPlugin = druidPlugin.setMinEvictableIdleTimeMillis(Integer.parseInt(druidConfig.getProperty("jdbc.MinEvictableIdleTimeMillis")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.MaxPoolPreparedStatementPerConnectionSize"))) {
druidPlugin = druidPlugin.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(druidConfig.getProperty("jdbc.MaxPoolPreparedStatementPerConnectionSize")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.timeBetweenEvictionRunsMillis"))) {
druidPlugin = druidPlugin.setTimeBetweenEvictionRunsMillis(Integer.parseInt(druidConfig.getProperty("jdbc.timeBetweenEvictionRunsMillis")));
}
if(StringUtil.isNotBlank(druidConfig.getProperty("jdbc.minEvictableIdleTimeMillis"))) {
druidPlugin = druidPlugin.setMinEvictableIdleTimeMillis(Integer.parseInt(druidConfig.getProperty("jdbc.minEvictableIdleTimeMillis")));
}
return druidPlugin;
}
示例10: loadFromClasspath
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* Loads props from classpath.
*/
public static void loadFromClasspath(final Props p, final String... patterns) {
final ClassScanner scanner = new ClassScanner() {
@Override
protected void onEntry(EntryData entryData) throws IOException {
String encoding = JoddCore.encoding;
if (StringUtil.endsWithIgnoreCase(entryData.getName(), ".properties")) {
encoding = StringPool.ISO_8859_1;
}
p.load(entryData.openInputStream(), encoding);
}
};
scanner.setIncludeResources(true);
scanner.setIgnoreException(true);
scanner.setExcludeAllEntries(true);
scanner.setIncludedEntries(patterns);
scanner.scanDefaultClasspath();
}
示例11: resolveActiveProfiles
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* Resolves active profiles from special property.
* This property can be only a base property!
* If default active property is not defined, nothing happens.
* Otherwise, it will replace currently active profiles.
*/
protected void resolveActiveProfiles() {
if (activeProfilesProp == null) {
activeProfiles = null;
return;
}
final PropsEntry pv = data.getBaseProperty(activeProfilesProp);
if (pv == null) {
// no active profile set as the property, exit
return;
}
final String value = pv.getValue();
if (StringUtil.isBlank(value)) {
activeProfiles = null;
return;
}
activeProfiles = StringUtil.splitc(value, ',');
StringUtil.trimAll(activeProfiles);
}
示例12: readHeaders
import jodd.util.StringUtil; //导入依赖的package包/类
/**
* Parses headers.
*/
protected void readHeaders(BufferedReader reader) {
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException ioex) {
throw new HttpException(ioex);
}
if (StringUtil.isBlank(line)) {
break;
}
int ndx = line.indexOf(':');
if (ndx != -1) {
header(line.substring(0, ndx), line.substring(ndx + 1));
} else {
throw new HttpException("Invalid header: " + line);
}
}
}
示例13: convert
import jodd.util.StringUtil; //导入依赖的package包/类
public Class convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Class.class) {
return (Class) value;
}
try {
String className = value.toString().trim();
if (className.endsWith(".class")) {
className = StringUtil.substring(className, 0, -6);
}
return ClassLoaderUtil.loadClass(className);
} catch (ClassNotFoundException cnfex) {
throw new TypeConversionException(value, cnfex);
}
}
示例14: convert
import jodd.util.StringUtil; //导入依赖的package包/类
public Float convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Float.class) {
return (Float) value;
}
if (value instanceof Number) {
return Float.valueOf(((Number)value).floatValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Float.valueOf(1) : Float.valueOf(0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Float.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}
示例15: convert
import jodd.util.StringUtil; //导入依赖的package包/类
public Integer convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == Integer.class) {
return (Integer) value;
}
if (value instanceof Number) {
return Integer.valueOf(((Number)value).intValue());
}
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue() ? Integer.valueOf(1) : Integer.valueOf(0);
}
try {
String stringValue = value.toString().trim();
if (StringUtil.startsWithChar(stringValue, '+')) {
stringValue = stringValue.substring(1);
}
return Integer.valueOf(stringValue);
} catch (NumberFormatException nfex) {
throw new TypeConversionException(value, nfex);
}
}