input
stringlengths
10
828
output
stringlengths
5
107
public item model get user item by id int itemid item model item null for int i 0 i model get items size i item model item model model get items get i if item model get id itemid item item model break return item
retrieve the user item model with the item id
public item model get user item by db id int item db id item model item null for int i 0 i model get items size i item model item model model get items get i if item model get db id item db id item item model break return item
retrieve the user item model with the item dbid
public world object model get user object model by id int userid world object model object model null for int i 0 i model get world users size i object model model get world users get i if object model get id userid break return object model
retrieve a users model with the userid
public void center map map controller animate to new geo point model get user object model get latitude model get user object model get longitude
center map to where the user is
public void show messages show dialog constants dialog id messages history
show history of messages received
public string compose messages string msg for int i model get messages size 1 i 0 i message model message model get messages get i msg message to string n return msg
composed history of messages from message models
public void set user item icons item model weapon get user item by db id model get current weapon db id item model armour get user item by db id model get current armour db id string weapon icon string armour icon if weapon null weapon icon weapon get object model get icon if armour null armour icon armour get object model get icon model get user object model set weapon icon weapon icon model get user object model set armour icon armour icon
set the current user item icons
public void launch website intent intent web new intent intent action view uri parse http inquedesign com techspasm hauntedworld current activity start activity intent web
launches the techspasm website
public void on compass sensor change int degree model model model get instance model set compass value degree if get current actitivy name equals constants activity classname combat combat current activity on compass sensor change degree redraw log i application contorller new compass value degree
handle when compass value changes
public engine get player to move return get player get board whose turn
returns the player who has to move now
protected void next turn whose turn whose turn
switchs the player who has to move
public boolean get winner return winner
returns the playing direction of the winner of the game
protected board board return my board
returns a fast and small and immutable implementation of the board interface
private void set final field field final byte what fields field row field col what
changes the contents of a field on the board
protected jroot pane create root pane return new cgo root pane true
called by the constructor methods to create the default root pane
public string get applet info return plays conway go a simple game played on a go board see http conwaygo sourceforge net
returns information about this applet
public void init resize get root pane get preferred size
initializes the applet
public void start cgo root pane get root pane start game
starts the applet
private void set final int col final int row final byte what fields row col what
changes the contents of a field on the board
public void stop cgo root pane get root pane abort game
stops the applet
public void destroy cgo root pane get root pane quit
destroys the applet
protected jroot pane create root pane return new cgo root pane
called by the constructor methods to create the default root pane
protected string get i18n property string name return resource bundle get bundle this get class get name get string name
returns a localized version of the requested property
public string get name return get i18n property name
returns the localized version of the name property
public string get version return get i18n property version
returns the localized version of the version property
public string get description return get i18n property description
returns the localized version of the description property
public string get author return get i18n property author
returns the localized version of the author property
public boolean can play both sides return false
this default implementation always returns false
public field point2 field point point return new field point x left space field width point y top space field height
converts a point in the components pixel coordinates
public void init game long rand seed random set seed rand seed
initializes the random number generator
public game get game return game get source
returns the game where this event evolved
public field get field return where
returns the field where the figure is set
public engine get player boolean direction return direction up player up player down
returns the engine that plays in the specified direction
public byte pop return size 0 1 leaps size
removes and returns the last jump from this move
public background game get game return game
returns the model of this delegate
public void set status text string text status line set text text
sets the text to show in the status line
public boolean is alive return game runner playing
returns true if a game is running
private void show warning string key joption pane show message dialog this i18n get key i18n get warn joption pane warning message
displays a warning
private void show error string key joption pane show message dialog this i18n get key i18n get error joption pane error message
displays information about an error
private void show error string key string param joption pane show message dialog this i18n get key param i18n get error joption pane error message
displays information about an error
private void show error string key string params joption pane show message dialog this i18n get key params i18n get error joption pane error message
displays information about an error
private string convert language type elanguage types language if language conversion map contains key language return language conversion map get language return text
converts languages provided in the global language type into local types
public static iaccumulator get accumulator return new accumulator
this implementation accumulates into primitive double value
public void check double result if result size init value throw new runtime exception test current test failed
checks the sum of an array
private boolean is candidate class string class name if class name null return false javax faces context faces context boolean is candidate class name contains faces context impl return is candidate
check if we should consider class for instrumentation
private void assert valid input faces context context if context null throw new null pointer exception
this method checks for null context and component
public void print transformer factory tran factory transformer factory new instance transformer a transformer try a transformer tran factory new transformer source src new domsource document result dest new stream result new file output stream new file c temp xml a transformer transform src dest catch exception e e print stack trace
print out current state of the context to a stream
public void start entry node element elem context get document create element entry entry node generated append child elem context set parent entry node
create new entry
public void start fields node element elem context get document create element fields fields node generated append child elem context set parent fields node
create new fields node
public void start methods node element elem context get document create element methods methods node generated append child elem context set parent methods node
create new fields node
private node make null node document doc context get document element node doc create element null attr name attr doc create attribute name name attr set value node set attribute node name attr attr type attr doc create attribute type type attr set value nullref node set attribute node type attr attr value atr doc create attribute value value atr set value null node set attribute node value atr return node
create a node that represents a null object
protected void c object o buffer append o
append objects to string to the end of the buffer
public void register converter converter converters add converter
add new converter
public converter lookup class type converter cached converter converter cache get type if cached converter null return cached converter for converter con converters if con can convert type converter cache put type con return con return new default converter
lookup existing converter if nothing found return default converter
private string get expression map string string request map string expression string s exp request map get exp if is expression s exp expression s exp else string method request map get method string bean request map get bean expression bean method return expression
get a expression of bean
private boolean is expression string exp if exp null return false return exp starts with exp ends with
check if given string is a expression from the web param bean
protected boolean modifiers supported field field return field is synthetic modifier is static field get modifiers modifier is transient field get modifiers
check if we have access to the field
private boolean has getter method field field object obj boolean is boolean is boolean field field for class super clazz obj get class super clazz object class super clazz super clazz get superclass for method method super clazz get declared methods string getter name get getter name field get name false if is boolean getter name get getter name field get name true if getter name equals method get name return true return false
check if given object has getter method in the given object
public boolean is start of event string s try boolean b matcher match s last string tested b s null return b catch stack overflow error e logger error jakarta regexp fails to parse s e get message e return false
returns true if this line is a first line of an event
public void set color for provider log provider provider color new color if logger is debug enabled logger debug setting color for provider new color boolean is new colors by provider get provider null colors by provider put provider new color if is new fire provider added provider new color else fire provider color changed provider new color
associates the given provider and color
public color choose color for log provider provider color already chosen color colors by provider get provider if provider null provider is transient already chosen color null string pref color uninterpreted colors by provider get provider to string color new color pref color null get random color new color integer parse int pref color set color for provider provider new color return new color return already chosen color
if the provider is already associated with a color use it
public void add from file file f if f length 0 log event recognizer recognizer request recognizer from user f if recognizer null user cancelled return log provider provider new file log reader recognizer f get absolute path add from provider provider else logger error empty file
ajoute tous les evenements contenus dans le fichier aux evenements visualis s
public void save preferences preferences saver save all preferences create global config
modifie les evenements visibles en enlevant tous ceux du provider fourni
public void test string memory usage array list list new array list runtime get runtime gc runtime r runtime get runtime long used memory before r total memory r free memory for int j 0 j str count j string buffer sb new string buffer for int i 0 i str length i sb append i list add new string holder sb to string long used memory after r total memory r free memory system out println memory used used memory after used memory before joption pane show confirm dialog null close
memory used seems to be 10 times bigger using 1
public void set color for provider log provider provider color new color if logger is debug enabled logger debug setting color for provider new color boolean is new colors by provider get provider null colors by provider put provider new color if is new fire provider added provider new color else fire provider color changed provider new color fire provider added provider todo fire color changed event for provider table1 invalidate table1 repaint
associates the given provider and color
public color choose color for log provider provider object already chosen color colors by provider get provider if provider null provider is transient already chosen color null string pref color string uninterpreted colors by provider get provider to string color new color pref color null get random color swing rgbto color integer parse int pref color new color display get current integer parse int pref color set color for provider provider new color return new color return color already chosen color
if the provider is already associated with a color use it
protected void update parts log event part parts for log event part part parts if predicates by part contains key part if logger is debug enabled logger debug adding new predicate for part predicates by part put part create predicate part else if logger is debug enabled logger debug reusing existing predicate for part todo
updates the predicates currently used to match these parts
private void parse file snapshot event table set model new log table model debug log reader log reader new debug log reader recognizer try list list log reader parse event table set model new log table model list log reader get parts regexp message ta set text catch unparseable log file exception e regexp message ta set text e get message catch ioexception e regexp message ta set text e get message catch runtime exception e regexp message ta set text e get message
applies the regexp to parse the file snapshot
public void action performed action event e if action close equals e get action command dialog set visible false dialog dispose
close dialog window when user clicks close
public void show dialog pack dialog set location relative to frame dialog set visible true
display the dialog box
public void start application log info starting musollo abstract mp3 categorizer categorizer new simple categorizer categorizer set target dir new file configuration get instance get target location try new mp3 indexer new file configuration get instance get index location new jaudio tagger reader new jaudio tagger writer new music brainz updater categorizer catch index exception e log error indexing error e catch gen puid exception e log error gen puid error e
when calling this method the application is started and runs once
public void set target dir final file target if target null throw new illegal argument exception target directory is null if target is directory throw new illegal argument exception target is not a directory or does not exist this target dir target
setter to set the target directory to move the categorized files to
public int get album track number return album track number
gets the album track number
public file get mp3 file return this mp3 file
gets the file name
public void set slow search boolean be slow this slow be slow
set if the search should behave slow
public search result model search string search term throws search exception result new search result model search term searcher id for int i 0 i get max num results i result add search result row new search result row matchings rnd next int matchings length links rnd next int links length summaries rnd next int summaries length simulate slow search if slow try thread sleep 1000 rnd next int 5000 catch interrupted exception ex throw new search exception search interrupted ex return result
search for the given string and return the results
public string get searcher id return searcher
convenience method to access the searcher id after the search
public void add search result row search result row row matching add row
adds a result row
private void create gui jcomponent main component new niki component this props main component set background color white set content pane main component
create the gui
public void set max num results int max num results if max num results 10 throw new illegal argument exception can search for at most 10 results in google super set max num results max num results searcher set max results max num results
set maximum number of search results to search at once
public void set data search result model new results this data rows new results get search result rows fire table data changed
updates internal data structures and fires a
public string get url int row return data rows row get link
get the url associated with the search result of the row given
public isearch result listener get search result listener return this
get the search result listener that is interested in the
private void pack rows jtable table for int row 0 row table get row count row get the preferred height int h get preferred row height table row now set the row height using the preferred height if table get row height row h table set row height row h
for each row the height of a row is set to the preferred
private int get preferred row height jtable table int row get the current default height for all rows int height table get row height determine highest cell in the row for int col 0 col table get column count col table cell renderer renderer table get cell renderer row col component comp table prepare renderer renderer row col int h comp get preferred size height height math max height h return height
returns the preferred height of a row
public void action performed action event evt update properties ordered key text field map props dialog hide
if user clicks ok we read all the query params out of the
public void action performed action event evt search string search input get text logger logger logger get logger ch netcetera wikisearch swing logger fine search component action performed search string search string if null search string equals search string error label set text please enter keyword else rush off starting all the searchers for int i 0 i searcher ids length i string searcher id searcher ids i search worker worker new search worker searcher factory new searcher searcher id search string result container get result listener searcher id worker start required for swing worker v3 see docs
react to users search command
public void add result component result component result searcher idto result map put result get searcher id result add tab result get searcher id result fixme sr does not yet work but it should http java sun com docs books tutorial uiswing components tabbedpane html assign alt number to the search tabs if searcher idto result map size key mapping length int index searcher idto result map size 1 set mnemonic at index index
add result component with this method
public void window closing window event we update properties ordered key text field map props dialog hide
if user closes dialog we read all the query params out of
public isearch result listener get result listener string searcher id return result component searcher idto result map get searcher id get search result listener
get a result listener for a certain searcher
public object construct do the search finally try results searcher search search term catch search exception sex variable shortnames logger log level warning searching caused an error sex sex print stack trace system err return results
the expensive operation is to be implemented in here
public void init try thread sleep 1000 rnd next int 2000 catch interrupted exception iex ok
does nothing besides some waiting to simulate a slow
public void sort object keys object values if keys null values null throw new illegal argument exception neither keys or values are allowed to be null if keys length 1 return internal sort keys values 0 keys length 1
sorts keys and values in parallel
public string get text string full name if full name null throw new illegal argument exception full name must not be null int slash pos full name last index of f separator if slash pos 0 return full name return full name substring slash pos 1
extracts the last part of a text separated by a
public boolean match string str if f matcher null throw new illegal state exception call set filter before calling match return f matcher match str
try to match filter with string
protected void notify listeners for iterator iter listeners iterator iter has next iselection listener listener iselection listener iter next listener update this
notify all the listeners of a new selection
protected void update selection some multi therading fun again but here we abuse the swing worker a bit we don t use the swing part at all but it s just a convenient helper class swing worker worker new swing worker public object construct lookup threaded this super update selection return null worker start
update the selection
private void update lists string pattern filtered list set filter pattern string matches filtered list get selection match list set list data matches if matches length 0 after new list data is set in the gui select first element for convenience match list set selected index 0 update qualifier list 0
update both the match and the qualifier list to contain only entries for
public void set data string elements if elements null f elements new string 0 else copy list for sorting f elements new string elements length system arraycopy elements 0 f elements 0 elements length int length f elements length fill labels f labels new string length for int i 0 i length i string text f label provider get text f elements i f labels i text f sorter sort f labels f elements f filtered indices new int length f folded indices new int length update list
sets the list of elements
private void update qualifier list int match list selection index if match list selection index 0 string qualifiers filtered list get folded elements match list selection index qualifier list set list data qualifiers if qualifiers length 0 qualifier list set selected index 0
update the qualifier list for the match list entry given by