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

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

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

JClass.outer介绍

[英]Returns the class in which this class is nested, or null if this is a top-level class.
[中]返回嵌套该类的类,如果该类是顶级类,则返回null。

代码示例

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

private static boolean isNestedInSelf(JClass clazz, JClass c) {
  while (clazz != null) {
    if (clazz.equals(c)) {
      return true;
    }
    clazz = clazz.outer();
  }
    return false;
}

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

/**
 * This class extends the specifed class.
 *
 * @param superClass
 *        Superclass for this class
 *
 * @return This class
 */
public JDefinedClass _extends(JClass superClass) {
  if (this.classType==ClassType.INTERFACE)
    throw new IllegalArgumentException("unable to set the super class for an interface");
  if (superClass == null)
    throw new NullPointerException();
  
  for( JClass o=superClass.outer(); o!=null; o=o.outer() ){
    if(this==o){
      throw new IllegalArgumentException("Illegal class inheritance loop." +
      "  Outer class " + this.name + " may not subclass from inner class: " + o.name());
    }
  }
  
  this.superClass = superClass;
  return this;
}

代码示例来源:origin: org.jvnet.ws.wadl/wadl-core

/**
 * Look for an owner class that has the same name, if it has then fail
 * @return true is this class name is valid
 */
private boolean validClassName(JClass parentClass, String className) {
  
  while(parentClass!=null) {
    // And inner class cannot have the same name as a sibling class
    if (parentClass.name().equals(className)) {
      return false;
    }
    
    parentClass = parentClass.outer();
    if (parentClass!=null)
    {
      int i=0;
    }
  }
  
  return true;
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools

public static String getClassName(final JClass theClass) {
  return (theClass.outer() == null ? theClass.fullName()
      : getClassName(theClass.outer()) + "$" + theClass.name());
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools

public static String getPackagedClassName(final JClass theClass) {
  return (theClass.outer() == null ? theClass.fullName()
      : getPackagedClassName(theClass.outer()) + "$"
          + theClass.name());
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools

public static String getDottedLocalClassName(final JClass theClass) {
  return (theClass.outer() == null ? theClass.name()
      : getDottedLocalClassName(theClass.outer()) + "."
          + theClass.name());
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools

public static String getLocalClassName(final JClass theClass) {
  return (theClass.outer() == null ? theClass.name()
      : getLocalClassName(theClass.outer()) + "$" + theClass.name());
}

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

/**
 * This class extends the specifed class.
 *
 * @param superClass
 *        Superclass for this class
 *
 * @return This class
 */
public JDefinedClass _extends(JClass superClass) {
  if (this.classType==ClassType.INTERFACE)
    if(superClass.isInterface()){
      return this._implements(superClass);
    } else throw new IllegalArgumentException("unable to set the super class for an interface");
  if (superClass == null)
    throw new NullPointerException();
  
  for( JClass o=superClass.outer(); o!=null; o=o.outer() ){
    if(this==o){
      throw new IllegalArgumentException("Illegal class inheritance loop." +
      "  Outer class " + this.name + " may not subclass from inner class: " + o.name());
    }
  }
  
  this.superClass = superClass;
  return this;
}

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

/**
 * This class extends the specifed class.
 *
 * @param superClass
 *        Superclass for this class
 *
 * @return This class
 */
public JDefinedClass _extends(JClass superClass) {
  if (this.classType==ClassType.INTERFACE)
    if(superClass.isInterface()){
      return this._implements(superClass);
    } else throw new IllegalArgumentException("unable to set the super class for an interface");
  if (superClass == null)
    throw new NullPointerException();
  
  for( JClass o=superClass.outer(); o!=null; o=o.outer() ){
    if(this==o){
      throw new IllegalArgumentException("Illegal class inheritance loop." +
      "  Outer class " + this.name + " may not subclass from inner class: " + o.name());
    }
  }
  
  this.superClass = superClass;
  return this;
}

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

/**
 * This class extends the specifed class.
 *
 * @param superClass
 *        Superclass for this class
 *
 * @return This class
 */
public JDefinedClass _extends(JClass superClass) {
  if (this.classType==ClassType.INTERFACE)
    if(superClass.isInterface()){
      return this._implements(superClass);
    } else throw new IllegalArgumentException("unable to set the super class for an interface");
  if (superClass == null)
    throw new NullPointerException();
  
  for( JClass o=superClass.outer(); o!=null; o=o.outer() ){
    if(this==o){
      throw new IllegalArgumentException("Illegal class inheritance loop." +
      "  Outer class " + this.name + " may not subclass from inner class: " + o.name());
    }
  }
  
  this.superClass = superClass;
  return this;
}

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

/**
 * This class extends the specifed class.
 *
 * @param superClass
 *        Superclass for this class
 *
 * @return This class
 */
public JDefinedClass _extends(JClass superClass) {
  if (this.classType==ClassType.INTERFACE)
    if(superClass.isInterface()){
      return this._implements(superClass);
    } else throw new IllegalArgumentException("unable to set the super class for an interface");
  if (superClass == null)
    throw new NullPointerException();
  
  for( JClass o=superClass.outer(); o!=null; o=o.outer() ){
    if(this==o){
      throw new IllegalArgumentException("Illegal class inheritance loop." +
      "  Outer class " + this.name + " may not subclass from inner class: " + o.name());
    }
  }
  
  this.superClass = superClass;
  return this;
}

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

/**
 * Returns true if the symbol represented by the short name
 * is "importable".
 */
public boolean collisions(JDefinedClass enclosingClass) {
  // special case where a generated type collides with a type in package java
  // more than one type with the same name
  if(classes.size() > 1)
    return true;
  // an id and (at least one) type with the same name
  if(id && classes.size() != 0)
    return true;
  for(JClass c : classes) {
    if(c._package()==javaLang) {
      // make sure that there's no other class with this name within the same package
      Iterator itr = enclosingClass._package().classes();
      while(itr.hasNext()) {
        // even if this is the only "String" class we use,
        // if the class called "String" is in the same package,
        // we still need to import it.
        JDefinedClass n = (JDefinedClass)itr.next();
        if(n.name().equals(c.name()))
          return true;    //collision
      }
    }
    if(c.outer()!=null)
      return true; // avoid importing inner class to work around 6431987. Also see jaxb issue 166
  }
  return false;
}

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

if( !collectedReferences.get(id).getClasses().isEmpty() ) {
  for( JClass type : collectedReferences.get(id).getClasses() ) {
    if (type.outer()!=null) {
      collectedReferences.get(id).setId(false);
      return this;

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

if( !collectedReferences.get(id).getClasses().isEmpty() ) {
  for( JClass type : collectedReferences.get(id).getClasses() ) {
    if (type.outer()!=null) {
      collectedReferences.get(id).setId(false);
      return this;

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

if( !collectedReferences.get(id).getClasses().isEmpty() ) {
  for( JClass type : collectedReferences.get(id).getClasses() ) {
    if (type.outer()!=null) {
      collectedReferences.get(id).setId(false);
      return this;

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

if( !collectedReferences.get(id).getClasses().isEmpty() ) {
  for( JClass type : collectedReferences.get(id).getClasses() ) {
    if (type.outer()!=null) {
      collectedReferences.get(id).setId(false);
      return this;

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

/**
 * determine if an import statement should be supressed
 *
 * @param clazz JType that may or may not have an import
 * @param c JType that is the current class being processed
 * @return true if an import statement should be suppressed, false otherwise
 */
private boolean supressImport(JClass clazz, JClass c) {
  if(clazz._package().isUnnamed())
    return true;
  final String packageName = clazz._package().name();
  if(packageName.equals("java.lang"))
    return true;    // no need to explicitly import java.lang classes

  if (clazz._package() == c._package()){ 
    // inner classes require an import stmt.
    // All other pkg local classes do not need an
    // import stmt for ref.
    if(clazz.outer()==null) {
      return true;    // no need to explicitly import a class into itself
    }
  }
  return false;
}

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

if(clazz.outer()==null) {
  return true;    // no need to explicitly import a class into itself

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

if(clazz.outer()==null) {
  return true;    // no need to explicitly import a class into itself

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

if(clazz.outer()==null) {
  return true;    // no need to explicitly import a class into itself

相关文章