org.stringtemplate.v4.STGroup.getAttributeRenderer()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(91)

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

STGroup.getAttributeRenderer介绍

[英]Get renderer for class T associated with this group.

For non-imported groups and object-to-render of class T, use renderer (if any) registered for T. For imports, any renderer set on import group is ignored even when using an imported template. You should set the renderer on the main group you use (or all to be sure). I look at import groups as "helpers" that should give me templates and nothing else. If you have multiple renderers for String, say, then just make uber combined renderer with more specific format names.
[中]获取与此组关联的类T的渲染器。
对于类T的非导入组和要渲染的对象,请使用为T注册的渲染器(如果有)。对于导入,即使使用导入的模板,也会忽略在导入组上设置的任何渲染器。您应该在使用的主组上设置渲染器(或者确保全部)。我把导入组视为“助手”,应该给我提供模板,而不是其他任何东西。比如说,如果你有多个字符串渲染器,那么只需使用更具体的格式名称制作uber组合渲染器即可。

代码示例

代码示例来源:origin: org.antlr/stringtemplate

protected int writePOJO(STWriter out, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  AttributeRenderer r = group.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: antlr/stringtemplate4

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: jsevellec/cassandra-unit

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: org.antlr/ST4

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

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

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: antlr/antlr3

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

代码示例来源:origin: apache/servicemix-bundles

protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
  String formatString = null;
  if ( options!=null ) formatString = options[Option.FORMAT.ordinal()];
  // ask the native group defining the surrounding template for the renderer
  AttributeRenderer r = scope.st.impl.nativeGroup.getAttributeRenderer(o.getClass());
  String v;
  if ( r!=null ) v = r.toString(o, formatString, locale);
  else v = o.toString();
  int n;
  if ( options!=null && options[Option.WRAP.ordinal()]!=null ) {
    n = out.write(v, options[Option.WRAP.ordinal()]);
  }
  else {
    n = out.write(v);
  }
  return n;
}

相关文章

微信公众号

最新文章

更多