Example usage for java.util Properties isEmpty

List of usage examples for java.util Properties isEmpty

Introduction

In this page you can find the example usage for java.util Properties isEmpty.

Prototype

@Override
    public boolean isEmpty() 

Source Link

Usage

From source file:org.apache.sqoop.orm.ClassWriter.java

/**
 * Generate the ORM code for the class.//  www . jav  a 2s.c  o m
 */
public void generate(String invalidIdentifierPrefix) throws IOException {
    Map<String, Integer> columnTypes = getColumnTypes();

    String[] colNames = getColumnNames(columnTypes);

    // Translate all the column names into names that are safe to
    // use as identifiers.
    String[] cleanedColNames = cleanColNames(colNames, invalidIdentifierPrefix);
    Set<String> uniqColNames = new HashSet<String>();
    for (int i = 0; i < colNames.length; i++) {
        String identifier = cleanedColNames[i];

        // Name can't be blank
        if (identifier.isEmpty()) {
            throw new IllegalArgumentException("We found column without column "
                    + "name. Please verify that you've entered all column names "
                    + "in your query if using free form query import (consider "
                    + "adding clause AS if you're using column transformation)");
        }

        // Guarantee uniq col identifier
        if (uniqColNames.contains(identifier)) {
            throw new IllegalArgumentException(
                    "Duplicate Column identifier " + "specified: '" + identifier + "'");
        }
        uniqColNames.add(identifier);

        // Make sure the col->type mapping holds for the
        // new identifier name, too.
        String col = colNames[i];
        Integer type = columnTypes.get(col);
        if (type == null) {
            // column doesn't have a type, means that is illegal column name!
            throw new IllegalArgumentException("Column name '" + col + "' not in table");
        }
        columnTypes.put(identifier, type);
    }

    // Check that all explicitly mapped columns are present in result set
    Properties mapping = options.getMapColumnJava();
    if (mapping != null && !mapping.isEmpty()) {
        for (Object column : mapping.keySet()) {
            if (!uniqColNames.contains((String) column)) {
                throw new IllegalArgumentException(
                        "No column by the name " + column + "found while importing data");
            }
        }
    }

    // The db write() method may use column names in a different
    // order. If this is set in the options, pull it out here and
    // make sure we format the column names to identifiers in the same way
    // as we do for the ordinary column list.
    String[] dbWriteColNames = options.getDbOutputColumns();
    String[] cleanedDbWriteColNames = null;
    if (null == dbWriteColNames) {
        cleanedDbWriteColNames = cleanedColNames;
    } else {
        cleanedDbWriteColNames = cleanColNames(dbWriteColNames);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("selected columns:");
        for (String col : cleanedColNames) {
            LOG.debug("  " + col);
        }

        if (cleanedDbWriteColNames != cleanedColNames) {
            // dbWrite() has a different set of columns than the rest of the
            // generators.
            LOG.debug("db write column order:");
            for (String dbCol : cleanedDbWriteColNames) {
                LOG.debug("  " + dbCol);
            }
        }
    }

    // Generate the Java code.
    StringBuilder sb = generateClassForColumns(columnTypes, cleanedColNames, cleanedDbWriteColNames);

    // Write this out to a file in the jar output directory.
    // We'll move it to the user-visible CodeOutputDir after compiling.
    String codeOutDir = options.getJarOutputDir();

    // Get the class name to generate, which includes package components.
    String className = new TableClassName(options).getClassForTable(tableName);
    // Convert the '.' characters to '/' characters.
    String sourceFilename = className.replace('.', File.separatorChar) + ".java";
    String filename = codeOutDir + sourceFilename;

    if (LOG.isDebugEnabled()) {
        LOG.debug("Writing source file: " + filename);
        LOG.debug("Table name: " + tableName);
        StringBuilder sbColTypes = new StringBuilder();
        for (String col : colNames) {
            Integer colType = columnTypes.get(col);
            sbColTypes.append(col + ":" + colType + ", ");
        }
        String colTypeStr = sbColTypes.toString();
        LOG.debug("Columns: " + colTypeStr);
        LOG.debug("sourceFilename is " + sourceFilename);
    }

    compileManager.addSourceFile(sourceFilename);

    // Create any missing parent directories.
    File file = new File(filename);
    File dir = file.getParentFile();
    if (null != dir && !dir.exists()) {
        boolean mkdirSuccess = dir.mkdirs();
        if (!mkdirSuccess) {
            LOG.debug("Could not create directory tree for " + dir);
        }
    }

    OutputStream ostream = null;
    Writer writer = null;
    try {
        ostream = new FileOutputStream(filename);
        writer = new OutputStreamWriter(ostream);
        writer.append(sb.toString());
    } finally {
        if (null != writer) {
            try {
                writer.close();
            } catch (IOException ioe) {
                // ignored because we're closing.
            }
        }

        if (null != ostream) {
            try {
                ostream.close();
            } catch (IOException ioe) {
                // ignored because we're closing.
            }
        }
    }
}

