Example usage for org.apache.commons.io FilenameUtils separatorsToSystem

List of usage examples for org.apache.commons.io FilenameUtils separatorsToSystem

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils separatorsToSystem.

Prototype

public static String separatorsToSystem(String path) 

Source Link

Document

Converts all separators to the system separator.

Usage

From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParserTest.java

@Test
public void testLoadConfig() throws CmdLineParseException, IOException {
    FetcherConfig config = new FetcherConfig();

    File expectedDir = new File(SystemUtils.getUserHome(), FilenameUtils.separatorsToSystem(".sdkfido/work"));

    Assert.assertThat("Config.dryRun", config.isDryRun(), is(false));
    Assert.assertThat("Config.workDir", config.getWorkDir(), is(expectedDir));
    Assert.assertThat("Config.outputType", config.getOutputType(), is(OutputProjectType.SDK));

    File confFile = MavenTestingUtils.getTestResourceFile("config2.properties");

    StringWriter capture = new StringWriter();
    ConfigCmdLineParser parser = new ConfigCmdLineParser(this, config);
    parser.setOut(capture);/*from   www .j  a  v  a  2s  . c om*/
    String[] args = { "--config", confFile.getAbsolutePath() };
    parser.parse(args);

    PathAssert.assertFileExists("Config File", confFile);

    Assert.assertThat("Config.dryRun", config.isDryRun(), is(true));
    Assert.assertThat("config.maven.groupId", config.getMaven().getGroupId(), is("com.android.sdk.testee"));
    Assert.assertThat("config.maven.artifactId", config.getMaven().getArtifactId(), is("artifact-test"));
    Assert.assertThat("config.maven.includeStubJar", config.getMaven().isIncludeStubJar(), is(false));
    Assert.assertThat("config.outputType", config.getOutputType(), is(OutputProjectType.MAVEN_MULTI));
}

From source file:com.orient.lib.xbmc.addons.Addon.java

/**
 * Language File Handling/* www. j  av a2  s.  c om*/
 */
public boolean loadStrings() {
    // Path where the language strings reside
    String chosenPath = props.path + "/resources/language/" + Locale.getDefault().getDisplayLanguage();

    chosenPath = FilenameUtils.separatorsToSystem(chosenPath + "/strings.xml");

    Document stringsXmlDoc = XMLUtils.getDocument(chosenPath);

    if (stringsXmlDoc == null) {
        hasStrings = false;
        return false;
    }

    return hasStrings = stringsFromXML(stringsXmlDoc, true);
}

From source file:cs.ox.ac.uk.sors.PreferencesTestA.java

