Java Code Examples for com.android.utils.ILogger

The following examples show how to use com.android.utils.ILogger. These examples are extracted from open source projects. 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
@Override
public boolean parse(@NonNull String line,
                     @NonNull OutputLineReader reader,
                     @NonNull List<Message> messages,
                     @NonNull ILogger logger) throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String json = m.group(1);
    if (json.trim().isEmpty()) {
        return false;
    }

    GsonBuilder gsonBuilder = new GsonBuilder();
    MessageJsonSerializer.registerTypeAdapters(gsonBuilder);
    Gson gson = gsonBuilder.create();
    try {
        Message msg = gson.fromJson(json, Message.class);
        messages.add(msg);
        return true;
    } catch (JsonParseException e) {
        throw new ParsingFailedException(e);
    }
}
 
Example 2
Source Project: javaide   Source File: ArgvParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ArgvParser(ILogger logger) {
    super(logger, ACTIONS);

    // The following defines the parameters of the actions defined in mAction.

    // --- merge manifest ---

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "o", KEY_OUT,                           //$NON-NLS-1$
            "Output path (where to write the merged manifest). Use - for stdout.", null);

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "1", KEY_MAIN,                          //$NON-NLS-1$
            "Path of the main manifest (what to merge *into*)", null);

    define(Mode.STRING_ARRAY, true,
            VERB_MERGE, NO_VERB_OBJECT, "2", KEY_LIBS,                          //$NON-NLS-1$
            "Paths of library manifests to be merged into the main one.",
            null);
}
 
Example 3
Source Project: java-n-IDE-for-Android   Source File: AvdManager.java    License: Apache License 2.0 6 votes vote down vote up
public AvdInfo updateAvd(AvdInfo avd,
        Map<String, String> newProperties,
        AvdStatus status,
        ILogger log) throws IOException {
    // now write the config file
    File configIniFile = new File(avd.getDataFolderPath(), CONFIG_INI);
    writeIniFile(configIniFile, newProperties, true);

    // finally create a new AvdInfo for this unbroken avd and add it to the list.
    // instead of creating the AvdInfo object directly we reparse it, to detect other possible
    // errors
    // FIXME: We may want to create this AvdInfo by reparsing the AVD instead. This could detect other errors.
    AvdInfo newAvd = new AvdInfo(
            avd.getName(),
            avd.getIniFile(),
            avd.getDataFolderPath(),
            avd.getTargetHash(),
            avd.getTarget(),
            avd.getTag(),
            avd.getAbiType(),
            newProperties);

    replaceAvd(avd, newAvd);

    return newAvd;
}
 
Example 4
Source Project: javaide   Source File: ManifestMerger2.java    License: GNU General Public License v3.0 6 votes vote down vote up
private ManifestMerger2(
        @NonNull ILogger logger,
        @NonNull File mainManifestFile,
        @NonNull ImmutableList<Pair<String, File>> libraryFiles,
        @NonNull ImmutableList<File> flavorsAndBuildTypeFiles,
        @NonNull ImmutableList<Invoker.Feature> optionalFeatures,
        @NonNull Map<String, Object> placeHolderValues,
        @NonNull KeyBasedValueResolver<SystemProperty> systemPropertiesResolver,
        @NonNull MergeType mergeType,
        @NonNull Optional<File> reportFile) {
    this.mSystemPropertyResolver = systemPropertiesResolver;
    this.mPlaceHolderValues = placeHolderValues;
    this.mManifestFile = mainManifestFile;
    this.mLogger = logger;
    this.mLibraryFiles = libraryFiles;
    this.mFlavorsAndBuildTypeFiles = flavorsAndBuildTypeFiles;
    this.mOptionalFeatures = optionalFeatures;
    this.mMergeType = mergeType;
    this.mReportFile = reportFile;
}
 
Example 5
Source Project: java-n-IDE-for-Android   Source File: CommandLineParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new command-line processor.
 *
 * @param logger An SDK logger object. Must not be null.
 * @param actions The list of actions recognized on the command-line.
 *                See the javadoc of {@link #mActions} for more details.
 *
 * @see #mActions
 */
public CommandLineParser(ILogger logger, String[][] actions) {
    mLog = logger;
    mActions = actions;

    /*
     * usage should fit in 80 columns, including the space to print the options:
     * "  -v --verbose  7890123456789012345678901234567890123456789012345678901234567890"
     */

    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "v", KEY_VERBOSE,
                       "Verbose mode, shows errors, warnings and all messages.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "s", KEY_SILENT,
                       "Silent mode, shows errors only.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "h", KEY_HELP,
                       "Help on a specific command.",
                       false);
}
 
