Java 类com.sun.codemodel.internal.JClassContainer 实例源码

项目:OpenJSharp    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:openjdk-jdk10    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:openjdk9    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:lookaside_java-1.8.0-openjdk    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:infobip-open-jdk-8    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:OLD-OpenJDK8    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:openjdk-icedtea7    文件:BeanGenerator.java   
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:OpenJSharp    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:openjdk-jdk10    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:openjdk-jdk10    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:openjdk-jdk10    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:openjdk9    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:openjdk9    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:openjdk9    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:lookaside_java-1.8.0-openjdk    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:infobip-open-jdk-8    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:infobip-open-jdk-8    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:infobip-open-jdk-8    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:OLD-OpenJDK8    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:OLD-OpenJDK8    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:OLD-OpenJDK8    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:openjdk-icedtea7    文件:BeanGenerator.java   
public JClassContainer getContainer(CClassInfoParent parent, Aspect aspect) {
    CClassInfoParent.Visitor<JClassContainer> v;
    switch (aspect) {
        case EXPOSED:
            v = exposedContainerBuilder;
            break;
        case IMPLEMENTATION:
            v = implContainerBuilder;
            break;
        default:
            assert false;
            throw new IllegalStateException();
    }
    return parent.accept(v);
}
项目:openjdk-icedtea7    文件:SignatureWriter.java   
private void dumpChildren( JClassContainer cont ) throws IOException {
    Iterator itr = cont.classes();
    while(itr.hasNext()) {
        JDefinedClass cls = (JDefinedClass)itr.next();
        ClassOutline ci = classSet.get(cls);
        if(ci!=null)
            dump(ci);
    }
}
项目:openjdk-icedtea7    文件:CodeModelClassFactory.java   
/**
 * Create a dummy class to recover from an error.
 *
 * We won't generate the code, so the client will never see this class
 * getting generated.
 */
private JDefinedClass createDummyClass(JClassContainer parent) {
    try {
        return parent._class("$$$garbage$$$"+(ticketMaster++));
    } catch( JClassAlreadyExistsException ee ) {
        return ee.getExistingClass();
    }
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onBean(CClassInfo bean) {
    return getClazz(bean).ref;
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onElement(CElementInfo element) {
    // hmm...
    return getElement(element).implClass;
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onPackage(JPackage pkg) {
    return model.strategy.getPackage(pkg, EXPOSED);
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onBean(CClassInfo bean) {
    return getClazz(bean).implClass;
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onElement(CElementInfo element) {
    return getElement(element).implClass;
}
项目:OpenJSharp    文件:BeanGenerator.java   
public JClassContainer onPackage(JPackage pkg) {
    return model.strategy.getPackage(pkg, Aspect.IMPLEMENTATION);
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createClass( JClassContainer parent, String name, Locator source ) {
    return createClass( parent, JMod.PUBLIC, name, source );
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source ) {
    return createClass(parent,mod,name,source,ClassType.CLASS);
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createInterface( JClassContainer parent, String name, Locator source ) {
    return createInterface( parent, JMod.PUBLIC, name, source );
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createInterface( JClassContainer parent, int mod, String name, Locator source ) {
    return createClass(parent,mod,name,source,ClassType.INTERFACE);
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createClass(
    JClassContainer parent, String name, Locator source, ClassType kind ) {
    return createClass(parent,JMod.PUBLIC,name,source,kind);
}
项目:OpenJSharp    文件:CodeModelClassFactory.java   
public JDefinedClass createClass(
    JClassContainer parent, int mod, String name, Locator source, ClassType kind ) {

    if(!JJavaName.isJavaIdentifier(name)) {
        // report the error
        errorReceiver.error( new SAXParseException(
            Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source ));
        return createDummyClass(parent);
    }


    try {
        if(parent.isClass() && kind==ClassType.CLASS)
            mod |= JMod.STATIC;

        JDefinedClass r = parent._class(mod,name,kind);
        // use the metadata field to store the source location,
        // so that we can report class name collision errors.
        r.metadata = source;

        return r;
    } catch( JClassAlreadyExistsException e ) {
        // class collision.
        JDefinedClass cls = e.getExistingClass();

        // report the error
        errorReceiver.error( new SAXParseException(
            Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ),
            (Locator)cls.metadata ));
        errorReceiver.error( new SAXParseException(
            Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ),
            source ));

        if( !name.equals(cls.name()) ) {
            // on Windows, FooBar and Foobar causes name collision
            errorReceiver.error( new SAXParseException(
                Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION,
                    name, cls.name() ), null ) );
        }

        if(Util.equals((Locator)cls.metadata,source)) {
            errorReceiver.error( new SAXParseException(
                Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ),
                source ));
        }

        return createDummyClass(parent);
    }
}