de.scheisseichfindemalkeinen.rules
Class Rule

java.lang.Object
  extended by de.scheisseichfindemalkeinen.hoster.Hoster
      extended by de.scheisseichfindemalkeinen.rules.Rule

public class Rule
extends Hoster

A Rule can be defined by the user. The input is then the Container-URL or the Sourcecode of the Container-URL. The user can define if the rule should do a replacement in the Container-URL or download the Container-Page and do a replacement there. For the replacement Regular Expressions are used. There also the possibillity to do a replacement for a nicer filename. A rule has for all those modes pipelines. So in a pipeline multiple replacements can be defined. A rule is stored as an XML-File.


Field Summary
static int DUPLICATES_BH_DEFAULT
          DUPLICATES_BH_DEFAULT
static int DUPLICATES_CONTAINER_URL_AND_THUMBNAIL_URL
          DUPLICATES_CONTAINER_URL_AND_THUMBNAIL_URL
static int DUPLICATES_CONTAINER_URL_ONLY
          DUPLICATES_CONTAINER_URL_ONLY
static int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_FIRST
          DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_FIRST
static int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_LAST
          DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_LAST
static int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_FIRST
          DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_FIRST
static int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_LAST
          DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_LAST
static org.apache.log4j.Logger logger
          Logger for this class
static int REFERRER_CUSTOM
          Custom string as referrer
static int REFERRER_FIRST_CONTAINER_URL
          Last Container-URL as referrer
static int REFERRER_LAST_CONTAINER_URL
          Last Container-URL as referrer
static int REFERRER_NO_REFERRER
          No referrer
static int REFERRER_ORIGIN_PAGE
          Origin-Page (Referrer-URL) as referrer
static int RULE_MODE_CONTAINER_OR_THUMBNAIL_URL
          Replace in Container-URL or Thumbnail-URL
static int RULE_MODE_CONTAINER_PAGE_SOURCECODE
          Replace in Container-Page-Sourcecode
static int RULE_MODE_FILENAME
          Replace Filename
static int RULE_MODE_FILENAME_ON_DOWNLOAD_SELECTION
          Replace Filename
 
Constructor Summary
Rule(java.lang.String file)
          Constructor
Rule(java.lang.String name, java.lang.String version, int mode, java.lang.String pattern, java.lang.String file)
          Constructor
 
Method Summary
static java.lang.String downloadContainerPage(java.lang.String url, java.lang.String referrer)
          Downloads and Returns the sourcecode of a Container-Page
 java.lang.String getCustomReferrer()
          Returns the customReferrer
 java.lang.String getCustomReferrerDownload()
          Returns the customReferrerDownload
 int getDuplicateRemoveMode()
          Returns the duplicateRemoveMode
 java.io.File getFile()
          Returns the path of the XML-File
 java.lang.String getFilename(java.lang.String url)
          Returns the filename after replacement
 java.util.Vector<java.lang.String> getMaxConnectionDomains()
          Returns the maxConnectionDomains
 int getMaxConnections()
          Returns the maxConnections
 java.lang.String getName()
          Returns the name
 java.lang.String getPattern()
          Returns the Container-URL-Pattern
 RulePipeline getPipelineFilename()
          Returns the pipelineFilename
 RulePipeline getPipelineFilenameDownloadSelection()
          Returns the pipelineFilenameDownloadSelection
 java.util.Vector<RulePipeline> getPipelines()
          Returns the pipelines Filename- and Filename-on-Download-Selection pipelines are not included
 int getReferrerMode()
          Returns the referrerMode
 int getReferrerModeDownload()
          Returns the referrerModeDownload
 boolean getStatusOK()
          Returns if the status of the object is ok
 java.lang.String[] getURLAndFilename(URLParseObject upo)
          Returns parsed URL and filename
 java.lang.String[] getURLAndFilename(URLParseObject upo, OptionString pagesourcecode)
          Returns parsed URL and filename
 java.lang.String getVersion()
          Returns the version
 boolean isFromThisHoster(java.lang.String url, Rule sourceRule)
          Returns if this rule can parse the URL
 boolean isResend()
          Returns if the URL must again be parsed by the HostManager
 boolean isUseContentDisposition()
          Returns the useContentDisposition
 boolean removeDuplicateEqualsMethod(URL url1, URL url2)
          Method to compare to URLs for removing duplicate URLs Attention: This Method is called always when the equals-Method on an URL-Object is called.
 void setCustomReferrer(java.lang.String customReferrer)
          Sets the customReferrer
 void setCustomReferrerDownload(java.lang.String customReferrerDownload)
          Sets the customReferrerDownload
 void setDuplicateRemoveMode(int duplicateRemoveMode)
          Sets the duplicateRemoveMode
 void setFile(java.io.File file)
          Sets the path of the XML-File
 void setMaxConnectionDomains(java.util.Vector<java.lang.String> maxConnectionDomains)
          Sets the maxConnectionDomains
 void setMaxConnections(int maxConnections)
          Sets the maxConnections
 void setName(java.lang.String name)
          Sets the name
 void setPattern(java.lang.String pattern)
          Sets the Container-URL-Pattern
 void setReferrerMode(int referrerMode)
          Sets the referrerMode
 void setReferrerModeDownload(int referrerModeDownload)
          Sets the referrerModeDownload
 void setResend(boolean resend)
          Sets the flag
 void setUseContentDisposition(boolean useContentDisposition)
          Sets the useContentDisposition
 void setVersion(java.lang.String version)
          Sets the version
 java.lang.String toString()
           
 boolean writeRule()
          Saves the rule to the XML-File
 
