Example usage for org.eclipse.jdt.internal.core.util HashtableOfArrayToObject getKey

List of usage examples for org.eclipse.jdt.internal.core.util HashtableOfArrayToObject getKey

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util HashtableOfArrayToObject getKey.

Prototype

public Object[] getKey(Object[] key, int keyLength) 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.JarPackageFragmentRoot.java

License:Open Source License

private void initRawPackageInfo(HashtableOfArrayToObject rawPackageInfo, String entryName, boolean isDirectory,
        String compliance) {/*from  w  ww  . j a v  a  2 s.  c o  m*/
    int lastSeparator = isDirectory ? entryName.length() - 1 : entryName.lastIndexOf('/');
    String[] pkgName = Util.splitOn('/', entryName, 0, lastSeparator);
    String[] existing = null;
    int length = pkgName.length;
    int existingLength = length;
    while (existingLength >= 0) {
        existing = (String[]) rawPackageInfo.getKey(pkgName, existingLength);
        if (existing != null)
            break;
        existingLength--;
    }
    //        JavaModelManager manager = JavaModelManager.getJavaModelManager();
    for (int i = existingLength; i < length; i++) {
        // sourceLevel must be null because we know nothing about it based on a jar file
        if (Util.isValidFolderNameForPackage(pkgName[i], null, compliance)) {
            System.arraycopy(existing, 0, existing = new String[i + 1], 0, i);
            existing[i] = manager.intern(pkgName[i]);
            rawPackageInfo.put(existing, new ArrayList[] { EMPTY_LIST, EMPTY_LIST });
        } else {
            // non-Java resource folder
            if (!isDirectory) {
                ArrayList[] children = (ArrayList[]) rawPackageInfo.get(existing);
                if (children[1/*NON_JAVA*/] == EMPTY_LIST)
                    children[1/*NON_JAVA*/] = new ArrayList();
                children[1/*NON_JAVA*/].add(entryName);
            }
            return;
        }
    }
    if (isDirectory)
        return;

    // add classfile info amongst children
    ArrayList[] children = (ArrayList[]) rawPackageInfo.get(pkgName);
    if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(entryName)) {
        if (children[0/*JAVA*/] == EMPTY_LIST)
            children[0/*JAVA*/] = new ArrayList();
        String nameWithoutExtension = entryName.substring(lastSeparator + 1, entryName.length() - 6);
        children[0/*JAVA*/].add(nameWithoutExtension);
    } else {
        if (children[1/*NON_JAVA*/] == EMPTY_LIST)
            children[1/*NON_JAVA*/] = new ArrayList();
        children[1/*NON_JAVA*/].add(entryName);
    }

}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaProjectElementInfo.java

License:Open Source License

static void addSuperPackageNames(String[] pkgName, HashtableOfArrayToObject packageFragments) {
    for (int i = pkgName.length - 1; i > 0; i--) {
        if (packageFragments.getKey(pkgName, i) == null) {
            System.arraycopy(pkgName, 0, pkgName = new String[i], 0, i);
            packageFragments.put(pkgName, NO_ROOTS);
        }//from w w w .j a v  a2  s  .  c o  m
    }
}