From source file:com.jdom.word.playdough.model.gamepack.GamePackFileGenerator.java

public List<Properties> generateGamePacks(int numberOfPlayableWordsInEachPack) {
    List<Properties> finishedPacks = new ArrayList<Properties>();

    Properties allProperties = generateProperties();

    List<String> allPlayableWords = PropertiesUtil.getPropertyAsList(allProperties,
            GamePack.PLAYABLE_WORDS_KEY);

    Iterator<String> iter = allPlayableWords.iterator();
    Properties currentPack = new Properties();
    List<String> currentPackPlayableWords = new ArrayList<String>();
    for (int i = 0; iter.hasNext(); i++) {
        String playableWord = iter.next();
        System.out.println("Finding a pack for word #" + i + " [" + playableWord + "]");
        String playableWordPrefix = playableWord + ".";

        if (i % numberOfPlayableWordsInEachPack == 0 && i > 0) {
            currentPack.setProperty(GamePack.PLAYABLE_WORDS_KEY,
                    StringUtils.join(currentPackPlayableWords, PropertiesUtil.SEPARATOR));
            finishedPacks.add(currentPack);
            currentPackPlayableWords.clear();
            currentPack = new Properties();
        }/*from  ww w. j a  v a 2 s  . c o  m*/

        currentPackPlayableWords.add(playableWord);
        Iterator<Entry<Object, Object>> propertiesIter = allProperties.entrySet().iterator();

        while (propertiesIter.hasNext()) {
            Entry<Object, Object> entry = propertiesIter.next();
            String key = (String) entry.getKey();
            if (key.startsWith(playableWordPrefix)) {
                currentPack.setProperty(key, (String) entry.getValue());
                propertiesIter.remove();
            }
        }
    }

    if (!currentPack.isEmpty()) {
        currentPack.setProperty(GamePack.PLAYABLE_WORDS_KEY,
                StringUtils.join(currentPackPlayableWords, PropertiesUtil.SEPARATOR));
        finishedPacks.add(currentPack);
    }

    return finishedPacks;
}

From source file:org.apache.archiva.converter.artifact.LegacyToDefaultConverter.java

private boolean doRelocation(Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model,
        ArtifactRepository repository, FileTransaction transaction) throws IOException {
    Properties properties = v3Model.getProperties();
    if (properties.containsKey("relocated.groupId") || properties.containsKey("relocated.artifactId")
    //$NON-NLS-1$ //$NON-NLS-2$
            || properties.containsKey("relocated.version")) //$NON-NLS-1$
    {//  ww  w  .  j  a v  a 2  s  .  c  o m
        String newGroupId = properties.getProperty("relocated.groupId", v3Model.getGroupId()); //$NON-NLS-1$
        properties.remove("relocated.groupId"); //$NON-NLS-1$

        String newArtifactId = properties.getProperty("relocated.artifactId", v3Model.getArtifactId()); //$NON-NLS-1$
        properties.remove("relocated.artifactId"); //$NON-NLS-1$

        String newVersion = properties.getProperty("relocated.version", v3Model.getVersion()); //$NON-NLS-1$
        properties.remove("relocated.version"); //$NON-NLS-1$

        String message = properties.getProperty("relocated.message", ""); //$NON-NLS-1$ //$NON-NLS-2$
        properties.remove("relocated.message"); //$NON-NLS-1$

        if (properties.isEmpty()) {
            v3Model.setProperties(null);
        }

        writeRelocationPom(v3Model.getGroupId(), v3Model.getArtifactId(), v3Model.getVersion(), newGroupId,
                newArtifactId, newVersion, message, repository, transaction);

        v3Model.setGroupId(newGroupId);
        v3Model.setArtifactId(newArtifactId);
        v3Model.setVersion(newVersion);

        artifact.setGroupId(newGroupId);
        artifact.setArtifactId(newArtifactId);
        artifact.setVersion(newVersion);

        return true;
    } else {
        return false;
    }
}

From source file:org.apache.geode.cache.query.QueryTestUtils.java

public void createCache(Properties prop) {
    if (null != prop && !prop.isEmpty()) {
        cache = new CacheFactory(prop).create();
    } else {/*ww w  .  ja va2s .c  o  m*/
        cache = new CacheFactory().set(MCAST_PORT, "0").create();
    }
}

From source file:org.apache.geode.cache.client.internal.PoolImpl.java

