当前位置: 首页>>代码示例>>Java>>正文


Java ValidationError类代码示例

本文整理汇总了Java中org.fourthline.cling.model.ValidationError的典型用法代码示例。如果您正苦于以下问题:Java ValidationError类的具体用法?Java ValidationError怎么用?Java ValidationError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValidationError类属于org.fourthline.cling.model包,在下文中一共展示了ValidationError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public LocalService read(Class<?> clazz, ServiceId id, ServiceType type,
                               boolean supportsQueryStateVariables, Set<Class> stringConvertibleTypes)
        throws LocalServiceBindingException {

    Map<StateVariable, StateVariableAccessor> stateVariables = readStateVariables(clazz, stringConvertibleTypes);
    Map<Action, ActionExecutor> actions = readActions(clazz, stateVariables, stringConvertibleTypes);

    // Special treatment of the state variable querying action
    if (supportsQueryStateVariables) {
        actions.put(new QueryStateVariableAction(), new QueryStateVariableExecutor());
    }

    try {
        return new LocalService(type, id, actions, stateVariables, stringConvertibleTypes, supportsQueryStateVariables);

    } catch (ValidationException ex) {
        log.severe("Could not validate device model: " + ex.toString());
        for (ValidationError validationError : ex.getErrors()) {
            log.severe(validationError.toString());
        }
        throw new LocalServiceBindingException("Validation of model failed, check the log");
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:24,代码来源:AnnotationLocalServiceBinder.java

示例2: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getUpc() != null) {
        // This is broken in more than half of the devices I've tested, so let's not even bother with a warning
        if (getUpc().length() != 12) {
            log.fine("UPnP specification violation, UPC must be 12 digits: " + getUpc());
        } else {
            try {
                Long.parseLong(getUpc());
            } catch (NumberFormatException ex) {
                log.fine("UPnP specification violation, UPC must be 12 digits all-numeric: " + getUpc());
            }
        }
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:DeviceDetails.java

示例3: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
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;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:StateVariable.java

示例4: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getMajor() != 1) {
        errors.add(new ValidationError(
                getClass(),
                "major",
                "UDA major spec version must be 1"
        ));
    }
    if (getMajor() < 0) {
        errors.add(new ValidationError(
                getClass(),
                "minor",
                "UDA minor spec version must be equal or greater 0"
        ));
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:UDAVersion.java

示例5: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getType() != null) {

        // Only validate the graph if we have a device type - that means we validate only if there
        // actually is a fully hydrated graph, not just a discovered device of which we haven't even
        // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device
        // type. Now that is a risky assumption...

        errors.addAll(getVersion().validate());

        if (getDetails() != null) {
            errors.addAll(getDetails().validate());
        }

        if (hasServices()) {
            for (Service service : getServices()) {
                if (service != null)
                    errors.addAll(service.validate());
            }
        }

        if (hasEmbeddedDevices()) {
            for (Device embeddedDevice : getEmbeddedDevices()) {
                if (embeddedDevice != null)
                    errors.addAll(embeddedDevice.validate());
            }
        }
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:34,代码来源:Device.java

示例6: RemoteService

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public RemoteService(ServiceType serviceType, ServiceId serviceId,
                     URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                     Action<RemoteService>[] actions, StateVariable<RemoteService>[] stateVariables) throws ValidationException {
    super(serviceType, serviceId, actions, stateVariables);

    this.descriptorURI = descriptorURI;
    this.controlURI = controlURI;
    this.eventSubscriptionURI = eventSubscriptionURI;

    List<ValidationError> errors = validateThis();
    if (errors.size() > 0) {
        throw new ValidationException("Validation of device graph failed, call getErrors() on exception", errors);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:15,代码来源:RemoteService.java

示例7: validateThis

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validateThis() {
    List<ValidationError> errors = new ArrayList();

    if (getDescriptorURI() == null) {
        errors.add(new ValidationError(
                getClass(),
                "descriptorURI",
                "Descriptor location (SCPDURL) is required"
        ));
    }

    if (getControlURI() == null) {
        errors.add(new ValidationError(
                getClass(),
                "controlURI",
                "Control URL is required"
        ));
    }

    if (getEventSubscriptionURI() == null) {
        errors.add(new ValidationError(
                getClass(),
                "eventSubscriptionURI",
                "Event subscription URL is required"
        ));
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:30,代码来源:RemoteService.java

示例8: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
@Override
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();
    errors.addAll(super.validate());

    // We have special rules for local icons, the URI must always be a relative path which will
    // be added to the device base URI!
    if (hasIcons()) {
        for (Icon icon : getIcons()) {
            if (icon.getUri().isAbsolute()) {
                errors.add(new ValidationError(
                        getClass(),
                        "icons",
                        "Local icon URI can not be absolute: " + icon.getUri()
                ));
            }
            if (icon.getUri().toString().contains("../")) {
                errors.add(new ValidationError(
                        getClass(),
                        "icons",
                        "Local icon URI must not contain '../': " + icon.getUri()
                ));
            }
            if (icon.getUri().toString().startsWith("/")) {
                errors.add(new ValidationError(
                        getClass(),
                        "icons",
                        "Local icon URI must not start with '/': " + icon.getUri()
                ));
            }
        }
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:36,代码来源:LocalDevice.java

示例9: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
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;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:36,代码来源:ActionArgument.java

示例10: createLocalDevice

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public void createLocalDevice() throws ValidationException
{
	String version = "";
	try {
		version = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName;
	} catch (PackageManager.NameNotFoundException e) {
		Log.e(TAG, "Application version name not found");
	}

	DeviceDetails details = new DeviceDetails(
		SettingsActivity.getSettingContentDirectoryName(ctx),
		new ManufacturerDetails(ctx.getString(R.string.app_name), ctx.getString(R.string.app_url)),
		new ModelDetails(ctx.getString(R.string.app_name), ctx.getString(R.string.app_url)),
		ctx.getString(R.string.app_name), version);

	List<ValidationError> l = details.validate();
	for( ValidationError v : l )
	{
		Log.e(TAG, "Validation pb for property "+ v.getPropertyName());
		Log.e(TAG, "Error is " + v.getMessage());
	}


	DeviceType type = new UDADeviceType("MediaServer", 1);

	localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, localService);
}
 
开发者ID:trishika,项目名称:DroidUPnP,代码行数:28,代码来源:MediaServer.java

示例11: Device

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public Device(DI identity, UDAVersion version, DeviceType type, DeviceDetails details,
              Icon[] icons, S[] services, D[] embeddedDevices) throws ValidationException {

    this.identity = identity;
    this.version = version == null ? new UDAVersion() : version;
    this.type = type;
    this.details = details;

    // We don't fail device validation if icons were invalid, only log a warning. To
    // comply with mutability rules (can't set icons field in validate() method), we
    // validate the icons here before we set the field value
    List<Icon> validIcons = new ArrayList<Icon>();
    if (icons != null) {
        for (Icon icon : icons) {
            if (icon != null) {
                icon.setDevice(this); // Set before validate()!
                List<ValidationError> iconErrors = icon.validate();
                if(iconErrors.isEmpty()) {
                    validIcons.add(icon);
                } else {
                    log.warning("Discarding invalid '" + icon + "': " + iconErrors);
                }
            }
        }
    }
    this.icons = validIcons.toArray(new Icon[validIcons.size()]);

    boolean allNullServices = true;
    if (services != null) {
        for (S service : services) {
            if (service != null) {
                allNullServices = false;
                service.setDevice(this);
            }
        }
    }
    this.services = services == null || allNullServices ? null : services;

    boolean allNullEmbedded = true;
    if (embeddedDevices != null) {
        for (D embeddedDevice : embeddedDevices) {
            if (embeddedDevice != null) {
                allNullEmbedded = false;
                embeddedDevice.setParentDevice(this);
            }
        }
    }
    this.embeddedDevices = embeddedDevices == null || allNullEmbedded  ? null : embeddedDevices;

    List<ValidationError> errors = validate();
    if (errors.size() > 0) {
        if (log.isLoggable(Level.FINEST)) {
            for (ValidationError error : errors) {
                log.finest(error.toString());
            }
        }
        throw new ValidationException("Validation of device graph failed, call getErrors() on exception", errors);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:60,代码来源:Device.java

示例12: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getServiceType() == null) {
        errors.add(new ValidationError(
                getClass(),
                "serviceType",
                "Service type/info is required"
        ));
    }

    if (getServiceId() == null) {
        errors.add(new ValidationError(
                getClass(),
                "serviceId",
                "Service ID is required"
        ));
    }

    // TODO: If the service has no evented variables, it should not have an event subscription URL, which means
    // the url element in the device descriptor must be present, but empty!!!!

    /* TODO: This doesn't fit into our meta model, we don't know if a service has state variables until
     we completely hydrate it from a service descriptor
    if (getStateVariables().length == 0) {
        errors.add(new ValidationError(
                getClass(),
                "stateVariables",
                "Service must have at least one state variable"
        ));
    }
    */

    if (hasActions()) {
        for (Action action : getActions()) {
            errors.addAll(action.validate());
        }
    }

    if (hasStateVariables()) {
        for (StateVariable stateVariable : getStateVariables()) {
            errors.addAll(stateVariable.validate());
        }
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:48,代码来源:Service.java

示例13: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList();

    if (getDatatype() == null) {
        errors.add(new ValidationError(
                getClass(),
                "datatype",
                "Service state variable has no datatype"
        ));
    }

    if (getAllowedValues() != null) {

        if (getAllowedValueRange() != null) {
            errors.add(new ValidationError(
                    getClass(),
                    "allowedValues",
                    "Allowed value list of state variable can not also be restricted with allowed value range"
            ));
        }

        if (!Datatype.Builtin.STRING.equals(getDatatype().getBuiltin())) {
            errors.add(new ValidationError(
                    getClass(),
                    "allowedValues",
                    "Allowed value list of state variable only available for string datatype, not: " + getDatatype()
            ));
        }

        for (String s : getAllowedValues()) {
            if (s.length() > 31) {
                log.warning("UPnP specification violation, allowed value string must be less than 32 chars: " + s);
            }
        }

        if(!foundDefaultInAllowedValues(defaultValue, allowedValues)) {
            log.warning("UPnP specification violation, allowed string values " +
                                "don't contain default value: " + defaultValue
            );
        }
    }

    if (getAllowedValueRange() != null) {
        errors.addAll(getAllowedValueRange().validate());
    }

    return errors;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:49,代码来源:StateVariableTypeDetails.java

示例14: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
public List<ValidationError> validate() {
    return new ArrayList();
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:4,代码来源:StateVariableAllowedValueRange.java

示例15: validate

import org.fourthline.cling.model.ValidationError; //导入依赖的package包/类
@Override
public List<ValidationError> validate() {
    return Collections.EMPTY_LIST;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:5,代码来源:QueryStateVariableAction.java


注:本文中的org.fourthline.cling.model.ValidationError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。