public void testMerge() throws Exception {

    // Configuration.
    final DecompositionStrategy decomposition = DecompositionStrategy.DECOMPOSE;
    final RewritingLanguage rewLang = RewritingLanguage.UCQ;
    final SubCheckStrategy subchkStrategy = SubCheckStrategy.INTRADEC;
    final NCCheck ncCheckStrategy = NCCheck.NONE;

    LOGGER.info("Decomposition: " + decomposition.name());
    LOGGER.info("Rewriting Language: " + rewLang.name());
    LOGGER.info("Subsumption Check Strategy: " + subchkStrategy.name());
    LOGGER.info("Negative Constraints Check Strategy " + ncCheckStrategy.name());

    final String creationDate = dateFormat.format(new Date());

    // Parse the program
    final Parser parser = new Parser();
    parser.parse(getStringFile(_DEFAULT_INPUT_PATH + "prefDB-ontology.dtg"));

    // Get the rules
    final List<IRule> rules = parser.getRules();

    // Get the queries
    final List<IQuery> queryHeads = parser.getQueries();
    final Map<IPredicate, IRelation> conf = parser.getDirectives();
    if (!conf.isEmpty()) {
        StorageManager.getInstance();/* www  .  ja  va2s.  co  m*/
        StorageManager.configure(conf);
    }

    // Get the TGDs from the set of rules
    final List<IRule> tgds = RewritingUtils.getTGDs(rules, queryHeads);

    final List<IRule> mSBox = RewritingUtils.getSBoxRules(rules, queryHeads);
    final IRuleSafetyProcessor ruleProc = new StandardRuleSafetyProcessor();
    ruleProc.process(mSBox);
    final IQueryRewriter ndmRewriter = new NDMRewriter(mSBox);

    // Convert the query bodies in rules
    final List<IRule> bodies = new LinkedList<IRule>(rules);
    bodies.removeAll(tgds);

    final IRule query = RewritingUtils.getQueries(bodies, queryHeads).get(0);

    // get the constraints from the set of rules
    final Set<IRule> constraints = RewritingUtils.getConstraints(rules, queryHeads);

    final Set<Expressivity> exprs = RewritingUtils.getExpressivity(tgds);
    LOGGER.info("Expressivity: " + exprs.toString());

    if (!exprs.contains(Expressivity.LINEAR) && !exprs.contains(Expressivity.STICKY)) {
        extracted();
    }

    // compute the dependency graph
    LOGGER.debug("Computing position dependencies.");
    long posDepTime = System.currentTimeMillis();
    Map<Pair<IPosition, IPosition>, Set<List<IRule>>> deps = DepGraphUtils.computePositionDependencyGraph(tgds);
    posDepTime = System.currentTimeMillis() - posDepTime;
    CacheManager.setupCaching();

    // if linear TGDs, compute the atom coverage graph.
    LOGGER.debug("Computing atom coverage graph.");
    long atomCoverGraphTime = System.currentTimeMillis();
    if (exprs.contains(Expressivity.LINEAR)) {
        deps = DepGraphUtils.computeAtomCoverageGraph(deps);
    }
    atomCoverGraphTime = System.currentTimeMillis() - atomCoverGraphTime;

    final ParallelRewriter cnsRewriter = new ParallelRewriter(DecompositionStrategy.MONOLITIC,
            RewritingLanguage.UCQ, SubCheckStrategy.NONE, NCCheck.NONE);
    long ncRewTime = System.currentTimeMillis();
    final Set<IRule> rewrittenConstraints = Sets.newHashSet();
    if (!ncCheckStrategy.equals(NCCheck.NONE)) {
        for (final IRule c : constraints) {
            rewrittenConstraints.addAll(cnsRewriter.getRewriting(c, tgds, new HashSet<IRule>(), deps, exprs));
        }
    }
    ncRewTime = System.currentTimeMillis() - ncRewTime;

    LOGGER.debug("Finished rewriting constraints.");

    Map<String, Double> probModel = ProbabilisticModel.get(_DEFAULT_INPUT_PATH + "reviews.txt");
    // Compute the Rewriting
    final ParallelRewriter rewriter = new ParallelRewriter(decomposition, rewLang, subchkStrategy,
            ncCheckStrategy);

    // List<Integer> ks = new ArrayList<Integer>();
    // ks.add(5);

    List<MergingStrategy> str = new ArrayList<MergingStrategy>();
    //str.add(PreferenceStrategy.PREFS_GEN);
    str.add(MergingStrategy.PREFS_PT);
    str.add(MergingStrategy.PREFS_RANK);
    str.add(MergingStrategy.PREFS_SORT);

    LOGGER.trace("start the things.");
    final String summaryPrefix = StringUtils.join(creationDate, "-");

    final File sizeSummaryFile = FileUtils.getFile(_WORKING_DIR,
            FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/"),
            FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR),
            StringUtils.join(summaryPrefix, "-", "size-summary.csv"));
    final CSVWriter sizeSummaryWriter = new CSVWriter(new FileWriter(sizeSummaryFile), ',');

    final File timeSummaryFile = FileUtils.getFile(_WORKING_DIR,
            FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/"),
            FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR),
            StringUtils.join(summaryPrefix, "-", "time-summary.csv"));
    final CSVWriter timeSummaryWriter = new CSVWriter(new FileWriter(timeSummaryFile), ',');
    sizeSummaryWriter.writeNext(UReportingUtils.getSummaryRewritingSizeReportHeader());
    timeSummaryWriter.writeNext(UReportingUtils.getSummaryRewritingTimeReportHeader());

    // for (int nbNodes = 500; nbNodes < 1000; nbNodes += 500) {
    // for (int nbNodes = 10; nbNodes < 20; nbNodes += 10) {
    for (int nbNodes = 1000; nbNodes < 13000; nbNodes += 1000) {

        double sparisity = 0.15;
        //double sparsity = 0.15 and  experirement no  gen and no transitve closure, expeirment 1000> 13.0000
        // for (Integer k : ks) {
        for (int con = 0; con < 10; con++) {

            PrefParameters parameters = new PrefParameters(nbNodes, sparisity);
            IRule q = query;

            CacheManager.setupCaching();

            final String queryPredicate = q.getHead().iterator().next().getAtom().getPredicate()
                    .getPredicateSymbol();

            // Setup reporting
            final JoDSReporter rep = JoDSReporter.getInstance(true);
            JoDSReporter.setupReporting();
            JoDSReporter.setQuery(queryPredicate);
            JoDSReporter.setTest("test" + con);

            rep.setValue(URewMetric.DEPGRAPH_TIME, posDepTime);
            LOGGER.info("Processing query: ".concat(q.toString()));
            final long overallTime = System.currentTimeMillis();
            final Set<IRule> rewriting = rewriter.getRewriting(q, tgds, rewrittenConstraints, deps, exprs);
            rep.setValue(URewMetric.REW_TIME, System.currentTimeMillis() - overallTime);
            rep.setValue(URewMetric.REW_SIZE, (long) rewriting.size());

            rep.setValue(URewMetric.REW_CNS_TIME, ncRewTime);

            IRelation result = getRelation(rewriting, parameters, ndmRewriter);
            // CONSTRUCT graph
            long constPrefGraphTime = System.currentTimeMillis();
            final PreferencesGraph prefGraph = PreferenceGenerator
                    .generatePreferenceGraph(parameters.getSparsity(), result);
            System.out.println("Gen" + prefGraph.getEdgesSize());
            rep.setValue(URewMetric.PREFGRAPH_CONST_SIZE_V, (long) prefGraph.getVertexesSize());
            rep.setValue(URewMetric.PREFGRAPH_CONST_SIZE_E, (long) prefGraph.getEdgesSize());
            constPrefGraphTime = System.currentTimeMillis() - constPrefGraphTime;
            rep.setValue(URewMetric.PREFGRAPH_CONST_TIME, constPrefGraphTime);

            // TRANSITIVE graph
            long transitiveClosureTime = System.currentTimeMillis();
            //TransitiveClosure c = TransitiveClosure.INSTANCE;
            //c.closeSimpleDirectedGraph(prefGraph.g);
            transitiveClosureTime = System.currentTimeMillis() - transitiveClosureTime;
            rep.setValue(URewMetric.TRANSITIVE_CLOSURE_TIME, transitiveClosureTime);
            rep.setValue(URewMetric.PREFGRAPH_TRA_SIZE_V, (long) prefGraph.getVertexesSize());
            rep.setValue(URewMetric.PREFGRAPH_TRA_SIZE_E, (long) prefGraph.getEdgesSize());
            System.out.println("Trans" + prefGraph.getEdgesSize() + "-" + transitiveClosureTime);

            PreferencesGraph prefMerged = null;
            Map<ITuple, Integer> ranks = null;
            // Merge Graph graph
            for (MergingStrategy strategyQA : str) {
                JoDSReporter.setStrategy(strategyQA);
                long mergeOperatorTime = System.currentTimeMillis();
                if (strategyQA == MergingStrategy.PREFS_GEN) {
                    double t = 0.3;//randInt(509, 761)/100.0;
                    mergeOperatorTime = System.currentTimeMillis();
                    prefMerged = CombinationAlgorithms.combPrefsGen(prefGraph, probModel, t);
                    mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime;
                } else {
                    if (strategyQA == MergingStrategy.PREFS_PT) {
                        mergeOperatorTime = System.currentTimeMillis();
                        double p = 0.5;//randInt(383, 887)/100.0;
                        prefMerged = CombinationAlgorithms.combPrefsPT(prefGraph, probModel, p);
                        mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime;
                    } else {
                        if (strategyQA == MergingStrategy.PREFS_RANK) {
                            mergeOperatorTime = System.currentTimeMillis();
                            ranks = CombinationAlgorithms.combPrefsRank(prefGraph, probModel, Function.Max);
                            mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime;
                        } else {
                            if (strategyQA == MergingStrategy.PREFS_SORT) {
                                mergeOperatorTime = System.currentTimeMillis();
                                prefMerged = CombinationAlgorithms.combPrefsSort(prefGraph, probModel);
                                mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime;

                            }
                        }
                    }
                }
                if (prefMerged != null) {
                    rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_V, (long) prefMerged.getVertexesSize());
                    rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_E, (long) prefMerged.getEdgesSize());
                } else {
                    rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_V, (long) 0);
                    rep.setValue(URewMetric.PREFGRAPH_TOPK_SIZE_E, (long) 0);
                }
                System.out.print("test" + con + strategyQA + "\n");
                for (int k = 5; k < 10; k = k + 5) {
                    JoDSReporter.setK(k);
                    rep.setValue(URewMetric.PREFGRAPH_MERGE_TIME, (long) mergeOperatorTime);
                    long topKTime = System.currentTimeMillis();
                    List<ITuple> topk = null;
                    if (strategyQA == MergingStrategy.PREFS_RANK) {

                        topk = TopKAlgorithms.topkPrefsRank(ranks, k);
                    } else {
                        topk = TopKAlgorithms.getTopK(prefMerged, k);
                    }
                    topKTime = System.currentTimeMillis() - topKTime;
                    rep.setValue(URewMetric.PREFGRAPH_TOPK_TIME, topKTime);

                    int sizeAnswer = (topk != null) ? topk.size() : 0;
                    rep.setValue(URewMetric.ANSWER_SIZE, (long) sizeAnswer);
                    sizeSummaryWriter.writeNext(rep.getSummarySizeMetrics());
                    timeSummaryWriter.writeNext(rep.getSummaryTimeMetrics());
                    sizeSummaryWriter.flush();
                    timeSummaryWriter.flush();
                }
            }
        }

    }

    sizeSummaryWriter.close();
    timeSummaryWriter.close();

}