public RegionService createAuthenticatedCacheView(Properties properties) {
    if (!this.multiuserSecureModeEnabled) {
        throw new UnsupportedOperationException(
                "Operation not supported when multiuser-authentication is false.");
    }//from   ww  w  . j a v a2 s .c o m
    if (properties == null || properties.isEmpty()) {
        throw new IllegalArgumentException("Security properties cannot be empty.");
    }
    Cache cache = CacheFactory.getInstance(InternalDistributedSystem.getAnyInstance());

    Properties props = new Properties();
    for (Entry<Object, Object> entry : properties.entrySet()) {
        props.setProperty((String) entry.getKey(), (String) entry.getValue());
    }
    ProxyCache proxy = new ProxyCache(props, (InternalCache) cache, this);
    synchronized (this.proxyCacheList) {
        this.proxyCacheList.add(proxy);
    }
    return proxy;
}

From source file:com.agiletec.plugins.jacms.apsadmin.portal.specialwidget.listviewer.ContentListViewerWidgetAction.java

protected Properties createUserFilterProperties() throws ApsSystemException {
    String filterKey = this.getUserFilterKey();
    if (null == filterKey)
        return null;
    Properties properties = new Properties();
    try {//from w w w. jav  a  2s.  co  m
        if (filterKey.equals(UserFilterOptionBean.KEY_FULLTEXT)) {
            properties.put(UserFilterOptionBean.PARAM_KEY, filterKey);
            properties.put(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(false));
        } else if (filterKey.equals(UserFilterOptionBean.KEY_CATEGORY)) {
            properties.put(UserFilterOptionBean.PARAM_KEY, filterKey);
            properties.put(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(false));
            if (null != this.getUserFilterCategoryCode()
                    && this.getUserFilterCategoryCode().trim().length() > 0) {
                properties.put(UserFilterOptionBean.PARAM_CATEGORY_CODE, this.getUserFilterCategoryCode());
            }

        } else if (filterKey.startsWith(UserFilterOptionBean.TYPE_ATTRIBUTE + "_")) {
            properties.put(UserFilterOptionBean.PARAM_KEY,
                    filterKey.substring((UserFilterOptionBean.TYPE_ATTRIBUTE + "_").length()));
            properties.put(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(true));
        }
        if (properties.isEmpty())
            return null;
    } catch (Throwable t) {
        _logger.error("Error creating user filter", t);
        throw new ApsSystemException("Error creating user filter", t);
    }
    return properties;
}

From source file:org.protocoder.network.ProtocoderHttpServer.java

