org.fourthline.cling.model.ModelUtil Java Examples

The following examples show how to use org.fourthline.cling.model.ModelUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TVRemoteIME   Author: kingthy   File: StateVariable.java    License: GNU General Public License v2.0 6 votes vote down vote up
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getName() == null || getName().length() == 0) {
        errors.add(new ValidationError(
                getClass(),
                "name",
                "StateVariable without name of: " + getService()
        ));
    } else if (!ModelUtil.isValidUDAName(getName())) {
        log.warning("UPnP specification violation of: " + getService().getDevice());
        log.warning("Invalid state variable name: " + this);
    }

    errors.addAll(getTypeDetails().validate());

    return errors;
}
 
Example #2
Source Project: TVRemoteIME   Author: kingthy   File: OutgoingNotificationRequest.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected OutgoingNotificationRequest(Location location, LocalDevice device, NotificationSubtype type) {
    super(
            new UpnpRequest(UpnpRequest.Method.NOTIFY),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.type = type;

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));

    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
    getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(type));
}
 
Example #3
Source Project: TVRemoteIME   Author: kingthy   File: DefaultUpnpServiceConfiguration.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected DefaultUpnpServiceConfiguration(int streamListenPort, boolean checkRuntime) {
    if (checkRuntime && ModelUtil.ANDROID_RUNTIME) {
        throw new Error("Unsupported runtime environment, use org.fourthline.cling.android.AndroidUpnpServiceConfiguration");
    }

    this.streamListenPort = streamListenPort;

    defaultExecutorService = createDefaultExecutorService();

    datagramProcessor = createDatagramProcessor();
    soapActionProcessor = createSOAPActionProcessor();
    genaEventProcessor = createGENAEventProcessor();

    deviceDescriptorBinderUDA10 = createDeviceDescriptorBinderUDA10();
    serviceDescriptorBinderUDA10 = createServiceDescriptorBinderUDA10();

    namespace = createNamespace();
}
 
Example #4
Source Project: DroidDLNA   Author: offbye   File: StateVariable.java    License: GNU General Public License v3.0 6 votes vote down vote up
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getName() == null || getName().length() == 0) {
        errors.add(new ValidationError(
                getClass(),
                "name",
                "StateVariable without name of: " + getService()
        ));
    } else if (!ModelUtil.isValidUDAName(getName())) {
        log.warning("UPnP specification violation of: " + getService().getDevice());
        log.warning("Invalid state variable name: " + this);
    }

    errors.addAll(getTypeDetails().validate());

    return errors;
}
 
Example #5
Source Project: DroidDLNA   Author: offbye   File: OutgoingNotificationRequest.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected OutgoingNotificationRequest(Location location, LocalDevice device, NotificationSubtype type) {
    super(
            new UpnpRequest(UpnpRequest.Method.NOTIFY),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.type = type;

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));

    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
    getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(type));
}
 
Example #6
Source Project: DroidDLNA   Author: offbye   File: DefaultUpnpServiceConfiguration.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected DefaultUpnpServiceConfiguration(int streamListenPort, boolean checkRuntime) {
    if (checkRuntime && ModelUtil.ANDROID_RUNTIME) {
        throw new Error("Unsupported runtime environment, use org.fourthline.cling.android.AndroidUpnpServiceConfiguration");
    }

    this.streamListenPort = streamListenPort;

    defaultExecutorService = createDefaultExecutorService();

    datagramProcessor = createDatagramProcessor();
    soapActionProcessor = createSOAPActionProcessor();
    genaEventProcessor = createGENAEventProcessor();

    deviceDescriptorBinderUDA10 = createDeviceDescriptorBinderUDA10();
    serviceDescriptorBinderUDA10 = createServiceDescriptorBinderUDA10();

    namespace = createNamespace();
}
 
Example #7
Source Project: TVRemoteIME   Author: kingthy   File: AnnotationActionBinder.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException {

        // Validate datatype as good as we can
        // (for enums and other convertible types, the state variable type should be STRING)

        Datatype.Default expectedDefaultMapping =
                ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type)
                        ? Datatype.Default.STRING
                        : Datatype.Default.getByJavaType(type);

        log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping);

        if (expectedDefaultMapping != null &&
                !stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) {

            // TODO: Consider custom types?!
            throw new LocalServiceBindingException(
                    "State variable '" + stateVariable + "' datatype can't handle action " +
                            "argument's Java type (change one): " + expectedDefaultMapping.getJavaType()
            );

        } else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) {
            throw new LocalServiceBindingException(
                    "State variable '" + stateVariable  + "' should be custom datatype " +
                            "(action argument type is unknown Java type): " + type.getSimpleName()
            );
        }

        log.finer("State variable matches required argument datatype (or can't be validated because it is custom)");
    }
 