From source file:com.bluexml.side.util.deployer.war.DirectWebAppsDeployer.java

public File getWebAppXMLFile() {
    String path = FilenameUtils.separatorsToSystem("/WEB-INF/web.xml");
    return new File(getDeployedWebbAppFolder().getAbsolutePath() + path);
}

From source file:com.bluexml.side.util.deployer.war.DirectWebAppsDeployer.java

public File getIncrementalLastDeployedFlag() {
    String path = FilenameUtils.separatorsToSystem("/META-INF/lastDeployed.txt");
    return new File(getDeployedWebbAppFolder().getAbsolutePath() + path);
}

From source file:com.pieframework.model.repository.ModelStore.java

public static String getModelDir(String query, Configuration config) {
    // Load the model based on the query
    System tmp = new System();
    String modelString = config.getCurrentModels();
    String modelName = PIEID.getId(query, tmp);
    String modelIdVersion = modelName + File.separatorChar
            + config.getCurrentModelVersion(modelName, modelString);
    String modelDir = FilenameUtils.separatorsToSystem(config.getData()) + modelIdVersion;

    return modelDir;
}

From source file:au.org.ala.delta.io.OutputFileSelector.java

public void setImageDirectory(String directoryName) {
    _imageDirectory = FilenameUtils.separatorsToSystem(directoryName);
}

