Package com.biglybt.core.metasearch.impl
Class EngineImpl
- java.lang.Object
-
- com.biglybt.core.metasearch.impl.EngineImpl
-
- All Implemented Interfaces:
Engine
- Direct Known Subclasses:
PluginEngine
,WebEngine
public abstract class EngineImpl extends java.lang.Object implements Engine
-
-
Field Summary
Fields Modifier and Type Field Description private int
az_version
private static int
DEFAULT_UPDATE_CHECK_SECS
private java.util.List
first_level_mapping
private long
id
private boolean
is_public
private long
last_updated
protected static java.lang.String
LD_AUTO_DL_SUPPORTED
protected static java.lang.String
LD_COOKIES
protected static java.lang.String
LD_CREATED_BY_ME
protected static java.lang.String
LD_ETAG
protected static java.lang.String
LD_LAST_MODIFIED
protected static java.lang.String
LD_LAST_UPDATE_CHECK
protected static java.lang.String
LD_LINK_IS_TORRENT
protected static java.lang.String
LD_UPDATE_CHECK_SECS
(package private) static boolean
logging_enabled
private MetaSearchImpl
meta_search
private java.lang.String
name
private float
preferred_count
private float
rank_bias
private java.util.List
second_level_mapping
private int
selection_state
private boolean
selection_state_recorded
private int
source
private int
type
private byte[]
uid
private int
update_check_default_secs
private java.lang.String
update_url
private java.util.Map
user_data
private int
version
-
Fields inherited from interface com.biglybt.core.metasearch.Engine
AUTO_DL_SUPPORTED_NO, AUTO_DL_SUPPORTED_UNKNOWN, AUTO_DL_SUPPORTED_YES, AZ_VERSION, CT_AUDIO, CT_GAME, CT_VIDEO, ENGINE_SOURCE_LOCAL, ENGINE_SOURCE_RSS, ENGINE_SOURCE_STRS, ENGINE_SOURCE_UNKNOWN, ENGINE_SOURCE_VUZE, ENGINE_TYPE_JSON, ENGINE_TYPE_PLUGIN, ENGINE_TYPE_REGEX, ENGINE_TYPE_RSS, ENGINE_TYPE_STRS, FIELD_ASSET_DATE, FIELD_CATEGORY, FIELD_CDPLINK, FIELD_COMMENTS, FIELD_CONTENT_TYPE, FIELD_DATE, FIELD_DISCARD, FIELD_DOWNLOADBTNLINK, FIELD_DRMKEY, FIELD_HASH, FIELD_IDS, FIELD_NAME, FIELD_NAMES, FIELD_PEERS, FIELD_PLAYLINK, FIELD_PRIVATE, FIELD_RANK, FIELD_SEEDS, FIELD_SIZE, FIELD_SUPERSEEDS, FIELD_TORRENTLINK, FIELD_VOTES, FIELD_VOTES_DOWN, SC_BATCH_PERIOD, SC_FORCE_FULL, SC_REMOVE_DUP_HASH, SC_SOURCE, SEL_STATE_AUTO_SELECTED, SEL_STATE_DESELECTED, SEL_STATE_FORCE_DESELECTED, SEL_STATE_MANUAL_SELECTED, SEL_STATE_STRINGS, VUZE_FILE_COMPONENT_ENGINE_KEY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EngineImpl(MetaSearchImpl _meta_search, int _type, long _id, long _last_updated, float _rank_bias, java.lang.String _name)
protected
EngineImpl(MetaSearchImpl meta_search, int type, long id, long last_updated, float rank_bias, java.lang.String name, JSONObject map)
protected
EngineImpl(MetaSearchImpl _meta_search, java.util.Map map)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPotentialAssociation(java.lang.String key)
protected void
allocateUID(long id)
float
applyRankBias(float _rank)
void
checkSelectionStateRecorded()
protected void
configDirty()
protected void
debugLog(java.lang.String str)
protected void
debugStart()
void
delete()
protected void
exportBEncodedMappings(java.util.Map map, java.lang.String name, java.util.List mappings)
protected void
exportJSONMappings(JSONObject res, java.lang.String str, java.util.List l, boolean level_1)
protected void
exportToBencodedMap(java.util.Map map, boolean generic)
protected void
exportToJSONObject(JSONObject res)
java.lang.String
exportToJSONString()
VuzeFile
exportToVuzeFile()
VuzeFile
exportToVuzeFile(boolean generic)
void
exportToVuzeFile(java.io.File target)
int
getAutoDownloadSupported()
int
getAZVersion()
protected java.io.File
getDebugFile()
long
getId()
protected long
getLastUpdateCheck()
long
getLastUpdated()
protected boolean
getLocalBoolean(java.lang.String key, boolean def)
private java.lang.String
getLocalKey()
protected long
getLocalLong(java.lang.String key, long def)
protected java.lang.String
getLocalString(java.lang.String key)
protected MetaSearchImpl
getMetaSearch()
java.lang.String
getName()
float
getPreferredWeighting()
float
getRankBias()
int
getSelectionState()
int
getSource()
java.lang.String
getString()
java.lang.String
getString(boolean full)
Subscription
getSubscription()
int
getType()
java.lang.String
getUID()
protected int
getUpdateCheckSecs()
protected java.lang.String
getUpdateURL()
protected java.lang.Object
getUserData(java.lang.Object key)
int
getVersion()
protected java.util.List
importBEncodedMappings(java.util.Map map, java.lang.String name)
protected static EngineImpl
importFromBEncodedMap(MetaSearchImpl meta_search, java.util.Map map)
static Engine
importFromJSONString(MetaSearchImpl meta_search, int type, long id, long last_updated, float rank_bias, java.lang.String name, java.lang.String content)
protected java.util.List
importJSONMappings(JSONObject map, java.lang.String str, boolean level_1)
boolean
isActive()
boolean
isAuthenticated()
boolean
isMine()
boolean
isPublic()
protected void
log(java.lang.String str)
protected void
log(java.lang.String str, java.lang.Throwable e)
protected Result[]
mapResults(Result[] results)
void
recordSelectionState()
void
reset()
resets to initial state (e.g.boolean
sameLogicAs(Engine other)
Tests for sameness in terms of function (ignores id, selection state etc)Result[]
search(SearchParameter[] params, java.util.Map context, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener)
protected Result[]
searchAndMap(SearchParameter[] params, java.util.Map context, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener)
protected abstract Result[]
searchSupport(SearchParameter[] params, java.util.Map searchContext, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener)
protected void
setDefaultUpdateCheckSecs(int secs)
protected void
setId(long _id)
protected void
setLastUpdateCheck(long when)
protected void
setLocalBoolean(java.lang.String key, boolean value)
protected void
setLocalLong(java.lang.String key, long value)
protected void
setLocalString(java.lang.String key, java.lang.String value)
protected void
setLocalUpdateCheckSecs(int secs)
void
setMine(boolean mine)
protected void
setName(java.lang.String n)
void
setPreferredDelta(float delta)
protected void
setPublic(boolean p)
void
setRankBias(float _rank_bias)
void
setSelectionState(int state)
void
setSource(int _source)
protected void
setUID(java.lang.String str)
protected void
setUpdateURL(java.lang.String url)
protected void
setUserData(java.lang.Object key, java.lang.Object value)
protected void
setVersion(int _v)
protected int
vuzeFieldToID(java.lang.String field)
protected java.lang.String
vuzeIDToField(int id)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.metasearch.Engine
exportToBencodedMap, exportToBencodedMap, getDownloadLinkCSS, getIcon, getNameEx, getReferer, isAnonymous, isShareable, supportsContext, supportsField
-
-
-
-
Field Detail
-
DEFAULT_UPDATE_CHECK_SECS
private static final int DEFAULT_UPDATE_CHECK_SECS
- See Also:
- Constant Field Values
-
logging_enabled
static boolean logging_enabled
-
LD_COOKIES
protected static final java.lang.String LD_COOKIES
- See Also:
- Constant Field Values
-
LD_ETAG
protected static final java.lang.String LD_ETAG
- See Also:
- Constant Field Values
-
LD_LAST_MODIFIED
protected static final java.lang.String LD_LAST_MODIFIED
- See Also:
- Constant Field Values
-
LD_LAST_UPDATE_CHECK
protected static final java.lang.String LD_LAST_UPDATE_CHECK
- See Also:
- Constant Field Values
-
LD_UPDATE_CHECK_SECS
protected static final java.lang.String LD_UPDATE_CHECK_SECS
- See Also:
- Constant Field Values
-
LD_CREATED_BY_ME
protected static final java.lang.String LD_CREATED_BY_ME
- See Also:
- Constant Field Values
-
LD_AUTO_DL_SUPPORTED
protected static final java.lang.String LD_AUTO_DL_SUPPORTED
- See Also:
- Constant Field Values
-
LD_LINK_IS_TORRENT
protected static final java.lang.String LD_LINK_IS_TORRENT
- See Also:
- Constant Field Values
-
meta_search
private MetaSearchImpl meta_search
-
type
private int type
-
id
private long id
-
last_updated
private long last_updated
-
name
private java.lang.String name
-
uid
private byte[] uid
-
version
private int version
-
is_public
private boolean is_public
-
az_version
private int az_version
-
selection_state
private int selection_state
-
selection_state_recorded
private boolean selection_state_recorded
-
source
private int source
-
rank_bias
private float rank_bias
-
preferred_count
private float preferred_count
-
first_level_mapping
private java.util.List first_level_mapping
-
second_level_mapping
private java.util.List second_level_mapping
-
update_url
private java.lang.String update_url
-
update_check_default_secs
private int update_check_default_secs
-
user_data
private java.util.Map user_data
-
-
Constructor Detail
-
EngineImpl
protected EngineImpl(MetaSearchImpl _meta_search, int _type, long _id, long _last_updated, float _rank_bias, java.lang.String _name)
-
EngineImpl
protected EngineImpl(MetaSearchImpl _meta_search, java.util.Map map) throws java.io.IOException
- Throws:
java.io.IOException
-
EngineImpl
protected EngineImpl(MetaSearchImpl meta_search, int type, long id, long last_updated, float rank_bias, java.lang.String name, JSONObject map) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
importFromBEncodedMap
protected static EngineImpl importFromBEncodedMap(MetaSearchImpl meta_search, java.util.Map map) throws java.io.IOException
- Throws:
java.io.IOException
-
importFromJSONString
public static Engine importFromJSONString(MetaSearchImpl meta_search, int type, long id, long last_updated, float rank_bias, java.lang.String name, java.lang.String content) throws java.io.IOException
- Throws:
java.io.IOException
-
exportToBencodedMap
protected void exportToBencodedMap(java.util.Map map, boolean generic) throws java.io.IOException
- Throws:
java.io.IOException
-
exportToJSONObject
protected void exportToJSONObject(JSONObject res) throws java.io.IOException
- Throws:
java.io.IOException
-
importJSONMappings
protected java.util.List importJSONMappings(JSONObject map, java.lang.String str, boolean level_1) throws java.io.IOException
- Throws:
java.io.IOException
-
exportJSONMappings
protected void exportJSONMappings(JSONObject res, java.lang.String str, java.util.List l, boolean level_1)
-
importBEncodedMappings
protected java.util.List importBEncodedMappings(java.util.Map map, java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
exportBEncodedMappings
protected void exportBEncodedMappings(java.util.Map map, java.lang.String name, java.util.List mappings) throws java.io.IOException
- Throws:
java.io.IOException
-
exportToJSONString
public java.lang.String exportToJSONString() throws java.io.IOException
- Specified by:
exportToJSONString
in interfaceEngine
- Throws:
java.io.IOException
-
getAZVersion
public int getAZVersion()
- Specified by:
getAZVersion
in interfaceEngine
-
getVersion
public int getVersion()
- Specified by:
getVersion
in interfaceEngine
-
setVersion
protected void setVersion(int _v)
-
setUID
protected void setUID(java.lang.String str)
-
allocateUID
protected void allocateUID(long id)
-
sameLogicAs
public boolean sameLogicAs(Engine other)
Description copied from interface:Engine
Tests for sameness in terms of function (ignores id, selection state etc)- Specified by:
sameLogicAs
in interfaceEngine
- Returns:
-
search
public Result[] search(SearchParameter[] params, java.util.Map context, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener) throws SearchException
- Specified by:
search
in interfaceEngine
- Throws:
SearchException
-
searchAndMap
protected Result[] searchAndMap(SearchParameter[] params, java.util.Map context, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener) throws SearchException
- Throws:
SearchException
-
searchSupport
protected abstract Result[] searchSupport(SearchParameter[] params, java.util.Map searchContext, int desired_max_matches, int absolute_max_matches, java.lang.String headers, ResultListener listener) throws SearchException
- Throws:
SearchException
-
getMetaSearch
protected MetaSearchImpl getMetaSearch()
-
vuzeFieldToID
protected int vuzeFieldToID(java.lang.String field)
-
vuzeIDToField
protected java.lang.String vuzeIDToField(int id)
-
setId
protected void setId(long _id)
-
getLastUpdated
public long getLastUpdated()
- Specified by:
getLastUpdated
in interfaceEngine
-
setName
protected void setName(java.lang.String n)
-
setPublic
protected void setPublic(boolean p)
-
getSelectionState
public int getSelectionState()
- Specified by:
getSelectionState
in interfaceEngine
-
setSelectionState
public void setSelectionState(int state)
- Specified by:
setSelectionState
in interfaceEngine
-
isAuthenticated
public boolean isAuthenticated()
- Specified by:
isAuthenticated
in interfaceEngine
-
recordSelectionState
public void recordSelectionState()
- Specified by:
recordSelectionState
in interfaceEngine
-
checkSelectionStateRecorded
public void checkSelectionStateRecorded()
- Specified by:
checkSelectionStateRecorded
in interfaceEngine
-
getRankBias
public float getRankBias()
- Specified by:
getRankBias
in interfaceEngine
-
setRankBias
public void setRankBias(float _rank_bias)
- Specified by:
setRankBias
in interfaceEngine
-
setPreferredDelta
public void setPreferredDelta(float delta)
- Specified by:
setPreferredDelta
in interfaceEngine
-
getPreferredWeighting
public float getPreferredWeighting()
- Specified by:
getPreferredWeighting
in interfaceEngine
-
applyRankBias
public float applyRankBias(float _rank)
- Specified by:
applyRankBias
in interfaceEngine
-
getUpdateURL
protected java.lang.String getUpdateURL()
-
setUpdateURL
protected void setUpdateURL(java.lang.String url)
-
getUpdateCheckSecs
protected int getUpdateCheckSecs()
-
setDefaultUpdateCheckSecs
protected void setDefaultUpdateCheckSecs(int secs)
-
setLocalUpdateCheckSecs
protected void setLocalUpdateCheckSecs(int secs)
-
getLastUpdateCheck
protected long getLastUpdateCheck()
-
setLastUpdateCheck
protected void setLastUpdateCheck(long when)
-
getAutoDownloadSupported
public int getAutoDownloadSupported()
- Specified by:
getAutoDownloadSupported
in interfaceEngine
- Returns:
- one of AUTO_DL constants above
-
configDirty
protected void configDirty()
-
addPotentialAssociation
public void addPotentialAssociation(java.lang.String key)
- Specified by:
addPotentialAssociation
in interfaceEngine
-
getSubscription
public Subscription getSubscription()
- Specified by:
getSubscription
in interfaceEngine
-
exportToVuzeFile
public void exportToVuzeFile(java.io.File target) throws java.io.IOException
- Specified by:
exportToVuzeFile
in interfaceEngine
- Throws:
java.io.IOException
-
exportToVuzeFile
public VuzeFile exportToVuzeFile() throws java.io.IOException
- Specified by:
exportToVuzeFile
in interfaceEngine
- Throws:
java.io.IOException
-
exportToVuzeFile
public VuzeFile exportToVuzeFile(boolean generic) throws java.io.IOException
- Throws:
java.io.IOException
-
getLocalKey
private java.lang.String getLocalKey()
-
reset
public void reset()
Description copied from interface:Engine
resets to initial state (e.g. if the engine has state pertaining to what has/hasn't been downloaded such as etags then this will be cleared)
-
setLocalString
protected void setLocalString(java.lang.String key, java.lang.String value)
-
getLocalString
protected java.lang.String getLocalString(java.lang.String key)
-
setLocalBoolean
protected void setLocalBoolean(java.lang.String key, boolean value)
-
getLocalBoolean
protected boolean getLocalBoolean(java.lang.String key, boolean def)
-
setLocalLong
protected void setLocalLong(java.lang.String key, long value)
-
getLocalLong
protected long getLocalLong(java.lang.String key, long def)
-
setUserData
protected void setUserData(java.lang.Object key, java.lang.Object value)
-
getUserData
protected java.lang.Object getUserData(java.lang.Object key)
-
getDebugFile
protected java.io.File getDebugFile()
-
debugStart
protected void debugStart()
-
debugLog
protected void debugLog(java.lang.String str)
-
log
protected void log(java.lang.String str)
-
log
protected void log(java.lang.String str, java.lang.Throwable e)
-
getString
public java.lang.String getString(boolean full)
-
-