📄 crawluri.html
字号:
<a name="596" href="#596">596</a> classname.substring(index + 1): classname);<a name="597" href="#597">597</a> }<a name="598" href="#598">598</a> <a name="599" href="#599">599</a> <em>/**<em>*</em></em><a name="600" href="#600">600</a> <em> * Add an annotation: an abbrieviated indication of something special</em><a name="601" href="#601">601</a> <em> * about this URI that need not be present in every crawl.log line,</em><a name="602" href="#602">602</a> <em> * but should be noted for future reference. </em><a name="603" href="#603">603</a> <em> *</em><a name="604" href="#604">604</a> <em> * @param annotation the annotation to add; should not contain </em><a name="605" href="#605">605</a> <em> * whitespace or a comma</em><a name="606" href="#606">606</a> <em> */</em><a name="607" href="#607">607</a> <strong>public</strong> <strong>void</strong> addAnnotation(String annotation) {<a name="608" href="#608">608</a> String annotations;<a name="609" href="#609">609</a> <strong>if</strong>(containsKey(A_ANNOTATIONS)) {<a name="610" href="#610">610</a> annotations = getString(A_ANNOTATIONS);<a name="611" href="#611">611</a> annotations += <span class="string">","</span>+annotation;<a name="612" href="#612">612</a> } <strong>else</strong> {<a name="613" href="#613">613</a> annotations = annotation;<a name="614" href="#614">614</a> }<a name="615" href="#615">615</a> <a name="616" href="#616">616</a> putString(A_ANNOTATIONS,annotations);<a name="617" href="#617">617</a> }<a name="618" href="#618">618</a> <a name="619" href="#619">619</a> <em>/**<em>*</em></em><a name="620" href="#620">620</a> <em> * TODO: Implement truncation using booleans rather than as this</em><a name="621" href="#621">621</a> <em> * ugly String parse.</em><a name="622" href="#622">622</a> <em> * @return True if fetch was truncated.</em><a name="623" href="#623">623</a> <em> */</em><a name="624" href="#624">624</a> <strong>public</strong> <strong>boolean</strong> isTruncatedFetch() {<a name="625" href="#625">625</a> <strong>return</strong> annotationContains(TRUNC_SUFFIX);<a name="626" href="#626">626</a> }<a name="627" href="#627">627</a> <a name="628" href="#628">628</a> <strong>public</strong> <strong>boolean</strong> isLengthTruncatedFetch() {<a name="629" href="#629">629</a> <strong>return</strong> annotationContains(LENGTH_TRUNC);<a name="630" href="#630">630</a> }<a name="631" href="#631">631</a> <a name="632" href="#632">632</a> <strong>public</strong> <strong>boolean</strong> isTimeTruncatedFetch() {<a name="633" href="#633">633</a> <strong>return</strong> annotationContains(TIMER_TRUNC);<a name="634" href="#634">634</a> }<a name="635" href="#635">635</a> <a name="636" href="#636">636</a> <strong>public</strong> <strong>boolean</strong> isHeaderTruncatedFetch() {<a name="637" href="#637">637</a> <strong>return</strong> annotationContains(HEADER_TRUNC);<a name="638" href="#638">638</a> }<a name="639" href="#639">639</a> <a name="640" href="#640">640</a> <strong>protected</strong> <strong>boolean</strong> annotationContains(<strong>final</strong> String str2Find) {<a name="641" href="#641">641</a> <strong>boolean</strong> result = false;<a name="642" href="#642">642</a> <strong>if</strong> (!containsKey(A_ANNOTATIONS)) {<a name="643" href="#643">643</a> <strong>return</strong> result;<a name="644" href="#644">644</a> }<a name="645" href="#645">645</a> String annotations = getString(A_ANNOTATIONS);<a name="646" href="#646">646</a> <strong>if</strong> (annotations != <strong>null</strong> && annotations.length() > 0) {<a name="647" href="#647">647</a> result = annotations.indexOf(str2Find) >= 0;<a name="648" href="#648">648</a> }<a name="649" href="#649">649</a> <strong>return</strong> result;<a name="650" href="#650">650</a> }<a name="651" href="#651">651</a> <a name="652" href="#652">652</a> <em>/**<em>*</em></em><a name="653" href="#653">653</a> <em> * Get the annotations set for this uri.</em><a name="654" href="#654">654</a> <em> *</em><a name="655" href="#655">655</a> <em> * @return the annotations set for this uri.</em><a name="656" href="#656">656</a> <em> */</em><a name="657" href="#657">657</a> <strong>public</strong> String getAnnotations() {<a name="658" href="#658">658</a> <strong>return</strong> (containsKey(A_ANNOTATIONS))?<a name="659" href="#659">659</a> getString(A_ANNOTATIONS): <strong>null</strong>;<a name="660" href="#660">660</a> }<a name="661" href="#661">661</a> <a name="662" href="#662">662</a> <em>/**<em>*</em></em><a name="663" href="#663">663</a> <em> * Get the embeded hop count.</em><a name="664" href="#664">664</a> <em> *</em><a name="665" href="#665">665</a> <em> * @return the embeded hop count.</em><a name="666" href="#666">666</a> <em> */</em><a name="667" href="#667">667</a> <strong>public</strong> <strong>int</strong> getEmbedHopCount() {<a name="668" href="#668">668</a> <strong>return</strong> embedHopCount;<a name="669" href="#669">669</a> }<a name="670" href="#670">670</a> <a name="671" href="#671">671</a> <em>/**<em>*</em></em><a name="672" href="#672">672</a> <em> * Get the link hop count.</em><a name="673" href="#673">673</a> <em> *</em><a name="674" href="#674">674</a> <em> * @return the link hop count.</em><a name="675" href="#675">675</a> <em> */</em><a name="676" href="#676">676</a> <strong>public</strong> <strong>int</strong> getLinkHopCount() {<a name="677" href="#677">677</a> <strong>return</strong> linkHopCount;<a name="678" href="#678">678</a> }<a name="679" href="#679">679</a> <a name="680" href="#680">680</a> <em>/**<em>*</em></em><a name="681" href="#681">681</a> <em> * Mark this uri as being a seed.</em><a name="682" href="#682">682</a> <em> *</em><a name="683" href="#683">683</a> <em> */</em><a name="684" href="#684">684</a> <strong>public</strong> <strong>void</strong> markAsSeed() {<a name="685" href="#685">685</a> linkHopCount = 0;<a name="686" href="#686">686</a> embedHopCount = 0;<a name="687" href="#687">687</a> }<a name="688" href="#688">688</a> <a name="689" href="#689">689</a> <em>/**<em>*</em></em><a name="690" href="#690">690</a> <em> * Get the user agent to use for crawling this URI.</em><a name="691" href="#691">691</a> <em> *</em><a name="692" href="#692">692</a> <em> * If null the global setting should be used.</em><a name="693" href="#693">693</a> <em> *</em><a name="694" href="#694">694</a> <em> * @return user agent or null</em><a name="695" href="#695">695</a> <em> */</em><a name="696" href="#696">696</a> <strong>public</strong> String getUserAgent() {<a name="697" href="#697">697</a> <strong>return</strong> userAgent;<a name="698" href="#698">698</a> }<a name="699" href="#699">699</a> <a name="700" href="#700">700</a> <em>/**<em>*</em></em><a name="701" href="#701">701</a> <em> * Set the user agent to use when crawling this URI.</em><a name="702" href="#702">702</a> <em> *</em><a name="703" href="#703">703</a> <em> * If not set the global settings should be used.</em><a name="704" href="#704">704</a> <em> *</em><a name="705" href="#705">705</a> <em> * @param string user agent to use</em><a name="706" href="#706">706</a> <em> */</em><a name="707" href="#707">707</a> <strong>public</strong> <strong>void</strong> setUserAgent(String string) {<a name="708" href="#708">708</a> userAgent = string;<a name="709" href="#709">709</a> }<a name="710" href="#710">710</a> <a name="711" href="#711">711</a> <em>/**<em>*</em></em><a name="712" href="#712">712</a> <em> * Set which processor should be the next processor to process this uri</em><a name="713" href="#713">713</a> <em> * instead of using the default next processor.</em><a name="714" href="#714">714</a> <em> *</em><a name="715" href="#715">715</a> <em> * @param processorChain the processor chain to skip to.</em><a name="716" href="#716">716</a> <em> * @param processor the processor in the processor chain to skip to.</em><a name="717" href="#717">717</a> <em> */</em><a name="718" href="#718">718</a> <strong>public</strong> <strong>void</strong> skipToProcessor(<a href="../../../../org/archive/crawler/framework/ProcessorChain.html">ProcessorChain</a> processorChain,<a name="719" href="#719">719</a> <a href="../../../../org/archive/crawler/framework/Processor.html">Processor</a> processor) {<a name="720" href="#720">720</a> setNextProcessorChain(processorChain);<a name="721" href="#721">721</a> setNextProcessor(processor);<a name="722" href="#722">722</a> }<a name="723" href="#723">723</a> <a name="724" href="#724">724</a> <em>/**<em>*</em></em><a name="725" href="#725">725</a> <em> * Set which processor chain should be processing this uri next.</em><a name="726" href="#726">726</a> <em> *</em><a name="727" href="#727">727</a> <em> * @param processorChain the processor chain to skip to.</em><a name="728" href="#728">728</a> <em> */</em><a name="729" href="#729">729</a> <strong>public</strong> <strong>void</strong> skipToProcessorChain(<a href="../../../../org/archive/crawler/framework/ProcessorChain.html">ProcessorChain</a> processorChain) {<a name="730" href="#730">730</a> setNextProcessorChain(processorChain);<a name="731" href="#731">731</a> setNextProcessor(<strong>null</strong>);<a name="732" href="#732">732</a> }<a name="733" href="#733">733</a> <a name="734" href="#734">734</a> <em>/**<em>*</em></em><a name="735" href="#735">735</a> <em> * For completed HTTP transactions, the length of the content-body.</em><a name="736" href="#736">736</a> <em> *</em><a name="737" href="#737">737</a> <em> * @return For completed HTTP transactions, the length of the content-body.</em><a name="738" href="#738">738</a> <em> */</em><a name="739" href="#739">739</a> <strong>public</strong> <strong>long</strong> getContentLength() {<a name="740" href="#740">740</a> <strong>if</strong> (<strong>this</strong>.contentLength < 0) {<a name="741" href="#741">741</a> <strong>this</strong>.contentLength = (getHttpRecorder() != <strong>null</strong>)?<a name="742" href="#742">742</a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -