gpt4 book ai didi

org.geotools.ysld.parse.YamlParseContext类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:20:12 29 4
gpt4 key购买 nike

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

YamlParseContext介绍

[英]Holds the context of a call to YamlParser#parse(YamlParseHandler,Map) during its descent into the YamlObject being parsed.
[中]在YamlParser#parse(YamlParserHandler,Map)下降到正在分析的YamlObject期间,保存对其调用的上下文。

代码示例

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

@Test
  public void testDocHints() throws Exception {
    YamlParseContext ctxt = new YamlParseContext();
    YamlParseHandler handler = createMock(YamlParseHandler.class);
    YamlObject obj1 = createMock(YamlObject.class);

    replay(handler);

    ctxt.push(obj1, handler);

    assertThat(ctxt.getDocHint("testHint1"), nullValue());
    ctxt.setDocHint("testHint1", "th1v1");
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v1"));
    ctxt.setDocHint("testHint1", "th1v2");
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));

    assertThat(ctxt.getDocHint("testHint2"), nullValue());
    ctxt.setDocHint("testHint2", "th2v1");
    assertThat((String) ctxt.getDocHint("testHint2"), is("th2v1"));
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));

    verify(handler);
  }
}

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

/**
 * Add a handler to the stack handling the current object. Used for "inlined"/common properties.
 *
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(YamlParseHandler handler) {
  return doPush(curr.obj, handler);
}

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

/**
   * Parse the yaml provided to this instance using the provided {@link YamlParseHandler}.
   *
   * @param root The {@link YamlParseHandler} that handles the root of the parsed {@link
   *     YamlObject}.
   * @param hints
   * @return The root {@link YamlParseHandler}, once it has finished handling the parsed {@link
   *     YamlObject}..
   * @throws IOException
   */
  @SuppressWarnings("PMD.EmptyWhileStmt")
  public <T extends YamlParseHandler> T parse(T root, Map<String, Object> hints)
      throws IOException {
    Object parsed = YamlUtil.getSafeYaml().load(yaml);

    YamlParseContext context = new YamlParseContext();
    context.mergeDocHints(hints);
    context.push(YamlObject.create(parsed), root);

    while (context.next()) ;

    return root;
  }
}

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

/**
 * Parse a child of the current object if present
 *
 * @param key key of the child entry
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(String key, YamlParseHandler handler) {
  return push(curr.obj, key, handler);
}

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

context.setDocHint(ZoomContext.HINT_ID, getZoomContext(root.map("grid")));
  context.push("feature-styles", new FeatureStyleParser(style, factory));
} else if (root.has("rules")) {
  context.push("rules", new RuleParser(newFeatureTypeStyle(), factory));
} else if (root.has("symbolizers")) {
  context.push("symbolizers", new SymbolizersParser(newRule(), factory));
} else if (root.has("point")
    || root.has("line")
    || root.has("text")
    || root.has("raster")) {
  context.push(new SymbolizersParser(newRule(), factory));

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

protected ZoomContext getZoomContext(YamlParseContext context) {
    return Util.forceDefaultForNull(
        (ZoomContext) context.getDocHint(ZoomContext.HINT_ID),
        WellKnownZoomContextFinder.getInstance().get("DEFAULT"));
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlSeq seq = obj.seq();
    for (YamlObject o : seq) {
      context.push(
          o,
          "mark",
          new MarkParser(factory) {
            @Override
            protected void mark(Mark mark) {
              g.graphicalSymbols().add(mark);
            }
          });
      context.push(
          o,
          "external",
          new ExternalGraphicParser(factory) {
            @Override
            protected void externalGraphic(ExternalGraphic externalGraphic) {
              g.graphicalSymbols().add(externalGraphic);
            }
          });
    }
  }
}

代码示例来源:origin: org.geotools/gt-ysld

context.setDocHint(ZoomContext.HINT_ID, getZoomContext(root.map("grid")));
  context.push("feature-styles", new FeatureStyleParser(style, factory));
} else if (root.has("rules")) {
  context.push("rules", new RuleParser(newFeatureTypeStyle(), factory));
} else if (root.has("symbolizers")) {
  context.push("symbolizers", new SymbolizersParser(newRule(), factory));
} else if (root.has("point")
    || root.has("line")
    || root.has("text")
    || root.has("raster")) {
  context.push(new SymbolizersParser(newRule(), factory));

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlMap map = obj.map();
    sym.setName(map.str("name"));
    if (map.has("geometry")) {
      sym.setGeometry(Util.expression(map.str("geometry"), factory));
    }
    UomMapper uomMapper = (UomMapper) context.getDocHint(UomMapper.KEY);
    if (map.has("uom")) {
      sym.setUnitOfMeasure(uomMapper.getUnit(map.str("uom")));
    }
    sym.getOptions().putAll(Util.vendorOptions(map));
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    super.handle(obj, context);
    context.push(new GraphicParser(factory, sym.getGraphic()));
  }
}

代码示例来源:origin: org.geotools/gt-ysld

/**
   * Parse the yaml provided to this instance using the provided {@link YamlParseHandler}.
   *
   * @param root The {@link YamlParseHandler} that handles the root of the parsed {@link
   *     YamlObject}.
   * @param hints
   * @return The root {@link YamlParseHandler}, once it has finished handling the parsed {@link
   *     YamlObject}..
   * @throws IOException
   */
  public <T extends YamlParseHandler> T parse(T root, Map<String, Object> hints)
      throws IOException {
    Object parsed = YamlUtil.getSafeYaml().load(yaml);

    YamlParseContext context = new YamlParseContext();
    context.mergeDocHints(hints);
    context.push(YamlObject.create(parsed), root);

    while (context.next()) ;

    return root;
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    externalGraphic(external);
    YamlMap map = obj.map();
    if (map.has("url")) {
      String value = map.str("url");
      try {
        external.setLocation(
            ((ResourceLocator) context.getDocHint("resourceLocator"))
                .locateResource(value));
      } catch (IllegalArgumentException e) {
        external.setURI("file:" + value);
      }
    }
    external.setFormat(map.str("format"));
  }
}

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

