コード例 #1
0
  @UpnpAction(
      out = {
        @UpnpOutputArgument(
            name = "Result",
            stateVariable = "A_ARG_TYPE_Result",
            getterName = "getResult"),
        @UpnpOutputArgument(
            name = "NumberReturned",
            stateVariable = "A_ARG_TYPE_Count",
            getterName = "getCount"),
        @UpnpOutputArgument(
            name = "TotalMatches",
            stateVariable = "A_ARG_TYPE_Count",
            getterName = "getTotalMatches"),
        @UpnpOutputArgument(
            name = "UpdateID",
            stateVariable = "A_ARG_TYPE_UpdateID",
            getterName = "getContainerUpdateID")
      })
  public BrowseResult browse(
      @UpnpInputArgument(name = "ObjectID", aliases = "ContainerID") String objectId,
      @UpnpInputArgument(name = "BrowseFlag") String browseFlag,
      @UpnpInputArgument(name = "Filter") String filter,
      @UpnpInputArgument(name = "StartingIndex", stateVariable = "A_ARG_TYPE_Index")
          UnsignedIntegerFourBytes firstResult,
      @UpnpInputArgument(name = "RequestedCount", stateVariable = "A_ARG_TYPE_Count")
          UnsignedIntegerFourBytes maxResults,
      @UpnpInputArgument(name = "SortCriteria") String orderBy)
      throws ContentDirectoryException {

    SortCriterion[] orderByCriteria;
    try {
      orderByCriteria = SortCriterion.valueOf(orderBy);
    } catch (Exception ex) {
      throw new ContentDirectoryException(
          ContentDirectoryErrorCode.UNSUPPORTED_SORT_CRITERIA, ex.toString());
    }

    try {
      return browse(
          objectId,
          BrowseFlag.valueOrNullOf(browseFlag),
          filter,
          firstResult.getValue(),
          maxResults.getValue(),
          orderByCriteria);
    } catch (ContentDirectoryException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ContentDirectoryException(ErrorCode.ACTION_FAILED, ex.toString());
    }
  }