Example 6
Source Project: javaide   Source File: Error5Parser.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    for (Pattern pattern : MSG_PATTERNS) {
        Matcher m = pattern.matcher(line);
        if (m.matches()) {
            String sourcePath = m.group(1);
            String lineNumber = m.group(2);
            String msgText = m.group(3);
            Message.Kind kind = Message.Kind.ERROR;
            if (msgText.startsWith("warning: ")) {
                // NDK warning also matches this regexp
                kind = Message.Kind.WARNING;
            }
            if (sourcePath.endsWith(SdkConstants.DOT_JAVA)) {
                return false;
            }
            Message msg = createMessage(kind, msgText, sourcePath, lineNumber, "", logger);
            messages.add(msg);
            return true;
        }
    }
    return false;
}
 
Example 7
Source Project: java-n-IDE-for-Android   Source File: BuildToolInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the build-tool is valid by verifying that the expected binaries
 * are actually present. This checks that all known paths point to a valid file
 * or directory.
 *
 * @param log An optional logger. If non-null, errors will be printed there.
 * @return True if the build-tool folder contains all the expected tools.
 */
public boolean isValid(@Nullable ILogger log) {
    for (Map.Entry<PathId, String> entry : mPaths.entrySet()) {
        File f = new File(entry.getValue());
        // check if file is missing. It's only ok if the revision of the build-tools
        // is lower than the min rev of the element.
        if (!f.exists() && entry.getKey().isPresentIn(mRevision)) {
            if (log != null) {
                log.warning("Build-tool %1$s is missing %2$s at %3$s",  //$NON-NLS-1$
                        mRevision.toString(),
                        entry.getKey(), f.getAbsolutePath());
            }
            return false;
        }
    }
    return true;
}
 
Example 8
Source Project: javaide   Source File: ResourceSet.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void readSourceFolder(File sourceFolder, ILogger logger)
        throws MergingException {
    List<Message> errors = Lists.newArrayList();
    File[] folders = sourceFolder.listFiles();
    if (folders != null) {
        for (File folder : folders) {
            if (folder.isDirectory() && !isIgnored(folder)) {
                FolderData folderData = getFolderData(folder);
                if (folderData != null) {
                    try {
                        parseFolder(sourceFolder, folder, folderData, logger);
                    } catch (MergingException e) {
                        errors.addAll(e.getMessages());
                    }
                }
            }
        }
    }
    MergingException.throwIfNonEmpty(errors);
}
 
Example 9
Source Project: java-n-IDE-for-Android   Source File: ResourceSet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Reads the content of a typed resource folder (sub folder to the root of res folder), and
 * loads the resources from it.
 *
 *
 * @param sourceFolder the main res folder
 * @param folder the folder to read.
 * @param folderData the folder Data
 * @param logger a logger object
 *
 * @throws MergingException if something goes wrong
 */
private void parseFolder(File sourceFolder, File folder, FolderData folderData, ILogger logger)
        throws MergingException {
    File[] files = folder.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            if (!file.isFile() || isIgnored(file)) {
                continue;
            }

            ResourceFile resourceFile = createResourceFile(file, folderData, logger);
            if (resourceFile != null) {
                processNewDataFile(sourceFolder, resourceFile, true /*setTouched*/);
            }
        }
    }
}
 
Example 10
Source Project: java-n-IDE-for-Android   Source File: DataSet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Update the DataSet with a given file.
 *
 * @param sourceFolder the sourceFile containing the changedFile
 * @param changedFile The changed file
 * @param fileStatus the change state
 * @return true if the set was properly updated, false otherwise
 * @throws MergingException if something goes wrong
 */
