com.sun.codemodel.JType.parse()方法的使用及代码示例

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

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

JType.parse介绍

[英]Obtains a reference to the primitive type object from a type name.
[中]从类型名称获取对基元类型对象的引用。

代码示例

代码示例来源:origin: joelittlejohn/jsonschema2pojo

/**
 * Check if a name string refers to a given type.
 * 
 * @param name
 *            the name of a Java type
 * @param owner
 *            the current code model for type generation
 * @return <code>true</code> when the given name refers to a primitive Java
 *         type (e.g. "int"), otherwise <code>false</code>
 */
public static boolean isPrimitive(String name, JCodeModel owner) {
  try {
    return JType.parse(owner, name) != owner.VOID;
  } catch (IllegalArgumentException e) {
    return false;
  }
}

代码示例来源:origin: com.googlecode.jsonschema2pojo/jsonschema2pojo-core

/**
 * Check if a name string refers to a given type.
 * 
 * @param name
 *            the name of a Java type
 * @param owner
 *            the current code model for type generation
 * @return <code>true</code> when the given name refers to a primitive Java
 *         type (e.g. "int"), otherwise <code>false</code>
 */
public static boolean isPrimitive(String name, JCodeModel owner) {
  try {
    return JType.parse(owner, name) != owner.VOID;
  } catch (IllegalArgumentException e) {
    return false;
  }
}

代码示例来源:origin: org.jsonschema2pojo/jsonschema2pojo-core

/**
 * Check if a name string refers to a given type.
 * 
 * @param name
 *            the name of a Java type
 * @param owner
 *            the current code model for type generation
 * @return <code>true</code> when the given name refers to a primitive Java
 *         type (e.g. "int"), otherwise <code>false</code>
 */
public static boolean isPrimitive(String name, JCodeModel owner) {
  try {
    return JType.parse(owner, name) != owner.VOID;
  } catch (IllegalArgumentException e) {
    return false;
  }
}

代码示例来源:origin: sun-jaxb/jaxb-xjc

public JPrimitiveType getPrimitiveType() {
  Class v = boxToPrimitive.get(_class);
  if(v!=null)
    return JType.parse(JCodeModel.this,v.getName());
  else
    return null;
}

代码示例来源:origin: com.unquietcode.tools.jcodemodel/codemodel

public JPrimitiveType getPrimitiveType() {
  Class<?> v = boxToPrimitive.get(_class);
  if(v!=null)
    return JType.parse(JCodeModel.this,v.getName());
  else
    return null;
}

代码示例来源:origin: com.sun.codemodel/codemodel

public JPrimitiveType getPrimitiveType() {
  Class<?> v = boxToPrimitive.get(_class);
  if(v!=null)
    return JType.parse(JCodeModel.this,v.getName());
  else
    return null;
}

代码示例来源:origin: org.glassfish.metro/webservices-tools

public JPrimitiveType getPrimitiveType() {
  Class<?> v = boxToPrimitive.get(_class);
  if(v!=null)
    return JType.parse(JCodeModel.this,v.getName());
  else
    return null;
}

代码示例来源:origin: javaee/jaxb-v2

public JPrimitiveType getPrimitiveType() {
  Class<?> v = boxToPrimitive.get(_class);
  if(v!=null)
    return JType.parse(JCodeModel.this,v.getName());
  else
    return null;
}

代码示例来源:origin: sun-jaxb/jaxb-xjc

public JType _ref(Class c) {
  if(c.isPrimitive())
    return JType.parse(this,c.getName());
  else
    return ref(c);
}

代码示例来源:origin: org.glassfish.metro/webservices-tools

public JType _ref(Class<?> c) {
  if(c.isPrimitive())
    return JType.parse(this,c.getName());
  else
    return ref(c);
}

代码示例来源:origin: org.raml/raml-jaxrs-codegen-core

/**
 * <p>getGeneratorType.</p>
 *
 * @param clazz a {@link java.lang.Class} object.
 * @return a {@link com.sun.codemodel.JType} object.
 */
public JType getGeneratorType(final Class<?> clazz)
{
  return clazz.isPrimitive() ? JType.parse(codeModel, clazz.getSimpleName()) : codeModel.ref(clazz);
}

代码示例来源:origin: javaee/jaxb-v2

