com.thoughtworks.xstream.converters.ConversionException Java Examples
The following examples show how to use
com.thoughtworks.xstream.converters.ConversionException.
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 File: ChannelXmlResult.java From smarthome with Eclipse Public License 2.0 | 6 votes |
protected ChannelDefinition toChannelDefinition(String bindingId) throws ConversionException { String id = getId(); String typeId = getTypeId(); String typeUID = getTypeUID(bindingId, typeId); // Convert the channel properties into a map Map<String, String> propertiesMap = new HashMap<>(); for (NodeValue property : getProperties()) { propertiesMap.put(property.getAttributes().get("name"), (String) property.getValue()); } return new ChannelDefinitionBuilder(id, new ChannelTypeUID(typeUID)).withProperties(propertiesMap) .withLabel(getLabel()).withDescription(getDescription()).withAutoUpdatePolicy(getAutoUpdatePolicy()) .build(); }
Example #2
Source File: ChannelTypeConverter.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private Set<String> readTags(NodeIterator nodeIterator) throws ConversionException { Set<String> tags = null; List<?> tagsNode = nodeIterator.nextList("tags", false); if (tagsNode != null) { tags = new HashSet<>(tagsNode.size()); for (Object tagNodeObject : tagsNode) { NodeValue tagNode = (NodeValue) tagNodeObject; if ("tag".equals(tagNode.getNodeName())) { String tag = (String) tagNode.getValue(); if (tag != null) { tags.add(tag); } } else { throw new ConversionException("The 'tags' node must only contain 'tag' nodes!"); } } } return tags; }
Example #3
Source File: AbstractChronicleMapConverter.java From Chronicle-Map with Apache License 2.0 | 6 votes |
private static Class forName(String clazz) { try { return Class.forName(clazz); } catch (ClassNotFoundException e) { boolean isNative = clazz.endsWith($$NATIVE); boolean isHeap = clazz.endsWith($$HEAP); if (!isNative && !isHeap) throw new ConversionException("class=" + clazz, e); final String nativeInterface = isNative ? clazz.substring(0, clazz.length() - $$NATIVE.length()) : clazz.substring(0, clazz.length() - $$HEAP.length()); try { Values.newNativeReference(Class.forName(clazz)); return Class.forName(nativeInterface); } catch (Exception e1) { throw new ConversionException("class=" + clazz, e1); } } }
Example #4
Source File: NodeIterator.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
/** * Returns the next attribute if the specified name of the node fits to the next node * and the attribute with the specified name could be found, or {@code null} if the * node or attribute does not exist. In the last case the iterator will <i>not</i> * increase its iteration counter. * <p> * The next node must be of the type {@link NodeAttributes}. * * @param nodeName the name of the node to be read next (must neither be null, nor empty) * @param attributeName the name of the attribute of the node to be read next * (must neither be null, nor empty) * @param required true if the occurrence of the node's attribute has to be ensured * @return the next attribute of the specified name of the node and attribute * (could be null or empty) * @throws ConversionException if the specified node's attribute could not be found in the * next node however it was specified as required */ public String nextAttribute(String nodeName, String attributeName, boolean required) throws ConversionException { if (hasNext()) { Object nextNode = next(); if (nextNode instanceof NodeAttributes) { if (nodeName.equals(((NodeName) nextNode).getNodeName())) { return ((NodeAttributes) nextNode).getAttribute(attributeName); } } this.index--; } if (required) { throw new ConversionException( "The attribute '" + attributeName + "' in the node '" + nodeName + "' is missing!"); } return null; }
Example #5
Source File: CGLIBEnhancedConverter.java From lams with GNU General Public License v2.0 | 6 votes |
private Callback createReverseEngineeredCallbackOfProperType(Callback callback, int index, Map callbackIndexMap) { Class iface = null; Class[] interfaces = callback.getClass().getInterfaces(); for (int i = 0; i < interfaces.length; i++ ) { if (Callback.class.isAssignableFrom(interfaces[i])) { iface = interfaces[i]; if (iface == Callback.class) { ConversionException exception = new ConversionException( "Cannot handle CGLIB callback"); exception.add("CGLIB-callback-type", callback.getClass().getName()); throw exception; } interfaces = iface.getInterfaces(); if (Arrays.asList(interfaces).contains(Callback.class)) { break; } i = -1; } } return (Callback)Proxy.newProxyInstance( iface.getClassLoader(), new Class[]{iface}, new ReverseEngineeringInvocationHandler(index, callbackIndexMap)); }
Example #6
Source File: NodeIterator.java From smarthome with Eclipse Public License 2.0 | 6 votes |
/** * Returns the next attribute if the specified name of the node fits to the next node * and the attribute with the specified name could be found, or {@code null} if the * node or attribute does not exist. In the last case the iterator will <i>not</i> * increase its iteration counter. * <p> * The next node must be of the type {@link NodeAttributes}. * * @param nodeName the name of the node to be read next (must neither be null, nor empty) * @param attributeName the name of the attribute of the node to be read next * (must neither be null, nor empty) * @param required true if the occurrence of the node's attribute has to be ensured * @return the next attribute of the specified name of the node and attribute * (could be null or empty) * @throws ConversionException if the specified node's attribute could not be found in the * next node however it was specified as required */ public String nextAttribute(String nodeName, String attributeName, boolean required) throws ConversionException { if (hasNext()) { Object nextNode = next(); if (nextNode instanceof NodeAttributes) { if (nodeName.equals(((NodeName) nextNode).getNodeName())) { return ((NodeAttributes) nextNode).getAttribute(attributeName); } } this.index--; } if (required) { throw new ConversionException("The attribute '" + attributeName + "' in the node '" + nodeName + "' is missing!"); } return null; }
Example #7
Source File: ChannelXmlResult.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
protected ChannelDefinition toChannelDefinition(String bindingId) throws ConversionException { String id = getId(); String typeId = getTypeId(); String typeUID = getTypeUID(bindingId, typeId); // Convert the channel properties into a map Map<String, String> propertiesMap = new HashMap<>(); for (NodeValue property : getProperties()) { propertiesMap.put(property.getAttributes().get("name"), (String) property.getValue()); } return new ChannelDefinitionBuilder(id, new ChannelTypeUID(typeUID)).withProperties(propertiesMap) .withLabel(getLabel()).withDescription(getDescription()).withAutoUpdatePolicy(getAutoUpdatePolicy()) .build(); }
Example #8
Source File: ChannelGroupTypeConverter.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Override protected ChannelGroupTypeXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException { ChannelGroupTypeUID channelGroupTypeUID = new ChannelGroupTypeUID(super.getUID(attributes, context)); boolean advanced = isAdvanced(attributes, false); String label = super.readLabel(nodeIterator); String description = super.readDescription(nodeIterator); String category = readCategory(nodeIterator); List<ChannelXmlResult> channelTypeDefinitions = readChannelTypeDefinitions(nodeIterator); ChannelGroupTypeXmlResult groupChannelType = new ChannelGroupTypeXmlResult(channelGroupTypeUID, advanced, label, description, category, channelTypeDefinitions); return groupChannelType; }
Example #9
Source File: ChannelTypeConverter.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
private Set<String> readTags(NodeIterator nodeIterator) throws ConversionException { Set<String> tags = null; List<?> tagsNode = nodeIterator.nextList("tags", false); if (tagsNode != null) { tags = new HashSet<>(tagsNode.size()); for (Object tagNodeObject : tagsNode) { NodeValue tagNode = (NodeValue) tagNodeObject; if ("tag".equals(tagNode.getNodeName())) { String tag = (String) tagNode.getValue(); if (tag != null) { tags.add(tag); } } else { throw new ConversionException("The 'tags' node must only contain 'tag' nodes!"); } } } return tags; }
Example #10
Source File: EventDescriptionConverter.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private EventOption toEventOption(NodeValue nodeValue) throws ConversionException { if ("option".equals(nodeValue.getNodeName())) { String value; String label; Map<String, String> attributes = nodeValue.getAttributes(); if ((attributes != null) && (attributes.containsKey("value"))) { value = attributes.get("value"); } else { throw new ConversionException("The node 'option' requires the attribute 'value'!"); } label = (String) nodeValue.getValue(); return new EventOption(value, label); } throw new ConversionException("Unknown type in the list of 'options'!"); }
Example #11
Source File: JavaFieldConverter.java From lams with GNU General Public License v2.0 | 6 votes |
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { String methodName = null; String declaringClassName = null; while((methodName == null || declaringClassName == null) && reader.hasMoreChildren()) { reader.moveDown(); if (reader.getNodeName().equals("name")) { methodName = reader.getValue(); } else if (reader.getNodeName().equals("clazz")) { declaringClassName = reader.getValue(); } reader.moveUp(); } Class declaringClass = (Class)javaClassConverter.fromString(declaringClassName); try { return declaringClass.getDeclaredField(mapper.realMember(declaringClass, methodName)); } catch (NoSuchFieldException e) { throw new ConversionException(e); } }
Example #12
Source File: StackTraceElementConverter.java From lams with GNU General Public License v2.0 | 6 votes |
public Object fromString(String str) { Matcher matcher = PATTERN.matcher(str); if (matcher.matches()) { String declaringClass = matcher.group(1); String methodName = matcher.group(2); String fileName = matcher.group(3); if (fileName.equals("Unknown Source")) { return FACTORY.unknownSourceElement(declaringClass, methodName); } else if (fileName.equals("Native Method")) { return FACTORY.nativeMethodElement(declaringClass, methodName); } else { if (matcher.group(4) != null) { int lineNumber = Integer.parseInt(matcher.group(5)); return FACTORY.element(declaringClass, methodName, fileName, lineNumber); } else { return FACTORY.element(declaringClass, methodName, fileName); } } } else { throw new ConversionException("Could not parse StackTraceElement : " + str); } }
Example #13
Source File: XStream.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Deserialize an object from a hierarchical data structure (such as XML). * * @param root If present, the passed in object will have its fields populated, as opposed * to XStream creating a new instance. Note, that this is a special use case! * With the ReflectionConverter XStream will write directly into the raw memory * area of the existing object. Use with care! * @param dataHolder Extra data you can use to pass to your converters. Use this as you * want. If not present, XStream shall create one lazily as needed. * @throws XStreamException if the object cannot be deserialized */ public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder) { try { if (!securityInitialized && !securityWarningGiven) { securityWarningGiven = true; System.err.println("Security framework of XStream not initialized, XStream is probably vulnerable."); } return marshallingStrategy.unmarshal( root, reader, dataHolder, converterLookup, mapper); } catch (ConversionException e) { Package pkg = getClass().getPackage(); String version = pkg != null ? pkg.getImplementationVersion() : null; e.add("version", version != null ? version : "not available"); throw e; } }
Example #14
Source File: ConverterValueMap.java From smarthome with Eclipse Public License 2.0 | 6 votes |
/** * Reads-in {@code N} children in a key-value map and returns it. * * @param reader the reader to be used to read-in the children (must not be null) * @param numberOfValues the number of children to be read in (< 0 = until end of section) * @param context * @return the key-value map containing the read-in children (not null, could be empty) * @throws ConversionException if not all children could be read-in */ public static Map<String, Object> readValueMap(HierarchicalStreamReader reader, int numberOfValues, UnmarshallingContext context) throws ConversionException { Map<String, Object> valueMap = new HashMap<>((numberOfValues >= 0) ? numberOfValues : 10); int counter = 0; while (reader.hasMoreChildren() && ((counter < numberOfValues) || (numberOfValues == -1))) { reader.moveDown(); if (reader.hasMoreChildren()) { List<?> list = (List<?>) context.convertAnother(context, List.class); valueMap.put(reader.getNodeName(), list); } else { valueMap.put(reader.getNodeName(), reader.getValue()); } reader.moveUp(); counter++; } if ((counter < numberOfValues) && (numberOfValues > 0)) { throw new ConversionException("Not all children could be read-in!"); } return valueMap; }
Example #15
Source File: ThreadSafePropertyEditor.java From lams with GNU General Public License v2.0 | 6 votes |
public ThreadSafePropertyEditor(Class type, int initialPoolSize, int maxPoolSize) { if (!PropertyEditor.class.isAssignableFrom(type)) { throw new IllegalArgumentException(type.getName() + " is not a " + PropertyEditor.class.getName()); } editorType = type; pool = new Pool(initialPoolSize, maxPoolSize, new Pool.Factory() { public Object newInstance() { ErrorWritingException ex = null; try { return editorType.newInstance(); } catch (InstantiationException e) { ex = new ConversionException("Faild to call default constructor", e); } catch (IllegalAccessException e) { ex = new ObjectAccessException("Cannot call default constructor", e); } ex.add("construction-type", editorType.getName()); throw ex; } }); }
Example #16
Source File: ThingTypeXmlResult.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
protected List<ChannelDefinition> toChannelDefinitions(List<ChannelXmlResult> channelTypeReferences) throws ConversionException { List<ChannelDefinition> channelTypeDefinitions = null; if (channelTypeReferences != null && !channelTypeReferences.isEmpty()) { channelTypeDefinitions = new ArrayList<>(channelTypeReferences.size()); for (ChannelXmlResult channelTypeReference : channelTypeReferences) { channelTypeDefinitions.add(channelTypeReference.toChannelDefinition(this.thingTypeUID.getBindingId())); } } return channelTypeDefinitions; }
Example #17
Source File: CommandDescriptionConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Override public final CommandDescription unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { NodeList nodes = (NodeList) context.convertAnother(context, NodeList.class); NodeIterator nodeIterator = new NodeIterator(nodes.getList()); NodeList commandOptionsNode = (NodeList) nodeIterator.next(); if (commandOptionsNode != null) { if ("options".equals(commandOptionsNode.getNodeName())) { CommandDescriptionBuilder commandDescriptionBuilder = CommandDescriptionBuilder.create(); for (Object coNodeObject : commandOptionsNode.getList()) { NodeValue optionsNode = (NodeValue) coNodeObject; if ("option".equals(optionsNode.getNodeName())) { String name = (String) optionsNode.getValue(); String command = optionsNode.getAttributes().get("value"); if (name != null && command != null) { commandDescriptionBuilder.withCommandOption(new CommandOption(command, name)); } } else { throw new ConversionException("The 'options' node must only contain 'option' nodes!"); } } nodeIterator.assertEndOfType(); return commandDescriptionBuilder.build(); } } nodeIterator.assertEndOfType(); return null; }
Example #18
Source File: ThingTypeConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected List<ChannelXmlResult>[] getChannelTypeReferenceObjects(NodeIterator nodeIterator) throws ConversionException { List<ChannelXmlResult> channelTypeReferences = null; List<ChannelXmlResult> channelGroupTypeReferences = null; channelTypeReferences = (List<ChannelXmlResult>) nodeIterator.nextList("channels", false); if (channelTypeReferences == null) { channelGroupTypeReferences = (List<ChannelXmlResult>) nodeIterator.nextList("channel-groups", false); } return new List[] { channelTypeReferences, channelGroupTypeReferences }; }
Example #19
Source File: ConfigDescriptionParameterConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
private BigDecimal toNumber(String value) { try { if (value != null) { return new BigDecimal(value); } } catch (NumberFormatException e) { throw new ConversionException("The value '" + value + "' could not be converted to a decimal number.", e); } return null; }
Example #20
Source File: ThingTypeConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Override protected ThingTypeXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException { ThingTypeXmlResult thingTypeXmlResult = new ThingTypeXmlResult( new ThingTypeUID(super.getUID(attributes, context)), readSupportedBridgeTypeUIDs(nodeIterator, context), super.readLabel(nodeIterator), super.readDescription(nodeIterator), readCategory(nodeIterator), getListed(attributes), getExtensibleChannelTypeIds(attributes), getChannelTypeReferenceObjects(nodeIterator), getProperties(nodeIterator), getRepresentationProperty(nodeIterator), super.getConfigDescriptionObjects(nodeIterator)); return thingTypeXmlResult; }
Example #21
Source File: ChannelConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
protected ChannelXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException { String id = attributes.get("id"); String typeId = attributes.get("typeId"); String label = (String) nodeIterator.nextValue("label", false); String description = (String) nodeIterator.nextValue("description", false); List<NodeValue> properties = getProperties(nodeIterator); AutoUpdatePolicy autoUpdatePolicy = readAutoUpdatePolicy(nodeIterator); ChannelXmlResult channelXmlResult = new ChannelXmlResult(id, typeId, label, description, properties, autoUpdatePolicy); return channelXmlResult; }
Example #22
Source File: AbstractChronicleMapConverter.java From Chronicle-Map with Apache License 2.0 | 5 votes |
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // empty map if ("[\"\"]".equals(reader.getValue())) return null; if (!"cmap".equals(reader.getNodeName())) throw new ConversionException("should be under 'cmap' node"); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); final String nodeName0 = reader.getNodeName(); if (!nodeName0.equals("entry")) throw new ConversionException("unable to convert node named=" + nodeName0); final K k; final V v; reader.moveDown(); k = deserialize(context, reader); reader.moveUp(); reader.moveDown(); v = deserialize(context, reader); reader.moveUp(); if (k != null) map.put(k, v); reader.moveUp(); } reader.moveUp(); return null; }
Example #23
Source File: VersionedExternalizable.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public Object doUnmarshal(final Object result, final HierarchicalStreamReader reader, final UnmarshallingContext context) { final String currentVersion = ((VersionedExternalizable) result).getExternalizableVersion(); final String oldVersion = reader.getAttribute(VERSION_ATTRIBUTE); if ((oldVersion == null) || !currentVersion.equals(oldVersion)) { // This is one place we might put a version translation method in the future.... throw new ConversionException("Cannot convert " + result + " from version " + oldVersion + " to version " + currentVersion); } return super.doUnmarshal(result, reader, context); }
Example #24
Source File: EventDescriptionConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
private List<EventOption> toListOfEventOptions(NodeList nodeList) throws ConversionException { if ("options".equals(nodeList.getNodeName())) { List<EventOption> eventOptions = new ArrayList<>(); for (Object nodeObject : nodeList.getList()) { eventOptions.add(toEventOption((NodeValue) nodeObject)); } return eventOptions; } throw new ConversionException("Unknown type '" + nodeList.getNodeName() + "'!"); }
Example #25
Source File: PbBlank.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * decodes <code>PbBlank</code> from <code>file</code> specified by argument * <code>filename</code> * * @param filename location to read data from * @param doValidate the value of doValidate * @return <code>Object</code> - the <code>PbBlank</code> created from the * specified XML <code>file</code> * @throws java.io.FileNotFoundException * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException @pre * <code>filename</code> references an XML <code>file</code> @post * <code>PbBlank</code> stored in <code>filename</code> is returned */ public Object readXMLObject(String filename, boolean doValidate) throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException { PbBlank retPbBlank = null; BufferedReader reader = URIHelper.getBufferedReader(filename); if (reader != null) { boolean validXML = true; XStream xstream = getXStreamReader(); if (doValidate) { validXML = URIHelper.validateXML(reader, filename, PbBlankXMLSchemaURL); } if (validXML) { // re-create reader reader = URIHelper.getBufferedReader(filename); try { retPbBlank = (PbBlank) xstream.fromXML(reader); } catch (ConversionException e) { throw new ETException(null, e.getMessage()); } // System.out.println( "This is your PbBlank that was just read successfully:\n" ); // String xml2 = getXStreamWriter().toXML( retPbBlank ); // // System.out.println( xml2 ); // System.out.flush(); } } else { throw new FileNotFoundException("Badly formed or missing XML data file."); } return retPbBlank; }
Example #26
Source File: ValueConverter.java From Chronicle-Map with Apache License 2.0 | 5 votes |
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { try { ValueModel valueModel = ValueModel.acquire(context.getRequiredType()); Object result = valueModel.heapClass().newInstance(); fillInObject(reader, context, valueModel, result); return result; } catch (Exception e) { throw new ConversionException( "class=" + context.getRequiredType().getCanonicalName(), e); } }
Example #27
Source File: BridgeTypeConverter.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override protected BridgeTypeXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException { BridgeTypeXmlResult bridgeTypeXmlResult = new BridgeTypeXmlResult(new ThingTypeUID(getUID(attributes, context)), readSupportedBridgeTypeUIDs(nodeIterator, context), readLabel(nodeIterator), readDescription(nodeIterator), readCategory(nodeIterator), getListed(attributes), getExtensibleChannelTypeIds(attributes), getChannelTypeReferenceObjects(nodeIterator), getProperties(nodeIterator), getRepresentationProperty(nodeIterator), getConfigDescriptionObjects(nodeIterator)); return bridgeTypeXmlResult; }
Example #28
Source File: SampleMetaData.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * decodes <code>ValueModel</code> from <code>file</code> specified by * argument <code>filename</code> * * @param filename location to read data from * @param doValidate the value of doValidate * @return <code>Object</code> - the <code>ValueModel</code> created from * the specified XML <code>file</code> * @throws java.io.FileNotFoundException * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException * @pre <code>filename</code> references an XML <code>file</code> * @post <code>ValueModel</code> stored in <code>filename</code> is returned */ public Object readXMLObject(String filename, boolean doValidate) throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException { SampleMetaData mySampleMetaData = null; BufferedReader reader = URIHelper.getBufferedReader(filename); if (reader != null) { boolean validXML = false; XStream xstream = getXStreamReader(); validXML = true;//URIHelper.validateXML(reader, getSampleMetaDataXMLSchemaURL()); if (validXML) { // re-create reader reader = URIHelper.getBufferedReader(filename); try { mySampleMetaData = (SampleMetaData) xstream.fromXML(reader); } catch (ConversionException e) { throw new ETException(null, e.getMessage()); } // System.out.println("\nThis is your SampleMetaData that was just read successfully:\n"); // String xml2 = getXStreamWriter().toXML(mySampleMetaData); // // System.out.println(xml2); // System.out.flush(); } } else { throw new FileNotFoundException("Badly formed or missing XML data file."); } return mySampleMetaData; }
Example #29
Source File: ThingTypeXmlResult.java From smarthome with Eclipse Public License 2.0 | 5 votes |
protected List<ChannelDefinition> toChannelDefinitions(List<ChannelXmlResult> channelTypeReferences) throws ConversionException { List<ChannelDefinition> channelTypeDefinitions = null; if ((channelTypeReferences != null) && (channelTypeReferences.size() > 0)) { channelTypeDefinitions = new ArrayList<>(channelTypeReferences.size()); for (ChannelXmlResult channelTypeReference : channelTypeReferences) { channelTypeDefinitions.add(channelTypeReference.toChannelDefinition(this.thingTypeUID.getBindingId())); } } return channelTypeDefinitions; }
Example #30
Source File: BindingInfoConverter.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
private URI readConfigDescriptionURI(NodeIterator nodeIterator) throws ConversionException { String uriText = nodeIterator.nextAttribute("config-description-ref", "uri", false); if (uriText != null) { try { return new URI(uriText); } catch (URISyntaxException ex) { throw new ConversionException( "The URI '" + uriText + "' in node " + "'config-description-ref' is invalid!", ex); } } return null; }