import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Vector;
/**
// Specific reference to custom URL link provider
private UrlProviderI customProvider;
- // List of columns which this provider will supply
- private List<String> colNames = new ArrayList<String>();
-
/**
- * Construct URL provider from string of cached URLs, and set default URL
+ * Constructor for UrlProvider composite
*
* @param defaultUrlString
- * id of the current default URL
- * @param cachedUrlList
- * string listing current active URLs, expected to be custom URLs
- * separated by |, or ids of URLs
+ * id of default url
+ * @param allProviders
+ * list of UrlProviders this provider gives access to
*/
- public UrlProvider(String defaultUrlString, String cachedUrlList)
+ public UrlProvider(String defaultUrlString,
+ List<UrlProviderI> allProviders)
{
- // create all the UrlProviders we need
- providers = new ArrayList<UrlProviderI>();
-
- UrlProviderI idProvider = new IdentifiersUrlProvider(cachedUrlList,
- IdentifiersUrlProvider.ID_ORG_FILE);
- customProvider = new CustomUrlProvider(cachedUrlList);
- providers.add(idProvider);
- providers.add(customProvider);
+ providers = allProviders;
- setUpColumns();
+ customProvider = findCustomProvider();
// check that the defaultUrl still exists
if (!setDefaultUrl(defaultUrlString))
chooseDefaultUrl();
}
}
-
- /**
- * Construct URL provider from a map of (label,url) pairs, and set default URL
- *
- * @param defaultUrlString
- * id of the current default URL
- * @param urlList
- * vector of (label, url) pairs
+
+ /*
+ * Store ref to custom url provider
*/
- public UrlProvider(String defaultUrlString, Map<String, String> urlList)
+ private UrlProviderI findCustomProvider()
{
- // create all the UrlProviders we need
- providers = new ArrayList<UrlProviderI>();
-
- UrlProviderI idProvider = new IdentifiersUrlProvider(null,
- IdentifiersUrlProvider.ID_ORG_FILE);
- customProvider = new CustomUrlProvider(urlList);
- providers.add(idProvider);
- providers.add(customProvider);
-
- setUpColumns();
-
- // check that the defaultUrl still exists
- if (!setDefaultUrl(defaultUrlString))
+ for (UrlProviderI p : providers)
{
- chooseDefaultUrl();
+ if (p.getClass().equals(CustomUrlProvider.class))
+ {
+ return p;
+ }
}
- }
- private void setUpColumns()
- {
- colNames.add("Name");
- colNames.add("URL");
- colNames.add("In Menu");
- colNames.add("Default");
- colNames.add("ID");
+ System.out
+ .println("Error initialising UrlProvider - no custom url provider");
+ return null;
}
@Override
{
return customProvider.isUserEntry(id);
}
-
- @Override
- public List<String> getDisplayColumnNames()
- {
- return colNames.subList(0, 4);
- }
}