in baremaps-rpsl/src/main/java/org/apache/baremaps/rpsl/RpslSpliterator.java [38:82]
public boolean tryAdvance(Consumer<? super RpslObject> consumer) {
List<RpslAttribute> attributes = new ArrayList<>();
String attributeName = null;
StringBuilder attributeValue = new StringBuilder();
while (advanceLine()) {
if (currentLine.isEmpty()) {
if (!attributes.isEmpty()) {
attributes.add(new RpslAttribute(attributeName, attributeValue.toString()));
consumer.accept(new RpslObject(attributes));
return true;
}
continue;
}
if (currentLine.startsWith("#") || currentLine.startsWith("%")) {
continue; // Skip comments
}
if (currentLine.startsWith(" ") || currentLine.startsWith("+")) {
// Continuation of the previous attribute's value
attributeValue.append('\n').append(currentLine.trim());
} else {
// New attribute
if (attributeName != null) {
attributes.add(new RpslAttribute(attributeName, attributeValue.toString()));
}
int index = currentLine.indexOf(':');
if (index < 0) {
// Handle error: malformed attribute line
continue;
}
attributeName = currentLine.substring(0, index).trim();
attributeValue = new StringBuilder(currentLine.substring(index + 1).trim());
}
}
if (attributeName != null) {
attributes.add(new RpslAttribute(attributeName, attributeValue.toString()));
consumer.accept(new RpslObject(attributes));
return true;
}
return false;
}