public JType _ref(Class<?> c) {
  if(c.isPrimitive())
    return JType.parse(this,c.getName());
  else
    return ref(c);
}

代码示例来源:origin: com.sun.codemodel/codemodel

public JType _ref(Class<?> c) {
  if(c.isPrimitive())
    return JType.parse(this,c.getName());
  else
    return ref(c);
}

代码示例来源:origin: com.unquietcode.tools.jcodemodel/codemodel

public JType _ref(Class<?> c) {
  if(c.isPrimitive())
    return JType.parse(this,c.getName());
  else
    return ref(c);
}

代码示例来源:origin: mulesoft-labs/raml-jaxrs-codegen

public JType getGeneratorType(final Class<?> clazz)
{
  return clazz.isPrimitive() ? JType.parse(codeModel, clazz.getSimpleName()) : codeModel.ref(clazz);
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-fluent-api

/** Returns true if the given type is a primitive int; false otherwise. */
  private boolean isInt(JType type) 
  {
    JCodeModel codeModel = type.owner();
    return type.isPrimitive() 
      && codeModel.INT.equals(
        JType.parse(codeModel, type.name()));
  }
}

代码示例来源:origin: net.java.dev.jaxb2-commons/jaxb-fluent-api

/** Returns true if the given type is a primitive int; false otherwise. */
  private boolean isInt(JType type) 
  {
    JCodeModel codeModel = type.owner();
    return type.isPrimitive() 
      && codeModel.INT.equals(
        JType.parse(codeModel, type.name()));
  }
}

代码示例来源:origin: sun-jaxb/jaxb-xjc

/**
 * Obtains a type object from a type name.
 *
 * <p>
 * This method handles primitive types, arrays, and existing {@link Class}es.
 *
 * @exception ClassNotFoundException
 *      If the specified type is not found.
 */
public JType parseType(String name) throws ClassNotFoundException {
  // array
  if(name.endsWith("[]"))
    return parseType(name.substring(0,name.length()-2)).array();
  // try primitive type
  try {
    return JType.parse(this,name);
  } catch (IllegalArgumentException e) {
    ;
  }
  // existing class
  return new TypeNameParser(name).parseTypeName();
}

代码示例来源:origin: javaee/jaxb-v2

/**
 * Obtains a type object from a type name.
 *
 * <p>
 * This method handles primitive types, arrays, and existing {@link Class}es.
 *
 * @exception ClassNotFoundException
 *      If the specified type is not found.
 */
public JType parseType(String name) throws ClassNotFoundException {
  // array
  if(name.endsWith("[]"))
    return parseType(name.substring(0,name.length()-2)).array();
  // try primitive type
  try {
    return JType.parse(this,name);
  } catch (IllegalArgumentException e) {
    ;
  }
  // existing class
  return new TypeNameParser(name).parseTypeName();
}

代码示例来源:origin: dremio/dremio-oss

private List<Partitioner> createClassInstances(int actualPartitions) throws SchemaChangeException {
 // set up partitioning function
 final LogicalExpression expr = config.getExpr();
 final ClassGenerator<Partitioner> cg = context.getClassProducer().createGenerator(Partitioner.TEMPLATE_DEFINITION).getRoot();
 ClassGenerator<Partitioner> cgInner = cg.getInnerGenerator("OutgoingRecordBatch");
 final LogicalExpression materializedExpr = context.getClassProducer().materialize(expr, incoming);
 // generate code to copy from an incoming value vector to the destination partition's outgoing value vector
 JExpression bucket = JExpr.direct("bucket");
 // generate evaluate expression to determine the hash
 ClassGenerator.HoldingContainer exprHolder = cg.addExpr(materializedExpr);
 cg.getEvalBlock().decl(JType.parse(cg.getModel(), "int"), "bucket", exprHolder.getValue().mod(JExpr.lit(outGoingBatchCount)));
 cg.getEvalBlock()._return(cg.getModel().ref(Math.class).staticInvoke("abs").arg(bucket));
 CopyUtil.generateCopies(cgInner, incoming, incoming.getSchema().getSelectionVectorMode() == SelectionVectorMode.FOUR_BYTE);
 // compile and setup generated code
 List<Partitioner> subPartitioners = cg.getCodeGenerator().getImplementationClass(actualPartitions);
 return subPartitioners;
}

相关文章