public GString plus(String that) { return plus(new GStringImpl(EMPTY_OBJECT_ARRAY, new String[] { that })); }
@Test public void testCoerceCharSequenceToString() { assertEquals(coerce(new StringBuilder("abc"), String.class), "abc"); assertEquals(coerce(new GStringImpl(new Object[0], new String[0]), String.class), ""); }
@Test public void testCoerceCharSequenceToString() { assertEquals(TypeCoercions.coerce(new StringBuilder("abc"), String.class), "abc"); assertEquals(TypeCoercions.coerce(new GStringImpl(new Object[0], new String[0]), String.class), ""); }
public GString plus(GString that) { Object[] values = getValues(); return new GStringImpl(appendValues(values, that.getValues()), appendStrings(getStrings(), that.getStrings(), values.length)); }
/** * Sets the path part of the URI. * * @param str the path part of the URI * @return a reference to the builder */ public UriBuilder setPath(final String str) { return setPath(new GStringImpl(EMPTY, new String[]{str})); }
/** * Sets the path part of the URI. * * @param str the path part of the URI * @return a reference to the builder */ public UriBuilder setPath(final String str) { final String[] parts; if (str.startsWith("/")) { parts = new String[]{str}; } else { final String base = getPath().toString(); parts = new String[]{base, base.endsWith("/") ? "" : "/", str}; } return setPath(new GStringImpl(EMPTY, parts)); }
/** * Sets the path part of the URI. * * @param str the path part of the URI * @return a reference to the builder */ public UriBuilder setPath(final String str) { final String[] parts; if (str.startsWith("/")) { parts = new String[]{str}; } else { final String base = getPath().toString(); parts = new String[]{base, base.endsWith("/") ? "" : "/", str}; } return setPath(new GStringImpl(EMPTY, parts)); }
protected final void populateFrom(final URI uri) { try { setScheme(uri.getScheme()); setPort(uri.getPort()); setHost(uri.getHost()); final String path = uri.getPath(); if (path != null) { setPath(new GStringImpl(EMPTY, new String[]{path})); } final String rawQuery = uri.getQuery(); if (rawQuery != null) { setQuery(Form.decode(new StringBuilder(rawQuery), StandardCharsets.UTF_8)); } setFragment(uri.getFragment()); setUserInfo(uri.getUserInfo()); } catch (IOException e) { throw new RuntimeException(e); } }
protected final void populateFrom(final URI uri) { boolean useRaw = useRawValues != null ? useRawValues : false; try { setScheme(uri.getScheme()); setPort(uri.getPort()); setHost(uri.getHost()); final String path = useRaw ? uri.getRawPath() : uri.getPath(); if (path != null) { setPath(new GStringImpl(EMPTY, new String[]{path})); } final String rawQuery = useRaw ? uri.getRawQuery() : uri.getQuery(); if (rawQuery != null) { if (useRaw) { setQuery(extractQueryMap(rawQuery)); } else { setQuery(Form.decode(new StringBuilder(rawQuery), UTF_8)); } } setFragment(useRaw ? uri.getRawFragment() : uri.getFragment()); setUserInfo(useRaw ? uri.getRawUserInfo() : uri.getUserInfo()); } catch (IOException e) { //this seems o.k. to just convert to a runtime exception, //we started with a valid URI, so this should never happen. throw new RuntimeException(e); } }
protected final void populateFrom(final URI uri) { boolean useRaw = useRawValues != null ? useRawValues : false; try { setScheme(uri.getScheme()); setPort(uri.getPort()); setHost(uri.getHost()); final String path = useRaw ? uri.getRawPath() : uri.getPath(); if (path != null) { setPath(new GStringImpl(EMPTY, new String[]{path})); } final String rawQuery = useRaw ? uri.getRawQuery() : uri.getQuery(); if (rawQuery != null) { if (useRaw) { setQuery(extractQueryMap(rawQuery)); } else { setQuery(Form.decode(new StringBuilder(rawQuery), UTF_8)); } } setFragment(useRaw ? uri.getRawFragment() : uri.getFragment()); setUserInfo(useRaw ? uri.getRawUserInfo() : uri.getUserInfo()); } catch (IOException e) { //this seems o.k. to just convert to a runtime exception, //we started with a valid URI, so this should never happen. throw new RuntimeException(e); } }