Skip to content

Commit 6906797

Browse files
committed
Client:优化数据存取
1 parent b11ab6a commit 6906797

5 files changed

Lines changed: 260 additions & 226 deletions

File tree

APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/StringUtil.java

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.regex.Matcher;
2121
import java.util.regex.Pattern;
2222

23+
import android.annotation.SuppressLint;
24+
2325
/**通用字符串(String)相关类,为null时返回""
2426
* @author Lemon
2527
* @use StringUtil.
@@ -453,46 +455,6 @@ public static boolean isPath(String path) {
453455
&& path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false;
454456
}
455457

456-
/**分割路径
457-
* @param path
458-
* @return
459-
*/
460-
public static String[] splitPath(String path) {
461-
if (StringUtil.isNotEmpty(path, true) == false) {
462-
return null;
463-
}
464-
return isPath(path) ? split(path, SEPARATOR) : new String[] {path};
465-
}
466-
/**将s分割成String[]
467-
* @param s
468-
* @return
469-
*/
470-
public static String[] split(String s) {
471-
return split(s, null);
472-
}
473-
/**将s用split分割成String[]
474-
* @param s
475-
* @param split
476-
* @return
477-
*/
478-
public static String[] split(String s, String split) {
479-
s = getString(s);
480-
if (s.isEmpty()) {
481-
return null;
482-
}
483-
if (isNotEmpty(split, false) == false) {
484-
split = ",";
485-
}
486-
while (s.startsWith(split)) {
487-
s = s.substring(split.length());
488-
}
489-
while (s.endsWith(split)) {
490-
s = s.substring(0, s.length() - split.length());
491-
}
492-
return s.contains(split) ? s.split(split) : new String[]{s};
493-
}
494-
495-
496458
/**判断字符类型是否是路径
497459
* @param path
498460
* @return
@@ -716,6 +678,84 @@ public static String getPrice(double price, int formatType) {
716678
}
717679
}
718680

681+
682+
/**分割路径
683+
* @param path
684+
* @return
685+
*/
686+
public static String[] splitPath(String path) {
687+
if (StringUtil.isNotEmpty(path, true) == false) {
688+
return null;
689+
}
690+
return isPath(path) ? split(path, SEPARATOR) : new String[] {path};
691+
}
692+
/**将s分割成String[]
693+
* @param s
694+
* @return
695+
*/
696+
public static String[] split(String s) {
697+
return split(s, null);
698+
}
699+
/**将s用split分割成String[]
700+
* @param s
701+
* @param split
702+
* @return
703+
*/
704+
public static String[] split(String s, String split) {
705+
s = getString(s);
706+
if (s.isEmpty()) {
707+
return null;
708+
}
709+
if (isNotEmpty(split, false) == false) {
710+
split = ",";
711+
}
712+
while (s.startsWith(split)) {
713+
s = s.substring(split.length());
714+
}
715+
while (s.endsWith(split)) {
716+
s = s.substring(0, s.length() - split.length());
717+
}
718+
return s.contains(split) ? s.split(split) : new String[]{s};
719+
}
720+
721+
/**
722+
* @param key
723+
* @param suffix
724+
* @return key + suffix,第一个字母小写
725+
*/
726+
public static String addSuffix(String key, String suffix) {
727+
key = StringUtil.getNoBlankString(key);
728+
if (key.isEmpty()) {
729+
return firstCase(suffix);
730+
}
731+
732+
return firstCase(key) + firstCase(suffix, true);
733+
}
734+
/**
735+
* @param key
736+
*/
737+
public static String firstCase(String key) {
738+
return firstCase(key, false);
739+
}
740+
/**
741+
* @param key
742+
* @param upper
743+
* @return
744+
*/
745+
@SuppressLint("DefaultLocale")
746+
public static String firstCase(String key, boolean upper) {
747+
key = StringUtil.getString(key);
748+
if (key.isEmpty()) {
749+
return "";
750+
}
751+
752+
String first = key.substring(0, 1);
753+
key = (upper ? first.toUpperCase() : first.toLowerCase()) + key.substring(1, key.length());
754+
755+
return key;
756+
}
757+
758+
719759
//校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
720760

721761
}

0 commit comments

Comments
 (0)