本文整理汇总了Java中groovy.lang.GString.toString方法的典型用法代码示例。如果您正苦于以下问题:Java GString.toString方法的具体用法?Java GString.toString怎么用?Java GString.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类groovy.lang.GString
的用法示例。
在下文中一共展示了GString.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toURI
import groovy.lang.GString; //导入方法依赖的package包/类
/**
* Converts the parts of the `UriBuilder` to the `URI` object instance.
*
* @return the generated `URI` representing the parts contained in the builder
*/
public URI toURI() throws URISyntaxException {
final String scheme = traverse(this, UriBuilder::getParent, UriBuilder::getScheme, Traverser::notNull);
final Integer port = traverse(this, UriBuilder::getParent, UriBuilder::getPort, notValue(DEFAULT_PORT));
final String host = traverse(this, UriBuilder::getParent, UriBuilder::getHost, Traverser::notNull);
final GString path = traverse(this, UriBuilder::getParent, UriBuilder::getPath, Traverser::notNull);
final String query = populateQueryString(traverse(this, UriBuilder::getParent, UriBuilder::getQuery, Traverser::nonEmptyMap));
final String fragment = traverse(this, UriBuilder::getParent, UriBuilder::getFragment, Traverser::notNull);
final String userInfo = traverse(this, UriBuilder::getParent, UriBuilder::getUserInfo, Traverser::notNull);
final Boolean useRaw = traverse(this, UriBuilder::getParent, UriBuilder::getUseRawValues, Traverser::notNull);
if (useRaw != null && useRaw) {
return toRawURI(scheme, port, host, path, query, fragment, userInfo);
} else {
return new URI(scheme, userInfo, host, (port == null ? -1 : port), ((path == null) ? null : path.toString()), query, fragment);
}
}
示例2: asType
import groovy.lang.GString; //导入方法依赖的package包/类
/**
* Converts the GString to a File, or delegates to the default
* {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(Object, Class)}
*
* @param self a GString
* @param c the desired class
* @return the converted object
* @since 1.5.0
*/
@SuppressWarnings("unchecked")
public static <T> T asType(GString self, Class<T> c) {
if (c == File.class) {
return (T) new File(self.toString());
} else if (Number.class.isAssignableFrom(c) || c.isPrimitive()) {
return asType(self.toString(), c);
}
return DefaultGroovyMethods.asType((Object) self, c);
}
示例3: testConstructorWithGStringCoercion
import groovy.lang.GString; //导入方法依赖的package包/类
public void testConstructorWithGStringCoercion() throws Throwable {
GString gstring = new GString(new Object[]{new Integer(123)}) {
public String[] getStrings() {
return new String[]{""};
}
};
Object expected = new Long(gstring.toString());
assertConstructor(expected, new Object[]{gstring});
}