Search in sources :

Example 1 with CommandList

use of cern.c2mon.server.common.device.CommandList in project c2mon by c2mon.

the class DeviceClassFacadeImpl method parseXmlCommands.

/**
 * Parse the XML representation of the commands of a device class (which comes
 * from configuration) and return it as a list of commands.
 *
 * @param xmlString the XML representation string of the device class commands
 *
 * @return the list of commands
 * @throws Exception if the XML could not be parsed
 */
private List<Command> parseXmlCommands(String xmlString) throws Exception {
    List<Command> commands = new ArrayList<>();
    Serializer serializer = new Persister();
    CommandList commandList = serializer.read(CommandList.class, xmlString);
    for (Command command : commandList.getCommands()) {
        commands.add(command);
    }
    return commands;
}
Also used : CommandList(cern.c2mon.server.common.device.CommandList) Command(cern.c2mon.server.common.device.Command) ArrayList(java.util.ArrayList) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Command (cern.c2mon.server.common.device.Command)1 CommandList (cern.c2mon.server.common.device.CommandList)1 ArrayList (java.util.ArrayList)1 Serializer (org.simpleframework.xml.Serializer)1 Persister (org.simpleframework.xml.core.Persister)1