public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
public void setTags(String tags) { List<String> nvPairs = asList(tags.split(",")); this.tags = nvPairs .stream() .map(this::extractNVPair) .map(mapEntry -> new Tag().withKey(mapEntry.getKey()).withValue(mapEntry.getValue())) .collect(Collectors.toList()); }
public static Collection<Tag> parseTags(InputStream is) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(is); ArrayNode jsonNodes = (ArrayNode) tree; return StreamSupport.stream(jsonNodes.spliterator(), false) .map(node -> { return new Tag() .withKey(node.get("Key").asText()) .withValue(node.get("Value").asText()); }) .collect(Collectors.toList()); } }
protected final Collection<Tag> getAwsTags(StepExecution stepExecution) { Collection<Tag> tagList = new ArrayList<>(); if (this.tags != null) { for (String tag : this.tags) { int i = tag.indexOf('='); if (i < 0) { throw new IllegalArgumentException("Missing = in tag " + tag); } String key = tag.substring(0, i); String value = tag.substring(i + 1); tagList.add(new Tag().withKey(key).withValue(value)); } } if (this.tagsFile != null) { FilePath tagsFile = loadFileFromWorkspace(stepExecution, this.tagsFile); try { tagList.addAll(TagsFileParser.parseTags(tagsFile.read())); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InterruptedException e) { Thread.interrupted(); throw new RuntimeException(e); } } return tagList; }
/** * Allows you to add any number of nested preconfigured StackTag elements. * * @param stackTag * a preconfigured StackTag object. */ public void addConfiguredStackTag(StackTag stackTag) { tags.add(new Tag().withKey(stackTag.getKey()).withValue( stackTag.getValue())); }
.collect(Collectors.toList())); task.conventionMapping("cfnStackTags", () -> cfnExt.getStackTags().entrySet().stream() .map(it -> new Tag() .withKey(it.getKey().toString()) .withValue(it.getValue().toString())) .collect(Collectors.toList())); task.conventionMapping("cfnStackTags", () -> cfnExt.getStackTags().entrySet().stream() .map(it -> new Tag() .withKey(it.getKey().toString()) .withValue(it.getValue().toString()))
public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
stackRequest .withParameters(populatedExpectedParameters) .withTags(new Tag().withKey("Creator").withValue("testgrid-" + tgEnvironment));