org.yaml.snakeyaml.resolver.Resolver类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.yaml.snakeyaml.resolver.Resolver类的一些代码示例,展示了Resolver类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resolver类的具体详情如下:
包路径:org.yaml.snakeyaml.resolver.Resolver
类名称:Resolver

Resolver介绍

[英]Resolver tries to detect a type by content (when the tag is implicit)
[中]解析程序尝试按内容检测类型(当标记是隐式的时)

代码示例

代码示例来源:origin: embulk/embulk

  1. @Override
  2. public Tag resolve(NodeId kind, String value, boolean implicit) {
  3. return super.resolve(kind, value, implicit); // checks implicit resolvers
  4. }
  5. }

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Create Yaml instance. It is safe to create a few instances and use them
  3. * in different Threads.
  4. *
  5. * @param constructor
  6. * BaseConstructor to construct incoming documents
  7. * @param representer
  8. * Representer to emit outgoing objects
  9. * @param dumperOptions
  10. * DumperOptions to configure outgoing objects
  11. * @param loadingConfig
  12. * LoadingConfig to control load behavior
  13. */
  14. public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
  15. LoaderOptions loadingConfig) {
  16. this(constructor, representer, dumperOptions, loadingConfig, new Resolver());
  17. }

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Add an implicit scalar detector. If an implicit scalar value matches the
  3. * given regexp, the corresponding tag is assigned to the scalar.
  4. *
  5. * @param tag
  6. * tag to assign to the node
  7. * @param regexp
  8. * regular expression to match against
  9. * @param first
  10. * a sequence of possible initial characters or null (which means
  11. * any).
  12. */
  13. public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
  14. resolver.addImplicitResolver(tag, regexp, first);
  15. }

代码示例来源:origin: redisson/redisson

  1. public Resolver() {
  2. addImplicitResolvers();
  3. }

代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml

  1. public Resolver() {
  2. addImplicitResolvers();
  3. }

代码示例来源:origin: redisson/redisson

  1. Tag nodeTag = _yamlResolver.resolve(NodeId.scalar, value, scalar.getImplicit().canOmitTagInPlainScalar());
  2. if (nodeTag == Tag.STR) {
  3. return JsonToken.VALUE_STRING;

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Create Yaml instance. It is safe to create a few instances and use them
  3. * in different Threads.
  4. *
  5. * @param constructor
  6. * BaseConstructor to construct incoming documents
  7. * @param representer
  8. * Representer to emit outgoing objects
  9. * @param dumperOptions
  10. * DumperOptions to configure outgoing objects
  11. */
  12. public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) {
  13. this(constructor, representer, dumperOptions, new LoaderOptions(), new Resolver());
  14. }

代码示例来源:origin: redisson/redisson

  1. protected void addImplicitResolvers() {
  2. addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");
  3. /*
  4. * INT must be before FLOAT because the regular expression for FLOAT
  5. * matches INT (see issue 130)
  6. * http://code.google.com/p/snakeyaml/issues/detail?id=130
  7. */
  8. addImplicitResolver(Tag.INT, INT, "-+0123456789");
  9. addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789.");
  10. addImplicitResolver(Tag.MERGE, MERGE, "<");
  11. addImplicitResolver(Tag.NULL, NULL, "~nN\0");
  12. addImplicitResolver(Tag.NULL, EMPTY, null);
  13. addImplicitResolver(Tag.TIMESTAMP, TIMESTAMP, "0123456789");
  14. // The following implicit resolver is only for documentation
  15. // purposes.
  16. // It cannot work
  17. // because plain scalars cannot start with '!', '&', or '*'.
  18. addImplicitResolver(Tag.YAML, YAML, "!&*");
  19. }

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

  1. public Resolver() {
  2. addImplicitResolvers();
  3. }