public boolean updateWith(File sourceFolder, File changedFile, FileStatus fileStatus,
                          ILogger logger)
        throws MergingException {
    switch (fileStatus) {
        case NEW:
            return handleNewFile(sourceFolder, changedFile, logger);
        case CHANGED:
            return handleChangedFile(sourceFolder, changedFile);
        case REMOVED:
            F dataFile = mDataFileMap.get(changedFile);

            if (dataFile == null) {
                return false;
            }

            // flag all resource items are removed
            for (I dataItem : dataFile.getItems()) {
                dataItem.setRemoved();
            }
            return true;
    }

    return false;
}
 
Example 11
Source Project: java-n-IDE-for-Android   Source File: ManifestMerger2.java    License: Apache License 2.0 6 votes vote down vote up
private ManifestMerger2(
        @NonNull ILogger logger,
        @NonNull File mainManifestFile,
        @NonNull ImmutableList<Pair<String, File>> libraryFiles,
        @NonNull ImmutableList<File> flavorsAndBuildTypeFiles,
        @NonNull ImmutableList<Invoker.Feature> optionalFeatures,
        @NonNull Map<String, Object> placeHolderValues,
        @NonNull KeyBasedValueResolver<SystemProperty> systemPropertiesResolver,
        @NonNull MergeType mergeType,
        @NonNull Optional<File> reportFile) {
    this.mSystemPropertyResolver = systemPropertiesResolver;
    this.mPlaceHolderValues = placeHolderValues;
    this.mManifestFile = mainManifestFile;
    this.mLogger = logger;
    this.mLibraryFiles = libraryFiles;
    this.mFlavorsAndBuildTypeFiles = flavorsAndBuildTypeFiles;
    this.mOptionalFeatures = optionalFeatures;
    this.mMergeType = mergeType;
    this.mReportFile = reportFile;
}
 
Example 12
Source Project: javaide   Source File: Error3Parser.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String sourcePath = m.group(1);
    String lineNumber = m.group(2);
    String msgText = m.group(3);

    Message msg = createMessage(Message.Kind.ERROR, msgText, sourcePath,
            lineNumber, "", logger);
    messages.add(msg);
    return true;
}
 
Example 13
Source Project: java-n-IDE-for-Android   Source File: ArgvParser.java    License: Apache License 2.0 6 votes vote down vote up
public ArgvParser(ILogger logger) {
    super(logger, ACTIONS);

    // The following defines the parameters of the actions defined in mAction.

    // --- merge manifest ---

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "o", KEY_OUT,                           //$NON-NLS-1$
            "Output path (where to write the merged manifest). Use - for stdout.", null);

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "1", KEY_MAIN,                          //$NON-NLS-1$
            "Path of the main manifest (what to merge *into*)", null);

    define(Mode.STRING_ARRAY, true,
            VERB_MERGE, NO_VERB_OBJECT, "2", KEY_LIBS,                          //$NON-NLS-1$
            "Paths of library manifests to be merged into the main one.",
            null);
}
 
Example 14
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String sourcePath = m.group(2);
    // Certain files can safely be skipped without marking the project as having errors.
    // See isHidden() in AaptAssets.cpp:
    String type = m.group(1);
    if (type.equals("backup")         // main.xml~, etc
            || type.equals("hidden")      // .gitignore, etc
            || type.equals("index")) {    // thumbs.db, etc
        return true;
    }
    Message msg = createMessage(Message.Kind.WARNING, line, sourcePath,
            null, "", logger);
    messages.add(msg);
    return true;
}
 
Example 15
Source Project: atlas   Source File: TBIncrementalVisitor.java    License: Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static boolean isClassTargetingNewerPlatform(
        int targetApiLevel,
        @NonNull Type targetApiAnnotationType,
        @NonNull AsmUtils.ClassReaderProvider locator,
        @NonNull ClassNode classNode,
        @NonNull ILogger logger) throws IOException {

    List<AnnotationNode> invisibleAnnotations =
            AsmUtils.getInvisibleAnnotationsOnClassOrOuterClasses(locator, classNode, logger);
    for (AnnotationNode classAnnotation : invisibleAnnotations) {
        if (classAnnotation.desc.equals(targetApiAnnotationType.getDescriptor())) {
            int valueIndex = 0;
            List values = classAnnotation.values;
            while (valueIndex < values.size()) {
                String name = (String) values.get(valueIndex);
                if (name.equals("value")) {
                    Object value = values.get(valueIndex + 1);
                    return Integer.class.cast(value) > targetApiLevel;
                }
                valueIndex = valueIndex + 2;
            }
        }
    }
    return false;
}
 
