org.gudy.azureus2.plugins.utils
Interface Utilities

All Known Implementing Classes:
UtilitiesImpl

public interface Utilities


Nested Class Summary
static interface Utilities.JSONClient
           
static interface Utilities.JSONServer
           
 
Method Summary
 void addLocationProvider(LocationProvider provider)
           
 void addLocationProviderListener(LocationProviderListener listener)
           
 void addPowerManagementListener(PowerManagementListener listener)
           
 void addScriptProviderListener(ScriptProvider.ScriptProviderListener provider)
           
 ByteBuffer allocateDirectByteBuffer(int size)
           
 PooledByteBuffer allocatePooledByteBuffer(byte[] data)
           
 PooledByteBuffer allocatePooledByteBuffer(int size)
           
 PooledByteBuffer allocatePooledByteBuffer(Map data)
           
 int compareVersions(String v1, String v2)
          Compares two version strings for order.
 AggregatedDispatcher createAggregatedDispatcher(long idle_dispatch_time, long max_queue_size)
          create a dispatcher that will queue runnable items until either the limit is reached or the dispatcher hasn't had an entry added for the defined idle time
 AggregatedList createAggregatedList(AggregatedListAcceptor acceptor, long idle_dispatch_time, long max_queue_size)
           
 DelayedTask createDelayedTask(Runnable r)
          Adds a low priority task that will be scheduled at some point after existing tasks have completed.
 void createProcess(String command_line)
          create a child process and executes the supplied command line.
 void createThread(String name, Runnable target)
          create and run a thread for the target.
 UTTimer createTimer(String name)
          Creates a UTTimer instance.
 UTTimer createTimer(String name, boolean lightweight)
          Creates a UTTimer instance.
 UTTimer createTimer(String name, int priority)
          Creates a UTTimer instance.
 ByteArrayWrapper createWrapper(byte[] data)
           
 void deleteResilientBEncodedFile(File parent_dir, String file_name, boolean use_backup)
           
 void freeDirectByteBuffer(ByteBuffer buffer)
           
 String getAzureusProgramDir()
           
 String getAzureusUserDir()
           
 long getCurrentSystemTime()
          Get the current system time, like System.currentTimeMillis(), only the time lookup is cached for performance reasons.
 List<DistributedDatabase> getDistributedDatabases(String[] networks)
           
 List<DistributedDatabase> getDistributedDatabases(String[] networks, Map<String,Object> options)
           
 FeatureManager getFeatureManager()
           
 Formatters getFormatters()
           
 InputStream getImageAsStream(String image_name)
           
 LocaleUtilities getLocaleUtilities()
           
 List<LocationProvider> getLocationProviders()
           
 Monitor getMonitor()
           
 InetAddress getPublicAddress()
          Returns a public IP address of the machine or null if it can't be determined
 InetAddress getPublicAddress(boolean ipv6)
           
 ResourceDownloaderFactory getResourceDownloaderFactory()
           
 ResourceUploaderFactory getResourceUploaderFactory()
           
 RSSFeed getRSSFeed(InputStream is)
          Deprecated.  
 RSSFeed getRSSFeed(ResourceDownloader feed_location)
          Deprecated.  
 RSSFeed getRSSFeed(URL feed_location)
           
 RSSFeed getRSSFeed(URL source_url, InputStream is)
           
 RSSFeed getRSSFeed(URL source_url, ResourceDownloader feed_location)
           
 List<ScriptProvider> getScriptProviders()
           
 SearchInitiator getSearchInitiator()
           
 SESecurityManager getSecurityManager()
           
 Semaphore getSemaphore()
           
 SimpleXMLParserDocumentFactory getSimpleXMLParserDocumentFactory()
           
 SubscriptionManager getSubscriptionManager()
           
 TagManager getTagManager()
           
 boolean isCVSVersion()
           
 boolean isFreeBSD()
           
 boolean isLinux()
           
 boolean isOSX()
           
 boolean isSolaris()
           
 boolean isUnix()
           
 boolean isWindows()
           
 Tag lookupTag(String name)
           
 String normaliseFileName(String f_name)
          Converts a file name so that all characters in the file name are compatible with the underlying filesystem.
 Map readResilientBEncodedFile(File parent_dir, String file_name, boolean use_backup)
           
 void registerJSONRPCClient(Utilities.JSONClient client)
           
 void registerJSONRPCServer(Utilities.JSONServer server)
           
 void registerScriptProvider(ScriptProvider provider)
           
 void registerSearchProvider(SearchProvider provider)
           
 void removeLocationProvider(LocationProvider provider)
           
 void removeLocationProviderListener(LocationProviderListener listener)
           
 void removePowerManagementListener(PowerManagementListener listener)
           
 void removeScriptProviderListener(ScriptProvider.ScriptProviderListener provider)
           
 String reverseDNSLookup(InetAddress address)
          attempts a reverse DNS lookup of an address, null if it fails
 boolean supportsPowerStateControl(int state)
           
 void unregisterJSONRPCClient(Utilities.JSONClient client)
           
 void unregisterJSONRPCServer(Utilities.JSONServer server)
           
 void unregisterScriptProvider(ScriptProvider provider)
           
 void unregisterSearchProvider(SearchProvider provider)
           
 void writeResilientBEncodedFile(File parent_dir, String file_name, Map data, boolean use_backup)
           
 

