new AddressBuilder() .withName("Sherlock Holmes") .withStreet("221b Baker Street") .withCity("London") .withPostCode("NW1", "3RX") .build();
/** * Set the anchor section of this {@link Address}. */ public AddressBuilderAnchor anchor(String anchor) { return parent.anchor(anchor); }
@Override public Address build() { return parent.build(); }
@Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { // TODO integrate rewrite with navigation (See PrettyNavigationHandler) if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } }
/** * Builds a special outcome processed by {@link RewriteNavigationHandler} */ private String buildRedirectOutcome() { AddressBuilderPath builderPath = AddressBuilder.begin().pathEncoded(viewId); for (Entry<String, List<String>> param : parameters.entrySet()) { String[] values = param.getValue().toArray(new String[param.getValue().size()]); builderPath.queryEncoded(param.getKey(), (Object[]) values); } String url = builderPath.toString(); return RewriteNavigationHandler.REDIRECT_PREFIX + url; }
@Override public Address buildLiteral() { return parent.buildLiteral(); }
/** * Set the path section of this {@link Address}. The given value will be stored without additional * encoding or decoding. */ public AddressBuilderPath path(CharSequence path) { return parent.path(path); }
query = decodeHTMLAmpersands(query); int index = 0; query(entry.getKey(), entry.getValue().toArray());
/** * Set the domain section of this {@link Address}. */ public AddressBuilderDomain domain(CharSequence domain) { return parent.domain(domain); }
this.queries = Collections.unmodifiableMap(parent.getQueries()); query = toQuery(parent.queries).toString();
@Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { // TODO integrate rewrite with navigation (See PrettyNavigationHandler) if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } }
/** * Builds a special outcome processed by {@link RewriteNavigationHandler} */ private String buildRedirectOutcome() { AddressBuilderPath builderPath = AddressBuilder.begin().pathEncoded(viewId); for (Entry<String, List<String>> param : parameters.entrySet()) { String[] values = param.getValue().toArray(new String[param.getValue().size()]); builderPath.queryEncoded(param.getKey(), (Object[]) values); } String url = builderPath.toString(); return RewriteNavigationHandler.REDIRECT_PREFIX + url; }
@Override public Address buildLiteral() { return parent.buildLiteral(); }
/** * Set the path section of this {@link Address}. The given value will be stored without additional encoding or * decoding. */ public AddressBuilderPath path(CharSequence path) { return parent.path(path); }
query = decodeHTMLAmpersands(query); int index = 0; query(entry.getKey(), entry.getValue().toArray());
/** * Set the domain section of this {@link Address}. */ public AddressBuilderDomain domain(CharSequence domain) { return parent.domain(domain); }
this.queries = Collections.unmodifiableMap(parent.getQueries()); query = toQuery(parent.queries).toString();
@Override public String encodeRedirectURL(final String url) { Address address = AddressBuilder.create(url); OutboundServletRewrite<ServletRequest, ServletResponse, Address> event = rewrite(address); if (event.getFlow().is(ServletRewriteFlow.ABORT_REQUEST)) { return event.getOutboundAddress().toString(); } return super.encodeRedirectURL(event.getOutboundAddress().toString()); }
/** * Create a new {@link Address} from the given URL. Improperly formatted or encoded URLs are not parse-able and will * result in an exception. No builder parameterization is possible using this method. * * @see http://en.wikipedia.org/wiki/URI_scheme * @throws IllegalArgumentException when the input URL or URL fragment is not valid. */ public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
@Override public Address buildLiteral() { return parent.buildLiteral(); }