Example 16
Source Project: javaide   Source File: CommandLineParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a new command-line processor.
 *
 * @param logger An SDK logger object. Must not be null.
 * @param actions The list of actions recognized on the command-line.
 *                See the javadoc of {@link #mActions} for more details.
 *
 * @see #mActions
 */
public CommandLineParser(ILogger logger, String[][] actions) {
    mLog = logger;
    mActions = actions;

    /*
     * usage should fit in 80 columns, including the space to print the options:
     * "  -v --verbose  7890123456789012345678901234567890123456789012345678901234567890"
     */

    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "v", KEY_VERBOSE,
                       "Verbose mode, shows errors, warnings and all messages.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "s", KEY_SILENT,
                       "Silent mode, shows errors only.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "h", KEY_HELP,
                       "Help on a specific command.",
                       false);
}
 
Example 17
Source Project: javaide   Source File: DataSet.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update the DataSet with a given file.
 *
 * @param sourceFolder the sourceFile containing the changedFile
 * @param changedFile The changed file
 * @param fileStatus the change state
 * @return true if the set was properly updated, false otherwise
 * @throws MergingException if something goes wrong
 */
public boolean updateWith(File sourceFolder, File changedFile, FileStatus fileStatus,
                          ILogger logger)
        throws MergingException {
    switch (fileStatus) {
        case NEW:
            return handleNewFile(sourceFolder, changedFile, logger);
        case CHANGED:
            return handleChangedFile(sourceFolder, changedFile, logger);
        case REMOVED:
            return handleRemovedFile(changedFile);
    }

    return false;
}
 
Example 18
Source Project: javaide   Source File: LocalSdkParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Try to find a platform-tools package at the given location.
 * Returns null if not found.
 */
private Package scanPlatformTools(File platformToolsFolder, ILogger log) {
    // Can we find some properties?
    Properties props = parseProperties(new File(platformToolsFolder,
            SdkConstants.FN_SOURCE_PROP));

    // We're not going to check that all tools are present. At the very least
    // we should expect to find adb, aidl, aapt and dx (adapted to the current OS).

    if (platformToolsFolder.listFiles() == null) {
        // ListFiles is null if the directory doesn't even exist.
        // Not going to find anything in there...
        return null;
    }

    // Create our package. use the properties if we found any.
    try {
        Package pkg = PlatformToolPackage.create(
                null,                           //source
                props,                          //properties
                0,                              //revision
                null,                           //license
                "Platform Tools",               //description
                null,                           //descUrl
                platformToolsFolder.getPath()   //archiveOsPath
                );

        return pkg;
    } catch (Exception e) {
        log.error(e, null);
    }
    return null;
}
 
Example 19
Source Project: javaide   Source File: AssetSet.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void readFiles(@NonNull File sourceFolder, @NonNull File folder, @NonNull ILogger logger)
        throws MergingException {
    File[] files = folder.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            if (!isIgnored(file)) {
                if (file.isFile()) {
                    handleNewFile(sourceFolder, file, logger);
                } else if (file.isDirectory()) {
                    readFiles(sourceFolder, file, logger);
                }
            }
        }
    }
}
 
Example 20
Source Project: java-n-IDE-for-Android   Source File: LocalSdkParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Find any directory in the /extras/vendors/path folders for extra packages.
 * This isn't a recursive search.
 */
private void scanExtras(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File root = new File(sdkManager.getLocation(), SdkConstants.FD_EXTRAS);

    for (File vendor : listFilesNonNull(root)) {
        if (vendor.isDirectory()) {
            scanExtrasDirectory(vendor.getAbsolutePath(), visited, packages, log);
        }
    }
}
 
Example 21
Source Project: java-n-IDE-for-Android   Source File: LocalSdkParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Find any other directory in the given "root" directory that hasn't been visited yet
 * and assume they contain extra packages. This is <em>not</em> a recursive search.
 */
