Java Code Examples for sun.tools.java.Identifier#isQualified()

The following examples show how to use sun.tools.java.Identifier#isQualified() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Type.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example 2
Source File: Type.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example 3
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example 4
Source File: Type.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example 5
Source File: IDLNames.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 6
Source File: IDLNames.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 7
Source File: IDLNames.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 8
Source File: IDLNames.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 9
Source File: IDLNames.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 10
Source File: IDLNames.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 11
Source File: IDLNames.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 12
Source File: IDLNames.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 13
Source File: IDLNames.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 14
Source File: IDLNames.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 15
Source File: IDLNames.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 16
Source File: IDLNames.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 17
Source File: IDLNames.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 18
Source File: IDLNames.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}
 
Example 19
Source File: IDLNames.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a qualified Identifier into an array of IDL names.
 * <p>
 * Section 28.3.2.1    (see CompoundType)
 * Throws exception if fails 28.3.2.7.
 */
public static String[] getModuleNames (Identifier theID,
                                       boolean boxIt,
                                       BatchEnvironment env) throws Exception {

    String[] result = null;

    if (theID.isQualified()) {

        // Extract the qualifier...

        Identifier id = theID.getQualifier();

        // 28.3.2.7 Case sensitive module names.

        env.modulesContext.assertPut(id.toString());

        // Count them...

        int count = 1;
        Identifier current = id;
        while (current.isQualified()) {
            current = current.getQualifier();
            count++;
        }

        result = new String[count];
        int index = count-1;
        current = id;

        // Now walk them and fill our array (backwards)...

        for (int i = 0; i < count; i++) {

            String item = current.getName().toString();

            // Check namesCache...

            String cachedItem = (String) env.namesCache.get(item);

            if (cachedItem == null) {

                // 28.3.2.4 Illegal identifier characters...

                cachedItem = convertToISOLatin1(item);

                // Run it through the name checks...

                cachedItem = getTypeOrModuleName(cachedItem);

                // Add it to the namesCache...

                env.namesCache.put(item,cachedItem);
            }

            result[index--] = cachedItem;
            current = current.getQualifier();
        }
    }


    // If it is supposed to be "boxed", prepend
    // IDL_BOXEDIDL_MODULE...

    if (boxIt) {
        if (result == null) {
            result = IDL_BOXEDIDL_MODULE;
        } else {
        String[] boxed = new String[result.length+IDL_BOXEDIDL_MODULE.length];
        System.arraycopy(IDL_BOXEDIDL_MODULE,0,boxed,0,IDL_BOXEDIDL_MODULE.length);
        System.arraycopy(result,0,boxed,IDL_BOXEDIDL_MODULE.length,result.length);
        result = boxed;
    }
    }

    return result;
}
 
Example 20
Source File: IDLNames.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert a type name.
 * <p>
 * Section 28.3.2.5
 * Section 28.3.2.7 (class or interface names only)
 * Throws exception if fails 28.3.2.7.
 */
public static String getClassOrInterfaceName (Identifier id,
                                              BatchEnvironment env) throws Exception {

    // Get the type and package name...

    String typeName = id.getName().toString();
    String packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
    }

    // Check namesCache...

    String result = (String) env.namesCache.get(typeName);

    if (result == null) {

        // 28.3.2.5 Inner classes...

        result = replace(typeName,". ","__");

        // 28.3.2.4 Illegal identifier characters...

        result = convertToISOLatin1(result);

        // 28.3.2.7 Case sensitive class or interface names...

        NameContext context = NameContext.forName(packageName,false,env);
        context.assertPut(result);

        // Run it through the name checks...

        result = getTypeOrModuleName(result);

        // Add it to the namesCache...

        env.namesCache.put(typeName,result);
    }

    return result;
}