Methods inherited from class de.scheisseichfindemalkeinen.hoster.Hoster
isDeveloper, setDeveloper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RULE_MODE_CONTAINER_OR_THUMBNAIL_URL

public static final int RULE_MODE_CONTAINER_OR_THUMBNAIL_URL
Replace in Container-URL or Thumbnail-URL

See Also:
Constant Field Values

RULE_MODE_CONTAINER_PAGE_SOURCECODE

public static final int RULE_MODE_CONTAINER_PAGE_SOURCECODE
Replace in Container-Page-Sourcecode

See Also:
Constant Field Values

RULE_MODE_FILENAME

public static final int RULE_MODE_FILENAME
Replace Filename

See Also:
Constant Field Values

RULE_MODE_FILENAME_ON_DOWNLOAD_SELECTION

public static final int RULE_MODE_FILENAME_ON_DOWNLOAD_SELECTION
Replace Filename

See Also:
Constant Field Values

REFERRER_NO_REFERRER

public static final int REFERRER_NO_REFERRER
No referrer

See Also:
Constant Field Values

REFERRER_LAST_CONTAINER_URL

public static final int REFERRER_LAST_CONTAINER_URL
Last Container-URL as referrer

See Also:
Constant Field Values

REFERRER_FIRST_CONTAINER_URL

public static final int REFERRER_FIRST_CONTAINER_URL
Last Container-URL as referrer

See Also:
Constant Field Values

REFERRER_ORIGIN_PAGE

public static final int REFERRER_ORIGIN_PAGE
Origin-Page (Referrer-URL) as referrer

See Also:
Constant Field Values

REFERRER_CUSTOM

public static final int REFERRER_CUSTOM
Custom string as referrer

See Also:
Constant Field Values

DUPLICATES_BH_DEFAULT

public static final int DUPLICATES_BH_DEFAULT
DUPLICATES_BH_DEFAULT

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_ONLY

public static final int DUPLICATES_CONTAINER_URL_ONLY
DUPLICATES_CONTAINER_URL_ONLY

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_AND_THUMBNAIL_URL

public static final int DUPLICATES_CONTAINER_URL_AND_THUMBNAIL_URL
DUPLICATES_CONTAINER_URL_AND_THUMBNAIL_URL

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_FIRST

public static final int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_FIRST
DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_FIRST

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_LAST

public static final int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_LAST
DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITH_THUMB_THUMBS_ALWAYS_LAST

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_FIRST

public static final int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_FIRST
DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_FIRST

See Also:
Constant Field Values

DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_LAST

public static final int DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_LAST
DUPLICATES_CONTAINER_URL_ONLY_REMOVE_WITHOUT_THUMB_THUMBS_ALWAYS_LAST

See Also:
Constant Field Values

logger

public static org.apache.log4j.Logger logger
Logger for this class

Constructor Detail

Rule

public Rule(java.lang.String file)
Constructor

Parameters:
file - Path to the XML-File

Rule

public Rule(java.lang.String name,
            java.lang.String version,
            int mode,
            java.lang.String pattern,
            java.lang.String file)
Constructor

Parameters:
name - Name
version - Version
mode - Mode
pattern - Container-URL-Pattern
file - Path to the XML-File
Method Detail

isFromThisHoster

public boolean isFromThisHoster(java.lang.String url,
                                Rule sourceRule)
Returns if this rule can parse the URL

Parameters:
url - Container-URL
sourceRule - Last rule which parsed the URL
Returns:
True if this rule can parse the URL

getStatusOK

public boolean getStatusOK()
Returns if the status of the object is ok

Returns:
True if ok

getURLAndFilename

public java.lang.String[] getURLAndFilename(URLParseObject upo)
                                     throws HostException
Returns parsed URL and filename

Parameters:
upo - URLParseObject
Returns:
URL and filename
Throws:
HostException

getURLAndFilename

public java.lang.String[] getURLAndFilename(URLParseObject upo,
                                            OptionString pagesourcecode)
                                     throws HostException
Returns parsed URL and filename

Parameters:
upo - URLParseObject
pagesourcecode - Container-Page-Source-Code
Returns:
URL and filename
Throws:
HostException

getFilename

public java.lang.String getFilename(java.lang.String url)
Returns the filename after replacement

Parameters:
url - URL
Returns:
Filename

writeRule

public boolean writeRule()
Saves the rule to the XML-File

Returns:
True if successful

getName

public java.lang.String getName()
Returns the name