@Override
public Response serve(String uri, String method, Properties header, Properties parms, Properties files) {

    Response res = null;/* ww  w . j a  va 2  s . com*/

    try {

        MLog.d(TAG, "received String" + uri + " " + method + " " + header + " " + " " + parms + " " + files);

        if (uri.startsWith(projectURLPrefix)) {

            // checking if we are inside the directory so we sandbox the app
            // TODO its pretty hack so this deserves coding it again
            Project p = ProjectManager.getInstance().getCurrentProject();

            String projectFolder = "/" + p.getFolder() + "/" + p.getName();
            // MLog.d("qq", "project folder is " + projectFolder);
            if (uri.replace(projectURLPrefix, "").contains(projectFolder)) {
                // MLog.d("qq", "inside project");
                return serveFile(uri.substring(uri.lastIndexOf('/') + 1, uri.length()), header,
                        new File(p.getStoragePath()), false);
            } else {
                // MLog.d("qq", "outside project");
                new Response(HTTP_NOTFOUND, MIME_HTML, "resource not found");
            }

        }

        // file upload
        if (!files.isEmpty()) {

            String name = parms.getProperty("name").toString();
            String folder = parms.getProperty("fileType").toString();

            Project p = ProjectManager.getInstance().get(folder, name);

            File src = new File(files.getProperty("pic").toString());
            File dst = new File(p.getStoragePath() + "/" + parms.getProperty("pic").toString());

            FileIO.copyFile(src, dst);

            JSONObject data = new JSONObject();
            data.put("result", "OK");

            return new Response("200", MIME_TYPES.get("txt"), data.toString());

        }

        // webapi
        JSONObject data = new JSONObject();

        // splitting the string into command and parameters
        String[] m = uri.split("=");

        String userCmd = m[0];
        String params = "";
        if (m.length > 1) {
            params = m[1];
        }
        MLog.d(TAG, "cmd " + userCmd);

        if (userCmd.contains("cmd")) {
            JSONObject obj = new JSONObject(params);

            Project foundProject;
            String name;
            String url;
            String newCode;
            String folder;

            MLog.d(TAG, "params " + obj.toString(2));

            String cmd = obj.getString("cmd");
            // fetch code
            if (cmd.equals("fetch_code")) {
                MLog.d(TAG, "--> fetch code");
                name = obj.getString("name");
                folder = obj.getString("type");

                Project p = ProjectManager.getInstance().get(folder, name);

                // TODO add type
                data.put("code", ProjectManager.getInstance().getCode(p));

                // list apps
            } else if (cmd.equals("list_apps")) {
                MLog.d(TAG, "--> list apps");

                folder = obj.getString("filter");

                ArrayList<Project> projects = ProjectManager.getInstance().list(folder, false);
                JSONArray projectsArray = new JSONArray();
                for (Project project : projects) {
                    projectsArray.put(ProjectManager.getInstance().toJson(project));
                }
                data.put("projects", projectsArray);

                // run app
            } else if (cmd.equals("run_app")) {
                MLog.d(TAG, "--> run app");

                name = obj.getString("name");
                folder = obj.getString("type");

                Project p = ProjectManager.getInstance().get(folder, name);
                ProjectManager.getInstance().setRemoteIP(obj.getString("remoteIP"));
                ProjectEvent evt = new ProjectEvent(p, "run");
                EventBus.getDefault().post(evt);
                MLog.i(TAG, "Running...");

                // execute app
            } else if (cmd.equals("execute_code")) {
                MLog.d(TAG, "--> execute code");

                // Save and run
                String code = parms.get("codeToSend").toString();

                Events.ExecuteCodeEvent evt = new Events.ExecuteCodeEvent(code);
                EventBus.getDefault().post(evt);
                MLog.i(TAG, "Execute...");

                // save_code
            } else if (cmd.equals("push_code")) {
                MLog.d(TAG, "--> push code " + method + " " + header);
                name = parms.get("name").toString();
                String fileName = parms.get("fileName").toString();
                newCode = parms.get("code").toString();
                MLog.d(TAG, "fileName -> " + fileName);
                // MLog.d(TAG, "code -> " + newCode);

                folder = parms.get("type").toString();

                // add type
                Project p = ProjectManager.getInstance().get(folder, name);
                ProjectManager.getInstance().writeNewCode(p, newCode, fileName);
                data.put("project", ProjectManager.getInstance().toJson(p));
                ProjectEvent evt = new ProjectEvent(p, "save");
                EventBus.getDefault().post(evt);

                MLog.i(TAG, "Saved");

                // list files in project
            } else if (cmd.equals("list_files_in_project")) {
                MLog.d(TAG, "--> create new project");
                name = obj.getString("name");
                folder = obj.getString("type");

                Project p = new Project(folder, name);
                JSONArray array = ProjectManager.getInstance().listFilesInProjectJSON(p);
                data.put("files", array);
                // ProjectEvent evt = new ProjectEvent(p, "new");
                // EventBus.getDefault().post(evt);

            } else if (cmd.equals("create_new_project")) {
                MLog.d(TAG, "--> create new project");

                name = obj.getString("name");
                Project p = new Project(ProjectManager.FOLDER_USER_PROJECTS, name);
                ProjectEvent evt = new ProjectEvent(p, "new");
                EventBus.getDefault().post(evt);

                Project newProject = ProjectManager.getInstance().addNewProject(ctx.get(), name,
                        ProjectManager.FOLDER_USER_PROJECTS, name);

                // remove app
            } else if (cmd.equals("remove_app")) {
                MLog.d(TAG, "--> remove app");
                name = obj.getString("name");
                folder = obj.getString("type");

                Project p = new Project(folder, name);
                ProjectManager.getInstance().deleteProject(p);
                ProjectEvent evt = new ProjectEvent(p, "update");
                EventBus.getDefault().post(evt);

                // rename app
            } else if (cmd.equals("rename_app")) {
                MLog.d(TAG, "--> rename app");

                // get help
            } else if (cmd.equals("get_documentation")) {
                MLog.d(TAG, "--> get documentation");

                // TODO do it automatically
                //main objects
                APIManager.getInstance().clear();
                APIManager.getInstance().addClass(PApp.class, true);
                APIManager.getInstance().addClass(PBoards.class, true);
                APIManager.getInstance().addClass(PConsole.class, true);
                APIManager.getInstance().addClass(PDashboard.class, true);
                APIManager.getInstance().addClass(PDevice.class, true);
                APIManager.getInstance().addClass(PFileIO.class, true);
                APIManager.getInstance().addClass(PMedia.class, true);
                APIManager.getInstance().addClass(PNetwork.class, true);
                APIManager.getInstance().addClass(PProtocoder.class, true);
                APIManager.getInstance().addClass(PSensors.class, true);
                APIManager.getInstance().addClass(PUI.class, true);
                APIManager.getInstance().addClass(PUtil.class, true);

                //boards
                APIManager.getInstance().addClass(PArduino.class, false);
                APIManager.getInstance().addClass(PSerial.class, false);
                APIManager.getInstance().addClass(PIOIO.class, false);

                //other
                APIManager.getInstance().addClass(PCamera.class, false);
                APIManager.getInstance().addClass(PDeviceEditor.class, false);
                APIManager.getInstance().addClass(PEvents.class, false);
                APIManager.getInstance().addClass(PMidi.class, false);
                APIManager.getInstance().addClass(PProcessing.class, false);
                APIManager.getInstance().addClass(PLiveCodingFeedback.class, false);
                APIManager.getInstance().addClass(PPureData.class, false);
                APIManager.getInstance().addClass(PSimpleHttpServer.class, false);
                APIManager.getInstance().addClass(PSocketIOClient.class, false);
                APIManager.getInstance().addClass(PSqLite.class, false);
                APIManager.getInstance().addClass(PVideo.class, false);
                APIManager.getInstance().addClass(PWebEditor.class, false);

                //widgets
                APIManager.getInstance().addClass(PAbsoluteLayout.class, false);
                APIManager.getInstance().addClass(PButton.class, false);
                APIManager.getInstance().addClass(PCanvasView.class, false);
                APIManager.getInstance().addClass(PCard.class, false);
                APIManager.getInstance().addClass(PCheckBox.class, false);
                APIManager.getInstance().addClass(PEditText.class, false);
                APIManager.getInstance().addClass(PGrid.class, false);
                APIManager.getInstance().addClass(PGridRow.class, false);
                APIManager.getInstance().addClass(PImageButton.class, false);
                APIManager.getInstance().addClass(PImageView.class, false);
                // TODO add plist item
                APIManager.getInstance().addClass(PList.class, false);
                APIManager.getInstance().addClass(PListItem.class, false);
                APIManager.getInstance().addClass(PMap.class, false);
                APIManager.getInstance().addClass(PNumberPicker.class, false);
                APIManager.getInstance().addClass(PPadView.class, false);
                APIManager.getInstance().addClass(PPlotView.class, false);
                APIManager.getInstance().addClass(PPopupCustomFragment.class, false);
                APIManager.getInstance().addClass(PProgressBar.class, false);
                APIManager.getInstance().addClass(PRadioButton.class, false);
                APIManager.getInstance().addClass(PRow.class, false);
                APIManager.getInstance().addClass(PScrollView.class, false);
                APIManager.getInstance().addClass(PSlider.class, false);
                APIManager.getInstance().addClass(PSpinner.class, false);
                APIManager.getInstance().addClass(PSwitch.class, false);
                APIManager.getInstance().addClass(PTextView.class, false);
                APIManager.getInstance().addClass(PToggleButton.class, false);
                APIManager.getInstance().addClass(PVerticalSeekbar.class, false);
                APIManager.getInstance().addClass(PWebView.class, false);
                APIManager.getInstance().addClass(PWindow.class, false);

                //dashboard
                APIManager.getInstance().addClass(PDashboardBackground.class, false);
                APIManager.getInstance().addClass(PDashboardButton.class, false);
                APIManager.getInstance().addClass(PDashboardCustomWidget.class, false);
                APIManager.getInstance().addClass(PDashboardHTML.class, false);
                APIManager.getInstance().addClass(PDashboardImage.class, false);
                APIManager.getInstance().addClass(PDashboardInput.class, false);
                APIManager.getInstance().addClass(PDashboardPlot.class, false);
                APIManager.getInstance().addClass(PDashboardSlider.class, false);
                APIManager.getInstance().addClass(PDashboardText.class, false);
                APIManager.getInstance().addClass(PDashboardVideoCamera.class, false);

                data.put("api", APIManager.getInstance().getDocumentation());
            }

            res = new Response("200", MIME_TYPES.get("txt"), data.toString());

        } else if (uri.contains("apps")) {
            String[] u = uri.split("/");

            // server webui
        } else {

            res = sendWebAppFile(uri, method, header, parms, files);
        }

    } catch (Exception e) {
        MLog.d(TAG, "response error " + e.toString());
    }

    // return serveFile(uri, header, servingFolder, true);
    return res;
}

