本文整理了Java中org.javalite.common.Util.split()
方法的一些代码示例,展示了Util.split()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.split()
方法的具体详情如下:
包路径:org.javalite.common.Util
类名称:Util
方法名:split
[英]Splits a string into an array using provided delimiter. Empty (but not blank) split chunks are omitted. The split chunks are trimmed.
[中]使用提供的分隔符将字符串拆分为数组。空的(但不是空的)分割块被省略。分割的块被修剪。
代码示例来源:origin: javalite/activejdbc
/**
* Splits a string into an array using provided delimiter. Empty (but not blank) split chunks are omitted.
* The split chunks are trimmed.
*
* @param input string to split.
* @param delimiter delimiter
* @return a string split into an array using a provided delimiter
*/
public static String[] split(String input, char delimiter) {
return split(input, String.valueOf(delimiter));
}
代码示例来源:origin: javalite/activejdbc
/**
* Convenience method, does the same as {@link #execute(String...)}, but will
* automatically convert a full command string to tokens for convenience.
* Here is how to call:
*
* <pre>
* System.out.println(execute("ls -ls").out);
* </pre>
*
* @param command - a single string representing a command and its arguments.
* @return instance of {@link Response} with result of execution.
*/
public static Response execute(String command) {
return execute(Util.split(command, " "));
}
代码示例来源:origin: javalite/activejdbc
private static synchronized Map<String, Set<String>> getModelMap() {
if (modelMap == null) {
try {
modelMap = new HashMap<>();
Enumeration<URL> urls = Registry.instance().getClass().getClassLoader().getResources("activejdbc_models.properties");
while(urls.hasMoreElements()) {
URL url = urls.nextElement();
LogFilter.log(LOGGER, LogLevel.INFO, "Loading models from: {}", url.toExternalForm());
String modelsFile = Util.read(url.openStream());
String[] lines = Util.split(modelsFile, System.getProperty("line.separator"));
for(String line : lines) {
String[] parts = Util.split(line, ':');
String modelName = parts[0];
String dbName = parts[1];
Set<String> modelNames = modelMap.computeIfAbsent(dbName, k -> new HashSet<>());
if (!modelNames.add(modelName)) {
throw new InitException(String.format("Model '{}' already exists for database '{}'", modelName, dbName));
}
}
}
} catch(IOException e) {
throw new InitException(e);
}
}
return modelMap;
}
代码示例来源:origin: javalite/activejdbc
String[] commandAndArgs = command.length == 1 && command[0].contains(" ") ? Util.split(command[0], " ") : command;
代码示例来源:origin: org.javalite/javalite-templator
@Override
public void setArguments(String argumentLine) {
this.argumentLine = argumentLine.trim();
String[] arguments = split(argumentLine, " ");
singleArgument = arguments.length == 1;
}
代码示例来源:origin: org.javalite/javalite-common
/**
* Splits a string into an array using provided delimiter. Empty (but not blank) split chunks are omitted.
* The split chunks are trimmed.
*
* @param input string to split.
* @param delimiter delimiter
* @return a string split into an array using a provided delimiter
*/
public static String[] split(String input, char delimiter) {
return split(input, String.valueOf(delimiter));
}
代码示例来源:origin: com.github.tchoulihan/javalite-common
/**
* Splits a string into an array using provided delimiter. Empty (but not blank) split chunks are omitted.
* The split chunks are trimmed.
*
* @param input string to split.
* @param delimiter delimiter
* @return a string split into an array using a provided delimiter
*/
public static String[] split(String input, char delimiter) {
return split(input, String.valueOf(delimiter));
}
代码示例来源:origin: javalite/activeweb
private String getTemplatePath(String containerName, String templateArgumentName){
String templatePath;
if(!templateArgumentName.startsWith("/")){ //need to get path of container - this is not a shared partial, so expect it is located in teh same
//directory with the containing template
String path = containerName.substring(0, containerName.lastIndexOf("/"));
templatePath = "/" + path + "/" + templateArgumentName;
}else{//this is a shared partial
if(Util.split(templateArgumentName, '/').length < 2){
throw new IllegalArgumentException("wrong name of shared partial");
}
String path = templateArgumentName.substring(0, templateArgumentName.lastIndexOf("/"));
templatePath = path + "/" + templateArgumentName.substring(templateArgumentName.lastIndexOf("/") + 1);
}
return templatePath;
}
代码示例来源:origin: org.javalite/javalite-common
/**
* Convenience method, does the same as {@link #execute(String...)}, but will
* automatically convert a full command string to tokens for convenience.
* Here is how to call:
*
* <pre>
* System.out.println(execute("ls -ls").out);
* </pre>
*
* @param command - a single string representing a command and its arguments.
* @return instance of {@link Response} with result of execution.
*/
public static Response execute(String command) {
return execute(Util.split(command, " "));
}
代码示例来源:origin: javalite/activeweb
/**
*
* @param containerName - name of the container template.
* @param templateArgumentName this is a name of a partial provided as an attribute to the "render" tag.
* @return full path to a template file.
*/
private String getTemplatePath(String containerName, String templateArgumentName){
String templatePath;
if(!templateArgumentName.startsWith("/")){ //need to get path of container - this is not a shared partial, so expect it is located in teh same
//directory with the containing template
String path = containerName.substring(0, containerName.lastIndexOf("/"));
templatePath = "/" + path + "/_" + templateArgumentName;
}else{//this is a shared partial
if(Util.split(templateArgumentName, '/').length < 2){
throw new IllegalArgumentException("wrong name of shared partial");
}
String path = templateArgumentName.substring(0, templateArgumentName.lastIndexOf("/"));
templatePath = path + "/_" + templateArgumentName.substring(templateArgumentName.lastIndexOf("/") + 1);
}
return templatePath;
}
代码示例来源:origin: org.javalite/javalite-templator
@Override
public void setArguments(String argumentLine) {
super.setArguments(argumentLine);
String[] arguments = Util.split(argumentLine, ' ');
if(arguments.length != 3 || !arguments[1].equals("as"))
throw new ParseException("List arguments must have format: 'collection as localVar'");
collectionName = arguments[0];
varName = arguments[2];
}
代码示例来源:origin: javalite/activeweb
@Override
protected void render(Map params, String body, Writer writer) throws Exception {
if (params.containsKey("key")) {
String key = params.get("key").toString();
if(params.containsKey("locale")){
String localeString = params.get("locale").toString();
String language, country;
Locale locale;
if(localeString.contains("_")){
language = split(localeString, '_')[0];
country = split(localeString, '_')[1];
locale = new Locale(language, country);
}else{
language = localeString;
locale = new Locale(language);
}
writer.write(Messages.message(key, locale, getParamsArray(params)));
}else{
writer.write(Messages.message(key, getParamsArray(params)));
}
}else{
writer.write("<span style=\"display:none\">you failed to supply key for this message tag</span>");
}
}
代码示例来源:origin: org.javalite/javalite-templator
@Override
public void setArguments(String argumentLine) {
super.setArguments(argumentLine);
this.expression = argumentLine.contains(".");
boolean hasBuiltIn = argumentLine.contains(" ");
if (argumentLine.length() - argumentLine.replace(" ", "").length() > 1)
throw new ParseException("Merge token: " + argumentLine + " has more that one space");
if (argumentLine.length() - argumentLine.replace(".", "").length() > 1)
throw new ParseException("Merge token: " + argumentLine + " has more that one dots");
if (hasBuiltIn) {
String[] parts = Util.split(argumentLine, ' ');
String builtInName = parts[1];
builtIn = TemplatorConfig.instance().getBuiltIn(builtInName);
if (expression) {
parts = Util.split(parts[0], '.');
this.objectName = parts[0];
this.propertyName = parts[1];
}
} else if (expression) {
String[] parts = Util.split(argumentLine, '.');
this.objectName = parts[0];
this.propertyName = parts[1];
}
}
代码示例来源:origin: javalite/activeweb
/**
* Used for custom routes
* @param routeConfig what was specified in the RouteConfig class
*/
protected RouteBuilder(String routeConfig) {
String[] segmentsArr = Util.split(routeConfig, '/');
for (String segmentStr : segmentsArr) {
Segment segment = new Segment(segmentStr);
segments.add(segment);
if (segment.wildCard) {
String wildCardSegment = segment.segment;
wildcardName = wildCardSegment.substring(1);
break; // break from loop, we are done!
}
}
if(segmentsArr.length > segments.size()){
throw new ConfigurationException("Cannot have URI segments past wild card");
}
this.routeConfig = routeConfig;
for (Segment segment : segments) {
if (segment.mandatory) {
mandatorySegmentCount++;
}
}
}
代码示例来源:origin: javalite/activeweb
String[] requestUriSegments = Util.split(requestUri, '/');
if(isWildcard() && requestUriSegments.length >= segments.size() && wildSegmentsMatch(requestUriSegments, controllerPath)){
String[] tailArr = Arrays.copyOfRange(requestUriSegments, segments.size() - 1, requestUriSegments.length);
代码示例来源:origin: org.javalite/activejdbc
while ((line = reader.readLine()) != null) {
String[] parts = split(line, ':');
String modelName = parts[0];
String dbName = parts[1];
代码示例来源:origin: javalite/activeweb
String[] partialParts = Util.split(params.get("partial").toString(), '/');
String partialName = partialParts[partialParts.length - 1];
Template partialTemplate = env.getConfiguration().getTemplate(partialPath + ".ftl" );
内容来源于网络,如有侵权,请联系作者删除!