代码示例来源:origin: redisson/redisson

  1. protected Node composeSequenceNode(String anchor) {
  2. SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
  3. String tag = startEvent.getTag();
  4. Tag nodeTag;
  5. boolean resolved = false;
  6. if (tag == null || tag.equals("!")) {
  7. nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit());
  8. resolved = true;
  9. } else {
  10. nodeTag = new Tag(tag);
  11. }
  12. final ArrayList<Node> children = new ArrayList<Node>();
  13. SequenceNode node = new SequenceNode(nodeTag, resolved, children, startEvent.getStartMark(),
  14. null, startEvent.getFlowStyle());
  15. if (anchor != null) {
  16. anchors.put(anchor, node);
  17. }
  18. while (!parser.checkEvent(Event.ID.SequenceEnd)) {
  19. children.add(composeNode(node));
  20. }
  21. Event endEvent = parser.getEvent();
  22. node.setEndMark(endEvent.getEndMark());
  23. return node;
  24. }

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Create Yaml instance. It is safe to create a few instances and use them
  3. * in different Threads.
  4. *
  5. * @param representer
  6. * Representer to emit outgoing objects
  7. * @param dumperOptions
  8. * DumperOptions to configure outgoing objects
  9. */
  10. public Yaml(Representer representer, DumperOptions dumperOptions) {
  11. this(new Constructor(), representer, dumperOptions, new LoaderOptions(), new Resolver());
  12. }

代码示例来源:origin: org.springframework.boot/spring-boot

  1. @Override
  2. public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
  3. if (tag == Tag.TIMESTAMP) {
  4. return;
  5. }
  6. super.addImplicitResolver(tag, regexp, first);
  7. }

代码示例来源:origin: harbby/presto-connectors

  1. public Resolver() {
  2. addImplicitResolvers();
  3. }

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

  1. Tag nodeTag = _yamlResolver.resolve(NodeId.scalar, value, scalar.getImplicit().canOmitTagInPlainScalar());
  2. if (nodeTag == Tag.STR) {
  3. return JsonToken.VALUE_STRING;

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Create Yaml instance. It is safe to create a few instances and use them
  3. * in different Threads.
  4. */
  5. public Yaml() {
  6. this(new Constructor(), new Representer(), new DumperOptions(), new LoaderOptions(),
  7. new Resolver());
  8. }

代码示例来源:origin: embulk/embulk

  1. @Override
  2. public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
  3. // This method is called by constructor through addImplicitResolvers
  4. // to setup default implicit resolvers.
  5. if (tag.equals(Tag.FLOAT)) {
  6. super.addImplicitResolver(Tag.FLOAT, FLOAT_EXCEPTING_ZERO_START, "-+0123456789.");
  7. } else if (tag.equals(Tag.BOOL)) {
  8. // use stricter rule (reject 'On', 'Off', 'Yes', 'No')
  9. super.addImplicitResolver(Tag.BOOL, Pattern.compile("^(?:[Tt]rue|[Ff]alse)$"), "TtFf");
  10. } else if (tag.equals(Tag.TIMESTAMP)) {
  11. // This solves some unexpected behavior that snakeyaml
  12. // deserializes "2015-01-01 00:00:00" to java.util.Date
  13. // but jackson serializes java.util.Date to an integer.
  14. return;
  15. } else {
  16. super.addImplicitResolver(tag, regexp, first);
  17. }
  18. }

代码示例来源:origin: com.opentext.ia/infoarchive-yaml

  1. @Override
  2. protected void addImplicitResolvers() {
  3. addImplicitResolver(Tag.STR, OFFSET_DATE_TIME, "0123456789");
  4. super.addImplicitResolvers();
  5. }

代码示例来源:origin: redisson/redisson

  1. protected Node composeScalarNode(String anchor) {
  2. ScalarEvent ev = (ScalarEvent) parser.getEvent();
  3. String tag = ev.getTag();
  4. boolean resolved = false;
  5. Tag nodeTag;
  6. if (tag == null || tag.equals("!")) {
  7. nodeTag = resolver.resolve(NodeId.scalar, ev.getValue(),
  8. ev.getImplicit().canOmitTagInPlainScalar());
  9. resolved = true;
  10. } else {
  11. nodeTag = new Tag(tag);
  12. }
  13. Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(),
  14. ev.getEndMark(), ev.getScalarStyle());
  15. if (anchor != null) {
  16. anchors.put(anchor, node);
  17. }
  18. return node;
  19. }

代码示例来源:origin: stackoverflow.com

  1. var Resolver = require('async-resolve');
  2. var resolver_obj = new Resolver();
  3. resolver_obj.resolve('module', __dirname, function(err, filename) {
  4. return console.log(filename);
  5. });

代码示例来源:origin: dyc87112/spring-cloud-config-admin

  1. @Override
  2. public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
  3. if (tag == Tag.TIMESTAMP) return;
  4. super.addImplicitResolver(tag, regexp, first);
  5. }
  6. }

相关文章