Method Detail

getAzureusUserDir

String getAzureusUserDir()

getAzureusProgramDir

String getAzureusProgramDir()

isCVSVersion

boolean isCVSVersion()

isWindows

boolean isWindows()

isLinux

boolean isLinux()

isSolaris

boolean isSolaris()

isOSX

boolean isOSX()

isUnix

boolean isUnix()
Returns:
Whether the OS is a unix flavor (linux, bsd, aix, etc)
Since:
2.4.0.3

isFreeBSD

boolean isFreeBSD()
Returns:
Whether the OS is FreeBSD
Since:
2.4.0.3

getImageAsStream

InputStream getImageAsStream(String image_name)

getSemaphore

Semaphore getSemaphore()

getMonitor

Monitor getMonitor()

allocateDirectByteBuffer

ByteBuffer allocateDirectByteBuffer(int size)

freeDirectByteBuffer

void freeDirectByteBuffer(ByteBuffer buffer)

allocatePooledByteBuffer

PooledByteBuffer allocatePooledByteBuffer(int size)

allocatePooledByteBuffer

PooledByteBuffer allocatePooledByteBuffer(byte[] data)

allocatePooledByteBuffer

PooledByteBuffer allocatePooledByteBuffer(Map data)
                                          throws IOException
Parameters:
data - must be b-encodable
Returns:
Throws:
IOException

getFormatters

Formatters getFormatters()

getLocaleUtilities

LocaleUtilities getLocaleUtilities()

createTimer

UTTimer createTimer(String name)
Creates a UTTimer instance. It will be configured for non-lightweight tasks by default.

Parameters:
name - Name for the UTTimer object.
Returns:
A UTTimer instance.

createTimer

UTTimer createTimer(String name,
                    boolean lightweight)
Creates a UTTimer instance.

Parameters:
name - Name for the UTTimer object.
lightweight - If true, it indicates that this timer will be used to perform small lightweight tasks. If false, it indicates that this timer will be used to perform expensive tasks. This allows Azureus to create the appropriate amount of resources to manage this timer.
Returns:
A UTTimer instance.

createTimer

UTTimer createTimer(String name,
                    int priority)
Creates a UTTimer instance.

Parameters:
name - Name for the UTTimer object.
priority - The Thread.XXX_PRIORITY value to use.
Returns:
A UTTimer instance.

createThread

void createThread(String name,
                  Runnable target)
create and run a thread for the target. This will be a daemon thread so that its existence doesn't interfere with Azureus closedown

Parameters:
name -
target -

createProcess

void createProcess(String command_line)
                   throws PluginException
create a child process and executes the supplied command line. The child process will not inherit any open handles on Windows, which does happen if Runtime is used directly. This relies on the Platform plugin, if this is not installed then this will fall back to using Runtime.exec

Parameters:
command_line -
Throws:
PluginException

getResourceDownloaderFactory

ResourceDownloaderFactory getResourceDownloaderFactory()

getResourceUploaderFactory

ResourceUploaderFactory getResourceUploaderFactory()

getSecurityManager

SESecurityManager getSecurityManager()

getSimpleXMLParserDocumentFactory

SimpleXMLParserDocumentFactory getSimpleXMLParserDocumentFactory()

getRSSFeed

RSSFeed getRSSFeed(InputStream is)
                   throws SimpleXMLParserDocumentException
Deprecated. 

Parameters:
is -
Returns:
Throws:
SimpleXMLParserDocumentException

getRSSFeed

RSSFeed getRSSFeed(URL source_url,
                   InputStream is)
                   throws SimpleXMLParserDocumentException
Throws:
SimpleXMLParserDocumentException

getRSSFeed

RSSFeed getRSSFeed(URL feed_location)
                   throws ResourceDownloaderException,
                          SimpleXMLParserDocumentException
Throws:
ResourceDownloaderException
SimpleXMLParserDocumentException

getRSSFeed

RSSFeed getRSSFeed(ResourceDownloader feed_location)
                   throws ResourceDownloaderException,
                          SimpleXMLParserDocumentException
Deprecated. 

Parameters:
feed_location -
Returns:
Throws:
ResourceDownloaderException
SimpleXMLParserDocumentException

getRSSFeed

RSSFeed getRSSFeed(URL source_url,
                   ResourceDownloader feed_location)
                   throws ResourceDownloaderException,
                          SimpleXMLParserDocumentException
Throws:
ResourceDownloaderException
SimpleXMLParserDocumentException

getPublicAddress

InetAddress getPublicAddress()
Returns a public IP address of the machine or null if it can't be determined


