input
stringlengths
10
828
output
stringlengths
5
107
public void set previous final feedforward layer previous this previous previous
set the previous layer
protected boolean v line clear final int x final int w this entry image get width this final int h this entry image get height this for int i 0 i h i if this pixel map i w x 1 return false return true
this method is called to determine
public void set output stream output stream os this os os
set the output stream
public spider input stream get stream return this stream
get the input stream being parsed
public void load string input file throws ioexception spider exception file reader f new file reader new file input file buffered reader r new buffered reader f string line while line r read line null try parse line line catch illegal argument exception e throw new spider exception e catch security exception e throw new spider exception e catch illegal access exception e throw new spider exception e catch no such field exception e throw new spider exception e r close f close
load the spider settings from a configuration file
public void read all throws ioexception while read 1
read all characters on the page
private void handle a string href throws ioexception if href null href href trim if href null urlutility contains invalid urlcharacters href if href to lower case starts with javascript href to lower case starts with rstp href to lower case starts with rtsp href to lower case starts with news href to lower case starts with irc href to lower case starts with mailto add url href spider reportable urltype hyperlink
this method is called when an anchor a tag is found
public boolean add url url url source int depth if contains url this waiting add url set status url source urlstatus status waiting depth if this current host null this current host url get host to lower case return true return false
add the specified url to the workload
public void clear this workload clear this waiting clear this working count 0
clear the workload
public boolean contains url url return this workload contains key url
determine if the workload contains the specified url
public url convert url string url throws workload exception try return new url url catch malformed urlexception e throw new workload exception e
convert the specified string to a url
public string get current host return this current host
get the current host
public int get depth url url urlstatus s this workload get url assert s null if s null return s get depth else return 1
get the depth of the specified url
public url get source url url urlstatus s this workload get url if s null return null else return s get source
get the source page that contains the specified url
public url get work url url try url this waiting poll 5 time unit seconds if url null set status url null urlstatus status working 1 this working count return url catch interrupted exception e return null
get a new url to work on
public void init spider spider throws workload exception
setup this workload manager for the specified spider
public void mark error url url this working count assert this working count 0 this waiting remove url set status url null urlstatus status error 1
mark the specified url as error
public void mark processed url url this working count assert this working count 0 this waiting remove url set status url null urlstatus status processed 1
mark the specified url as successfully processed
public string next host return null
move on to process the next host
public void resume throws workload exception throw new workload exception memory based workload managers can not resume
setup the workload so that it can be resumed from where
public void wait for work int time time unit length
if there is currently no work available then wait
public boolean workload empty if this waiting is empty return false return this working count 1
return true if there are no more workload units
private void set status url url url source urlstatus status status int depth urlstatus s this workload get url if s null s new urlstatus this workload put url s s set status status if source null s set source source if depth 1 s set depth depth
set the source status and depth for the specified url
public string format log record log string builder str new string builder str append log get level str append str append new date log get millis str append str append log get thread id str append str append log get message str append n if log get thrown null byte array output stream os new byte array output stream print stream ps new print stream os log get thrown print stack trace ps str append os to string ps close try os close catch ioexception e return str to string
called by the jdk logging system to format log entries
public void paint graphics g update
update the graphical display of the map
public void start create a random list of cities cities new city traveling salesman city count for int i 0 i traveling salesman city count i cities i new city int math random get bounds width 10 int math random get bounds height 60 start up the background thread started true map update map get graphics if worker null worker null worker new simulate annealing this worker set priority thread min priority worker start
start the background thread
public boolean begin host string host if this base null this base host return true else return false
this function is called when the spider is ready to
public void init spider spider
called when the spider is starting up
public void spider process url url url input stream stream throws ioexception byte buffer new byte 1024 int length string filename urlutility convert filename this path url true try output stream os new file output stream filename do length stream read buffer if length 1 os write buffer 0 length while length 1 os close catch file not found exception e e print stack trace
called when the spider is about to process a non html
public void spider urlerror url url
called when the spider tries to process a url but gets
public void run graphics g null for if this connection null open if g null g get content pane get graphics if g null get stats display stats g try thread sleep 10000 catch interrupted exception e return
run the background thread
private void display progress bar graphics g int y int width get width int progress width width 40 g set color color green g fill rect 10 y int progress width this done percent 16 g set color color black g draw rect 10 y progress width 16
draw a progress bar
private void get stats try this waiting this processing this error this done 0 result set rs this stmt status execute query while rs next string status rs get string 1 int count rs get int 2 if status equals ignore case w this waiting count else if status equals ignore case p this processing count else if status equals e this error count else if status equals d this done count rs close this depth 0 rs this stmt depth execute query if rs next this depth rs get int 1 catch sqlexception e e print stack trace
load the stats from the database
private void open try set title heaton research spider class for name this options db class new instance this connection driver manager get connection this options db url this options db uid this options db pwd this stmt status this connection prepare statement this sql status this stmt depth this connection prepare statement this sql depth catch instantiation exception e e print stack trace catch illegal access exception e e print stack trace catch class not found exception e e print stack trace catch sqlexception e e print stack trace
open a connection to the database
static public void main string args try if args length 1 system out println usage check links website to check else check links links new check links links check new url args 0 catch exception e e print stack trace
main method for the application
public void set endpoint address java lang string port name java lang string address throws javax xml rpc service exception if pig latin translator port equals port name set pig latin translator port endpoint address address else unknown port name throw new javax xml rpc service exception cannot set endpoint address for unknown port port name
set the endpoint address for the specified port name
public void init spider spider this workload manager spider get workload manager
called when the spider is starting up
public void spider process url url url input stream stream
called when the spider is about to process a non html
public void spider process url url url spider parse html parse try parse read all catch ioexception e logger log level info error reading page url to string
called when the spider is ready to process an html
public void spider urlerror url url url source try source this workload manager get source url string builder str new string builder str append bad url str append url to string str append found at str append source to string this bad add str to string catch workload exception e e print stack trace
called when the spider tries to process a url but gets
public void set function string prefix string local name method method if this functions null this functions new functions this functions set function prefix local name method
define a function
static public string quote string s char c0 c1 int i n l string builder buf new string builder for i 0 l s length n l 1 i n i c0 s char at i c1 s char at i 1 switch c0 case switch c1 case buf append c0 i i 1 break case case break default buf append c0 break buf append c0 if i l buf append s char at n return buf to string
quote a el expression
public void set ref id string s this refid static trim2 s this refid
use attribute refid to specify another variable holding an array of
public void set var string s this qvar static trim2 s this qvar
this attribute will be set if a query evaluates to true
public void set echo boolean b this echo b
use this attribute to dump the content of the
public void set op string s string p static trim2 s null if p null this opc p char at 0
use this attribute to specify the operation to execute
static public object append object argv int i n list l l new array list n argv length for i 0 n argv length i n i object obj argv i if obj instanceof iterable iterator i iterable obj iterator while i has next l add i next else null is like the empty list if obj null l add obj return l
this function returns a list containing all the elements
public void set base file file this base file
use this attribute to specify the base directory
public void set ws folder file file this wsfolder file
use this attribute to specify the workspace folder of eclipse
public void set sort boolean b this sort b
use this attribute to sort the final
protected void recover my scanner scanner scanner my scanner this scanner scanner recover true while sym symbol end eval sym symbol eof trytoken wh fixing issue 13 scanner recover false
recover from a syntax error while inside a el reference
public void set unique boolean b deprecated but kept for legacy reasons debug usage of attribute unique is deprecated
this attribute is kept for legacy reasons
public void set name string s this target static trim2 s this target
the name of the default target
public void set fail boolean b this fail b
whether to fail if the target does not exist
public void set override boolean b this override b
whether to override an existing default target
public void set validate boolean b deprecated but kept for legacy reasons debug usage of attribute validate is deprecated
this attribute is kept for legacy reasons
public void set test string s this test static elresolve this get project s
the test that must evaluate to true in order to execute the body
protected boolean eval throws build exception project p p this get project return static el2bool p this test
evalutes the internal test condition
public void exec throws build exception if this tasklist null iterator i org apache tools ant task task i this tasklist iterator while i has next task org apache tools ant task i next task perform
executes the when body
public void execute throws build exception if eval exec
evalutes the test condition and if true executes the body
public void set flush boolean b deprecated but kept for legacy reasons debug usage of attribute flush is deprecated
this attribute is kept for legacy reasons
public void build started build event event this build element new xml logger timed element this build element start time system current time millis this build element element this doc create element build tag
fired when the build starts this builds the top level element for the
protected void trytext try ast node node null if node text null this list add node catch exception e handle ex e
try to read a text node
public boolean tryvalue string value pattern p null if this regexstr null return false if this ispattern try p pattern compile this regexstr this flags catch exception e p pattern compile pattern quote this regexstr this flags else string glob static pattern as regex this regexstr p pattern compile glob this flags return match p value
try this value against this clause
private stack get stack stack thread stack stack this thread stacks get thread current thread if thread stack null thread stack new stack this thread stacks put thread current thread thread stack return thread stack
returns the stack of timed elements for the current thread
public void set name string s this name static trim2 s this name
the name of the macro to execute
protected void trytoken try consume token catch scan exception se this is a serious error system err println serious internal error system exit 1 catch parse exception pe handle ex pe catch exception e handle ex e
a method to consume a plain token
public void target started build event event target target event get target timed element target element new timed element target element start time system current time millis target element element this doc create element target tag target element element set attribute name attr target get name this targets put target target element get stack push target element
fired when a target starts building this pushes a timed element for the
private boolean savebuf string buf string fname boolean good true file output stream fo null file u if this logdir null buf null fname null u new file this logdir fname this debug writing upload log report u get absolute path try fo new file output stream u fo write buf get bytes catch exception e good false this error unable to write upload log report e finally static close fo return good
save content of buffer buf into logdir using filename fname
static protected void attr2buf string builder buf string v string name if name null v null buf append buf append name buf append buf append v buf append
a helper function to add an xml like attribute to a string buffer
public void set classpath path cp if this classpath null this classpath cp else this classpath append cp
set the classpath to be used for this compilation
public void set resource string s this resource s
name the resource to look for
public void set var string s this varname s
the property to fill with the url of the resource or class
private timed element get task element task task timed element element timed element this tasks get task if element null return element for enumeration e this tasks keys e has more elements task key task e next element if key instanceof unknown element if unknown element key get task task return timed element this tasks get key return null
get the timed element associated with a task
public void set next component helper next super set next next this dlgt super get next
set the next chained component helper
public boolean tryvalue string value pattern p null boolean b true if this regexstr null p this re compile this regexstr b this find this find p value this matches p value return b
try this value against this clause
public component helper get next return this dlgt
get the next chained component helper
public boolean tryvalue string value pattern p null boolean r true if this regexstr null p this glob compile this regexstr r this find this find p value this matches p value return r
try this value against this clause
public void set project project project this dlgt set project project
sets the project for this component helper
public void init sub project component helper helper this dlgt init sub project helper
used with creating child projects
public void set type string type string s static trim2 type null if s null this type static patterncompile s 0
set the name of the java class to be catched
public object create component string component name return this dlgt create component component name
create an object for a component
public void set match string match string s static trim2 match null if s null this match static patterncompile s pattern dotall
the pattern expession to use to select a particular exception
public class get component class string component name return this dlgt get component class component name
return the class of the component name
public void add try sequential seq this trylist add seq
a a sequential task container to the list of tries
public void add catch catch block cb this catchlist add cb
add a catch clause
public void add finally sequential seq this finallylist add seq
adds a finally clause
public ant type definition get definition string component name return this dlgt get definition component name
return the ant type definition for a component name
public void set property string p this property static trim2 p this property
sets the property attribute
public void set reference string r this reference static trim2 r this reference
sets the reference attribute
public void init default definitions this dlgt init default definitions
this method is initialization code implementing the original ant component
public void check task class final class task class throws build exception this dlgt check task class task class
checks whether or not a class is suitable for serving as ant task
public hashtable get task definitions return this dlgt get task definitions
returns the current task definition hashtable
public string to string string builder b b new string builder b append classpathentry attr2buf b this kind kind attr2buf b this path path attr2buf b this excluding excluding attr2buf b this sourcepath sourcepath attr2buf b this protec protected b append return b to string
this method is used to represent a entry for debugging purposes
public hashtable get data type definitions return this dlgt get data type definitions
returns the current type definition hashtable
public boolean tryvalue string value boolean r true if r this eq null if this flags pattern case insensitive 0 r this eq compare to ignore case value 0 else r this eq compare to value 0 if r this lt null if this flags pattern case insensitive 0 r value compare to ignore case this lt 0 else r value compare to this lt 0 if r this gt null if this flags pattern case insensitive 0 r value compare to ignore case this gt 0 else r value compare to this gt 0 return r
try this value against this clause
public hashtable get ant type table return this dlgt get ant type table
returns the current datatype definition hashtable
public object create data type string type name throws build exception return this dlgt create data type type name
creates a new instance of a data type
public boolean tryvalue string value pattern p null boolean r false if this regexstr null if this ispattern p this glob compile this regexstr else p this re compile this regexstr r this find this find p value this matches p value return r
try this value against this clause
public string get element name object element return this dlgt get element name element
returns a description of the type of the given element