Refine search
private Yaml newYaml() { return new Yaml(new SafeConstructor(), new Representer(), new DumperOptions(), new YamlTagResolver()); } }
@Override protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) { NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag); return isUnwantedNodeTuple(tuple.getValueNode()) ? null : tuple; }
public TypeDescription addTypeDescription(TypeDescription td) { if (Collections.EMPTY_MAP == typeDefinitions) { typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); } if (td.getTag() != null) { addClassTag(td.getType(), td.getTag()); } td.setPropertyUtils(getPropertyUtils()); return typeDefinitions.put(td.getType(), td); }
private static DumperOptions initDumperOptions(Representer representer) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); dumperOptions.setTimeZone(representer.getTimeZone()); return dumperOptions; }
FlowStyle oldStyle = representer.getDefaultFlowStyle(); if (flowStyle != null) { representer.setDefaultFlowStyle(flowStyle); dumpAll(list.iterator(), buffer, rootTag); representer.setDefaultFlowStyle(oldStyle); return buffer.toString();
public static MxisdConfig loadFromFile(String path) throws IOException { Representer rep = new Representer(); rep.getPropertyUtils().setAllowReadOnlyProperties(true); rep.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(new Constructor(MxisdConfig.class), rep); try (FileInputStream is = new FileInputStream(path)) { Object o = yaml.load(is); return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class); } }
@SuppressWarnings("unchecked") private static Map<String, String> parseYamlStream(InputStream tenantStream) { Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(), new Resolver() { @Override protected void addImplicitResolvers() { } // forces all yaml values to be parsed as Strings } ); return (Map<String, String>) yaml.load(tenantStream); } }
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) { super(new LinkedHashMap<>(), writeDefaults); this.format = format; DumperOptions options = new DumperOptions(); options.setIndent(4); options.setDefaultFlowStyle(format.getStyle()); Representer representer = new FancyRepresenter(); representer.setDefaultFlowStyle(format.getStyle()); yaml = new Yaml(new SafeConstructor(), representer, options); this.file = file; }
@Bean Yaml yamlParser() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); return new Yaml(new SafeConstructor(), new Representer(), options); }
private static Yaml getYaml() { Representer representer = new TapeRepresenter(); representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG); Constructor constructor = new TapeConstructor(); constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG)); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(BLOCK); dumperOptions.setWidth(256); Yaml yaml = new Yaml(constructor, representer, dumperOptions); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; } }
private String convertToYml(Map<String, Object> dockerComposeData) { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setLineBreak(LineBreak.WIN); Representer representer = new SkipNullRepresenter(); representer.addClassTag(LBConfigMetadataStyle.class, Tag.MAP); Yaml yaml = new Yaml(representer, options); String yamlStr = yaml.dump(dockerComposeData); return yamlStr.replaceAll("[$]", "\\$\\$"); }
@Override protected Yaml initialValue() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setPrettyFlow(false); options.setIndent(2); return new Yaml(new YamlConstructor(), new Representer(), options); } };
protected Yaml buildYaml() { Constructor constructor = new Constructor(); Representer representer = new Representer(); representer.setDefaultFlowStyle(FlowStyle.BLOCK); representer.setDefaultScalarStyle(ScalarStyle.PLAIN); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setAllowReadOnlyProperties(true); dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK); dumperOptions.setDefaultScalarStyle(ScalarStyle.PLAIN); dumperOptions.setLineBreak(this.getLineBreak()); LimitedResolver limitedResolver = new LimitedResolver(); return new Yaml(constructor, representer, dumperOptions, limitedResolver); }
Representer representer = new Representer(); representer.addClassTag(Rule.class, new Tag("!config")); Yaml yaml = new Yaml(new Constructor(Rule.class), representer); Rule rule = null; try { rule = yaml.loadAs(new FileReader(file), Rule.class); } catch (MarkedYAMLException yamlException) { throw new AraraException(
public IKubeClientConfig loadKubeClientConfig(Reader reader) { Representer representer = new Representer(); Yaml parser = new Yaml(new KubeClientConfigConstructor(new YamlPropertyUtils()), representer); representer.getPropertyUtils().setSkipMissingProperties(true); return parser.loadAs(reader, KubeClientConfig.class); }
private static void configYamlFormat(final ToolBelt belt, final RdClientConfig config) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle( "BLOCK".equalsIgnoreCase(config.getString("RD_YAML_FLOW", "BLOCK")) ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW ); dumperOptions.setPrettyFlow(config.getBool("RD_YAML_PRETTY", true)); Representer representer = new Representer(); representer.addClassTag(JobItem.class, Tag.MAP); representer.addClassTag(ScheduledJobItem.class, Tag.MAP); representer.addClassTag(DateInfo.class, Tag.MAP); representer.addClassTag(Execution.class, Tag.MAP); belt.formatter(new YamlFormatter(DataOutputAsFormatable, new Yaml(representer, dumperOptions))); belt.channels().infoEnabled(false); belt.channels().warningEnabled(false); belt.channels().errorEnabled(false); }
public static Yaml newYaml() { PropertyUtils propertyUtils = new AdvancedPropertyUtils(); propertyUtils.setSkipMissingProperties(true); propertyUtils.setAllowReadOnlyProperties(false); Constructor constructor = new Constructor(); Representer representer = new AdvancedRepresenter(); representer.setPropertyUtils(propertyUtils); representer.addClassTag(CircusTrainConfig.class, Tag.MAP); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setIndent(2); dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK); dumperOptions.setAllowReadOnlyProperties(true); return new Yaml(constructor, representer, dumperOptions); }
public void storeBodoDescriptor(BODODescriptor bodoDescriptor) throws IOException { Representer representer = new Representer(); representer.setPropertyUtils(new PropertyOrderingUtils()); Yaml yaml = new Yaml(representer); storeString(yaml.dump(bodoDescriptor)); }
/** * Creates and returns a new {@link Yaml} instance for (optional) * use in writing {@link ConfigOrBuilder} and {@link * MetadataOrBuilder} objects. * * <p>This method never returns {@code null}.</p> * * <p>Overrides of this method must not return {@code null}.</p> * * <p>Behavior is undefined if overrides of this method interact * with other methods defined by this class.</p> * * @return a non-{@code null} {@link Yaml} instance */ protected Yaml createYaml() { final Representer representer = new TerseRepresenter(); representer.setPropertyUtils(new CustomPropertyUtils()); final DumperOptions options = new DumperOptions(); options.setAllowReadOnlyProperties(true); return new Yaml(new SafeConstructor(), representer, options); }
public YamlReader(Constructor rootConstructor) { Representer representer = new Representer(); representer.getPropertyUtils().setSkipMissingProperties(true); yamlParser = new Yaml(rootConstructor, representer, new DumperOptions(), new CustomResolver()); }