From source file:org.openmrs.web.filter.initialization.InitializationFilter.java

private void loadInstallationScriptIfPresent() {
    Properties script = getInstallationScript();
    if (!script.isEmpty()) {
        wizardModel.installMethod = script.getProperty("install_method", wizardModel.installMethod);

        wizardModel.databaseConnection = script.getProperty("connection.url", wizardModel.databaseConnection);
        wizardModel.databaseDriver = script.getProperty("connection.driver_class", wizardModel.databaseDriver);
        wizardModel.currentDatabaseUsername = script.getProperty("connection.username",
                wizardModel.currentDatabaseUsername);
        wizardModel.currentDatabasePassword = script.getProperty("connection.password",
                wizardModel.currentDatabasePassword);

        String has_current_openmrs_database = script.getProperty("has_current_openmrs_database");
        if (has_current_openmrs_database != null) {
            wizardModel.hasCurrentOpenmrsDatabase = Boolean.valueOf(has_current_openmrs_database);
        }//w  ww .  j a  v  a 2 s.  c  o m
        wizardModel.createDatabaseUsername = script.getProperty("create_database_username",
                wizardModel.createDatabaseUsername);
        wizardModel.createDatabasePassword = script.getProperty("create_database_password",
                wizardModel.createDatabasePassword);

        String create_tables = script.getProperty("create_tables");
        if (create_tables != null) {
            wizardModel.createTables = Boolean.valueOf(create_tables);
        }

        String create_database_user = script.getProperty("create_database_user");
        if (create_database_user != null) {
            wizardModel.createDatabaseUser = Boolean.valueOf(create_database_user);
        }
        wizardModel.createUserUsername = script.getProperty("create_user_username",
                wizardModel.createUserUsername);
        wizardModel.createUserPassword = script.getProperty("create_user_password",
                wizardModel.createUserPassword);

        String add_demo_data = script.getProperty("add_demo_data");
        if (add_demo_data != null) {
            wizardModel.addDemoData = Boolean.valueOf(add_demo_data);
        }

        String module_web_admin = script.getProperty("module_web_admin");
        if (module_web_admin != null) {
            wizardModel.moduleWebAdmin = Boolean.valueOf(module_web_admin);
        }

        String auto_update_database = script.getProperty("auto_update_database");
        if (auto_update_database != null) {
            wizardModel.autoUpdateDatabase = Boolean.valueOf(auto_update_database);
        }

        wizardModel.adminUserPassword = script.getProperty("admin_user_password",
                wizardModel.adminUserPassword);
    }
}

