input
stringlengths
10
828
output
stringlengths
5
107
private string get diff element otp erlang list list string expected elements vector string expected elements2 new vector string arrays as list expected elements for int i 0 i list arity i string element otp erlang string list element at i string value if expected elements2 contains element return element expected elements2 remove element return null
checks if there are more elements in
private string get diff element list string list string expected elements list string expected elements2 new vector string arrays as list expected elements list remove all expected elements2 if list size 0 return list get 0 else return null
checks if there are more elements in
private connection get scalaris connection http servlet request request try return c factory create connection catch exception e if request null add to param notice request error pre e get message pre else system out println e e print stack trace return null
sets up the connection to the scalaris erlang node once on the server
private void check class class clazz for class ifc plugin interfaces if ifc is assignable from clazz list class assignable classes plugin map get ifc if assignable classes null assignable classes new linked list class plugin map put ifc assignable classes assignable classes add clazz
check whether the class matches any of the plug in interfaces and adds
public double weight vector double sv int n sv size double item 0 double total 0 double result 0 for int i 1 i n i int index i 1 double xi sv element at index item xi xi 2 0 i n n 1 0 total total item result math sqrt total big decimal bd new big decimal result bd bd set scale decimal place big decimal round up return bd double value
weight a vector of doubles using up elements
public double weight vector double sv int n sv size double item 0 double total 0 double result 0 for int i 1 i n i int index i 1 double xi sv element at index item xi xi 2 0 n i 1 0 n n 1 0 total total item result math sqrt total big decimal bd new big decimal result bd bd set scale decimal place big decimal round up return bd double value
weight a vector of doubles using down elements
public double weight vector double sv int n sv size double item 0 double total 0 double result 0 for int i 1 i n i int index i 1 xn is the last element if index n 1 double xn sv last element item xn xn 2 0 n 1 0 else double xi sv element at index item xi xi 1 0 n 1 0 total total item result math sqrt total big decimal bd new big decimal result bd bd set scale decimal place big decimal round up return bd double value
weight a vector of doubles using last element
public double weight vector double sv int n sv size double item 0 double total 0 double result 0 for int i 1 i n i int index i 1 x0 is the first element if index 0 double x0 sv first element item x0 x0 2 0 n 1 0 else double xi sv element at index item xi xi 1 0 n 1 0 total total item result math sqrt total big decimal bd new big decimal result bd bd set scale decimal place big decimal round up return bd double value
weight a vector of doubles using first element
public double weight vector double sv int n sv size double item 0 double total 0 double result 0 for int i 1 i n i int index i 1 double xi sv element at index item xi xi 1 0 n total total item result math sqrt total big decimal bd new big decimal result bd bd set scale decimal place big decimal round up return bd double value
weight a vector of doubles using all elements
public transformer string in string out throws ioexception input new buffered reader new file reader in output new print writer new buffered writer new file writer out
construct a buffered reader for the input file
public void read input throws ioexception string line input read line while line null string tokenizer tok new string tokenizer line fact f new fact f set source tok next token f set source tok next token f set target tok next token clusters add f get source facts add f line input read line input close
read the input rsf file and collect all the facts
public void write output iterator string icl clusters iterator while icl has next hash set string contents new hash set string string cluster icl next string result new string ss cluster iterator fact ifacts facts iterator while ifacts has next fact f ifacts next if f get source equals cluster contents add f get target iterator string icontents contents iterator while icontents has next string element icontents next result result concat element if icontents has next result result concat else result result concat n output print result output close
write into the output sil file with the facts and
public void read input throws ioexception string line input read line while line null int start 3 int end line index of string cluster line substring start end string header new string ss cluster string factline line substring header length string tokenizer tok new string tokenizer factline while tok has more tokens string target tok next token target trim if target ends with target target substring 0 target length 1 fact f new fact f set source cluster f set target target facts add element f line input read line
read the input rsf file and collect all the facts
public void write output iterator fact ifacts facts iterator while ifacts has next fact f ifacts next string result new string contain result result concat f get source f get target output println result output close
write into the target rsf file with the facts
public default mutable tree node transform rsfto tree string rsf throws exception try rsf2 tree rt new rsf2 tree rsf return rt rsf2tree catch ioexception e string err transform rsf into a tree err err fail to open rsf for reading or read from rsf throw new exception err e catch runtime exception e string err transform rsf into a tree if e instanceof no such element exception err err fail to parse rsf if e instanceof illegal argument exception err err rsf may have a circle throw new exception err e
creates and returns a tree representing the decomposition contained in
public string transform tree to rsf default mutable tree node tree throws exception try tree2 rsf tr new tree2 rsf tree return tr tree2rsf catch ioexception e string err transform the tree to a rsf err err fail to open tree get user object for writing throw new exception err e catch runtime exception e string err transform the tree to a rsf throw new exception err e
creates and returns a rsf file representing the decomposition contained
private default mutable tree node clone tree default mutable tree node root default mutable tree node result default mutable tree node root clone enumeration children root children while children has more elements default mutable tree node child default mutable tree node children next element result add clone tree child return result
clones a decomposition tree with the same structure and user objects
public void stop bundle context context throws exception super stop context plugin null code entity relations clear
this method is called when the plug in is stopped
public boolean equals object ob data type map other if ob null return false if ob this return true if get class get name equals ob get class get name return false other data type map ob if meta data size other meta data size return false for map entry string data type item meta data entry set ob other meta data get item get key if ob null if item get value null return false else if item get value null return false else if ob equals item get value return false return true
compares this data type map to another object and checks for equality
public boolean get value object val if val null return null else if val instanceof boolean return boolean val else if val instanceof string string str string val return new boolean str equals ignore case true else if val instanceof number number num number val return new boolean num int value 0 else throw new invalid attribute exception not boolean val
given a raw value from some source this method will provide a java
public boolean is valid choice boolean b return b null is required
verifies that the specified value is valid according to the rules of this
public currency get value object val if val null return null else if val instanceof currency return currency val else if val instanceof string return currency get instance string val else return currency get instance val to string
provides a currency value based on a raw value
public boolean equals object ob attribute map other if ob null return false if ob this return true if get class get name equals ob get class get name return false other attribute map ob if meta data size other meta data size return false for map entry string object item entry set ob other get item get key if ob null if item get value null return false else if item get value null return false else if ob equals item get value return false return true
compares the selected object
public boolean is valid choice currency curr if curr null return is required for currency choice choices if choice equals curr return true return false
validates that the specified currency is a valid value for this data type
public object get attribute string attr return get attr
this method just calls
public constraint new constraint data type t return new constraint name t complete
makes a copy of this constraint with a different data type
public string to string string buffer str new string buffer str append for map entry string object entry entry set object val entry get value str append entry get key str append str append val null null val to string str append str append return str to string
converts this mapping into a human readable string
public string get display value object ob if ob null return if ob instanceof translator return get display value locale get default ob return ob to string
provides a display value for an instance of this data type
public string get display value locale loc object ob if ob null return if ob instanceof translator suppress warnings rawtypes translation trans translator ob get loc if trans null return null return get display value trans get data else return get display value ob
provides a display version of the specified value translated for the target locale
public string get string value object ob if ob null return return ob to string
converts the specified value to a string representation for storage
public void clear synchronized this cache clear
clears out all elements of the cache and starts fresh
public void cache object key t val cache put key new soft reference t val
caches the specified object identified by the specified key
public t cache t item hash map string object keys if item null throw new null pointer exception multi caches may not have null values keys get keys item synchronized this item get current item for string key caches key set concurrent cache object t cache caches get key cache put keys get key item return item
places the specified item in the cache
public t find object val return find val null
finds the object from the cache with the specified unique identifier value
public boolean contains object ob for soft reference t ref cache values t item ref get if item null ob equals item if item instanceof cached item if cached item item is valid for cache return false return true return false
checks the specified object against the cache and verifies that it
public boolean contains all collection coll for object item coll if contains item return false return true
checks the passed in collection and determines if all elements
public boolean contains value object val synchronized this for v item values if item instanceof cached item cached item ci cached item item if ci is valid for cache ci equals val return true else if item equals val return true return false
verifies that the specified value is in the cache
public boolean contains key object key if cache contains key key return false else soft reference t ref cache get key t ob ref get if ob null release key return false if ob instanceof cached item if cached item ob is valid for cache release key return false return true
checks if an object with the specified key is in the cache
public t get object key soft reference t ref cache get key t ob if ref null return null ob ref get if ob null release key if ob instanceof cached item if cached item ob is valid for cache release key return null return ob
provides the cached object identified by the specified key
public string to string if cache null return null cache return cache to string
displays the current contents of the cache
private t get current t item for string key order concurrent cache object t cache caches get key object val get value key item t tmp if val instanceof big decimal val big decimal val long value tmp cache get val if tmp null if tmp instanceof cached item if cached item tmp is valid for cache return tmp else return tmp return item
provides the current version of the specified item stored in the cache
public v get or load k key cache loader v loader v item synchronized this if contains key key return get key item loader load if item null put if absent key item return get key else return null
retrieves the value for the specified key
private void put t item hash map string object keys if item null throw new null pointer exception multi caches may not have null values keys get keys item synchronized this for string key caches key set concurrent cache object t cache caches get key object ob keys get key if ob instanceof big decimal ob big decimal ob long value cache put ob item
places the specified item into the cache regardless of current cache state
public void release t item hash map string object keys get keys item synchronized this for string key order concurrent cache object t cache caches get key cache remove keys get key
releases the specified item from the cache
public v put k key v val synchronized this weak reference v ref new weak reference v val soft reference v ref new soft reference v val cache put key ref return get key
places the specified value into the cache
public void put all map extends k extends v map synchronized this for k key map key set put key map get key
places all elements in the specified map into this cache
public void release all synchronized this for concurrent cache object t cache caches values cache clear
releases all cached keys and objects
public v put if absent k key v val synchronized this v item if contains key key return put key val item get key if item instanceof cached item cached item ci cached item item if ci is valid for cache put key val return null return item
conditionally associates the specified value with the specified key if
public boolean remove object key object val string k key to string synchronized this v item if contains key k return false item get k if val null item null remove k return true if val null item null return false if val equals item remove k return true return false
removes the specified key only if the current value equals the specified value
public v replace k key v val synchronized this if contains key key return null return put key val
replaces the specified key only if it has some current value
public boolean replace k key v ov v nv synchronized this if remove key ov return false put key nv return true
replaces the current value of the specified key with the proposed new value
public void first page if page index 0 page index 0 current page null
sets the iterator to the first page in the iterator
public long get list id return list id
provides an application defined unique identifier for this
public void last page int idx pages size 1 if idx 0 idx 0 if page index idx page index idx current page null
navigates to the last page in the iterator
private boolean load page collection t list if pages size page index return false list pages get page index current page list iterator return true
loads the next page
public boolean next page page index if page index pages size page index return false load page return true
navigates to the next page in the iterator
public boolean previous page if page index 0 return false page index load page return true
navigates to the previous page in the iterator
public void reset current page null
resets the list to the beginning of the iterator
public boolean set page int p p if p 0 return false if p pages size return false page index p current page null return true
navigates to the specified page number with 0 being the first page
public void set page size int ps array list t tmp new array list t for collection t page pages for t item page tmp add item setup tmp ps sorter
changes the page size of the list and reforms the list
private void setup collection t items int ps comparator t sort collection t list iterator t it if sort null list items else list new tree set t sort list add all items sorter sort page size ps pages new array list collection t it list iterator while it has next array list t page new array list t pages add page for int i 0 i ps i t ob if it has next break ob it next page add ob
sets the collection up using the specified parameters
public void sort comparator t sort array list t tmp new array list t for collection t page pages tmp add all page setup tmp page size sort
re sorts the list according to the specified sorter
public string get comment int index if comments null index 0 index comments size throw new illegal argument exception not a valid comment index index return string comments get index
returns the indexth comment retrieved from the image
public void test create requirement throws reqtrack exception requirement dao dao get dao set up the requirement for testing requirement requirement new requirement requirement set name test requirement assert null requirement get id dao create requirement requirement log info requirement assert not null requirement get id
makes sure that calling create requirement assigns a primary key
public void test create requirement with id throws reqtrack exception requirement dao dao get dao set up the requirement for testing requirement requirement new requirement requirement set name test requirement requirement set id new long 1 try dao create requirement requirement fail should have thrown a reqtrack exception catch reqtrack exception e
makes sure that requirements with id cannot be created
private requirement dao get dao throws reqtrack exception application context context test helper get test context with schema requirement dao dao requirement dao context get bean requirement dao return dao
helper that returns a requirement dao call only once per method as
protected void set up context test helper get test context
creates the test application context
public void test configure db throws reqtrack exception reqtrack configuration configuration reqtrack configuration context get bean reqtrack configuration assert false configuration schema exists configuration configure db assert true configuration schema exists
makes sure that we can properly configure the database
public int do start tag throws jsp exception string buffer buffer new string buffer buffer append a href buffer append docs en buffer append get topic buffer append html target help buffer append get topic buffer append a tag utils get instance write page context buffer to string return skip body
writes a tag that links to the help system
public void process configuration file throws reqtrack exception try properties properties new properties properties load new file input stream config file string local context file name properties get property spring context file if local context file name null local context file new file local context file name catch ioexception e throw new reqtrack exception e
processes the configuration file if possible
private void process local context file string locations new string local context file get absolute path new file system xml application context locations application services get application context
processes the local context file
public void execute wizard dialog dialog new setup wizard dialog this dialog set preferred size new dimension 500 300 dialog show dialog
called to run this wizard
public boolean is complete return has local context file
checks whether we have a properly configured system
public object get session factory factory return session factory factory
spring managed field
public void set session factory factory object session factory factory this session factory factory session factory factory
spring managed field
public properties get local configuration return local properties
holds the properties that are specific to the current machine
public void exit int exit code string message save local configuration log info shutting down reqtrack message system exit exit code
cleanly shuts down the application
private void save local configuration if local properties null local property file null try write the resources local properties store new file output stream local property file reqtrack properties catch ioexception e log fatal couldn t write configuration file local property file e log info local properties saved to local property file
tries to save the local configuration if the file is known and properties
override protected void startup unified diff creator view app new unified diff creator view this app get frame set resizable false show app
at startup create and show the main frame of the application
public response collection checkout file collection files string role return daemon communication checkout files role
forwards a checkout call to the daemon communication
public response collection commit file collection files string role return daemon communication commit files role
forwards a commit call to the daemon communication
public response collection update file collection files string role return daemon communication update files role
forwards an update call to the daemon communication
public response collection list file collection files return daemon communication list files
forwards a list call to the daemon communication
public response collection add file collection files return daemon communication add files
forwards an add call to the daemon communication
public response collection remove file collection files return daemon communication remove files
forwards a remove call to the daemon communication
public response collection checkout file collection files string role message clear message command id internal message type checkout message files files message role role transfer message if message files null files remove all files files append collection message files return message response
forwards a checkout call to the server
public response collection commit file collection files string role message clear message command id internal message type commit message files files message role role transfer message if message files null files remove all files files append collection message files return message response
forwards a commit call to the server
public int get response count return responses size
returns the number of response objects in the collection
public void add response response response if response is error error true responses add response
adds a new response object to the collection
public void append collection response collection collection if collection has error error true responses add all collection responses
appends a response collection to this collection
public response get response int index response retval null try retval responses get index catch exception e retval null return retval
returns a specified response
public string to string string msg new string for int i 0 i responses size i response resp responses get i msg resp to string n return msg
prints the file collection to a readable string
public response collection update file collection files string role message clear message command id internal message type update message files files message role role transfer message files remove all files files append collection message files return message response
forwards an update call to the server
public int get type return sharpster common response type message
returns the type of this response
public int get type return sharpster common response type network error
returns the type of this response
public response collection add file collection files message clear message command id internal message type add message files files transfer message if message files null files remove all files files append collection message files return message response
forwards an add call to the server
public int get type return response type missing files
returns the type of this response
public void add file shared file file files add file
adds a new file object to the collection
public shared file get missing file return missing file
returns the file collection containing information about the missing files
public void append collection file collection collection files add all collection files
appends a file collection to this collection