Example #8
Source Project: TVRemoteIME   Author: kingthy   File: RemoteDeviceIdentity.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
  public String toString() {
      // Performance optimization, so we don't have to wrap all log("foo " + device) calls with isLoggable
if(ModelUtil.ANDROID_RUNTIME) {
          return "(RemoteDeviceIdentity) UDN: " + getUdn() + ", Descriptor: " + getDescriptorURL();
      }
      return "(" + getClass().getSimpleName() + ") UDN: " + getUdn() + ", Descriptor: " + getDescriptorURL();
  }
 
Example #9
Source Project: TVRemoteIME   Author: kingthy   File: ActionArgument.java    License: GNU General Public License v2.0 5 votes vote down vote up
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getName() == null || getName().length() == 0) {
        errors.add(new ValidationError(
                getClass(),
                "name",
                "Argument without name of: " + getAction()
        ));
    } else if (!ModelUtil.isValidUDAName(getName())) {
        log.warning("UPnP specification violation of: " + getAction().getService().getDevice());
        log.warning("Invalid argument name: " + this);
    } else if (getName().length() > 32) {
        log.warning("UPnP specification violation of: " + getAction().getService().getDevice());
        log.warning("Argument name should be less than 32 characters: " + this);
    }

    if (getDirection() == null) {
        errors.add(new ValidationError(
                getClass(),
                "direction",
                "Argument '"+getName()+"' requires a direction, either IN or OUT"
        ));
    }

    if (isReturnValue() && getDirection() != ActionArgument.Direction.OUT) {
        errors.add(new ValidationError(
                getClass(),
                "direction",
                "Return value argument '" + getName() + "' must be direction OUT"
        ));
    }

    return errors;
}
 
Example #10
Source Project: TVRemoteIME   Author: kingthy   File: OutgoingSearchRequest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutgoingSearchRequest(UpnpHeader searchTarget, int mxSeconds) {
    super(
            new UpnpRequest(UpnpRequest.Method.MSEARCH),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.searchTarget = searchTarget;

    getHeaders().add(UpnpHeader.Type.MAN, new MANHeader(NotificationSubtype.DISCOVER.getHeaderString()));
    getHeaders().add(UpnpHeader.Type.MX, new MXHeader(mxSeconds));
    getHeaders().add(UpnpHeader.Type.ST, searchTarget);
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
}
 
Example #11
Source Project: TVRemoteIME   Author: kingthy   File: SoapActionType.java    License: GNU General Public License v2.0 5 votes vote down vote up
public SoapActionType(String namespace, String type, Integer version, String actionName) {
    this.namespace = namespace;
    this.type = type;
    this.version = version;
    this.actionName = actionName;

    if (actionName != null && !ModelUtil.isValidUDAName(actionName)) {
        throw new IllegalArgumentException("Action name contains illegal characters: " + actionName);
    }
}
 
Example #12
Source Project: TVRemoteIME   Author: kingthy   File: CSV.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected List parseString(String s) throws InvalidValueException {
    String[] strings = ModelUtil.fromCommaSeparatedList(s);
    List values = new ArrayList();
    for (String string : strings) {
        values.add(datatype.getDatatype().valueOf(string));
    }
    return values;
}
 
Example #13
Source Project: TVRemoteIME   Author: kingthy   File: CSV.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
    List<String> stringValues = new ArrayList();
    for (T t : this) {
        stringValues.add(datatype.getDatatype().getString(t));
    }
    return ModelUtil.toCommaSeparatedList(stringValues.toArray(new Object[stringValues.size()]));
}
 
Example #14
Source Project: TVRemoteIME   Author: kingthy   File: AbstractAVTransportService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@UpnpAction(name = "GetCurrentTransportActions", out = @UpnpOutputArgument(name = "Actions", stateVariable = "CurrentTransportActions"))
public String getCurrentTransportActionsString(@UpnpInputArgument(name = "InstanceID") UnsignedIntegerFourBytes instanceId)
        throws AVTransportException {
    try {
        return ModelUtil.toCommaSeparatedList(getCurrentTransportActions(instanceId));
    } catch (Exception ex) {
        return ""; // TODO: Empty string is not defined in spec but seems reasonable for no available action?
    }
}
 
