Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.File;

import java.util.Map;
import java.util.Set;

import org.w3c.dom.Document;

public class Main {
    /**
     * Try to find the {@link Document} associated with a certain language
     * directory path. In case nothing is found, null is returned.
     * 
     * @param map
     *            {@link Map} in which the search will be made.
     * @param languageDirectory
     *            Directory holding the path to be compared, in order to find
     *            the {@link Document} in the given {@link Map}. This Object is
     *            updated with a reference to the object in the {@link Map}.
     * 
     * @return {@link Document} element associated, in case a match is
     *         successful.
     */
    private static Document findDocumentByLanguageDirectory(Map<File, Document> map, File languageDirectory) {
        Document document = null;
        Set<File> languageFolders = map.keySet();
        if (languageFolders != null) {
            for (File languageFolder : languageFolders) {
                if (languageFolder.getPath().equals(languageDirectory.getPath())) {
                    document = map.get(languageFolder);
                    languageDirectory = languageFolder;
                    break;
                }
            }
        }
        return document;
    }
}