From source file:com.xyphos.vmtgen.GUI.java

private void generateVMT() {
    if (-1 == lstFiles.getSelectedIndex()) {
        return;/*  w w  w.java2  s.  c o m*/
    }

    String value = lstFiles.getSelectedValue().toString();
    String path = FilenameUtils
            .separatorsToSystem(FilenameUtils.concat(workPath, FilenameUtils.getBaseName(value) + ".VMT"));

    File fileVMT = new File(path);
    try (PrintWriter out = new PrintWriter(fileVMT, "UTF-8")) {
        value = (0 == cmbShader.getSelectedIndex()) ? txtShader.getText()
                : cmbShader.getSelectedItem().toString();

        // write the shader
        out.printf("\"%s\"%n{%n", value);

        writeSpinner(out, nudAlpha, 1F, "$alpha", 4);
        writeSpinner(out, nudEnvMapContrast, 0F, "$envMapContrast", 3);
        writeSpinner(out, nudEnvMapContrast, 0F, "$envMapSaturation", 2);
        writeSpinner(out, nudEnvMapFrame, 0, "$envMapFrame", 3);

        // write surfaces
        int index = cmbSurface1.getSelectedIndex();
        if (0 != index) {
            value = (1 == index) ? txtSurface1.getText() : cmbSurface1.getSelectedItem().toString();

            writeKeyValue(true, out, "$surfaceProp", value, 3);
        }

        index = cmbSurface2.getSelectedIndex();
        if (0 != index) {
            value = (1 == index) ? txtSurface2.getText() : cmbSurface2.getSelectedItem().toString();

            writeKeyValue(true, out, "$surfaceProp2", value, 3);
        }

        writeKeyValue(!(value = txtKeywords.getText()).isEmpty(), out, "%keywords", value, 3);

        writeKeyValue(!(value = txtToolTexture.getText()).isEmpty(), out, "%toolTexture", value, 3);
        writeKeyValue(!(value = txtBaseTexture1.getText()).isEmpty(), out, "$baseTexture", value, 3);
        writeKeyValue(!(value = txtBaseTexture2.getText()).isEmpty(), out, "$baseTexture2", value, 3);
        writeKeyValue(!(value = txtDetailTexture.getText()).isEmpty(), out, "$detail", value, 4);
        writeKeyValue(!(value = txtBumpMap1.getText()).isEmpty(), out, "$bumpMap", value, 3);
        writeKeyValue(!(value = txtBumpMap2.getText()).isEmpty(), out, "$bumpMap2", value, 3);
        writeKeyValue(!(value = txtEnvMap.getText()).isEmpty(), out, "$envMap", value, 3);
        writeKeyValue(!(value = txtEnvMapMask.getText()).isEmpty(), out, "$envMapMask", value, 3);
        writeKeyValue(!(value = txtNormalMap.getText()).isEmpty(), out, "$normalMap", value, 3);
        writeKeyValue(!(value = txtDuDvMap.getText()).isEmpty(), out, "$DuDvMap", value, 3);

        value = "1";
        writeKeyValue(chkFlagAdditive.isSelected(), out, "$additive", value, 3);
        writeKeyValue(chkFlagAlphaTest.isSelected(), out, "$alphaTest", value, 3);
        writeKeyValue(chkFlagIgnoreZ.isSelected(), out, "$ignoreZ", value, 3);
        writeKeyValue(chkFlagNoCull.isSelected(), out, "$noCull", value, 4);
        writeKeyValue(chkFlagNoDecal.isSelected(), out, "$noDecal", value, 3);
        writeKeyValue(chkFlagNoLOD.isSelected(), out, "$noLOD", value, 3);
        writeKeyValue(chkFlagPhong.isSelected(), out, "$phong", value, 4);
        writeKeyValue(chkFlagSelfIllum.isSelected(), out, "$selfIllum", value, 3);
        writeKeyValue(chkFlagTranslucent.isSelected(), out, "$translucent", value, 3);
        writeKeyValue(chkFlagVertexAlpha.isSelected(), out, "$vertexAlpha", value, 3);
        writeKeyValue(chkFlagVertexColor.isSelected(), out, "$vertexColor", value, 3);

        writeKeyValue(chkCompileClip.isSelected(), out, "%compileClip", value, 3);
        writeKeyValue(chkCompileDetail.isSelected(), out, "%compileDetail", value, 3);
        writeKeyValue(chkCompileFog.isSelected(), out, "%compileFog", value, 3);
        writeKeyValue(chkCompileHint.isSelected(), out, "%compileHint", value, 3);
        writeKeyValue(chkCompileLadder.isSelected(), out, "%compileLadder", value, 3);
        writeKeyValue(chkCompileNoDraw.isSelected(), out, "%compileNoDraw", value, 3);
        writeKeyValue(chkCompileNoLight.isSelected(), out, "%compileNoLight", value, 3);
        writeKeyValue(chkCompileNonSolid.isSelected(), out, "%compileNonSolid", value, 2);
        writeKeyValue(chkCompileNpcClip.isSelected(), out, "%compileNpcClip", value, 3);
        writeKeyValue(chkCompilePassBullets.isSelected(), out, "%compilePassBullets", value, 2);
        writeKeyValue(chkCompilePlayerClip.isSelected(), out, "%compilePlayerClip", value, 2);
        writeKeyValue(chkCompilePlayerControlClip.isSelected(), out, "%compilePlayerControlClip", value, 2);
        writeKeyValue(chkCompileSkip.isSelected(), out, "%compileSkip", value, 3);
        writeKeyValue(chkCompileSky.isSelected(), out, "%compileSky", value, 3);
        writeKeyValue(chkCompileTrigger.isSelected(), out, "%compileTrigger", value, 3);

        // animation code
        if (animated) {
            value = nudFrameRate.getValue().toString();
            out.printf("%n\t\"proxies\"%n");
            out.printf("\t{%n");
            out.printf("\t\t\"animatedTexture\"%n");
            out.printf("\t\t{%n");
            out.printf("\t\t\t\"animatedTextureVar\"\t\t\"$baseTexture\"%n");
            out.printf("\t\t\t\"animatedTextureFrameNumVar\"\t\"$frame\"%n");
            out.printf("\t\t\t\"animatedTextureFrameRate\" \t\"%s\"%n", value);
            out.printf("\t\t}%n");
            out.printf("\t}%n");
        }

        out.print("}");
        out.flush();

        try {
            URL url = this.getClass().getClassLoader().getResource("blip.wav");
            AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
            clipBlip = AudioSystem.getClip();
            clipBlip.open(audioIn);
            clipBlip.start();
        } catch (LineUnavailableException | UnsupportedAudioFileException | IOException ex) {
            logger.log(Level.SEVERE, null, ex);
        }

    } catch (FileNotFoundException | UnsupportedEncodingException ex) {
        logger.log(Level.SEVERE, null, ex);
    }

}