Example #15
Source Project: TVRemoteIME   Author: kingthy   File: AVTransportLastChangeParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Source[] getSchemaSources() {
    // TODO: Android 2.2 has a broken SchemaFactory, we can't validate
    // http://code.google.com/p/android/issues/detail?id=9491&q=schemafactory&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
    if (!ModelUtil.ANDROID_RUNTIME) {
        return new Source[]{new StreamSource(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(SCHEMA_RESOURCE)
        )};
    }
    return null;
}
 
Example #16
Source Project: TVRemoteIME   Author: kingthy   File: PositionInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PositionInfo(PositionInfo copy, long relTimeSeconds, long absTimeSeconds) {
    this.track = copy.track;
    this.trackDuration = copy.trackDuration;
    this.trackMetaData = copy.trackMetaData;
    this.trackURI = copy.trackURI;
    this.relTime = ModelUtil.toTimeString(relTimeSeconds);
    this.absTime = ModelUtil.toTimeString(absTimeSeconds);
    this.relCount = copy.relCount;
    this.absCount = copy.absCount;
}
 
Example #17
Source Project: TVRemoteIME   Author: kingthy   File: RenderingControlLastChangeParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Source[] getSchemaSources() {
    // TODO: Android 2.2 has a broken SchemaFactory, we can't validate
    // http://code.google.com/p/android/issues/detail?id=9491&q=schemafactory&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
    if (!ModelUtil.ANDROID_RUNTIME) {
        return new Source[]{new StreamSource(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(SCHEMA_RESOURCE)
        )};
    }
    return null;
}
 
Example #18
Source Project: TVRemoteIME   Author: kingthy   File: AndroidRouter.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AndroidRouter(UpnpServiceConfiguration configuration,
                     ProtocolFactory protocolFactory,
                     Context context) throws InitializationException {
    super(configuration, protocolFactory);

    this.context = context;
    this.wifiManager = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE));
    this.networkInfo = NetworkUtils.getConnectedNetworkInfo(context);

    // Only register for network connectivity changes if we are not running on emulator
    if (!ModelUtil.ANDROID_EMULATOR) {
        this.broadcastReceiver = new ConnectivityBroadcastReceiver();
        context.registerReceiver(broadcastReceiver, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
    }
}
 
Example #19
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void positionChanged(int position) {
    log.fine("Position Changed event received: " + position);
    synchronized (ZxtMediaPlayer.this) {
        currentPositionInfo = new PositionInfo(1, currentMediaInfo.getMediaDuration(),
                currentMediaInfo.getCurrentURI(), ModelUtil.toTimeString(position/1000),
                ModelUtil.toTimeString(position/1000));
    }
}
 
Example #20
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void durationChanged(int duration) {
    log.fine("Duration Changed event received: " + duration);
    synchronized (ZxtMediaPlayer.this) {
        String newValue = ModelUtil.toTimeString(duration/1000);
        currentMediaInfo = new MediaInfo(currentMediaInfo.getCurrentURI(), "",
                new UnsignedIntegerFourBytes(1), newValue, StorageMedium.NETWORK);

        getAvTransportLastChange().setEventedValue(getInstanceId(),
                new AVTransportVariable.CurrentTrackDuration(newValue),
                new AVTransportVariable.CurrentMediaDuration(newValue));
    }
}
 
Example #21
Source Project: BeyondUPnP   Author: kevinshine   File: MediaResourceDao.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Item> getAudioList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    //Query all track,add to items
    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
        String album = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "audio" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new MusicTrack(String.valueOf(id), parentId, title, creator, album, new PersonWithRole(creator), res));

        c.moveToNext();
    }

    return items;
}
 
Example #22
Source Project: BeyondUPnP   Author: kevinshine   File: MediaResourceDao.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Item> getVideoList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Video.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "video" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new Movie(String.valueOf(id), parentId, title, creator, res));

        c.moveToNext();
    }

    return items;
}
 
Example #23
Source Project: DroidDLNA   Author: offbye   File: AnnotationActionBinder.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException {

        // Validate datatype as good as we can
        // (for enums and other convertible types, the state variable type should be STRING)

        Datatype.Default expectedDefaultMapping =
                ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type)
                        ? Datatype.Default.STRING
                        : Datatype.Default.getByJavaType(type);

        log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping);

        if (expectedDefaultMapping != null &&
                !stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) {

            // TODO: Consider custom types?!
            throw new LocalServiceBindingException(
                    "State variable '" + stateVariable + "' datatype can't handle action " +
                            "argument's Java type (change one): " + expectedDefaultMapping.getJavaType()
            );

        } else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) {
            throw new LocalServiceBindingException(
                    "State variable '" + stateVariable  + "' should be custom datatype " +
                            "(action argument type is unknown Java type): " + type.getSimpleName()
            );
        }

        log.finer("State variable matches required argument datatype (or can't be validated because it is custom)");
    }
 
