本文整理汇总了Java中org.codehaus.groovy.runtime.StringGroovyMethods类的典型用法代码示例。如果您正苦于以下问题:Java StringGroovyMethods类的具体用法?Java StringGroovyMethods怎么用?Java StringGroovyMethods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringGroovyMethods类属于org.codehaus.groovy.runtime包,在下文中一共展示了StringGroovyMethods类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addInstallTask
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private void addInstallTask(final Project project, final Distribution distribution) {
String taskName = TASK_INSTALL_NAME;
if (!MAIN_DISTRIBUTION_NAME.equals(distribution.getName())) {
taskName = "install" + StringGroovyMethods.capitalize(distribution.getName()) + "Dist";
}
Sync installTask = project.getTasks().create(taskName, Sync.class);
installTask.setDescription("Installs the project as a distribution as-is.");
installTask.setGroup(DISTRIBUTION_GROUP);
installTask.with(distribution.getContents());
installTask.into(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("" + project.getBuildDir() + "/install/" + distribution.getBaseName());
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:DistributionPlugin.java
示例2: escapeXml
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
/**
* Escape the following characters {@code " ' & < >} with their XML entities, e.g.
* {@code "bread" & "butter"} becomes {@code "bread" & "butter"}.
* Notes:<ul>
* <li>Supports only the five basic XML entities (gt, lt, quot, amp, apos)</li>
* <li>Does not escape control characters</li>
* <li>Does not support DTDs or external entities</li>
* <li>Does not treat surrogate pairs specially</li>
* <li>Does not perform Unicode validation on its input</li>
* </ul>
*
* @param orig the original String
* @return A new string in which all characters that require escaping
* have been replaced with the corresponding XML entities.
* @see #escapeControlCharacters(String)
*/
public static String escapeXml(String orig) {
return StringGroovyMethods.collectReplacements(orig, new Closure<String>(null) {
public String doCall(Character arg) {
switch (arg) {
case '&':
return "&";
case '<':
return "<";
case '>':
return ">";
case '"':
return """;
case '\'':
return "'";
}
return null;
}
});
}
开发者ID:apache,项目名称:groovy,代码行数:36,代码来源:XmlUtil.java
示例3: replaceHexEscapes
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static String replaceHexEscapes(String text) {
if (!text.contains(BACKSLASH)) {
return text;
}
Pattern p = Pattern.compile("(\\\\*)\\\\u([0-9abcdefABCDEF]{4})");
return StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
Object doCall(String _0, String _1, String _2) {
if (isLengthOdd(_1)) {
return _0;
}
return _1 + new String(Character.toChars(Integer.parseInt(_2, 16)));
}
});
}
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:StringUtils.java
示例4: replaceOctalEscapes
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static String replaceOctalEscapes(String text) {
if (!text.contains(BACKSLASH)) {
return text;
}
Pattern p = Pattern.compile("(\\\\*)\\\\([0-3]?[0-7]?[0-7])");
return StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
Object doCall(String _0, String _1, String _2) {
if (isLengthOdd(_1)) {
return _0;
}
return _1 + new String(Character.toChars(Integer.parseInt(_2, 8)));
}
});
}
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:StringUtils.java
示例5: replaceStandardEscapes
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static String replaceStandardEscapes(String text) {
if (!text.contains(BACKSLASH)) {
return text;
}
Pattern p = Pattern.compile("(\\\\*)\\\\([btnfr\"'])");
String result = StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
Object doCall(String _0, String _1, String _2) {
if (isLengthOdd(_1)) {
return _0;
}
Character character = STANDARD_ESCAPES.get(_2.charAt(0));
return _1 + (character != null ? character : _2);
}
});
return replace(result,"\\\\", "\\");
}
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:StringUtils.java
示例6: replaceLineEscape
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private static String replaceLineEscape(String text) {
if (!text.contains(BACKSLASH)) {
return text;
}
Pattern p = Pattern.compile("(\\\\*)\\\\\r?\n");
text = StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
Object doCall(String _0, String _1) {
if (isLengthOdd(_1)) {
return _0;
}
return _1;
}
});
return text;
}
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:StringUtils.java
示例7: toString
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public String toString() {
List buffer = new ArrayList();
if (this.years != 0) buffer.add(this.years + " years");
if (this.months != 0) buffer.add(this.months + " months");
if (this.days != 0) buffer.add(this.days + " days");
if (this.hours != 0) buffer.add(this.hours + " hours");
if (this.minutes != 0) buffer.add(this.minutes + " minutes");
if (this.seconds != 0 || this.millis != 0) {
int norm_millis = this.millis % 1000;
int norm_seconds = this.seconds + DefaultGroovyMethods.intdiv(this.millis - norm_millis, 1000).intValue();
CharSequence millisToPad = "" + Math.abs(norm_millis);
buffer.add((norm_seconds == 0 ? (norm_millis < 0 ? "-0" : "0") : norm_seconds) + "." + StringGroovyMethods.padLeft(millisToPad, 3, "0") + " seconds");
}
if (!buffer.isEmpty()) {
return DefaultGroovyMethods.join(buffer.iterator(), ", ");
} else {
return "0";
}
}
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:BaseDuration.java
示例8: addAssembleTask
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private void addAssembleTask(Project project, Distribution distribution, Task... tasks) {
String taskName = TASK_ASSEMBLE_NAME;
if (!MAIN_DISTRIBUTION_NAME.equals(distribution.getName())) {
taskName = "assemble" + StringGroovyMethods.capitalize(distribution.getName()) + "Dist";
}
Task assembleTask = project.getTasks().create(taskName);
assembleTask.setDescription("Assembles the " + distribution.getName() + " distributions");
assembleTask.setGroup(DISTRIBUTION_GROUP);
assembleTask.dependsOn((Object[]) tasks);
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:DistributionPlugin.java
示例9: createShrinkResourcesTask
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private ShrinkResources createShrinkResourcesTask(
final ApkVariantOutputData variantOutputData) {
BaseVariantData<?> variantData = (BaseVariantData<?>) variantOutputData.variantData;
ShrinkResources task = scope.getGlobalScope().getProject().getTasks()
.create("shrink" + StringGroovyMethods
.capitalize(variantOutputData.getFullName())
+ "Resources", ShrinkResources.class);
task.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder());
task.variantOutputData = variantOutputData;
final String outputBaseName = variantOutputData.getBaseName();
task.setCompressedResources(new File(
scope.getGlobalScope().getBuildDir() + "/" + FD_INTERMEDIATES + "/res/" +
"resources-" + outputBaseName + "-stripped.ap_"));
ConventionMappingHelper.map(task, "uncompressedResources", new Callable<File>() {
@Override
public File call() {
return variantOutputData.processResourcesTask.getPackageOutputFile();
}
});
task.dependsOn(
scope.getVariantScope().getObfuscationTask().getName(),
scope.getManifestProcessorTask().getName(),
variantOutputData.processResourcesTask);
return task;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PackageApplication.java
示例10: createGroovyToken
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private org.codehaus.groovy.syntax.Token createGroovyToken(Token token, int cardinality) {
String text = StringGroovyMethods.multiply((CharSequence) token.getText(), cardinality);
return new org.codehaus.groovy.syntax.Token(
"..<".equals(token.getText()) || "..".equals(token.getText())
? Types.RANGE_OPERATOR
: Types.lookup(text, Types.ANY),
text,
token.getLine(),
token.getCharPositionInLine() + 1
);
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:AstBuilder.java
示例11: paintComponent
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
// starting position in document
int start = textEditor.viewToModel(getViewport().getViewPosition());
// end position in document
int end = textEditor.viewToModel(new Point(10,
getViewport().getViewPosition().y +
(int) textEditor.getVisibleRect().getHeight())
);
// translate offsets to lines
Document doc = textEditor.getDocument();
int startline = doc.getDefaultRootElement().getElementIndex(start) + 1;
int endline = doc.getDefaultRootElement().getElementIndex(end) + 1;
Font f = textEditor.getFont();
int fontHeight = g.getFontMetrics(f).getHeight();
int fontDesc = g.getFontMetrics(f).getDescent();
int startingY = -1;
try {
startingY = textEditor.modelToView(start).y + fontHeight - fontDesc;
} catch (BadLocationException e1) {
System.err.println(e1.getMessage());
}
g.setFont(f);
for (int line = startline, y = startingY; line <= endline; y += fontHeight, line++) {
String lineNumber = StringGroovyMethods.padLeft(Integer.toString(line), 4, " ");
g.drawString(lineNumber, 0, y);
}
}
开发者ID:apache,项目名称:groovy,代码行数:32,代码来源:ConsoleTextEditor.java
示例12: createComparatorFor
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private static void createComparatorFor(ClassNode classNode, PropertyNode property, boolean reversed) {
String propName = StringGroovyMethods.capitalize((CharSequence) property.getName());
String className = classNode.getName() + "$" + propName + "Comparator";
ClassNode superClass = makeClassSafeWithGenerics(AbstractComparator.class, classNode);
InnerClassNode cmpClass = new InnerClassNode(classNode, className, ACC_PRIVATE | ACC_STATIC, superClass);
classNode.getModule().addClass(cmpClass);
cmpClass.addMethod(new MethodNode(
"compare",
ACC_PUBLIC,
ClassHelper.int_TYPE,
params(param(newClass(classNode), ARG0), param(newClass(classNode), ARG1)),
ClassNode.EMPTY_ARRAY,
createCompareMethodBody(property, reversed)
));
String fieldName = "this$" + propName + "Comparator";
// private final Comparator this$<property>Comparator = new <type>$<property>Comparator();
FieldNode cmpField = classNode.addField(
fieldName,
ACC_STATIC | ACC_FINAL | ACC_PRIVATE | ACC_SYNTHETIC,
COMPARATOR_TYPE,
ctorX(cmpClass));
classNode.addMethod(new MethodNode(
"comparatorBy" + propName,
ACC_PUBLIC | ACC_STATIC,
COMPARATOR_TYPE,
Parameter.EMPTY_ARRAY,
ClassNode.EMPTY_ARRAY,
returnS(fieldX(cmpField))
));
}
开发者ID:apache,项目名称:groovy,代码行数:34,代码来源:SortableASTTransformation.java
示例13: asCollection
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static Collection asCollection(Object value) {
if (value == null) {
return Collections.EMPTY_LIST;
} else if (value instanceof Collection) {
return (Collection) value;
} else if (value instanceof Map) {
Map map = (Map) value;
return map.entrySet();
} else if (value.getClass().isArray()) {
return arrayAsCollection(value);
} else if (value instanceof MethodClosure) {
MethodClosure method = (MethodClosure) value;
IteratorClosureAdapter adapter = new IteratorClosureAdapter(method.getDelegate());
method.call(adapter);
return adapter.asList();
} else if (value instanceof String || value instanceof GString) {
return StringGroovyMethods.toList((CharSequence) value);
} else if (value instanceof File) {
try {
return ResourceGroovyMethods.readLines((File) value);
} catch (IOException e) {
throw new GroovyRuntimeException("Error reading file: " + value, e);
}
} else if (value instanceof Class && ((Class) value).isEnum()) {
Object[] values = (Object[]) InvokerHelper.invokeMethod(value, "values", EMPTY_OBJECT_ARRAY);
return Arrays.asList(values);
} else {
// let's assume it's a collection of 1
return Collections.singletonList(value);
}
}
开发者ID:apache,项目名称:groovy,代码行数:32,代码来源:DefaultTypeTransformation.java
示例14: writeValue
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private static void writeValue(String key, String space, String prefix, Object value, BufferedWriter out) throws IOException {
// key = key.indexOf('.') > -1 ? InvokerHelper.inspect(key) : key;
boolean isKeyword = KEYWORDS.contains(key);
key = isKeyword ? InvokerHelper.inspect(key) : key;
if (!StringGroovyMethods.asBoolean(prefix) && isKeyword) prefix = "this.";
out.append(space).append(prefix).append(key).append('=').append(InvokerHelper.inspect(value));
out.newLine();
}
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:ConfigObject.java
示例15: aFile
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
@And("^a file \"([^\"]*)\":$")
public void aFile(String file, String body) throws Throwable {
Files.write(projectDir.resolve(file), StringUtils.trim(StringGroovyMethods.stripIndent((CharSequence) body)).getBytes());
}
开发者ID:bsideup,项目名称:gradle-maven-sync-plugin,代码行数:5,代码来源:GradleStepdefs.java
示例16: tokenize
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static List<String> tokenize(String rawExcludes) {
return rawExcludes == null ? new ArrayList<String>() : StringGroovyMethods.tokenize(rawExcludes, ", ");
}
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:AbstractASTTransformation.java
示例17: generateCompilerConfigurationFromOptions
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
public static CompilerConfiguration generateCompilerConfigurationFromOptions(CommandLine cli) throws IOException {
// Setup the configuration data
CompilerConfiguration configuration = new CompilerConfiguration();
if (cli.hasOption("classpath")) {
configuration.setClasspath(cli.getOptionValue("classpath"));
}
if (cli.hasOption('d')) {
configuration.setTargetDirectory(cli.getOptionValue('d'));
}
configuration.setParameters(cli.hasOption("pa"));
if (cli.hasOption("encoding")) {
configuration.setSourceEncoding(cli.getOptionValue("encoding"));
}
if (cli.hasOption("basescript")) {
configuration.setScriptBaseClass(cli.getOptionValue("basescript"));
}
// joint compilation parameters
if (cli.hasOption('j')) {
Map<String, Object> compilerOptions = new HashMap<String, Object>();
String[] namedValues = cli.getOptionValues("J");
compilerOptions.put("namedValues", namedValues);
String[] flags = cli.getOptionValues("F");
if (flags != null && cli.hasOption("pa")){
flags = Arrays.copyOf(flags, flags.length + 1);
flags[flags.length - 1] = "parameters";
}
compilerOptions.put("flags", flags);
configuration.setJointCompilationOptions(compilerOptions);
}
if (cli.hasOption("indy")) {
configuration.getOptimizationOptions().put("int", false);
configuration.getOptimizationOptions().put("indy", true);
}
String configScripts = System.getProperty("groovy.starter.configscripts", null);
if (cli.hasOption("configscript") || (configScripts != null && !configScripts.isEmpty())) {
List<String> scripts = new ArrayList<String>();
if (cli.hasOption("configscript")) {
scripts.add(cli.getOptionValue("configscript"));
}
if (configScripts != null) {
scripts.addAll(StringGroovyMethods.tokenize((CharSequence) configScripts, ','));
}
processConfigScripts(scripts, configuration);
}
return configuration;
}
开发者ID:apache,项目名称:groovy,代码行数:59,代码来源:FileSystemCompiler.java
示例18: writeConfig
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private void writeConfig(String prefix, ConfigObject map, BufferedWriter out, int tab, boolean apply) throws IOException {
String space = apply ? StringGroovyMethods.multiply(TAB_CHARACTER, tab) : "";
for (Object o1 : map.keySet()) {
String key = (String) o1;
Object v = map.get(key);
if (v instanceof ConfigObject) {
ConfigObject value = (ConfigObject) v;
if (!value.isEmpty()) {
Object dotsInKeys = null;
for (Object o : value.entrySet()) {
Entry e = (Entry) o;
String k = (String) e.getKey();
if (k.indexOf('.') > -1) {
dotsInKeys = e;
break;
}
}
int configSize = value.size();
Object firstKey = value.keySet().iterator().next();
Object firstValue = value.values().iterator().next();
int firstSize;
if (firstValue instanceof ConfigObject) {
firstSize = ((ConfigObject) firstValue).size();
} else {
firstSize = 1;
}
if (configSize == 1 || DefaultGroovyMethods.asBoolean(dotsInKeys)) {
if (firstSize == 1 && firstValue instanceof ConfigObject) {
key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
String writePrefix = prefix + key + "." + firstKey + ".";
writeConfig(writePrefix, (ConfigObject) firstValue, out, tab, true);
} else if (!DefaultGroovyMethods.asBoolean(dotsInKeys) && firstValue instanceof ConfigObject) {
writeNode(key, space, tab, value, out);
} else {
for (Object j : value.keySet()) {
Object v2 = value.get(j);
Object k2 = ((String) j).indexOf('.') > -1 ? InvokerHelper.inspect(j) : j;
if (v2 instanceof ConfigObject) {
key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
writeConfig(prefix + key, (ConfigObject) v2, out, tab, false);
} else {
writeValue(key + "." + k2, space, prefix, v2, out);
}
}
}
} else {
writeNode(key, space, tab, value, out);
}
}
} else {
writeValue(key, space, prefix, v, out);
}
}
}
开发者ID:apache,项目名称:groovy,代码行数:62,代码来源:ConfigObject.java
示例19: escapeControlCharacters
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
/**
* Escape control characters (below 0x20) with their XML entities, e.g.
* carriage return ({@code Ctrl-M or \r}) becomes {@code }
* Notes:<ul>
* <li>Does not escape non-ascii characters above 0x7e</li>
* <li>Does not treat surrogate pairs specially</li>
* <li>Does not perform Unicode validation on its input</li>
* </ul>
*
* @param orig the original String
* @return A new string in which all characters that require escaping
* have been replaced with the corresponding XML entities.
* @see #escapeXml(String)
*/
public static String escapeControlCharacters(String orig) {
return StringGroovyMethods.collectReplacements(orig, new Closure<String>(null) {
public String doCall(Character arg) {
if (arg < 31) {
return "&#" + (int) arg + ";";
}
return null;
}
});
}
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:XmlUtil.java
示例20: configureOverlay
import org.codehaus.groovy.runtime.StringGroovyMethods; //导入依赖的package包/类
private void configureOverlay(WarOverlay overlay, ExternalDependency dependency) {
War warTask = overlay.getWarTask();
String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());
dependency.setTransitive(false);
Configuration configuration = project.getConfigurations().create(overlay.getConfigurationName());
configuration.setDescription(String.format("Contents of the overlay '%s' for the task '%s'.", overlay.getName(), warTask.getName()));
configuration.getDependencies().add(dependency);
File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
Action<CopySpec> extractOverlay = copySpec -> {
copySpec.into(destinationDir);
copySpec.from((Callable<FileTree>) () -> project.zipTree(configuration.getSingleFile()));
};
Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay);
overlay.getWarCopySpec().from(extractOverlayTask);
if (overlay.isEnableCompilation()) {
project.sync(extractOverlay);
project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);
ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
.builtBy(extractOverlayTask);
project.getDependencies().add(COMPILE_CLASSPATH_CONFIGURATION_NAME, classes);
project.getDependencies().add(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, classes);
FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree()
.matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**"));
project.getDependencies().add(COMPILE_CLASSPATH_CONFIGURATION_NAME, libs);
project.getDependencies().add(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, libs);
}
}
开发者ID:freefair,项目名称:gradle-plugins,代码行数:43,代码来源:WarOverlayPlugin.java
注:本文中的org.codehaus.groovy.runtime.StringGroovyMethods类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论