|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
org.codehaus.groovy.runtime.SocketGroovyMethods
public class SocketGroovyMethods
This class defines new groovy methods for Sockets which enhance JDK classes inside the Groovy environment.
NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport |
---|
DefaultGroovyMethodsSupport.RangeInfo |
Constructor Summary | |
---|---|
SocketGroovyMethods()
|
Method Summary | ||
---|---|---|
static java.net.Socket |
accept(java.net.ServerSocket serverSocket,
boolean runInANewThread,
Closure closure)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread, as needed. |
|
static java.net.Socket |
accept(java.net.ServerSocket serverSocket,
Closure closure)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread. |
|
static java.io.OutputStream |
leftShift(java.net.Socket self,
byte[] value)
Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket |
|
static java.io.Writer |
leftShift(java.net.Socket self,
java.lang.Object value)
Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket |
|
static
|
withObjectStreams(java.net.Socket socket,
Closure<T> closure)
Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure. |
|
static
|
withStreams(java.net.Socket socket,
Closure<T> closure)
Passes the Socket's InputStream and OutputStream to the closure. |
Methods inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport |
---|
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketGroovyMethods()
Method Detail |
---|
public static <T> T withStreams(java.net.Socket socket, Closure<T> closure) throws java.io.IOException
socket
- a Socketclosure
- a Closure
java.io.IOException
- if an IOException occurs.public static <T> T withObjectStreams(java.net.Socket socket, Closure<T> closure) throws java.io.IOException
socket
- this Socketclosure
- a Closure
java.io.IOException
- if an IOException occurs.public static java.io.Writer leftShift(java.net.Socket self, java.lang.Object value) throws java.io.IOException
self
- a Socketvalue
- a value to append
java.io.IOException
- if an IOException occurs.public static java.io.OutputStream leftShift(java.net.Socket self, byte[] value) throws java.io.IOException
self
- a Socketvalue
- a value to append
java.io.IOException
- if an IOException occurs.public static java.net.Socket accept(java.net.ServerSocket serverSocket, Closure closure) throws java.io.IOException
serverSocket
- a ServerSocketclosure
- a Closure
java.io.IOException
- if an IOException occurs.ServerSocket.accept()
public static java.net.Socket accept(java.net.ServerSocket serverSocket, boolean runInANewThread, Closure closure) throws java.io.IOException
serverSocket
- a ServerSocketrunInANewThread
- This flag should be true, if the closure should be invoked in a new thread, else false.closure
- a Closure
java.io.IOException
- if an IOException occurs.ServerSocket.accept()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |