<commit_before>/**
 * Get more info at : www.jrebirth.org .
 * Copyright JRebirth.org © 2011-2013
 * Contact : <EMAIL>
 * 
 * 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.
 */
package org.jrebirth.core.resource.fxml;

import java.net.URL;

import org.jrebirth.core.resource.factory.AbstractResourceBuilder;
import org.jrebirth.core.ui.fxml.FXMLComponent;
import org.jrebirth.core.ui.fxml.FXMLUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * The class <strong>StyleSheetBuilder</strong>.
 * 
 * Class used to manage style sheet with weak reference.
 * 
 * @author <NAME>
 */
public final class FXMLBuilder extends AbstractResourceBuilder<FXMLItem, FXMLParams, FXMLComponent> {

    /** The class logger. */
    private static final Logger LOGGER = LoggerFactory.getLogger(FXMLBuilder.class);

    /** The css file extension. */
    private static final String FXML_EXT = ".fxml";

    /**
     * {@inheritDoc}
     */
    @Override
    protected FXMLComponent buildResource(final FXMLParams fp) {
        FXMLComponent component = null;
        if (fp instanceof FXML) {
            // Build the requested font
            component = buildFXMLComponent((FXML) fp);
        }
        if (component == null) {
            // Return the default ...

        }
        return component;
    }

    /**
     * Build a FXML component taht embed a node and its FXML controller.
     * 
     * @param fxmlParam the fxmlparams
     * 
     * @return the JavaFX image object
     */
    private FXMLComponent buildFXMLComponent(final FXML fxmlParam) {

        final StringBuilder sb = new StringBuilder();

        // sb.append(JRebirthParameters.STYLE_FOLDER.get()).append(Resources.PATH_SEP);
        //
        // if (!fp.path().isEmpty()) {
        // sb.append(fp.path()).append(Resources.PATH_SEP);
        // }
        //
        // sb.append(fp.name());
        //
        // if (!fp.name().endsWith(FXML_EXT)) {
        // sb.append(FXML_EXT);
        // }

        return FXMLUtils.loadFXML(null, sb.toString());
    }

    /**
     * Get a style sheet URL.
     * 
     * @param styleSheetPath the path of the style sheet, path must be separated by '/'<commit_msg>Bug fix for FXML workaround<commit_after>/**
 * Get more info at : www.jrebirth.org .
 * Copyright JRebirth.org © 2011-2013
 * Contact : <EMAIL>
 * 
 * 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.
 */
package org.jrebirth.core.resource.fxml;

import org.jrebirth.core.resource.factory.AbstractResourceBuilder;
import org.jrebirth.core.ui.fxml.FXMLComponent;
import org.jrebirth.core.ui.fxml.FXMLUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;

/**
 * The class <strong>StyleSheetBuilder</strong>.
 * 
 * Class used to manage style sheet with weak reference.
 * 
 * @author <NAME>
 */
public final class FXMLBuilder extends AbstractResourceBuilder<FXMLItem, FXMLParams, FXMLComponent> {

    /** The class logger. */
    private static final Logger LOGGER = LoggerFactory.getLogger(FXMLBuilder.class);

    /** The css file extension. */
    private static final String FXML_EXT = ".fxml";

    /**
     * {@inheritDoc}
     */
    @Override
    protected FXMLComponent buildResource(final FXMLParams fp) {
        FXMLComponent component = null;
        if (fp instanceof FXML) {
            // Build the requested font
            component = buildFXMLComponent((FXML) fp);
        }
        if (component == null) {
            // Return the default ...

        }
        return component;
    }

    /**
     * Build a FXML component taht embed a node and its FXML controller.
     * 
     * @param fxmlParam the fxmlparams
     * 
     * @return the JavaFX image object
     */
    private FXMLComponent buildFXMLComponent(final FXML fxmlParam) {

        final StringBuilder sb = new StringBuilder();

        // sb.append(JRebirthParameters.STYLE_FOLDER.get()).append(Resources.PATH_SEP);
        //
        // if (!fp.path().isEmpty()) {
        // sb.append(fp.path()).append(Resources.PATH_SEP);
        // }
        //
        // sb.append(fp.name());
        //
        // if (!fp.name().endsWith(FXML_EXT)) {
        // sb.append(FXML_EXT);
        // }

        return FXMLUtils.loadFXML(null, fxmlParam.absolutePath(), fxmlParam.absoluteBundlePath());
    }

    /**
     * Get a style sheet URL.
     * 
     * @param styleSheetPath the path of the style sheet, path must be separated by '/'
{'fraction_non_alphanumeric': 0.10931768158473955, 'fraction_numerical': 0.005135730007336757, 'mean_word_length': 2.5640522875816996, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7395052', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1541, 'n_words': 473}