getPublicAddress

InetAddress getPublicAddress(boolean ipv6)

reverseDNSLookup

String reverseDNSLookup(InetAddress address)
attempts a reverse DNS lookup of an address, null if it fails

Parameters:
address -
Returns:

getCurrentSystemTime

long getCurrentSystemTime()
Get the current system time, like System.currentTimeMillis(), only the time lookup is cached for performance reasons.

Returns:
current system time

createWrapper

ByteArrayWrapper createWrapper(byte[] data)

createAggregatedDispatcher

AggregatedDispatcher createAggregatedDispatcher(long idle_dispatch_time,
                                                long max_queue_size)
create a dispatcher that will queue runnable items until either the limit is reached or the dispatcher hasn't had an entry added for the defined idle time

Parameters:
idle_dispatch_time - milliseconds
max_queue_size - 0 -> infinite
Returns:

createAggregatedList

AggregatedList createAggregatedList(AggregatedListAcceptor acceptor,
                                    long idle_dispatch_time,
                                    long max_queue_size)

readResilientBEncodedFile

Map readResilientBEncodedFile(File parent_dir,
                              String file_name,
                              boolean use_backup)
Returns:
Map read from config file, or empty HashMap if error

writeResilientBEncodedFile

void writeResilientBEncodedFile(File parent_dir,
                                String file_name,
                                Map data,
                                boolean use_backup)

deleteResilientBEncodedFile

void deleteResilientBEncodedFile(File parent_dir,
                                 String file_name,
                                 boolean use_backup)

compareVersions

int compareVersions(String v1,
                    String v2)
Compares two version strings for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Example:

 compareVersions("1.1.0.0", "1.1.2.0"); // -
 compareVersions("1.1.0.0", "1.1.0"); // 0
 compareVersions("1.1.1.1", "1.1.1"); // +
 

Parameters:
v1 - the first version string to be compared
v2 - the second version string to be compared
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Since:
2.3.0.7

normaliseFileName

String normaliseFileName(String f_name)
Converts a file name so that all characters in the file name are compatible with the underlying filesystem. This includes quote characters, back and forwarded slashes, newline characters and so on.

Note - this is only intended for file names, rather than file paths.

Parameters:
f_name - File name to convert.
Returns:
Converted file name.

createDelayedTask

DelayedTask createDelayedTask(Runnable r)
Adds a low priority task that will be scheduled at some point after existing tasks have completed. In particular a system task exists that will block subsequent ones until after UI initialisation is complete. Plugins can therefore use this to schedule initialisation actions to occur after UI init is complete.

Returns:
Since:
3.0.5.3

registerSearchProvider

void registerSearchProvider(SearchProvider provider)
                            throws SearchException
Throws:
SearchException

unregisterSearchProvider

void unregisterSearchProvider(SearchProvider provider)
                              throws SearchException
Throws:
SearchException

getSearchInitiator

SearchInitiator getSearchInitiator()
                                   throws SearchException
Throws:
SearchException

getSubscriptionManager

SubscriptionManager getSubscriptionManager()
                                           throws SubscriptionException
Throws:
SubscriptionException

getFeatureManager

FeatureManager getFeatureManager()

supportsPowerStateControl

boolean supportsPowerStateControl(int state)

addPowerManagementListener

void addPowerManagementListener(PowerManagementListener listener)

removePowerManagementListener

void removePowerManagementListener(PowerManagementListener listener)

getLocationProviders

List<LocationProvider> getLocationProviders()

addLocationProvider

void addLocationProvider(LocationProvider provider)

removeLocationProvider

void removeLocationProvider(LocationProvider provider)

addLocationProviderListener

void addLocationProviderListener(LocationProviderListener listener)

removeLocationProviderListener

void removeLocationProviderListener(LocationProviderListener listener)

registerJSONRPCServer

void registerJSONRPCServer(Utilities.JSONServer server)

unregisterJSONRPCServer

void unregisterJSONRPCServer(Utilities.JSONServer server)

registerJSONRPCClient

void registerJSONRPCClient(Utilities.JSONClient client)

unregisterJSONRPCClient

void unregisterJSONRPCClient(Utilities.JSONClient client)

getDistributedDatabases

List<DistributedDatabase> getDistributedDatabases(String[] networks)

getDistributedDatabases

List<DistributedDatabase> getDistributedDatabases(String[] networks,
                                                  Map<String,Object> options)

getScriptProviders

List<ScriptProvider> getScriptProviders()

registerScriptProvider

void registerScriptProvider(ScriptProvider provider)

unregisterScriptProvider

void unregisterScriptProvider(ScriptProvider provider)

addScriptProviderListener

void addScriptProviderListener(ScriptProvider.ScriptProviderListener provider)

removeScriptProviderListener

void removeScriptProviderListener(ScriptProvider.ScriptProviderListener provider)

getTagManager

TagManager getTagManager()

lookupTag

Tag lookupTag(String name)