public class SocketClient extends Object
Constructor and Description |
---|
SocketClient()
Construct socket client with default host, port and programming language
of the source files to be uploaded.
|
SocketClient(String server,
int port)
Construct socket client by setting a server and port.
|
SocketClient(String server,
int port,
String language)
Construct socket client by setting a server name and port as well as the
programming language of the source files.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close connection to the MOSS server gracefully.
|
void |
connect()
Connect to the MOSS server and set the input and output streams for
communication.
|
Stage |
getCurrentStage() |
int |
getIncSetID()
Deprecated.
|
String |
getLanguage() |
String |
getOptC() |
int |
getOptD() |
long |
getOptM() |
long |
getOptN() |
int |
getOptX() |
int |
getPort() |
URL |
getResultURL() |
String |
getServer() |
int |
getSetID() |
Socket |
getSocket() |
List<String> |
getSupportedLanguages() |
String |
getUserID() |
String |
normalizeFilename(String filename) |
String |
readFromServer()
Read a single line of the server's response.
|
void |
run()
Shortcut method to connect to the MOSS server, send all initialization
parameters and set the programming language of all source files.
|
void |
sendInitialization()
Sends initialization commands to the server.
|
void |
sendLanguage()
Sends a command to the server to define the programming language of all
source files.
|
void |
sendLanguage(String language)
Sends a command to the server to define the programming language of all
source files.
|
void |
sendQuery()
Sends a command to tell the server that all files have been uploaded and
the search for plagiarism can start.
|
void |
setLanguage(String language)
Set the programming language of all source files.
|
void |
setOptC(String optC)
Sets a comment string which is attached to the MOSS report.
|
void |
setOptM(long optM)
Set the maximum amount of times a source code passage may appear before
it is ignored and treated as base code.
|
void |
setOptN(long optN)
Sets how many matches should be displayed in the MOSS results.
|
void |
setOptX(int optX)
Setting this value to 1 enables the experimental MOSS server.
|
void |
setPort(int port) |
void |
setServer(String server) |
void |
setSocket(Socket socket) |
void |
setUserID(String userID)
Set the MOSS user id for authentication with the MOSS server.
|
void |
uploadBaseFile(File file)
Uploads a single base file to the MOSS server.
|
void |
uploadFile(File file)
Uploads a single file to the MOSS server.
|
void |
uploadFile(File file,
boolean isBaseFile)
Uploads a single file to the MOSS server.
|
public SocketClient()
public SocketClient(String server, int port)
server
- host name or IP of the MOSS serverport
- port of the MOSS serverpublic SocketClient(String server, int port, String language)
server
- host name or IP of the MOSS serverport
- port of the MOSS serverlanguage
- programming language of all source filespublic void close()
public void connect() throws UnknownHostException, IOException, SecurityException
UnknownHostException
- if host resolution failsIOException
- if setting up the input streams failsSecurityException
- if a connection is disallowed by your security managerpublic Stage getCurrentStage()
@Deprecated public int getIncSetID()
public String getLanguage()
public String getOptC()
public int getOptD()
public long getOptM()
public long getOptN()
public int getOptX()
public int getPort()
public URL getResultURL()
public String getServer()
public int getSetID()
public Socket getSocket()
public List<String> getSupportedLanguages()
public String getUserID()
public String readFromServer() throws IOException
IOException
- if it was not possible to read from the socketpublic void run() throws MossException, IOException, UnknownHostException
MossException
- if the MOSS server returns an errorIOException
- if there is a (network) error while reading the server
responseUnknownHostException
- if host resolution failspublic void sendInitialization() throws MossException
MossException
public void sendLanguage() throws MossException, IOException
MossException
- if this language is not supported by the MOSS serverIOException
- if there is an error while reading the server answersetLanguage(String)
public void sendLanguage(String language) throws MossException, IOException
language
- the programming language of all source filesMossException
- if this language is not supported by the MOSS serverIOException
- if there is an error while reading the server answerpublic void sendQuery() throws MossException, IOException
MossException
- if there is an error when receiving results from the MOSS
serverIOException
- if the server communication failspublic void setLanguage(String language) throws MossException
language
- the programming language in which source file is written in.
Valid programming languages are: c, cc, java, ml, pascal, ada,
lisp, schema, haskell, fortran, ascii, vhdl, perl, matlab,
python, mips, prolog, spice, vb, csharp, modula2, a8086,
javascript and plsql.MossException
public void setOptC(String optC)
optC
- comment stringpublic void setOptM(long optM)
optM
- times a passage may appear before it is ignoredpublic void setOptN(long optN)
optN
- how many matches to displaypublic void setOptX(int optX)
optX
- 0 or 1. 0: regular MOSS server, 1: experimental MOSS server.public void setPort(int port)
public void setServer(String server)
public void setSocket(Socket socket)
public void setUserID(String userID)
userID
- your personalized ID to authenticate with. It should look like
/[0-9]+/ and is available on the MOSS page located at
http://theory.stanford.edu/~aiken/moss/public void uploadFile(File file) throws IOException
file
- the source code file to be uploadedIOException
- if the file could not be readpublic void uploadBaseFile(File file) throws IOException
file
- the base file to be uploadedIOException
- if the file could not be readpublic void uploadFile(File file, boolean isBaseFile) throws IOException
file
- the source code file to be uploadedisBaseFile
- true is base file. false otherwise.IOException
- if the file could not be readCopyright © 2012-2016. All Rights Reserved.