From source file:com.zb.jcseg.core.JcsegTaskConfig.java

/**
 * reset the value of its options from a propertie file . <br />
 * //from   www  .  j av  a  2s .c  o  m
 * @param proFile path of jcseg.properties file. when null is givend, jcseg will look up the default
 * jcseg.properties file. <br />
 * @throws IOException
 */
public void resetFromPropertyFile(String proFile) throws IOException {
    Properties lexPro = new Properties();
    String jarPath = null;
    /* load the mapping from the default property file. */
    if (proFile == null) {
        /**
         * <pre>
         *      0.load the jcseg.properties from the current data.
         *      1.load the jcseg.properties located with the jar file. 
         *      2.load the jcseg.properties from the classpath. 
         *      3.load the jcseg.properties from the user.home.
         * </pre>
         */
        boolean jcseg_properties = false;
        File pro_file = null;
        String fileName = System.getProperty("jcseg.properties.path");
        if (StringUtils.isNotEmpty(fileName)) {
            pro_file = new File(fileName);
            if (pro_file.exists()) {
                lexPro.load(new FileReader(pro_file));
                jcseg_properties = true;
            }
        }

        // File pro_file = stream2file(this.getClass().getResourceAsStream("/data/" + LEX_PROPERTY_FILE));
        // File pro_file = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile());
        // InputStream in = getClass().getResourceAsStream("/data/" + LEX_PROPERTY_FILE);

        if (!jcseg_properties) {
            lexPro.load(this.getClass().getResourceAsStream("/data/" + LEX_PROPERTY_FILE));
            if (!lexPro.isEmpty()) {
                jcseg_properties = true;
                jarPath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
                logger.info("resetFromPropertyFile jarPath :" + jarPath);
                // URL jarUrl = new URL(jarPath);
                // JarURLConnection jarCon = (JarURLConnection) jarUrl.openConnection();
                // jarCon.getJarFile();
                jarPath = StringUtils.remove(jarPath, ".jar");
                File workDir = new File(jarPath);
                // File.createTempFile("", "", new File(StringUtils.remove(jarPath, ".jar")));
                workDir.delete();
                workDir.mkdirs();
                if (!workDir.isDirectory()) {
                    logger.info("Mkdirs failed to create " + workDir);
                    throw new IOException("Mkdirs failed to create " + workDir);
                }
                logger.info("resetFromPropertyFile workDir :" + workDir.getPath());
                unJar(new JarFile(jarPath + ".jar"), workDir);
            }
        }
        if (!jcseg_properties) {
            pro_file = new File(JAR_HOME + "/" + LEX_PROPERTY_FILE);
            if (pro_file.exists()) {
                lexPro.load(new FileReader(pro_file));
                jcseg_properties = true;
            }
        }
        if (!jcseg_properties) {
            InputStream is = JcsegDictionaryFactory.class.getResourceAsStream("/" + LEX_PROPERTY_FILE);
            if (is != null) {
                lexPro.load(new BufferedInputStream(is));
                jcseg_properties = true;
            }
        }
        if (!jcseg_properties) {
            pro_file = new File(System.getProperty("user.home") + "/" + LEX_PROPERTY_FILE);
            if (pro_file.exists()) {
                lexPro.load(new FileReader(pro_file));
                jcseg_properties = true;
            }
        }

        /*
         * jcseg properties file loading status report, show the crorrent properties file location information . <br
         * />
         * @date 2014-09-06
         */
        if (!jcseg_properties) {
            String _report = "jcseg properties[jcseg.properties] file loading error: \n";
            _report += "try the follwing ways to solve the problem: \n";
            _report += "1. put jcseg.properties into the classpath.\n";
            _report += "2. put jcseg.properties together with the jcseg-core-{version}.jar file.\n";
            _report += "3. put jcseg.properties in directory " + System.getProperty("user.home") + "\n\n";
            throw new IOException(_report);
        }
    }
    /* load the mapping from the specified property file. */
    else {
        File pro_file = new File(proFile);
        if (!pro_file.exists())
            throw new IOException("property file [" + proFile + "] not found!");
        lexPro.load(new FileReader(pro_file));
    }

    /* about the lexicon */
    // the lexicon path
    logger.info("jcseg.properties :" + lexPro.values());
    lexPath = (StringUtils.isNotEmpty(jarPath) ? jarPath : StringUtils.EMPTY)
            + lexPro.getProperty("lexicon.path");
    logger.info("################ jarPath : " + jarPath);
    logger.info("################ jcseg.properties lexicon.path : " + lexPro.getProperty("lexicon.path"));
    logger.info("################ lexPath : " + lexPath);
    // lexPath = this.getClass().getResource(lexPath).getFile();
    if (lexPath == null) {
        throw new IOException("lexicon.path property not find in jcseg.properties file!!!");
    }
    if (lexPath.indexOf("{jar.dir}") > -1)
        lexPath = lexPath.replace("{jar.dir}", JAR_HOME);
    // System.out.println("path: "+lexPath);

    // the lexicon file prefix and suffix
    if (lexPro.getProperty("lexicon.suffix") != null)
        suffix = lexPro.getProperty("lexicon.suffix");
    if (lexPro.getProperty("lexicon.prefix") != null)
        prefix = lexPro.getProperty("lexicon.prefix");

    // reset all the options
    if (lexPro.getProperty("jcseg.maxlen") != null)
        MAX_LENGTH = Integer.parseInt(lexPro.getProperty("jcseg.maxlen"));
    if (lexPro.getProperty("jcseg.mixcnlen") != null)
        MIX_CN_LENGTH = Integer.parseInt(lexPro.getProperty("jcseg.mixcnlen"));
    if (lexPro.getProperty("jcseg.icnname") != null && lexPro.getProperty("jcseg.icnname").equals("1"))
        I_CN_NAME = true;
    if (lexPro.getProperty("jcseg.cnmaxlnadron") != null)
        MAX_CN_LNADRON = Integer.parseInt(lexPro.getProperty("jcseg.cnmaxlnadron"));
    if (lexPro.getProperty("jcseg.nsthreshold") != null)
        NAME_SINGLE_THRESHOLD = Integer.parseInt(lexPro.getProperty("jcseg.nsthreshold"));
    if (lexPro.getProperty("jcseg.pptmaxlen") != null)
        PPT_MAX_LENGTH = Integer.parseInt(lexPro.getProperty("jcseg.pptmaxlen"));
    if (lexPro.getProperty("jcseg.loadpinyin") != null && lexPro.getProperty("jcseg.loadpinyin").equals("1"))
        LOAD_CJK_PINYIN = true;
    if (lexPro.getProperty("jcseg.loadsyn") != null && lexPro.getProperty("jcseg.loadsyn").equals("1"))
        LOAD_CJK_SYN = true;
    if (lexPro.getProperty("jcseg.loadpos") != null && lexPro.getProperty("jcseg.loadpos").equals("1"))
        LOAD_CJK_POS = true;
    if (lexPro.getProperty("jcseg.clearstopword") != null
            && lexPro.getProperty("jcseg.clearstopword").equals("1"))
        CLEAR_STOPWORD = true;
    if (lexPro.getProperty("jcseg.cnnumtoarabic") != null
            && lexPro.getProperty("jcseg.cnnumtoarabic").equals("0"))
        CNNUM_TO_ARABIC = false;
    if (lexPro.getProperty("jcseg.cnfratoarabic") != null
            && lexPro.getProperty("jcseg.cnfratoarabic").equals("0"))
        CNFRA_TO_ARABIC = false;
    if (lexPro.getProperty("jcseg.keepunregword") != null
            && lexPro.getProperty("jcseg.keepunregword").equals("1"))
        KEEP_UNREG_WORDS = true;
    if (lexPro.getProperty("lexicon.autoload") != null && lexPro.getProperty("lexicon.autoload").equals("1"))
        lexAutoload = true;
    if (lexPro.getProperty("lexicon.polltime") != null)
        polltime = Integer.parseInt(lexPro.getProperty("lexicon.polltime"));
    if (lexPro.getProperty("wiselyUnionWord") != null && lexPro.getProperty("wiselyUnionWord").equals("1"))
        wiselyUnionWord = true;

    // secondary split
    if (lexPro.getProperty("jcseg.ensencondseg") != null
            && lexPro.getProperty("jcseg.ensencondseg").equals("0"))
        EN_SECOND_SEG = false;
    if (lexPro.getProperty("jcseg.stokenminlen") != null)
        STOKEN_MIN_LEN = Integer.parseInt(lexPro.getProperty("jcseg.stokenminlen"));

    // load the keep punctuations.
    if (lexPro.getProperty("jcseg.keeppunctuations") != null)
        KEEP_PUNCTUATIONS = lexPro.getProperty("jcseg.keeppunctuations");
}

