20 package net.sf.gridarta.model.archetypetype;
22 import java.util.Iterator;
25 import org.jetbrains.annotations.NotNull;
26 import org.jetbrains.annotations.Nullable;
35 public class ArchetypeType implements Iterable<ArchetypeAttributeSection> {
57 private final boolean map;
63 private final int @Nullable []
inv;
81 private final String
use;
116 this.inv =
inv ==
null ? null :
inv.clone();
134 public Iterator<ArchetypeAttributeSection>
iterator() {
179 return inv ==
null ? null :
inv.clone();
198 return result ==
null ?
"" : result.trim();
207 final String result =
use;
208 return result ==
null ?
"" : result.trim();
240 final StringBuilder sb =
new StringBuilder();
242 return sb.toString();
250 public void toString(@NotNull
final StringBuilder sb) {
258 sb.append(typeAttribute);
262 sb.append(
" section:");
263 sb.append(archetypeAttributeSection.getSectionName());
267 sb.append(archetypeAttribute);
280 final StringBuilder sb =
new StringBuilder();
289 while (start <
display.length()) {
290 final int end =
display.indexOf(
"${", start);
295 final int end2 =
display.indexOf(
'}', end + 2);
301 sb.append(
display, start, end);
302 final String spec =
display.substring(end + 2, end2);
303 final int question = spec.indexOf(
'?');
305 if (question == -1) {
306 value = baseObject.getAttributeString(spec);
308 final int colon = spec.indexOf(
':', question + 1);
309 final String attributeValue = baseObject.getAttributeString(spec.substring(0, question));
310 final boolean attributeExists = !attributeValue.isEmpty() && !attributeValue.equals(
"0");
311 if (attributeExists) {
312 value = spec.substring(question + 1, colon == -1 ? spec.length() : colon);
314 value = colon == -1 ?
"" : spec.substring(colon + 1);
320 sb.append(
display.substring(start));
324 return sb.toString();