Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros.internal.message.definition;
00018
00019 import com.google.common.base.Preconditions;
00020 import com.google.common.collect.Lists;
00021
00022 import java.util.List;
00023
00030 public class MessageDefinitionTupleParser {
00031
00032 private static final String SEPARATOR = "---";
00033
00044 public static List<String> parse(String definition, int size) {
00045 Preconditions.checkNotNull(definition);
00046 List<String> definitions = Lists.newArrayList();
00047 StringBuilder current = new StringBuilder();
00048 for (String line : definition.split("\n")) {
00049 if (line.startsWith(SEPARATOR)) {
00050 definitions.add(current.toString());
00051 current = new StringBuilder();
00052 continue;
00053 }
00054 current.append(line);
00055 current.append("\n");
00056 }
00057 if (current.length() > 0) {
00058 current.deleteCharAt(current.length() - 1);
00059 }
00060 definitions.add(current.toString());
00061 Preconditions.checkState(size == -1 || definitions.size() <= size,
00062 String.format("Message tuple exceeds expected size: %d > %d", definitions.size(), size));
00063 while (definitions.size() < size) {
00064 definitions.add("");
00065 }
00066 return definitions;
00067 }
00068 }