本文整理匯總了Java中xdean.jex.util.string.StringUtil類的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil類的具體用法?Java StringUtil怎麽用?Java StringUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StringUtil類屬於xdean.jex.util.string包,在下文中一共展示了StringUtil類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showLineJumpDialog
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private void showLineJumpDialog() {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Goto Line");
dialog.getDialogPane().setContentText("Input Line Number: ");
dialog.initOwner(area.getValue().getScene().getWindow());
TextField tf = dialog.getEditor();
int lines = StringUtil.countLine(area.getValue().getText());
ValidationSupport vs = new ValidationSupport();
vs.registerValidator(tf, Validator.<String> createPredicateValidator(
s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
String.format("Line number must be in [%d,%d]", 1, lines)));
dialog.showAndWait().ifPresent(s -> {
if (vs.isInvalid() == false) {
area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
}
});
}
示例2: initBar
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private void initBar() {
length.textProperty().bind(map(getCodeAreaValue(c -> c.textProperty()), t -> t.length()));
lines.textProperty().bind(map(getCodeAreaValue(c -> c.textProperty()), t -> StringUtil.countLine(t)));
caretLine.textProperty().bind(
map(getCodeAreaValue(c -> c.caretPositionProperty()), t -> StringUtil.countLine(area.getValue().getText().substring(0, t))));
caretColumn.textProperty().bind(map(getCodeAreaValue(c -> c.caretColumnProperty()), t -> t));
select.textProperty().bind(mapString(getCodeAreaValue(c -> c.selectedTextProperty()), t -> t.length() + " | " + StringUtil.countLine(t)));
charset.textProperty().bind(mapString(Options.charset.property(), t -> t.toString()));
inputType.textProperty().bind(Bindings.when(yep(overrideProperty)).then("Override").otherwise("Insert"));
bar.getRightItems().addAll(
margin(new Text("lines"), 0, 5), minWidth(lines, 60),
margin(new Text("length"), 0, 5), minWidth(length, 70),
new Separator(Orientation.VERTICAL),
margin(new Text("Col"), 0, 5), minWidth(caretColumn, 60),
margin(new Text("Line"), 0, 5), minWidth(caretLine, 60),
new Separator(Orientation.VERTICAL),
margin(new Text("Sel"), 0, 5), minWidth(select, 90),
new Separator(Orientation.VERTICAL),
minWidth(charset, 60),
new Separator(Orientation.VERTICAL),
minWidth(inputType, 60),
new Separator(Orientation.VERTICAL)
);
}
示例3: findCSS
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private static Range<Integer> findCSS(String text, int offset) {
int start = text.indexOf("{", offset);
int end = text.indexOf("}", start);
if (start > end || start == -1 || end == -1) {
return null;
}
start = offset + StringUtil.lastIndexOf(text.substring(offset, start), "{", "}") + 1;
return Range.closed(start, end + 1);
}
示例4: getSuggestionByRegex
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private static Collection<String> getSuggestionByRegex(String text, int caretPos, CSSContext context) {
String prePart = text.substring(0, caretPos);
int leftIndex = prePart.lastIndexOf('{');
int rightIndex = prePart.lastIndexOf('}');
if (leftIndex == rightIndex) {
return Collections.emptyList();
}
prePart = prePart.substring(Math.max(leftIndex, rightIndex) + 1);
Matcher matcher = pattern.matcher(prePart);
String lastMatch1 = "";
String lastMatch2 = null;
while (matcher.find()) {
lastMatch1 = matcher.group(1);
lastMatch2 = matcher.group(2);
}
final String keyWord = lastMatch2;
if (StringUtil.notEmpty(keyWord) && prePart.endsWith(keyWord)) {
if (leftIndex > rightIndex) {
if (lastMatch1.indexOf(':') > -1) {
// TODO value suggestion
} else {
return filterSuggestion(context.getKeys(), keyWord);
}
} else {
if (lastMatch1.indexOf('.') > -1) {
return filterSuggestion(context.getClasses(), keyWord);
} else if (lastMatch1.indexOf('#') > -1) {
return filterSuggestion(context.getIds(), keyWord);
} else if (lastMatch1.indexOf(':') > -1) {
return filterSuggestion(context.getStates(), keyWord);
} else {
return filterSuggestion(context.getJavaClasses(), keyWord);
}
}
}
return Collections.emptyList();
}
示例5: simpleFind
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private boolean simpleFind(CodeArea area, String text, int offset) {
Func3<String, String, Integer, Integer> func = caseSensitive.isSelected() ? String::indexOf
: StringUtil::indexOfIgnoreCase;
int index = func.call(area.getText(), text, offset);
if (index != -1) {
area.selectRange(index, index + text.length());
return true;
}
return false;
}
示例6: convert
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
public static FxmlEntity convert(Path path) throws IOException {
FxmlEntity fxml = new FxmlEntity();
fxml.setFields(new HashMap<>());
fxml.setImports(new ArrayList<>());
fxml.setMethods(new ArrayList<>());
List<String> lines = Files.readAllLines(path);
String text = String.join("\n", lines.toArray(new String[lines.size()]));
while (true) {
int[] pair = StringUtil.balancePair(text, "<", ">");
if (pair[0] == -1 || pair[1] == -1) {
break;
}
String now = text.substring(pair[0] + 1, pair[1]);
text = text.substring(pair[1] + 1);
if (now.startsWith("?import")) {
fxml.imports.add(now.substring(7, now.length() - 1));
} else {
String[] split = now.split(" ");
String name = split[0];
Map<String, String> map = new HashMap<>();
Stream.of(split)
.skip(1)
.map(s -> s.split("=", 2))
.filter(ss -> ss.length >= 2)
.forEach(ss -> map.put(ss[0].trim(), StringUtil.unWrap(ss[1], "\"", "\"")));
map.forEach((k, v) -> {
if ("fx:controller".equals(k)) {
int index = v.lastIndexOf('.');
fxml.setPackageName(v.substring(0, index));
fxml.setClassName(v.substring(index + 1));
} else if ("fx:id".equals(k)) {
fxml.fields.put(v, name);
} else if (k.startsWith("on") && v.startsWith("#")) {
fxml.methods.add(v.substring(1));
}
});
}
}
return fxml;
}
示例7: createURLString
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
public static String createURLString(String text) {
return "string:" + StringUtil.encode(text);
}
示例8: getInputStream
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(StringUtil.decode(getURL().toString().substring(7)).getBytes());
}
示例9: verify
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
public static boolean verify(String svg) {
if (StringUtil.isEmpty(svg)) {
return false;
}
return TaskUtil.uncatch(() -> new Path2D().appendSVGPath(svg));
}
示例10: loadSkin
import xdean.jex.util.string.StringUtil; //導入依賴的package包/類
private static void loadSkin() {
// load default skins
for (SkinStyle ss : DefaultSkin.values()) {
SKIN.addSkin(ss);
}
// load skin files in /skin
Path skinFolder = HOME_PATH.resolve("skin");
try {
if (Files.notExists(skinFolder)) {
Files.createDirectory(skinFolder);
} else {
Files.newDirectoryStream(skinFolder).forEach(path -> {
String fileName = path.getFileName().toString();
if (!Files.isDirectory(path) && (fileName.endsWith(".css") ||
fileName.endsWith(".bss"))) {
String url = path.toUri().toString();
String name = StringUtil.upperFirst(fileName.substring(0, fileName.length() - 4));
SKIN.addSkin(new SkinStyle() {
@Override
public String getURL() {
return url;
}
@Override
public String getName() {
return name;
}
});
}
});
}
} catch (IOException e) {
e.printStackTrace();
}
SKIN.getSkinList().stream().map(SkinStyle::getURL).map(s -> "loaded skin: " +
s).forEach(log::debug);
SKIN.changeSkin(DefaultSkin.CLASSIC);
String configSkin = Config.getProperty(ConfigKey.SKIN, null);
if (configSkin != null) {
SKIN.getSkinList().stream()
.filter(s -> s.getName().equals(configSkin))
.findAny()
.ifPresent(s -> SKIN.changeSkin(s));
}
JavaFxObservable.fromObservableValue(SKIN.skinProperty())
.subscribe(skin -> Config.setProperty(ConfigKey.SKIN, skin.getName()));
}