com.android.repository.impl.sources
Class LocalSourceProvider

java.lang.Object
  extended by com.android.repository.impl.sources.LocalSourceProvider
All Implemented Interfaces:
RepositorySourceProvider

public class LocalSourceProvider
extends java.lang.Object
implements RepositorySourceProvider

Reads RepositorySources saved locally. Allows sources to be saved, modified, and deleted.


Constructor Summary
LocalSourceProvider(java.io.File location, java.util.Collection<SchemaModule> allowedModules, FileOp fop)
          Create a new LocalSourceProvider.
 
Method Summary
 boolean addSource(RepositorySource source)
          Add a source to this provider.
 java.util.List<RepositorySource> getSources(Downloader downloader, SettingsController settings, ProgressIndicator logger, boolean forceRefresh)
          Gets the RepositorySources from this provider.
 boolean isModifiable()
          Whether this source is modifiable.
 boolean removeSource(RepositorySource source)
          Remove the specified source from this provider.
 void save(ProgressIndicator progress)
          Saves any changes in the sources to the specified file.
 void setRepoManager(RepoManager manager)
          Sets the RepoManager that will use this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalSourceProvider

public LocalSourceProvider(@NonNull
                           java.io.File location,
                           @NonNull
                           java.util.Collection<SchemaModule> allowedModules,
                           @NonNull
                           FileOp fop)
Create a new LocalSourceProvider.

Parameters:
location - The file to load from and save to.
allowedModules - The SchemaModules that are allowed to be used by sources provided by this provider.
fop - The FileOp to use for local file operations. For normal use should probably be FileOpImpl.
Method Detail

setRepoManager

public void setRepoManager(@NonNull
                           RepoManager manager)
Sets the RepoManager that will use this provider.


getSources

@NonNull
public java.util.List<RepositorySource> getSources(@Nullable
                                                           Downloader downloader,
                                                           @Nullable
                                                           SettingsController settings,
                                                           @NonNull
                                                           ProgressIndicator logger,
                                                           boolean forceRefresh)
Gets the RepositorySources from this provider.

Specified by:
getSources in interface RepositorySourceProvider
Parameters:
downloader - Unused by this provider.
settings - Unused by this provider.
logger - A ProgressIndicator to be used for showing progress and logging.
forceRefresh - If true, this provider should refresh its list of sources, rather than return any cached sources.

addSource

public boolean addSource(@NonNull
                         RepositorySource source)
Add a source to this provider. Note that it won't be persisted until save(ProgressIndicator) is called.

Specified by:
addSource in interface RepositorySourceProvider
Parameters:
source - The source to add.
Returns:
true if the source was successfully added, false otherwise.

isModifiable

public boolean isModifiable()
Whether this source is modifiable.

Specified by:
isModifiable in interface RepositorySourceProvider
Returns:
true for this class.

save

public void save(@NonNull
                 ProgressIndicator progress)
Saves any changes in the sources to the specified file.

Specified by:
save in interface RepositorySourceProvider
Parameters:
progress - ProgressIndicator for logging.

removeSource

public boolean removeSource(@NonNull
                            RepositorySource source)
Remove the specified source from this provider. Node that the remove won't be persisted until save(ProgressIndicator) is called.

Specified by:
removeSource in interface RepositorySourceProvider
Parameters:
source - The source to remove.
Returns:
true if a matching source was found and actually removed.
See Also:
RepositorySourceProvider.addSource(RepositorySource)