/** * Tracks connecting to the target. * * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void connectTarget(final boolean secure) { Asserts.check(!this.connected, "Already connected"); this.connected = true; this.secure = secure; }
@Override public int available() { final AsyncEntityProducer producer = entityProducerRef.get(); Asserts.notNull(producer, "Entity producer"); return producer.available(); }
/** * Tracks tunnelling to the target. * * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void tunnelTarget(final boolean secure) { Asserts.check(this.connected, "No tunnel unless connected"); Asserts.notNull(this.proxyChain, "No tunnel without proxy"); this.tunnelled = TunnelType.TUNNELLED; this.secure = secure; }
@Test(expected=IllegalStateException.class) public void testExpressionNotBlankFail3() { Asserts.notBlank(" \t \n\r", "Stuff"); }
@Test(expected=IllegalStateException.class) public void testExpressionNotEmptyFail1() { Asserts.notEmpty((String) null, "Stuff"); }
/** * Tracks tunnelling to a proxy in a proxy chain. * This will extend the tracked proxy chain, but it does not mark * the route as tunnelled. Only end-to-end tunnels are considered there. * * @param proxy the proxy tunnelled to * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void tunnelProxy(final HttpHost proxy, final boolean secure) { Args.notNull(proxy, "Proxy host"); Asserts.check(this.connected, "No tunnel unless connected"); Asserts.notNull(this.proxyChain, "No tunnel without proxy"); // prepare an extended proxy chain final HttpHost[] proxies = new HttpHost[this.proxyChain.length+1]; System.arraycopy(this.proxyChain, 0, proxies, 0, this.proxyChain.length); proxies[proxies.length-1] = proxy; this.proxyChain = proxies; this.secure = secure; }
@Test(expected=IllegalStateException.class) public void testExpressionNotEmptyBlank1() { Asserts.notBlank((String) null, "Stuff"); }
@Test(expected=IllegalStateException.class) public void testExpressionNotEmptyFail2() { Asserts.notEmpty("", "Stuff"); }
@Override public void produce(final DataStreamChannel channel) throws IOException { final AsyncEntityProducer producer = entityProducerRef.get(); Asserts.notNull(producer, "Entity producer"); producer.produce(channel); }
/** * Tracks layering a protocol. * * @param secure {@code true} if the route is secure, * {@code false} otherwise */ public final void layerProtocol(final boolean secure) { // it is possible to layer a protocol over a direct connection, // although this case is probably not considered elsewhere Asserts.check(this.connected, "No layered protocol unless connected"); this.layered = LayerType.LAYERED; this.secure = secure; }
@Test(expected=IllegalStateException.class) public void testExpressionNotEmptyBlank2() { Asserts.notBlank("", "Stuff"); }
@Override public void produce(final DataStreamChannel channel) throws IOException { final AsyncEntityProducer producer = entityProducerRef.get(); Asserts.notNull(producer, "Entity producer"); producer.produce(channel); }
protected void assertNotCompleted() { Asserts.check(!this.completed, "Encoding process already completed"); }
@Override public int available() { final AsyncEntityProducer producer = entityProducerRef.get(); Asserts.notNull(producer, "Entity producer"); return producer.available(); }
protected void assertNotCompleted() { Asserts.check(!this.completed, "Encoding process already completed"); }
private IOEventHandler ensureHandler() { final IOEventHandler handler = handlerRef.get(); Asserts.notNull(handler, "IO event handler"); return handler; }
/** * Obtains the content, once only. * * @return the content, if this is the first call to this method * since {@link #setContent setContent} has been called * * @throws IllegalStateException * if the content has not been provided */ @Override public InputStream getContent() throws IllegalStateException { Asserts.check(this.content != null, "Content has not been provided"); return this.content; }
private IOEventHandler ensureHandler() { final IOEventHandler handler = handlerRef.get(); Asserts.notNull(handler, "IO event handler"); return handler; }
/** * Obtains the content, once only. * * @return the content, if this is the first call to this method * since {@link #setContent setContent} has been called * * @throws IllegalStateException * if the content has not been provided */ @Override public InputStream getContent() throws IllegalStateException { Asserts.check(this.content != null, "Content has not been provided"); return this.content; }