Returns:
Name

setName

public void setName(java.lang.String name)
Sets the name

Parameters:
name - Name

getVersion

public java.lang.String getVersion()
Returns the version

Returns:
Version

setVersion

public void setVersion(java.lang.String version)
Sets the version

Parameters:
version - Version

getPattern

public java.lang.String getPattern()
Returns the Container-URL-Pattern

Returns:
Container-URL-Pattern

setPattern

public void setPattern(java.lang.String pattern)
Sets the Container-URL-Pattern

Parameters:
pattern - Container-URL-Pattern

getPipelines

public java.util.Vector<RulePipeline> getPipelines()
Returns the pipelines Filename- and Filename-on-Download-Selection pipelines are not included

Returns:
Pipelines

getPipelineFilename

public RulePipeline getPipelineFilename()
Returns the pipelineFilename

Returns:
pipelineFilename

getPipelineFilenameDownloadSelection

public RulePipeline getPipelineFilenameDownloadSelection()
Returns the pipelineFilenameDownloadSelection

Returns:
pipelineFilenameDownloadSelection

getFile

public java.io.File getFile()
Returns the path of the XML-File

Returns:
Path of the XML-File

setFile

public void setFile(java.io.File file)
Sets the path of the XML-File

Parameters:
file - Path of the XML-File

downloadContainerPage

public static java.lang.String downloadContainerPage(java.lang.String url,
                                                     java.lang.String referrer)
                                              throws HostException
Downloads and Returns the sourcecode of a Container-Page

Parameters:
url - Container-URL
referrer - Referrer
Returns:
Sourcecode
Throws:
HostException

isResend

public boolean isResend()
Returns if the URL must again be parsed by the HostManager

Returns:
True if the URL must again be parsed by the HostManager

setResend

public void setResend(boolean resend)
Sets the flag

Parameters:
resend - Flag if the URL must again be parsed by the HostManager

isUseContentDisposition

public boolean isUseContentDisposition()
Returns the useContentDisposition

Returns:
useContentDisposition

setUseContentDisposition

public void setUseContentDisposition(boolean useContentDisposition)
Sets the useContentDisposition

Parameters:
useContentDisposition - useContentDisposition

getReferrerMode

public int getReferrerMode()
Returns the referrerMode

Returns:
referrerMode

setReferrerMode

public void setReferrerMode(int referrerMode)
Sets the referrerMode

Parameters:
referrerMode - referrerMode

getReferrerModeDownload

public int getReferrerModeDownload()
Returns the referrerModeDownload

Returns:
referrerModeDownload

setReferrerModeDownload

public void setReferrerModeDownload(int referrerModeDownload)
Sets the referrerModeDownload

Parameters:
referrerModeDownload - referrerModeDownload

getCustomReferrer

public java.lang.String getCustomReferrer()
Returns the customReferrer

Returns:
customReferrer

setCustomReferrer

public void setCustomReferrer(java.lang.String customReferrer)
Sets the customReferrer

Parameters:
customReferrer - customReferrer

getCustomReferrerDownload

public java.lang.String getCustomReferrerDownload()
Returns the customReferrerDownload

Returns:
customReferrerDownload

setCustomReferrerDownload

public void setCustomReferrerDownload(java.lang.String customReferrerDownload)
Sets the customReferrerDownload

Parameters:
customReferrerDownload - customReferrerDownload

getMaxConnections

public int getMaxConnections()
Returns the maxConnections

Returns:
maxConnections

setMaxConnections

public void setMaxConnections(int maxConnections)
Sets the maxConnections

Parameters:
maxConnections - maxConnections

getMaxConnectionDomains

public java.util.Vector<java.lang.String> getMaxConnectionDomains()
Returns the maxConnectionDomains

Returns:
maxConnectionDomains

setMaxConnectionDomains

public void setMaxConnectionDomains(java.util.Vector<java.lang.String> maxConnectionDomains)
Sets the maxConnectionDomains

Parameters:
maxConnectionDomains - maxConnectionDomains

getDuplicateRemoveMode

public int getDuplicateRemoveMode()
Returns the duplicateRemoveMode

Returns:
duplicateRemoveMode

setDuplicateRemoveMode

public void setDuplicateRemoveMode(int duplicateRemoveMode)
Sets the duplicateRemoveMode

Parameters:
duplicateRemoveMode - duplicateRemoveMode

removeDuplicateEqualsMethod

public boolean removeDuplicateEqualsMethod(URL url1,
                                           URL url2)
Description copied from class: Hoster
Method to compare to URLs for removing duplicate URLs Attention: This Method is called always when the equals-Method on an URL-Object is called. And this happens as example on contains-Method on Collections and so on. So don't overwrite this Method until it is really necessary! If you overwrite this Method, then you have to know what you are doing!

Overrides:
removeDuplicateEqualsMethod in class Hoster
Parameters:
url1 - URL
url2 - URL
Returns:
True if url1 equals url2

toString

public java.lang.String toString()
Specified by:
toString in class Hoster