From source file:com.googlecode.fascinator.api.PluginManager.java

private static File getPathFile(String subDir) {
    String homePath = System.getenv("FASCINATOR_HOME");
    if (homePath == null) {
        homePath = DEFAULT_PATH;/*from  w w w.  j a v a2  s.c  o m*/
    }

    String path = System.getProperty(SYSTEM_KEY, homePath);

    String filePath = path + File.separator + FilenameUtils.separatorsToSystem(subDir);
    return new File(filePath);
}

From source file:fragment.web.AbstractConnectorControllerTest.java

@Test
public void testUploadServiceInstanceLogo() throws Exception {

    Configuration configuration = configurationService
            .locateConfigurationByName(Names.com_citrix_cpbm_portal_settings_images_uploadPath);
    configuration.setValue("src\\test\\resources");
    configurationService.update(configuration);
    ServiceInstance serviceInstance = serviceInstanceDao.find(1L);
    Assert.assertEquals(null, serviceInstance.getImagePath());
    MultipartFile logo = new MockMultipartFile("ServiceInstanceLogo.jpeg", "ServiceInstanceLogo.jpeg", "byte",
            "ServiceInstance".getBytes());
    ServiceInstanceLogoForm form = new ServiceInstanceLogoForm(serviceInstance);
    form.setLogo(logo);//  w ww. jav a  2  s  . co m
    BindingResult result = validate(form);
    HttpServletRequest request = new MockHttpServletRequest();
    map = new ModelMap();
    String resultString = controller.uploadServiceInstanceLogo(form, result, request, map);
    Assert.assertNotNull(resultString);
    Assert.assertEquals("success", resultString);
    serviceInstance = serviceInstanceDao.find(1L);
    Assert.assertEquals(FilenameUtils.separatorsToSystem("serviceInstance\\1\\ServiceInstanceLogo.jpeg"),
            serviceInstance.getImagePath());
}