From source file:org.schemaspy.Config.java

/**
 * Return all of the configuration options as a List of Strings, with
 * each parameter and its value as a separate element.
 *
 * @return/*from   ww  w . ja  v  a 2 s  . co  m*/
 * @throws IOException
 */
public List<String> asList() throws IOException {
    List<String> params = new ArrayList<>();

    if (originalDbSpecificOptions != null) {
        for (String key : originalDbSpecificOptions.keySet()) {
            String value = originalDbSpecificOptions.get(key);
            if (!key.startsWith("-"))
                key = "-" + key;
            params.add(key);
            params.add(value);
        }
    }

    if (isEncodeCommentsEnabled())
        params.add("-ahic");
    if (isEvaluateAllEnabled())
        params.add("-all");
    if (!isHtmlGenerationEnabled())
        params.add("-nohtml");
    if (!isImpliedConstraintsEnabled())
        params.add("-noimplied");
    if (!isLogoEnabled())
        params.add("-nologo");
    if (isMeterEnabled())
        params.add("-meter");
    if (!isNumRowsEnabled())
        params.add("-norows");
    if (!isViewsEnabled())
        params.add("-noviews");
    if (isRankDirBugEnabled())
        params.add("-rankdirbug");
    if (isRailsEnabled())
        params.add("-rails");
    if (isSingleSignOn())
        params.add("-sso");
    if (isSchemaDisabled())
        params.add("-noschema");

    String value = getDriverPath();
    if (value != null) {
        params.add("-dp");
        params.add(value);
    }
    params.add("-css");
    params.add(getCss());
    params.add("-charset");
    params.add(getCharset());
    params.add("-font");
    params.add(getFont());
    params.add("-fontsize");
    params.add(String.valueOf(getFontSize()));
    params.add("-t");
    params.add(getDbType());
    isHighQuality(); // query to set renderer correctly
    isLowQuality(); // query to set renderer correctly
    params.add("-renderer"); // instead of -hq and/or -lq
    params.add(getRenderer());
    value = getDescription();
    if (value != null) {
        params.add("-desc");
        params.add(value);
    }
    value = getPassword();
    if (value != null && !isPromptForPasswordEnabled()) {
        // note that we don't pass -pfp since child processes
        // won't have a console
        params.add("-p");
        params.add(value);
    }
    value = getCatalog();
    if (value != null) {
        params.add("-cat");
        params.add(value);
    }
    value = getSchema();
    if (value != null) {
        params.add("-s");
        params.add(value);
    }
    value = getUser();
    if (value != null) {
        params.add("-u");
        params.add(value);
    }
    value = getConnectionPropertiesFile();
    if (value != null) {
        params.add("-connprops");
        params.add(value);
    } else {
        Properties props = getConnectionProperties();
        if (!props.isEmpty()) {
            params.add("-connprops");
            StringBuilder buf = new StringBuilder();
            for (Entry<Object, Object> entry : props.entrySet()) {
                buf.append(entry.getKey());
                buf.append(ESCAPED_EQUALS);
                buf.append(entry.getValue());
                buf.append(';');
            }
            params.add(buf.toString());
        }
    }
    value = getDb();
    if (value != null) {
        params.add("-db");
        params.add(value);
    }
    value = getHost();
    if (value != null) {
        params.add("-host");
        params.add(value);
    }
    if (getPort() != null) {
        params.add("-port");
        params.add(getPort().toString());
    }
    value = getServer();
    if (value != null) {
        params.add("-server");
        params.add(value);
    }
    value = getMeta();
    if (value != null) {
        params.add("-meta");
        params.add(value);
    }

    value = getTemplateDirectory();
    if (value != null) {
        params.add("-template");
        params.add(value);
    }
    if (getGraphvizDir() != null) {
        params.add("-gv");
        params.add(getGraphvizDir().toString());
    }
    params.add("-loglevel");
    params.add(getLogLevel().toString().toLowerCase());
    params.add("-sqlFormatter");
    params.add(getSqlFormatter().getClass().getName());
    params.add("-i");
    params.add(getTableInclusions().toString());
    params.add("-I");
    params.add(getTableExclusions().toString());
    params.add("-X");
    params.add(getColumnExclusions().toString());
    params.add("-x");
    params.add(getIndirectColumnExclusions().toString());
    params.add("-dbthreads");
    params.add(String.valueOf(getMaxDbThreads()));
    params.add("-maxdet");
    params.add(String.valueOf(getMaxDetailedTables()));
    params.add("-o");
    params.add(getOutputDir().toString());

    return params;
}