/**
 * Add a handler to the stack handling the specified object
 *
 * @param obj the object to parse
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(YamlObject obj, YamlParseHandler handler) {
  return doPush(obj, handler);
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    String name = obj.map().str("name");
    sel.setChannelName(name);
    context.push(
        "contrast-enhancement",
        new ContrastEnhancementHandler() {
          @Override
          protected void set() {
            sel.setContrastEnhancement(this.contrast);
          }
        });
  }
}

代码示例来源:origin: org.geotools/gt-ysld

protected ZoomContext getZoomContext(YamlParseContext context) {
    return Util.forceDefaultForNull(
        (ZoomContext) context.getDocHint(ZoomContext.HINT_ID),
        WellKnownZoomContextFinder.getInstance().get("DEFAULT"));
  }
}

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

/**
 * Parse a child of the specified object if present
 *
 * @param scope object to start from
 * @param key key of the child entry
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(YamlObject scope, String key, YamlParseHandler handler) {
  YamlMap map = scope.map();
  if (map.has(key)) {
    return doPush(scope.map().obj(key), handler);
  }
  return this;
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlSeq seq = obj instanceof YamlMap ? YamlSeq.from(obj) : obj.seq();

    for (YamlObject o : seq) {
      YamlMap sym = o.map();

      if (sym.has("point")) {
        context.push(sym, "point", new PointParser(rule, factory));
      } else if (sym.has("line")) {
        context.push(sym, "line", new LineParser(rule, factory));
      } else if (sym.has("polygon")) {
        context.push(sym, "polygon", new PolygonParser(rule, factory));
      } else if (sym.has("text")) {
        context.push(sym, "text", new TextParser(rule, factory));
      } else if (sym.has("raster")) {
        context.push(sym, "raster", new RasterParser(rule, factory));
      }
    }
  }
}

代码示例来源:origin: org.geotools/gt-ysld

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlMap map = obj.map();
    sym.setName(map.str("name"));
    if (map.has("geometry")) {
      sym.setGeometry(Util.expression(map.str("geometry"), factory));
    }
    UomMapper uomMapper = (UomMapper) context.getDocHint(UomMapper.KEY);
    if (map.has("uom")) {
      sym.setUnitOfMeasure(uomMapper.getUnit(map.str("uom")));
    }
    sym.getOptions().putAll(Util.vendorOptions(map));
  }
}

代码示例来源:origin: org.geotools/gt-ysld

/**
 * Add a handler to the stack handling the specified object
 *
 * @param obj the object to parse
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(YamlObject obj, YamlParseHandler handler) {
  return doPush(obj, handler);
}

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  super.handle(obj, context);
  YamlMap map = obj.map();
  if (map.has("opacity")) {
    sym.setOpacity(Util.expression(map.str("opacity"), factory));
  }
  context.push(
      "color-map",
      new ColorMapParser(factory) {
        @Override
        protected void colorMap(ColorMap colorMap) {
          sym.setColorMap(colorMap);
        }
      });
  context.push("contrast-enhancement", new ContrastEnhancementHandler());
  context.push("channels", new ChannelsHandler());
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com