Example #24
Source Project: DroidDLNA   Author: offbye   File: RemoteDeviceIdentity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
  public String toString() {
      // Performance optimization, so we don't have to wrap all log("foo " + device) calls with isLoggable
if(ModelUtil.ANDROID_RUNTIME) {
          return "(RemoteDeviceIdentity) UDN: " + getUdn() + ", Descriptor: " + getDescriptorURL();
      }
      return "(" + getClass().getSimpleName() + ") UDN: " + getUdn() + ", Descriptor: " + getDescriptorURL();
  }
 
Example #25
Source Project: DroidDLNA   Author: offbye   File: ActionArgument.java    License: GNU General Public License v3.0 5 votes vote down vote up
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getName() == null || getName().length() == 0) {
        errors.add(new ValidationError(
                getClass(),
                "name",
                "Argument without name of: " + getAction()
        ));
    } else if (!ModelUtil.isValidUDAName(getName())) {
        log.warning("UPnP specification violation of: " + getAction().getService().getDevice());
        log.warning("Invalid argument name: " + this);
    } else if (getName().length() > 32) {
        log.warning("UPnP specification violation of: " + getAction().getService().getDevice());
        log.warning("Argument name should be less than 32 characters: " + this);
    }

    if (getDirection() == null) {
        errors.add(new ValidationError(
                getClass(),
                "direction",
                "Argument '"+getName()+"' requires a direction, either IN or OUT"
        ));
    }

    if (isReturnValue() && getDirection() != ActionArgument.Direction.OUT) {
        errors.add(new ValidationError(
                getClass(),
                "direction",
                "Return value argument '" + getName() + "' must be direction OUT"
        ));
    }

    return errors;
}
 
Example #26
Source Project: DroidDLNA   Author: offbye   File: OutgoingSearchRequest.java    License: GNU General Public License v3.0 5 votes vote down vote up
public OutgoingSearchRequest(UpnpHeader searchTarget, int mxSeconds) {
    super(
            new UpnpRequest(UpnpRequest.Method.MSEARCH),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.searchTarget = searchTarget;

    getHeaders().add(UpnpHeader.Type.MAN, new MANHeader(NotificationSubtype.DISCOVER.getHeaderString()));
    getHeaders().add(UpnpHeader.Type.MX, new MXHeader(mxSeconds));
    getHeaders().add(UpnpHeader.Type.ST, searchTarget);
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
}
 
Example #27
Source Project: DroidDLNA   Author: offbye   File: SoapActionType.java    License: GNU General Public License v3.0 5 votes vote down vote up
public SoapActionType(String namespace, String type, Integer version, String actionName) {
    this.namespace = namespace;
    this.type = type;
    this.version = version;
    this.actionName = actionName;

    if (actionName != null && !ModelUtil.isValidUDAName(actionName)) {
        throw new IllegalArgumentException("Action name contains illegal characters: " + actionName);
    }
}
 
Example #28
Source Project: DroidDLNA   Author: offbye   File: CSV.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected List parseString(String s) throws InvalidValueException {
    String[] strings = ModelUtil.fromCommaSeparatedList(s);
    List values = new ArrayList();
    for (String string : strings) {
        values.add(datatype.getDatatype().valueOf(string));
    }
    return values;
}
 
Example #29
Source Project: DroidDLNA   Author: offbye   File: CSV.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public String toString() {
    List<String> stringValues = new ArrayList();
    for (T t : this) {
        stringValues.add(datatype.getDatatype().getString(t));
    }
    return ModelUtil.toCommaSeparatedList(stringValues.toArray(new Object[stringValues.size()]));
}
 
Example #30
Source Project: DroidDLNA   Author: offbye   File: AbstractAVTransportService.java    License: GNU General Public License v3.0 5 votes vote down vote up
@UpnpAction(name = "GetCurrentTransportActions", out = @UpnpOutputArgument(name = "Actions", stateVariable = "CurrentTransportActions"))
public String getCurrentTransportActionsString(@UpnpInputArgument(name = "InstanceID") UnsignedIntegerFourBytes instanceId)
        throws AVTransportException {
    try {
        return ModelUtil.toCommaSeparatedList(getCurrentTransportActions(instanceId));
    } catch (Exception ex) {
        return ""; // TODO: Empty string is not defined in spec but seems reasonable for no available action?
    }
}