当前位置: 首页>>代码示例>>Java>>正文


Java GString.toString方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:http-builder-ng,项目名称:http-builder-ng,代码行数:22,代码来源:UriBuilder.java

示例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);
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:StringGroovyMethods.java

示例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});
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:InvokeConstructorTest.java


注:本文中的groovy.lang.GString.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。