本文整理汇总了Java中org.fourthline.cling.support.model.SortCriterion类的典型用法代码示例。如果您正苦于以下问题:Java SortCriterion类的具体用法?Java SortCriterion怎么用?Java SortCriterion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SortCriterion类属于org.fourthline.cling.support.model包,在下文中一共展示了SortCriterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browseRoot
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browses the top-level content of a type.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
// we have to override this to do an index-based id.
DIDLContent didl = new DIDLContent();
List<Genre> allItems = getAllItems();
if (filter != null) {
// filter items
}
if (orderBy != null) {
// sort items
}
List<Genre> selectedItems = Util.subList(allItems, firstResult, maxResults);
for (int i=0; i < selectedItems.size(); i++) {
Genre item = selectedItems.get(i);
didl.addContainer(createContainer(item, (int) (i+firstResult)));
}
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
}
示例2: browseRoot
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browses the top-level content of a type.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
DIDLContent didl = new DIDLContent();
List<T> allItems = getAllItems();
if (filter != null) {
// filter items (not implemented yet)
}
if (orderBy != null) {
// sort items (not implemented yet)
}
List<T> selectedItems = Util.subList(allItems, firstResult, maxResults);
for (T item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
}
示例3: browseObject
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browses a child of the container.
*/
public BrowseResult browseObject(String id, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
T item = getItemById(id);
List<U> allChildren = getChildren(item);
if (filter != null) {
// filter items (not implemented yet)
}
if (orderBy != null) {
// sort items (not implemented yet)
}
List<U> selectedChildren = Util.subList(allChildren, firstResult, maxResults);
DIDLContent didl = new DIDLContent();
for (U child : selectedChildren) {
addChild(didl, child);
}
return createBrowseResult(didl, selectedChildren.size(), allChildren.size());
}
示例4: searchByName
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
public BrowseResult searchByName(String name,
long firstResult, long maxResults,
SortCriterion[] orderBy)
throws ContentDirectoryException {
DIDLContent didl = new DIDLContent();
Class clazz = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
try {
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();
ParamSearchResult<T> result = getDispatcher().getSearchService().searchByName(name, (int) firstResult, (int) maxResults, allFolders, clazz);
List<T> selectedItems = result.getItems();
for (T item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), result.getTotalHits());
} catch (Exception e) {
return null;
}
}
示例5: browseRoot
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browses the top-level content.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
// AlbumUpnpProcessor overrides browseRoot() with an optimization;
// this restores the default behavior for the subclass.
DIDLContent didl = new DIDLContent();
List<Album> allItems = getAllItems();
if (filter != null) {
// filter items (not implemented yet)
}
if (orderBy != null) {
// sort items (not implemented yet)
}
List<Album> selectedItems = Util.subList(allItems, firstResult, maxResults);
for (Album item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
}
示例6: browseSync
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browse ContenDirctory synchronous
*
* @param pos Position
* the device and object to be browsed
* @return the browsing result
*/
public ContentDirectoryBrowseResult browseSync(Position pos) {
if(getProviderDevice() == null){
return null;
}
if (pos == null || pos.getDeviceId() == null ) {
if(getProviderDevice() != null){
return browseSync(getProviderDevice(),"0" , BrowseFlag.DIRECT_CHILDREN, "*", 0L, null, new SortCriterion[0]);
}else{
return null;
}
}
if (getProviderDevice() != null && !pos.getDeviceId().equals(getProviderDevice().getIdentity().getUdn().getIdentifierString())){
return browseSync(getProviderDevice(),"0" , BrowseFlag.DIRECT_CHILDREN, "*", 0L, null, new SortCriterion[0]);
}
return browseSync(getDevice(pos.getDeviceId()), pos.getObjectId(), BrowseFlag.DIRECT_CHILDREN, "*", 0L, null, new SortCriterion[0]);
}
示例7: browseAsync
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browse ContenDirctory asynchronous
*
* @param device the device to be browsed
* @param objectID the browsing root
* @param flag kind of browsing @see {@link BrowseFlag}
* @param filter a filter
* @param firstResult first result
* @param maxResults max result count
* @param orderBy sorting criteria @see {@link SortCriterion}
* @return the browsing result
*/
public ContentDirectoryBrowseResult browseAsync(Device<?, ?, ?> device, String objectID, BrowseFlag flag, String filter, long firstResult,
Long maxResults, SortCriterion... orderBy) {
Service service = device.findService(new UDAServiceId("ContentDirectory"));
ContentDirectoryBrowseResult result = new ContentDirectoryBrowseResult();
ContentDirectoryBrowseActionCallback actionCallback = null;
if (service != null) {
Log.d(getClass().getName(), "#####Service found: " + service.getServiceId() + " Type: " + service.getServiceType());
actionCallback = new ContentDirectoryBrowseActionCallback(service, objectID, flag, filter, firstResult, maxResults, result, orderBy);
getControlPoint().execute(actionCallback);
}
if (preferences.getBoolean(context.getString(R.string.settings_browse_thumbnails_coverlookup_chkbx), false)) {
result = enrichWithCover(result);
}
return result;
}
示例8: browse
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {
String address = Utils.getIPAddress(true);
String serverUrl = "http://" + address + ":" + JettyResourceServer.JETTY_SERVER_PORT;
//Create container by id
Container resultBean = ContainerFactory.createContainer(objectID, serverUrl);
DIDLContent content = new DIDLContent();
for (Container c : resultBean.getContainers())
content.addContainer(c);
for (Item item : resultBean.getItems())
content.addItem(item);
int count = resultBean.getChildCount();
String contentModel = "";
try {
contentModel = new DIDLParser().generate(content);
} catch (Exception e) {
throw new ContentDirectoryException(
ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString());
}
return new BrowseResult(contentModel, count, count);
}
示例9: Browse
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
*/
public Browse(Service service, String objectID, BrowseFlag flag,
String filter, long firstResult, Long maxResults, SortCriterion... orderBy) {
super(new ActionInvocation(service.getAction("Browse")));
log.fine("Creating browse action for object ID: " + objectID);
getActionInvocation().setInput("ObjectID", objectID);
getActionInvocation().setInput("BrowseFlag", flag.toString());
getActionInvocation().setInput("Filter", filter);
getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
getActionInvocation().setInput("RequestedCount",
new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
);
getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
示例10: Search
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
*/
public Search(Service service, String containerId, String searchCriteria, String filter,
long firstResult, Long maxResults, SortCriterion... orderBy) {
super(new ActionInvocation(service.getAction("Search")));
log.fine("Creating browse action for container ID: " + containerId);
getActionInvocation().setInput("ContainerID", containerId);
getActionInvocation().setInput("SearchCriteria", searchCriteria);
getActionInvocation().setInput("Filter", filter);
getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
getActionInvocation().setInput(
"RequestedCount",
new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
);
getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
示例11: search
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId,
String searchCriteria, String filter,
long firstResult, long maxResults,
SortCriterion[] orderBy) throws ContentDirectoryException {
// You can override this method to implement searching!
return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy);
}
示例12: browseRoot
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
/**
* Browses the top-level content of a type.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
DIDLContent didl = new DIDLContent();
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();
List<Album> selectedItems = getAlbumDao().getAlphabeticalAlbums((int) firstResult, (int) maxResults, false, true, allFolders);
for (Album item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), getAllItemsSize());
}
示例13: ContentDirectoryBrowseActionCallback
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
public ContentDirectoryBrowseActionCallback(Service<?, ?> service, String objectID,
BrowseFlag flag, String filter, long firstResult, Long maxResults, ContentDirectoryBrowseResult browsingResult,
SortCriterion... orderBy) {
super(service, objectID, flag, filter, firstResult, maxResults, orderBy);
this.browsingResult = browsingResult;
}
示例14: browse
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag, String filter, long firstResult,
long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {
if (!settingsService.getLicenseInfo().isLicenseOrTrialValid()) {
LOG.warn("UPnP/DLNA media server not available. Please upgrade to Subsonic Premium.");
throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, "Please upgrade to Subsonic Premium");
}
LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter +
", firstResult: " + firstResult + ", maxResults: " + maxResults);
// maxResult == 0 means all.
if (maxResults == 0) {
maxResults = Integer.MAX_VALUE;
}
try {
if (CONTAINER_ID_ROOT.equals(objectId)) {
return browseFlag == BrowseFlag.METADATA ? browseRootMetadata() : browseRoot(firstResult, maxResults);
}
if (CONTAINER_ID_PLAYLIST_ROOT.equals(objectId)) {
return browseFlag == BrowseFlag.METADATA ? browsePlaylistRootMetadata() : browsePlaylistRoot(firstResult, maxResults);
}
if (objectId.startsWith(CONTAINER_ID_PLAYLIST_PREFIX)) {
int playlistId = Integer.parseInt(objectId.replace(CONTAINER_ID_PLAYLIST_PREFIX, ""));
Playlist playlist = playlistService.getPlaylist(playlistId);
return browseFlag == BrowseFlag.METADATA ? browsePlaylistMetadata(playlist) : browsePlaylist(playlist, firstResult, maxResults);
}
int mediaFileId = Integer.parseInt(objectId.replace(CONTAINER_ID_FOLDER_PREFIX, ""));
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
return browseFlag == BrowseFlag.METADATA ? browseMediaFileMetadata(mediaFile) : browseMediaFile(mediaFile, firstResult, maxResults);
} catch (Throwable x) {
LOG.error("UPnP error: " + x, x);
throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString());
}
}
示例15: search
import org.fourthline.cling.support.model.SortCriterion; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId, String searchCriteria,
String filter, long firstResult, long maxResults,
SortCriterion[] orderBy) throws ContentDirectoryException {
// TODO Auto-generated method stub
Log.e(LOG_TAG, "containerId:" + containerId + ",searchCriteria:"
+ searchCriteria + ",filter:" + filter + ",firstResult:"
+ firstResult + ",maxResults:" + maxResults + ",orderBy:"
+ orderBy);
return super.search(containerId, searchCriteria, filter, firstResult,
maxResults, orderBy);
}