input
stringlengths
10
828
output
stringlengths
5
107
public void close try br close catch exception e system out println error closing file e get message
closes the input file
private void reproduce return
hatches a new bird exactly like this bird when the conditions are right
public void set health status string health desc health status health desc
allows the different objects and methods to update the health desc string that
private void nap final random rand new random int n try n rand next int int nap length if level of info 3 add to bird history napping n ms thread sleep n catch interrupted exception e add to bird history interrupted exception this is a level 5 message throw new runtime exception e
allows this thread to yield processing to other birds
public void set jl ref last ate jlabel ref last ate jl ref last ate ref last ate
the on screen field that displays the last time that this bird ate
public void open try out new file output stream file name true append to existing file p new print stream out catch exception e system err println error writing to output file e get message
opens the file name that was set when this object was created
public void write output string output string try p print output string catch exception e system err println error writing output to file e get message
writes the actual output to the file
public void add to error history string err msg add to food history err msg
adds the error event description to its history
public boolean is stop now return stop now
returns the value of the stop now variable as a boolean
public void set stop now boolean stop now if level of info 1 add to bird history bird stop now was set to stop now this stop now stop now
sets the value of the stop now variable
public string show string output oak size integer to string oak size collection map entry string object c oak entries iterator i c iterator while i has next map entry me map entry i next std food sf std food me get value output output concat n key me get key n contents sf get contents n history sf get history return output
provides a formatted output that represents the contents of the basic tuple tree
public string get bird name return bird name
returns the name of this bird as a string
public void set bird name string bird name if level of info 1 add to bird history bird name was set to bird name this bird name bird name
sets the name of the bird
public string get bird description return bird desc
returns the description of this bird as a string
public void set bird desc string bird desc if level of info 1 add to bird history bird desc was set to bird desc this bird desc bird desc
sets the description of this bird to the string that is passed in
public string get eats food return eats food
returns the name of the food that this bird eats
public void set eats food string name of food it eats if level of info 1 add to bird history food bird eats was set to name of food it eats this eats food name of food it eats
sets the name of the food work packets that this bird will eat
public string get name of food to store return stores food
returns the string name of the food that this bird stores
public void set stores food string name of food it stores if level of info 1 add to bird history food bird stores was set to name of food it stores this stores food name of food it stores
sets the name of the food that this bird stores
public string get aux food return null
returns a null string in abstract basic bird
public int get level of info return level of info
returns the current level of information recording within the bird
public void set bird history string bird history this bird history bird history
sets or replaces the bird history to some string value
public void add to bird history string historical event bird history bird history n mts get short milli time string bird name historical event
adds the historical event to the birds history
public void set input file name string file name if level of info 1 add to bird history input file name was set to file name input file name file name trim
sets the name of the input file that will be read
public long get hatch time return hatch time
retrieves the time that this bird was hatched launched
public long get life time return life time
retrieves the length of time that this bird should live in milliseconds
public void set life time long life time if level of info 1 add to bird history bird lifetime was set to life time millis this life time life time
sets the length of time that this bird should live in milliseconds
public long get last ate return last ate
retrieves the last time that this bird successfully ate based on the system
public long get stamina return stamina
retrieves the amount of stamina a bird was initally assigned in milliseconds
public long get nap length return nap length
retrieves the length of time in milliseconds that this bird should nap after
public void set nap length long nap length if level of info 1 add to bird history bird nap duration was set to nap length millis this nap length nap length
sets the length of time that this bird will nap in milliseconds
override protected void startup show new shipit view this
at startup create and show the main frame of the application
public void set current stage int stage if stage this current stage this current stage stage this current screen 1 if stage this current stage system err println stage not changed tried to give stage when stage is already this current stage
this function updates the stage of the subject to a later stage
public int get min stage int min stage 1 iterator subject it subjects vector iterator while it has next if 1 min stage min stage it next get current stage else min stage math min min stage it next get current stage return min stage
this function returns the minimal stage a subject is in among all
public boolean are all waiting boolean all are waiting true iterator subject it subjects vector iterator while it has next all are waiting it next is ready for next page all are waiting return all are waiting
this function returns whether all users are waiting
public void set query query form new query throws wrong parent exception throw an exception if the parent of disp obj is not this display page if this new query get parent container throw new wrong parent exception a display object was entered into this display page but doesn t list this display page as a parent a new instance of the display object needs to be created int index displayed objects index of query if 1 index displayed objects remove index displayed objects add index new query else displayed objects add new query this query new query
this function appends the new query if there was no previous query
public long get time from first display call return system current time millis first display call timestamp
this function returns the time in milliseconds from the first call of
public boolean process response after reinit map string string param reitin fields return process response param
this function is the same as the process response map string string
public void reinit current value default value has valid answer false is value illegal false illegal value warning
this functions resets the query field to the initial state
public boolean submit response string submited value check if the response is a legal submission for this field if validate submited value if it is legal store it and adjust the state flag current value submited value has valid answer true is value illegal false return true else if the value is illegal raise the flags and don t update the value has valid answer false is value illegal true return false
this function takes the string submitted as a response and handles it
private boolean validate string entry illegal value warning validator validate field entry entry if null illegal value warning return true else return false
this function takes the input and checks whether its a valid response
public void set minumum int min validator set min value min
sets the min for all query fields in this query
public void set maximum int max validator set max value max
sets the max for all query fields in this query
public void set multiple of int multiple of validator set multiple of multiple of
sets the multiple for all query fields in this query
public boolean is ready to start return is ready to start
this function returns true when the experiment process is ready to begin
public void set ready to start is connect more clients false is ready to start true
this function sets the experiment ready to start
public string find tag value string tag name system out println read tags get tag name return tags get tag name
this method finds the value of corresponding tag
public void write string key string res this tags put key res system out println write key res
writing of data to the structure
public void run try parser parse new input source edi catch ioexception e e print stack trace throw new runtime exception edi ioexception catch saxexception e e print stack trace throw new runtime exception edi saxexception
starts the flow of sax events
public int new child qname child name integer count child count get child name if count null count 1 else count count int value 1 child count put child name count return count int value
this method is called every time new child is added
public void test set edi string edi new file get absolute path test resources smooks edi assert not null can t find edi file edi input flow set edi edi
test case for
public void test set edifile not found exception try input flow set edi incorrect edi fail should have thrown an exception catch runtime exception e assert true true
test case for
protected void set up str tags org sopera di smooks string tags instance assert not null can t create string tags instance str tags
this method perform initialization of all resources that are needed to
public void test set edisecurity exception
test case for
protected void tear down str tags null assert null str tags
this method perform cleanup of all resources that are needed to test
public void test set mapping string mapping new file get absolute path test resources edi to xml input smooks mapping xml assert not null can t find mapping file mapping input flow set mapping mapping
test case for
public void test set mapping file not found exception try input flow set mapping incorrect mapping fail should throw an exception catch runtime exception e assert true true
test case for
public void test set mapping security exception
test case for
public void test set xpath hash map string saxlocation x paths new hash map string saxlocation
test case for
public void test get xpath ediprocess parser ediprocess instance assert not null can t create ediprocess instance parser string x path null x path input flow get xpath assert null x path
test case for
public void add word word tag word boolean exist false for tag t tags if word tag t get word equals ignore case word get word t increase number of occurences exist true if exist tags add word refresh
add a word to the tagcloud list
public void add image image tag image boolean exist false for tag w tags if w instanceof image tag if image tag w get url equals ignore case image get url w increase number of occurences exist true if exist tags add image refresh
add an image to the tagcloud list
public void increase number of occurences number of occurences
increase the code number of occurences code variable
public void set colored boolean is colored this is colored is colored if this is colored refresh
set whither you wan the tags to be colored randomly
public bitmap get cached bitmap string icon name bitmap bmp null if icon cache get icon name null bmp icon cache get icon name else bmp load icon icon name return bmp
get icon bitmap from cache
public void clear cache icon cache clear
empty the cache
private void load fonts activity activity typeface font typeface create from asset activity get assets fonts chiller ttf fonts put constants font chiller font
load fonts from resources
public typeface get font string fontid typeface font fonts get fontid return font
return a loaded font
private void eval win condition final item model item boolean is win false model model model get instance quest model quest model get current quest for int i 0 i quest get itemids length i if item get db id quest get itemids i quest get type constants quest type retrieve item is win true break if is win on win else smartfox controller get instance send item pickup msg item get id
check to see if user has found item to win quest
private void eval win condition final monster model monster boolean is win false model model model get instance quest model quest model get current quest if monster get is boss quest get type constants quest type defeat boss is win true if is win on win
check to see if defeated monster is boss
public activity get current activity return this current activity
get the currently focused activity
private void on win model model model get instance quest model quest model get current quest int itemid get quest reward quest smartfox controller get instance send quest defeated msg itemid
when user fulfils the win condition
public void on lose model model model get instance int health model get health total constants quest lose health refill 100 model set health health string msg a monster just killed you find a way to replenish your health and play again application controller get instance show toast msg msg null application controller get instance quit quest
when user has no more health left
public string to string string str string type str switch type case constants message type private type str private break default type str public break str from n str type str n str message n str sent at time n return str
output string of the message
public string get current actitivy name string class name current activity get class get simple name return class name
get the current activity class name
private string validate icon string icon string default icon switch this type case constants map marker type item default icon constants icon filename item break case constants map marker type monster default icon constants icon filename monster break case constants map marker type user default icon constants icon filename user break case constants map marker type quest default icon constants icon filename quest break default default icon constants icon filename missing break if icon null icon length 0 icon equals icon default icon return icon
make sure that icon should be set to default if its invalid
public void rebuild menu if this menu null on create options menu this menu
allow menus to be rebuilt dynamically
public void on connected edit text name field edit text find view by id r id txt user name image view login btn image view find view by id r id btn login name field set visibility view visible login btn set visibility view visible
change view when application is connected
public void on disconnected edit text name field edit text find view by id r id txt user name image view login btn image view find view by id r id btn login name field set visibility view invisible login btn set visibility view invisible
change view when application is not connected
public room get current room room room null if m sfsclient null room list ready room m sfsclient get active room return room
get the current room
public void send public message string message if m sfsclient null m sfsclient is connected m sfsclient send public message message
send a public message to every user in the same room
private void on recharged run on ui thread new runnable override public void run model model model get instance elapsed pause time constants combat pause step time if elapsed pause time combat util get pause time model get speed model reset combat action is charged true relative layout ring relative layout find view by id r id actions layout ring start animation ani fade in relative layout recharge area relative layout find view by id r id recharge area recharge area set visibility view invisible else run recharge timer update recharge bar
when user is able to make the next move
private void connect to server final string ip show dialog dialog connecting id connect method is called in separate thread so it does not blocks the ui final smart fox client sfs m sfsclient new thread override public void run sfs connect ip start
connects to smart fox server instance
private void recharge run on ui thread new runnable override public void run elapsed pause time 0 is charged false relative layout ring relative layout find view by id r id actions layout ring start animation ani fade out update recharge bar run recharge timer
lock the user from making new moves
private void connect to server final string ip final int port show dialog dialog connecting id connect method is called in separate thread so it does not blocks the ui final smart fox client sfs m sfsclient new thread override public void run sfs connect ip port start
connects to smart fox server instance
private void run recharge timer recharge timer new timer int pause constants combat pause step time recharge timer schedule new timer task override public void run on recharged pause
run the recharge timer
public boolean get is in combat boolean is in combat false string class name application controller get instance get current actitivy name if class name equals constants activity classname combat is in combat true return is in combat
if current activity is combat then user is in combat
private void send chat message gets the message the user have entered string message m text message get text to string if message length 0 and if it s the message is not empty it s send to the server m sfsclient send public message message m text message set text
sends the message entered by the user to the server
protected dialog on create dialog int id switch id case dialog connect id return get connect dialog case dialog connecting id return get connecting dialog case dialog connection error id return get connection error dialog case dialog login id return get login dialog case dialog login error id return get login error dialog case dialog connection lost id return get connection lost dialog default return super on create dialog id
callback for creating dialogs that are managed by the activity
private void reset ui m button send set enabled false m text message set enabled false m text chat set text m users clear remove dialog dialog connecting id remove dialog dialog connection error id remove dialog dialog connection lost id remove dialog dialog login id
resets the ui
private void enable chat ui m text message set enabled true m button send set enabled true
enables the chat related ui
private void append chat message final char sequence message appends the message m text chat append message and scroll the view to show the last message m scroll chat full scroll scroll view focus down
adds a chat message at the end of the chat history
private dialog get connecting dialog progress dialog connecting dialog connecting dialog new progress dialog this shows the connecting message connecting dialog set message this get string r string connecting dialog connecting connecting dialog set cancelable true if the user press the back button it quits the application connecting dialog set on cancel listener new on cancel listener public void on cancel dialog interface dialog simple chat this finish return connecting dialog
returns the connecting progress dialog
private dialog get connection error dialog alert dialog builder builder new alert dialog builder this shows the error message builder set message r string connection error dialog connection error set cancelable false set neutral button r string button ok new dialog interface on click listener and when is ok button is clicked shows the connect dialog public void on click dialog interface dialog int id remove dialog dialog connection error id show dialog dialog connect id return builder create
returns the connection error dialog
public void restart camera try m camera stop preview m preview running false m camera release m camera camera open m preview running true catch exception e
restarts camera to account for screen rotation
private dialog get login error dialog alert dialog builder builder new alert dialog builder this shows the error message builder set message m login error set cancelable false set neutral button r string button ok new dialog interface on click listener and when is ok button is clicked shows the login dialog public void on click dialog interface dialog int id remove dialog dialog login error id show dialog dialog login id return builder create
returns the login error dialog
public boolean is monster ignored int monsterid string id in string string value of monsterid boolean is ignored false if ignored monsters size 0 for int i 0 i ignored monsters size i if id in string equals ignored monsters get i is ignored true break return is ignored
check to see if a monster is on the ignored list
private dialog get connection lost dialog alert dialog builder builder new alert dialog builder this shows the error message builder set message r string connection lost dialog connection lost set cancelable false set neutral button r string button ok new dialog interface on click listener and when is ok button is clicked shows the connect dialog public void on click dialog interface dialog int id remove dialog dialog connection lost id show dialog dialog connect id return builder create
returns the connection lost dialog
public boolean is item ignored int itemid string id in string string value of itemid boolean is ignored false if ignored items size 0 for int i 0 i ignored items size i if id in string equals ignored items get i is ignored true break return is ignored
check to see if an item is on the ignored list
public void on compass sensor change int degree model model model get instance world object model monster model get target if model null monster null int monster deg combat util get target location in degrees model get user object model get latitude model get user object model get longitude monster get latitude monster get longitude degree 360 math abs degree monster deg move monster degree log i combat util monster is located at degree degree
handles when the compass listener value changes