private void scanExtrasDirectory(String extrasRoot,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File root = new File(extrasRoot);

    for (File dir : listFilesNonNull(root)) {
        if (dir.isDirectory() && !visited.contains(dir)) {
            Properties props = parseProperties(new File(dir, SdkConstants.FN_SOURCE_PROP));
            if (props != null) {
                try {
                    Package pkg = ExtraPackage.create(
                            null,                       //source
                            props,                      //properties
                            null,                       //vendor
                            dir.getName(),              //path
                            0,                          //revision
                            null,                       //license
                            null,                       //description
                            null,                       //descUrl
                            dir.getPath()               //archiveOsPath
                            );

                    packages.add(pkg);
                    visited.add(dir);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}
 
Example 22
Source Project: javaide   Source File: Error7Parser.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String sourcePath = m.group(2);
    String text = m.group(1);
    Message msg = createMessage(Message.Kind.ERROR, text, sourcePath, null, "", logger);
    messages.add(msg);
    return true;
}
 
Example 23
Source Project: java-n-IDE-for-Android   Source File: LocalSdkParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Scan the sources/folders and register valid as well as broken source packages.
 */
private void scanSources(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File srcRoot = new File(sdkManager.getLocation(), SdkConstants.FD_PKG_SOURCES);

    // The sources folder contains a list of platform folders.
    for (File platformDir : listFilesNonNull(srcRoot)) {
        if (platformDir.isDirectory() && !visited.contains(platformDir)) {
            visited.add(platformDir);

            // Ignore empty directories
            File[] srcFiles = platformDir.listFiles();
            if (srcFiles != null && srcFiles.length > 0) {
                Properties props =
                    parseProperties(new File(platformDir, SdkConstants.FN_SOURCE_PROP));

                try {
                    Package pkg = SourcePackage.create(platformDir, props);
                    packages.add(pkg);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}
 
Example 24
Source Project: java-n-IDE-for-Android   Source File: LocalSdkParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Try to find a docs package at the given location.
 * Returns null if not found.
 */
private Package scanDoc(File docFolder, ILogger log) {
    // Can we find some properties?
    Properties props = parseProperties(new File(docFolder, SdkConstants.FN_SOURCE_PROP));

    // To start with, a doc folder should have an "index.html" to be acceptable.
    // We don't actually check the content of the file.
    if (new File(docFolder, "index.html").isFile()) {
        try {
            Package pkg = DocPackage.create(
                    null,                       //source
                    props,                      //properties
                    0,                          //apiLevel
                    null,                       //codename
                    0,                          //revision
                    null,                       //license
                    null,                       //description
                    null,                       //descUrl
                    docFolder.getPath()         //archiveOsPath
                    );

            return pkg;
        } catch (Exception e) {
            log.error(e, null);
        }
    }

    return null;
}
 
Example 25
Source Project: javaide   Source File: LocalSdkParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * The sdk manager only lists valid addons. However here we also want to find "broken"
 * addons, i.e. addons that failed to load for some reason.
 * <p/>
 * Find any other sub-directories under the /add-ons root that hasn't been visited yet
 * and assume they contain broken addons.
 */
private void scanMissingAddons(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File addons = new File(new File(sdkManager.getLocation()), SdkConstants.FD_ADDONS);

    for (File dir : listFilesNonNull(addons)) {
        if (dir.isDirectory() && !visited.contains(dir)) {
            Pair<Map<String, String>, String> infos =
                parseAddonProperties(dir, sdkManager.getTargets(), log);
            Properties sourceProps =
                parseProperties(new File(dir, SdkConstants.FN_SOURCE_PROP));

            Map<String, String> addonProps = infos.getFirst();
            String error = infos.getSecond();
            try {
                Package pkg = AddonPackage.createBroken(dir.getAbsolutePath(),
                                                        sourceProps,
                                                        addonProps,
                                                        error);
                packages.add(pkg);
                visited.add(dir);
            } catch (Exception e) {
                log.error(e, null);
            }
        }
    }
}
 
Example 26
Source Project: javaide   Source File: LocalSdkParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Try to find a docs package at the given location.
 * Returns null if not found.
 */
private Package scanDoc(File docFolder, ILogger log) {
    // Can we find some properties?
    Properties props = parseProperties(new File(docFolder, SdkConstants.FN_SOURCE_PROP));

    // To start with, a doc folder should have an "index.html" to be acceptable.
    // We don't actually check the content of the file.
    if (new File(docFolder, "index.html").isFile()) {
        try {
            Package pkg = DocPackage.create(
                    null,                       //source
                    props,                      //properties
                    0,                          //apiLevel
                    null,                       //codename
                    0,                          //revision
                    null,                       //license
                    null,                       //description
                    null,                       //descUrl
                    docFolder.getPath()         //archiveOsPath
                    );

            return pkg;
        } catch (Exception e) {
            log.error(e, null);
        }
    }

    return null;
}
 
Example 27
Source Project: java-n-IDE-for-Android   Source File: AvdManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the path to the skin, as a relative path to the SDK.
 * @param skinName The name of the skin to find. Case-sensitive.
 * @param target The target where to find the skin.
 * @param log the log object to receive action logs. Cannot be null.
 */
@Deprecated
private String getSkinRelativePath(@NonNull String skinName,
                                   @NonNull IAndroidTarget target,
                                   @NonNull ILogger log) {
    if (log == null) {
        throw new IllegalArgumentException("log cannot be null");
    }

    // first look to see if the skin is in the target
    File skin = getSkinFolder(skinName, target);

    // skin really does not exist!
    if (skin.exists() == false) {
        log.error(null, "Skin '%1$s' does not exist.", skinName);
        return null;
    }

    // get the skin path
    String path = skin.getAbsolutePath();

    // make this path relative to the SDK location

    String sdkLocation = myLocalSdk.getPath();
    if (path.startsWith(sdkLocation) == false) {
        // this really really should not happen.
        log.error(null, "Target location is not inside the SDK.");
        assert false;
        return null;
    }

    path = path.substring(sdkLocation.length());
    if (path.charAt(0) == File.separatorChar) {
        path = path.substring(1);
    }
    return path;
}
 
Example 28
Source Project: javaide   Source File: DataSet.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected boolean handleChangedFile(
        @NonNull File sourceFolder,
        @NonNull File changedFile,
        @NonNull ILogger logger) throws MergingException {
    F dataFile = mDataFileMap.get(changedFile);
    for (I item : dataFile.getItems()) {
        item.setTouched();
    }
    return true;
}
 
Example 29
Source Project: java-n-IDE-for-Android   Source File: AvdManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Updates an AVD with new path to the system image folders.
 * @param avd the AVD to update.
 * @param log the log object to receive action logs. Cannot be null.
 * @throws IOException
 */
public AvdInfo updateAvd(AvdInfo avd, ILogger log) throws IOException {
    // get the properties. This is a unmodifiable Map.
    Map<String, String> oldProperties = avd.getProperties();

    // create a new map
    Map<String, String> properties = new HashMap<String, String>();
    if (oldProperties != null) {
        properties.putAll(oldProperties);
    }

    AvdStatus status;

    // create the path to the new system images.
    if (setImagePathProperties(avd.getTarget(),
                               avd.getTag(),
                               avd.getAbiType(),
                               properties,
                               log)) {
        if (properties.containsKey(AVD_INI_IMAGES_1)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_1,
                    properties.get(AVD_INI_IMAGES_1));
        }

        if (properties.containsKey(AVD_INI_IMAGES_2)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_2,
                    properties.get(AVD_INI_IMAGES_2));
        }

        status = AvdStatus.OK;
    } else {
        log.error(null, "Unable to find non empty system images folders for %1$s",
                avd.getName());
        //FIXME: display paths to empty image folders?
        status = AvdStatus.ERROR_IMAGE_DIR;
    }

    return updateAvd(avd, properties, status, log);
}
 
Example 30
Source Project: javaide   Source File: WorkQueue.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new queue, with a number of dedicated threads to process
 * the queue's jobs.
 *
 * @param logger to log messages
 * @param queueName a meaningful descriptive name.
 * @param workforce the number of dedicated threads for this queue.
 * @param growthTriggerRatio the ratio between outstanding requests and worker threads that
 *                           should trigger a growth in worker threads.
 */
public WorkQueue(
        @NonNull ILogger logger,
        @NonNull QueueThreadContext<T> queueThreadContext,
        @NonNull String queueName,
        int workforce,
        float growthTriggerRatio) {

    this.mLogger = logger;
    this.mName = queueName;
    this.mGrowthTriggerRation = growthTriggerRatio;
    this.mMWorkforceIncrement = workforce;
    this.mQueueThreadContext = queueThreadContext;
}