input
stringlengths
10
828
output
stringlengths
5
107
protected void disconnected if connected connected false die
the client has become disconnected from the server
private void send chat int conn id string origin string message send conn id new packet packet id packet chat origin message
transmits a chat message to one player
protected void send packet packet packet zip data try if out null out new object output stream socket get output stream out flush out reset write each packet fresh a lot changes out write object packet out flush system out println client packet packet get command sent catch ioexception ex system err println client error sending command
send the message to the server
private void send chat string origin string message string chat origin message send new packet packet id packet chat chat
transmits a chat message to all players
private void create game int conn id packet packet check if coach is already playing a game if get server game for connection conn id null send conn id new packet packet id error create game already joined game logger error connection conn id tried to create game while already playing game return create the new game int game id get free game id team team team packet get object 0 server game server game new server game game id this conn id team hosted games add server game logger info connection conn id created new game game id
creates a new game on this server and joins the coach
public void add close window listener close window listener listener check widget if listener null swt error swt error null argument web browser add close window listener listener
adds the listener to the collection of listeners who will be
public void add location listener location listener listener check widget if listener null swt error swt error null argument web browser add location listener listener
adds the listener to the collection of listeners who will be
public void add open window listener open window listener listener check widget if listener null swt error swt error null argument web browser add open window listener listener
adds the listener to the collection of listeners who will be
public void add progress listener progress listener listener check widget if listener null swt error swt error null argument web browser add progress listener listener
adds the listener to the collection of listeners who will be
public void add status text listener status text listener listener check widget if listener null swt error swt error null argument web browser add status text listener listener
adds the listener to the collection of listeners who will be
public void add title listener title listener listener check widget if listener null swt error swt error null argument web browser add title listener listener
adds the listener to the collection of listeners who will be
public void add visibility window listener visibility window listener listener check widget if listener null swt error swt error null argument web browser add visibility window listener listener
adds the listener to the collection of listeners who will be
public boolean back check widget return web browser back
navigate to the previous session history item
public boolean execute string script check widget if script null swt error swt error null argument return web browser execute script
execute the specified script
public boolean forward check widget return web browser forward
navigate to the next session history item
public string get url check widget return web browser get url
returns the current url
public boolean is back enabled check widget return web browser is back enabled
returns code true code if the receiver can navigate to the
public boolean is forward enabled check widget return web browser is forward enabled
returns code true code if the receiver can navigate to the
public void refresh check widget web browser refresh
refresh the current page
public void remove close window listener close window listener listener check widget if listener null swt error swt error null argument web browser remove close window listener listener
removes the listener from the collection of listeners who will
public void remove location listener location listener listener check widget if listener null swt error swt error null argument web browser remove location listener listener
removes the listener from the collection of listeners who will
public void remove open window listener open window listener listener check widget if listener null swt error swt error null argument web browser remove open window listener listener
removes the listener from the collection of listeners who will
public void remove progress listener progress listener listener check widget if listener null swt error swt error null argument web browser remove progress listener listener
removes the listener from the collection of listeners who will
public void remove status text listener status text listener listener check widget if listener null swt error swt error null argument web browser remove status text listener listener
removes the listener from the collection of listeners who will
public void remove title listener title listener listener check widget if listener null swt error swt error null argument web browser remove title listener listener
removes the listener from the collection of listeners who will
public void remove visibility window listener visibility window listener listener check widget if listener null swt error swt error null argument web browser remove visibility window listener listener
removes the listener from the collection of listeners who will
public boolean set url string url check widget if url null swt error swt error null argument return web browser set url url
loads a url
public void stop check widget web browser stop
stop any loading and rendering activity
public node list extract list string html node list nodes null try parser parser parser create parser html 8859 1 nodes parser extract all nodes that match new node filter public boolean accept node node if node get text trim length 3 return false else return true catch exception e e print stack trace return nodes
extract the data from page
public void create part control composite parent make actions hook context menu hook double click action contribute to action bars
this is a callback that will allow us
public connection get connection string data source name if data source name null throw new system exception data source name in connection factory cannot be null try data source ds data source factory get instance get data source data source name return ds get connection catch exception e e print stack trace throw new system exception e
finds and returns a connection from the given data source
public boolean is connection alive string data source name if data source name null throw new system exception data source name in connection factory cannot be null connection connection null try data source ds data source factory get instance get data source data source name connection ds get connection return connection null catch exception e return false finally clean connection
finds and returns whether the datasource is valid or not
protected void apply sales tax rounding money money money round to nearest five cent
adapt to moneys interface
public int hash code return new double my double hash code
using doubles hash code
public void set all parameters map parameters if parameters null parameters put all parameters
use this for post ed parameters that dont appear on the query string
public void test sales tax percentage should be10 item food new item this item new money 10 boolean false sales tax sales tax new sales tax sales tax visit food assert true food get sales tax equals new money 1
much better implemented with jmock verification
public string get character encoding return null fixme
i dont think this is needed for the most recent version
public void test visitor should not calculate import duty for non imported items book book new book this book new money 12 2 boolean false import duty duty new import duty duty visit book assert true book get sales tax equals money zero dollar
much better implemented with jmock verification
public void test visitor should calculate imported duty for imported items book book new book this book new money 12 2 boolean true import duty duty new import duty duty visit book assert false book get sales tax equals money zero dollar
much better implemented with jmock verification
public void test applicable percentage of tax should be5 book book new book this book new money 12 2 boolean true import duty duty new import duty duty visit book assert equals new money 0 65 book get sales tax
much better implemented with jmock verification
public void test accept should visit the visitor item item1 new item item name new money 12 32 boolean true item1 accept new sales tax assert true item1 get sales tax equals money zero dollar
much better implemented with jmock verification
public string encode url string url return null fixme
methods related to rewriting urls for sessions
public void run ping test run
executes the test
public string get latest version throws malformed urlexception xml rpc exception xml rpc client config impl config new xml rpc client config impl config set server url new url this server xml rpc client client new xml rpc client client set config config object params new object string version string client execute get latest version params return version
executes a xml rpc call to retrieve the latest client versionnumber
public void run try inet address addr inet address get by name this target if addr get host address to string equals this expected debug log resolve test test ok this result put resolve ok else debug log resolve test test failed no match got addr get host address to string but expected expected this result put resolve no match catch unknown host exception e debug log resolve test test failed resolve failed this result put resolve resolve fail
executes the test
public void store result hash map result map throws xml rpc exception malformed urlexception xml rpc client config impl config new xml rpc client config impl config set server url new url this server xml rpc client client new xml rpc client client set config config object params new object result map client execute store results params boolean rpccall boolean client execute store results params
executes a xml rpc call that will write the testresult into the database
public void run try socket s new socket inet address addr inet address get by name this target socket address sock addr new inet socket address addr port s connect sock addr 300 debug log connectivity test test ok this result put connectivity ok s close catch exception e debug log connectivity test test failed this result put connectivity fail
the actuall testing part of the test
public void write userdata string filename string username string password create the base for the xml file with the userdata element root el new element userdata rootelement document output doc new document root el root el add content new element username add content username root el add content new element password add content password try xmloutputter output new xmloutputter format get pretty format file writer writer new file writer filename output output output doc writer writer close catch exception e
write the userdata username password to a xmlfile filename
public boolean var file exists string filename i just try to build a document if this is possible file exists i return true if it fails and throws an exception and therefore does not exist i return false boolean exists try new saxbuilder false build this get class get resource filename exists true catch exception ex exists false return exists
returns a boolean depending on the existence of the file filename
public string get var value string filename string parent string child throws jdomexception ioexception saxbuilder builder new saxbuilder false document doc builder build this get class get resource filename return doc get root element get child parent get child child get text
reads a value from the xmlfile filename from the given parent
public string read userdata string filename throws jdomexception ioexception string userdata null saxbuilder builder new saxbuilder false document doc builder build new file filename element root el doc get root element userdata root el get child username get text userdata root el get child password get text return userdata
reads the userdata from the given filename
public string read cfg version string filename string versie nr null try saxbuilder builder new saxbuilder false document doc builder build new file filename element root el doc get root element versie nr root el get child cfg version get text catch exception e system out println e to string return return versie nr
read the versionnumber from the configfile
public void set main manifest file manifest main manifest manifest log set main manifest manifest project msg verbose
use main manifest file instead of this method
public void test find resources in main jar throws ioexception class loader cl get class get class loader system out println classloader cl enumeration e cl get resources index html int count 0 while e has more elements system out println test find resources in jars e next element count if count 1 fail test find resources in main error huh should find 1 copies of index html found count else system out println test find resources in jars ok
test the ability to find resources inside various places
public void test resource relative url throws ioexception malformed urlexception count string image button mail 1 gif now do it using get resource system out println test resource relative url opening using get resource image url url test class get resource image system out println test resource relative url opened url if url null fail test resource relative url error huh should find image using get resource else input stream is url open stream if is null fail test resource relative url error huh should find image as a resource else system out println test resource relative url ok
tests the ability to load a resource from a relative path
public void test external count external external new external class loader cl external get class get class loader system out println test external external loaded by cl system out println test external codebase external get class get protection domain get code source external external
tests the ability to load classes through a classpath argument passed into
public void test external file throws ioexception count open and verify copy using classloader class loader cl this get class get class loader url url cl get resource expand subdir txt copy url open stream null open and verify copy using class input stream is this get class get resource as stream expand subdir txt copy is null
tests the ability to load classes through a classpath argument passed into
public void test get resource throws ioexception count string resource resources resource 1 txt input stream is test class get resource resource open stream if is null fail test get resource error unable to load resource using test class get resource open stream else system out println test get resource ok able to load resource using test class get resource open stream
exercises the class
public class load class string name boolean resolve throws class not found exception set the context classloader in case any classloaders delegate to it otherwise it would default to the sun misc launcher app class loader which is used to launch the jar application and attempts to load through it would fail if that code is encapsulated inside the one jar access controller do privileged new privileged action public object run thread current thread set context class loader jar class loader this return null return super load class name resolve
override to ensure that this classloader is the thread context classloader
protected string canon string path path path replace all string canon path string next canon do next canon canon canon replace first while next equals canon return canon
make a path canonical removing
protected string resolve string resource if resource starts with resource resource substring 1 string resource null string caller get caller byte code caller code byte code byte code get caller if caller code null jar local first then global string tmp caller code codebase resource if byte code get tmp null resource tmp if resource null one last try if byte code get resource null resource null else resource resource verbose resource resource resolved to resource caller code null in codebase caller code codebase unknown codebase return resource
resolve a resource name
public void start string output xxx command line interpreter comman dinterpreter new command line interpreter command window inicia o command line interpreter e envia o command line window this command interpreter comman dinterpreter coloca disponivel na class inteira command window set text area street racer command line v 0 0 3 build n n command window append text area escreva help ou para mais informa es n n command window append text area command window j text field1 grab focus da o foco para poder escrever logo
inicia o command line
public int get vibrate time return default vibrate time
retrieve the amount of time to vibrate
public void set position int x int y m x x m y y
set the position of the tank explosion
public bitmap get bitmap return m bitmap
retrieve the bitmap associated with the generated terrain
public int get height at int index make sure the requested index is only in the positive half of the sine wave s period if index 0 index m period 2 return 1 return int math round m amplitude math sin index m period 2 math pi
retrieve the sine wave height at a given x index
public boolean is terrain int x int y if x 0 y 0 x m width y m height return false else return m bitmap get pixel x y color transparent
determine whether the pixel at the given position is terrain or sky
public boolean is settled return m unsettled columns is empty
determine whether there is any unsettled land pending which can result from explosion
public void set touch enabled boolean touch enabled m touch enabled touch enabled
set whether touches should be responsive or not
public void init thread m thread new game thread m surface holder m context
initialize the game thread
public game thread get thread return m thread
fetches the animation thread corresponding to this lunar view
public void surface changed surface holder holder int format int width int height m thread set surface size width height
callback invoked when the surface dimensions change
public void set initial position double x double y m initial x x m initial y y set current position x y
set the initial and current physical location of object
public void set current position double x double y m current x x m current y y
set the current physical location of object
public void set velocity double dx double dy m dx dx m dy dy
set the velocity of object
public void set wind int wind value m wind wind value
set the wind value associated with this object
public double get x return m current x
getter method for x position
public double get y return m current y
getter method for y position
public int get icon return m icon
retrieve the sprite icon associated with a given tank type
public boolean start next round log d game state start next round round integer to string m current round integer to string m num rounds if m current round 1 m num rounds return false else set up state for the new round m current round randomize terrain place players m terrain init terrain m current player index 1 m ordered players get random player ordering for scorched player player m players player reset damage player set health 100 player set power 300 start next turn return true
initialize round specific data and begin the next round
public void increment angle int delta m angle delta if m angle max angle m angle min angle m angle value set text integer to string m angle
increment the angle which is displayed on the hud
public int get current round return m current round
get the integer value of the current round
public void decrement angle int delta m angle delta if m angle min angle m angle max angle m angle value set text integer to string m angle
decrement the displayed angle
public long get cash return m cash
retrieve the amount of money the player currently has
public int get num rounds return m num rounds
get the total number of rounds in the current game
public void set num rounds int num rounds m num rounds num rounds
set the number of rounds in the current game
public boolean is wind enabled return m wind enabled
see if wind is enabled in the current game
public void set wind enabled boolean wind enabled m wind enabled wind enabled
set whether wind is enabled in the current game
public void set health int percent m health bar set progress percent m health label set text health integer to string percent m health label set text color color rgb int 255 190 0 percent 100 65 int 65 190 0 percent 100
set the displayed health for the current player
public void set players array list scorched player players m players players
set the list of players in the game
public void add player scorched player player m players add player
add a player to the game
public terrain get terrain return m terrain
retrieve the current terrain for the game
public long get earned cash return m earned cash
retrieve the total amount of money a player has earned
public scorched player get current player if m current player index 1 m ordered players size 0 return null else return m ordered players get m current player index
retrieve the player whose turn it currently is
public void set wind int value int magnitude math abs value m wind value set text value 0 integer to string magnitude value 0 m wind value set text color color rgb int 196 128 0 magnitude 100 int 196 128 0 magnitude 100 255
set the displayed wind value
public int get wind value if m wind enabled get current round 0 return 0 return m wind value
retrieve the current value of the wind
public int get damage dealt return m damage dealt
retrieve the total amount of damage the player has dealt to others
public void set weapon weapon type weapon m weapon icon set image bitmap bitmap factory decode resource get resources weapon get icon m weapon label set text weapon get name
set the displayed weapon type
public void increment cash long delta cash if delta cash 0 m earned cash delta cash m cash delta cash
increment the amount of cash a player has earned
private void randomize terrain long gen start time system current time millis clean up resources before we make our new terrain if m terrain null m terrain get bitmap null m terrain get bitmap recycle m terrain null system gc m terrain new sine wave terrain generator generate terrain log d game state randomize terrain generated in long to string system current time millis gen start time ms
create a new terrain for the round