public static Element appendNewElementIfNotNull(Document document, Element parent, String element, Object content) { return appendNewElementIfNotNull(document, parent, element, content, null); }
public static Element appendNewElementIfNotNull(Document document, Element parent, Enum el, Object content) { return appendNewElementIfNotNull(document, parent, el, content, null); }
public static Element appendNewElementIfNotNull(Document document, Element parent, Enum el, Object content, String namespace) { return appendNewElementIfNotNull(document, parent, el.toString(), content, namespace); }
private void generateActionArgument(ActionArgument actionArgument, Document descriptor, Element actionElement) { Element actionArgumentElement = appendNewElement(descriptor, actionElement, ELEMENT.argument); appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.name, actionArgument.getName()); appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.direction, actionArgument.getDirection().toString().toLowerCase(Locale.ROOT)); if (actionArgument.isReturnValue()) { // TODO: UPNP VIOLATION: WMP12 will discard RenderingControl service if it contains <retval> tags log.warning("UPnP specification violation: Not producing <retval> element to be compatible with WMP12: " + actionArgument); // appendNewElement(descriptor, actionArgumentElement, ELEMENT.retval); } appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.relatedStateVariable, actionArgument.getRelatedStateVariableName()); }
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) { if (!deviceModel.hasIcons()) return; Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList); for (Icon icon : deviceModel.getIcons()) { Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon); appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType()); appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth()); appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight()); appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth()); if (deviceModel instanceof RemoteDevice) { appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url, icon.getUri()); } else if (deviceModel instanceof LocalDevice) { appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url, namespace.getIconPath(icon)); } } }
protected void generateServiceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) { if (!deviceModel.hasServices()) return; Element serviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.serviceList); for (Service service : deviceModel.getServices()) { Element serviceElement = appendNewElement(descriptor, serviceListElement, ELEMENT.service); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceType, service.getServiceType()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceId, service.getServiceId()); if (service instanceof RemoteService) { RemoteService rs = (RemoteService) service; appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, rs.getDescriptorURI()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, rs.getControlURI()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, rs.getEventSubscriptionURI()); } else if (service instanceof LocalService) { LocalService ls = (LocalService) service; appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, namespace.getDescriptorPath(ls)); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, namespace.getControlPath(ls)); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, namespace.getEventSubscriptionPath(ls)); } } }
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) { Element classElement = appendNewElementIfNotNull( descriptor, parent, element, clazz.getValue(), DIDLObject.Property.UPNP.NAMESPACE.URI ); if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0) classElement.setAttribute("name", clazz.getFriendlyName()); if (appendDerivation) classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived())); }
protected void generateSpecVersion(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement) { Element specVersionElement = appendNewElement(descriptor, rootElement, ELEMENT.specVersion); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.major, deviceModel.getVersion().getMajor()); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.minor, deviceModel.getVersion().getMinor()); }
private void generateSpecVersion(Service serviceModel, Document descriptor, Element rootElement) { Element specVersionElement = appendNewElement(descriptor, rootElement, ELEMENT.specVersion); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.major, serviceModel.getDevice().getVersion().getMajor()); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.minor, serviceModel.getDevice().getVersion().getMinor()); }
appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType()); appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.friendlyName, deviceModelDetails.getFriendlyName() ); if (deviceModelDetails.getManufacturerDetails() != null) { appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.manufacturer, deviceModelDetails.getManufacturerDetails().getManufacturer() ); appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.manufacturerURL, deviceModelDetails.getManufacturerDetails().getManufacturerURI() appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.modelDescription, deviceModelDetails.getModelDetails().getModelDescription() ); appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.modelName, deviceModelDetails.getModelDetails().getModelName() ); appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.modelNumber, deviceModelDetails.getModelDetails().getModelNumber() ); appendNewElementIfNotNull( descriptor, deviceElement, ELEMENT.modelURL,
private void generateAction(Action action, Document descriptor, Element actionListElement) { Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action); appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName()); if (action.hasArguments()) { Element argumentListElement = appendNewElement(descriptor, actionElement, ELEMENT.argumentList); for (ActionArgument actionArgument : action.getArguments()) { generateActionArgument(actionArgument, descriptor, argumentListElement); } } }
appendNewElementIfNotNull(descriptor, stateVariableElement, ELEMENT.name, stateVariable.getName()); appendNewElementIfNotNull(descriptor, stateVariableElement, ELEMENT.dataType, ((CustomDatatype)stateVariable.getTypeDetails().getDatatype()).getName()); } else { appendNewElementIfNotNull(descriptor, stateVariableElement, ELEMENT.dataType, stateVariable.getTypeDetails().getDatatype().getBuiltin().getDescriptorName()); appendNewElementIfNotNull(descriptor, stateVariableElement, ELEMENT.defaultValue, stateVariable.getTypeDetails().getDefaultValue()); Element allowedValueListElement = appendNewElement(descriptor, stateVariableElement, ELEMENT.allowedValueList); for (String allowedValue : stateVariable.getTypeDetails().getAllowedValues()) { appendNewElementIfNotNull(descriptor, allowedValueListElement, ELEMENT.allowedValue, allowedValue); appendNewElementIfNotNull( descriptor, allowedValueRangeElement, ELEMENT.minimum, stateVariable.getTypeDetails().getAllowedValueRange().getMinimum() ); appendNewElementIfNotNull( descriptor, allowedValueRangeElement, ELEMENT.maximum, stateVariable.getTypeDetails().getAllowedValueRange().getMaximum() ); if (stateVariable.getTypeDetails().getAllowedValueRange().getStep() >= 1l) { appendNewElementIfNotNull( descriptor, allowedValueRangeElement, ELEMENT.step, stateVariable.getTypeDetails().getAllowedValueRange().getStep() );
appendNewElementIfNotNull( descriptor, itemElement, ); appendNewElementIfNotNull( descriptor, itemElement, ); appendNewElementIfNotNull( descriptor, itemElement,
appendNewElementIfNotNull( descriptor, containerElement, ); appendNewElementIfNotNull( descriptor, containerElement, ); appendNewElementIfNotNull( descriptor, containerElement,
public static Element appendNewElementIfNotNull(Document document, Element parent, Enum el, Object content) { return appendNewElementIfNotNull(document, parent, el, content, null); }
private void generateActionArgument(ActionArgument actionArgument, Document descriptor, Element actionElement) { Element actionArgumentElement = appendNewElement(descriptor, actionElement, ELEMENT.argument); appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.name, actionArgument.getName()); appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.direction, actionArgument.getDirection().toString().toLowerCase(Locale.ENGLISH)); if (actionArgument.isReturnValue()) { // TODO: UPNP VIOLATION: WMP12 will discard RenderingControl service if it contains <retval> tags log.warning("UPnP specification violation: Not producing <retval> element to be compatible with WMP12: " + actionArgument); // appendNewElement(descriptor, actionArgumentElement, ELEMENT.retval); } appendNewElementIfNotNull(descriptor, actionArgumentElement, ELEMENT.relatedStateVariable, actionArgument.getRelatedStateVariableName()); }
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) { Element classElement = appendNewElementIfNotNull( descriptor, parent, element, clazz.getValue(), DIDLObject.Property.UPNP.NAMESPACE.URI ); if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0) classElement.setAttribute("name", clazz.getFriendlyName()); if (appendDerivation) classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived())); }
protected void generateSpecVersion(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement) { Element specVersionElement = appendNewElement(descriptor, rootElement, ELEMENT.specVersion); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.major, deviceModel.getVersion().getMajor()); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.minor, deviceModel.getVersion().getMinor()); }
private void generateSpecVersion(Service serviceModel, Document descriptor, Element rootElement) { Element specVersionElement = appendNewElement(descriptor, rootElement, ELEMENT.specVersion); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.major, serviceModel.getDevice().getVersion().getMajor()); appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.minor, serviceModel.getDevice().getVersion().getMinor()); }
private void generateAction(Action action, Document descriptor, Element actionListElement) { Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action); appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName()); if (action.hasArguments()) { Element argumentListElement = appendNewElement(descriptor, actionElement, ELEMENT.argumentList); for (ActionArgument actionArgument : action.getArguments()) { generateActionArgument(actionArgument, descriptor, argumentListElement); } } }