|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
package org.videolan;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
import java.util.Enumeration;
|
|
Packit |
5e46da |
import java.util.Vector;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
import org.dvb.application.AppAttributes;
|
|
Packit |
5e46da |
import org.dvb.application.AppID;
|
|
Packit |
5e46da |
import org.dvb.application.AppProxy;
|
|
Packit |
5e46da |
import org.dvb.application.AppsDatabase;
|
|
Packit |
5e46da |
import org.dvb.application.AppsDatabaseEvent;
|
|
Packit |
5e46da |
import org.dvb.application.AppsDatabaseFilter;
|
|
Packit |
5e46da |
import org.videolan.bdjo.AppEntry;
|
|
Packit |
5e46da |
import org.videolan.bdjo.Bdjo;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public class BDJAppsDatabase extends AppsDatabase {
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private static final Object instanceLock = new Object();
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static public AppsDatabase getAppsDatabase() {
|
|
Packit |
5e46da |
synchronized (instanceLock) {
|
|
Packit |
5e46da |
if (instance == null)
|
|
Packit |
5e46da |
instance = new BDJAppsDatabase();
|
|
Packit |
5e46da |
return instance;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private static final Object appTableLock = new Object();
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public int size() {
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
if (appTable == null)
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
return appTable.length;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public Enumeration getAppIDs(AppsDatabaseFilter filter) {
|
|
Packit |
5e46da |
Vector ids = new Vector();
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
if (appTable != null)
|
|
Packit |
5e46da |
for (int i = 0; i < appTable.length; i++)
|
|
Packit |
5e46da |
if (filter.accept(appTable[i].getIdentifier()))
|
|
Packit |
5e46da |
ids.add(appTable[i].getIdentifier());
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return ids.elements();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public Enumeration getAppAttributes(AppsDatabaseFilter filter) {
|
|
Packit |
5e46da |
Vector attributes = new Vector();
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
if (appTable != null)
|
|
Packit |
5e46da |
for (int i = 0; i < size(); i++)
|
|
Packit |
5e46da |
if (filter.accept(appTable[i].getIdentifier()))
|
|
Packit |
5e46da |
attributes.add(appTable[i]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return attributes.elements();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public AppAttributes getAppAttributes(AppID key) {
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
if (appTable != null)
|
|
Packit |
5e46da |
for (int i = 0; i < size(); i++)
|
|
Packit |
5e46da |
if (key.equals(appTable[i].getIdentifier()))
|
|
Packit |
5e46da |
return appTable[i];
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public AppProxy getAppProxy(AppID key) {
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
if ((appTable != null) && (appProxys != null))
|
|
Packit |
5e46da |
for (int i = 0; i < size(); i++)
|
|
Packit |
5e46da |
if (key.equals(appTable[i].getIdentifier()))
|
|
Packit |
5e46da |
return appProxys[i];
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public Bdjo getBdjo() {
|
|
Packit |
5e46da |
return bdjo;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
protected void newDatabase(Bdjo bdjo, BDJAppProxy[] appProxys) {
|
|
Packit |
5e46da |
synchronized (appTableLock) {
|
|
Packit |
5e46da |
this.bdjo = bdjo;
|
|
Packit |
5e46da |
this.appProxys = appProxys;
|
|
Packit |
5e46da |
this.appTable = (bdjo != null) ? bdjo.getAppTable() : null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
notifyListeners(AppsDatabaseEvent.NEW_DATABASE, null);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private Bdjo bdjo = null;
|
|
Packit |
5e46da |
private BDJAppProxy[] appProxys = null;
|
|
Packit |
5e46da |
private AppEntry[] appTable = null;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private static BDJAppsDatabase instance = null;
|
|
Packit |
5e46da |
}
|