text:
package ryrycipe.controller;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ryrycipe.model.view.MaterialView;

import java.net.URL;
import java.util.ResourceBundle;
import java.util.regex.Pattern;

/**
 * Controller for the dialog used to select a number of material to include in the recipe.
 */
public class MaterialNumberDialogController implements Initializable {

    private final static Logger LOGGER = LoggerFactory.getLogger(MaterialNumberDialogController.class.getName());

    /**
     * {@link ImageView} of selected {@link MaterialView} to be introduced in the recipe
     */
    @FXML
    private ImageView materialImg;

    /**
     * {@link TextField} where the user enter the number of materials he wants.
     */
    @FXML
    private TextField nbMaterialField;

    /**
     * Number of materials needed for recipe component.
     */
    private int materialAmount;

    /**
     * Reference to the dialog's {@link Stage} to be enable to close it.
     */
    private Stage dialogStage;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        nbMaterialField.textProperty().addListener(((observable, oldValue, newValue) -> {
            Pattern pattern = Pattern.compile("^[0-9]+$");
            if (!newValue.isEmpty()){
                // Check if the new entered value is a number. If not set the oldValue
                if (!pattern.matcher(newValue).matches()) {
                    nbMaterialField.setText(oldValue);
                    return; // to not enter in following if statements
                }
                // Check if the user enters a '0' before other numbers to remove it.
                if (newValue.charAt(0) == '0' && newValue.length() > 1)
                    nbMaterialField.setText(newValue.substring(1));
            }

            // Check if the entered value does not exceed the number of needed materials
            if (!newValue.isEmpty() && Integer.valueOf(newValue) > materialAmount) {
                nbMaterialField.setText(String.valueOf(materialAmount));
            }
        }));
    }

    /**
     * Set the number of materials needed for a recipe a component and put it as default value in the
     * {@link MaterialNumberDialogController#nbMaterialField}
     *
     * @param amount Number of materials needed for a recipe a component.
     */
    public void setMaterialAmount(int amount) {
        this.materialAmount = amount;
        nbMaterialField.setText(String.valueOf(amount));
        nbMaterialField.selectNextWord();
    }

    /**
     * Close the dialog and update the corresponding RecipeComponent with the chosen MaterialView and number.
     * Note: Do nothing if no value is chosen.
     */
    @FXML
    private void handleOKBtn() {
        dialogStage.close();

        LOGGER.info("USer chose {} materials", nbMaterialField);
    }

    /**
     * Close the dialog when the user clicks the cancel button.
     */
    @FXML
    private void handleCancelBtn() {
        // Set TextField to '0' in order to remove potential numbers from the it before leaving the dialog
        nbMaterialField.setText("0");
        dialogStage.close();
    }

    @FXML
    private void handleEnterPressed(KeyEvent event) {
        if (event.getCode() == KeyCode.ENTER) {
            handleOKBtn();
        }
    }

    // -------------------- Accessors -------------------- //

    /**
     * Set the imageView with the selected MaterialView from {@link RecipeCreatorController#materialChooser}
     *
     * @param materialView {@link MaterialView}
     */
    public void setMaterialImage(MaterialView materialView) {
        this.materialImg.setImage(materialView.getImage());
    }

    public TextField getNbMaterialField() {
        return nbMaterialField;
    }

    public void setDialogStage(Stage dialogStage) {
        this.dialogStage = dialogStage;
    }
}


text:
package gov.nih.nci.cagrid.data.service.auditing;

import gov.nih.nci.cagrid.common.Utils;
import gov.nih.nci.cagrid.data.CqlSchemaConstants;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DateFormat;
import java.util.Date;
import java.util.Properties;

/**
 *  FileDataServiceAuditor
 *  A simple data service auditor which logs information to a file
 *
 * @author David Ervin
 *
 * @created May 21, 2007 9:53:51 AM
 * @version $Id: FileDataServiceAuditor.java,v 1.2 2007-05-25 19:39:00 dervin Exp $
 */
public class FileDataServiceAuditor extends DataServiceAuditor {

    public static final String AUDIT_FILE = "auditingFileName";
    public static final String DEFAULT_AUDIT_FILE = "dataServiceAuditing.log";
    public static final String PRINT_FULL_RESULTS = "printFullResults";
    public static final String DEFAULT_PRINT_FULL_RESULTS = Boolean.FALSE.toString();

    private BufferedWriter writer = null;

    public FileDataServiceAuditor() {
        super();
    }

    public Properties getDefaultConfigurationProperties() {
        Properties props = new Properties();
        props.setProperty(AUDIT_FILE, DEFAULT_AUDIT_FILE);
        return props;
    }

    public void auditQueryBegin(QueryBeginAuditingEvent event) {
        try {
            writeToLog("Query Begins at " + getCurrentTime() + "\n");
            writeToLog(getBaseEventInformation(event));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void auditQueryProcessingFailed(QueryProcessingFailedAuditingEvent event) {
        try {
            writeToLog("Query Processing Failed at " + getCurrentTime() + "\n");
            writeToLog(getBaseEventInformation(event));
            StringWriter exceptionStringWriter = new StringWriter();
            PrintWriter exceptionPrintWriter = new PrintWriter(exceptionStringWriter);
            event.getQueryProcessingException().printStackTrace(exceptionPrintWriter);
            writeToLog("\tException follows:\n");
            writeToLog(exceptionStringWriter.getBuffer().toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void auditQueryResults(QueryResultsAuditingEvent event) {
        try {
            boolean fullResults = Boolean.valueOf(
                getConfiguredProperties().getProperty(PRINT_FULL_RESULTS)).booleanValue();

            writeToLog("Query Results at " + getCurrentTime() + "\n");
            writeToLog(getBaseEventInformation(event));
            if (fullResults) {
                writeToLog("Query Results follow:\n");
                StringWriter resultsWriter = new StringWriter();
                try {
                    Utils.serializeObject(event.getResults(),
                        CqlSchemaConstants.CQL_RESULT_SET_QNAME, resultsWriter);
                } catch (Exception ex) {
                    resultsWriter.append("ERROR SERIALIZING CQL RESULTS: " + ex.getMessage());
                    ex.printStackTrace();
                }
                writeToLog(resultsWriter.getBuffer().toString());
            } else {
                String resultType = null;
                if (event.getResults().getAttributeResult() != null) {
                    resultType = "Attribute";
                } else if (event.getResults().getCountResult() != null) {
                    resultType = "Count";
                } else {
                    resultType = "Object";
                }
                writeToLog("Query Returned " + resultType + " results");
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void auditValidation(ValidationAuditingEvent event) {
        try {
            writeToLog("Validation Failed at " + getCurrentTime() + "\n");
            writeToLog(getBaseEventInformation(event));
            StringWriter exceptionStringWriter = new StringWriter();
            PrintWriter exceptionPrintWriter = new PrintWriter(exceptionStringWriter);
            if (event.getCqlStructureException() != null) {
                writeToLog("\tCQL Structure Validation failed:\n");
                event.getCqlStructureException().printStackTrace(exceptionPrintWriter);
            } else {
                writeToLog("\tDomain Validation failed:\n");
                event.getDomainValidityException().printStackTrace(exceptionPrintWriter);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    private String getCurrentTime() {
        return DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date());
    }

    private String getBaseEventInformation(BaseAuditingEvent event) {
        StringBuffer buff = new StringBuffer();
        buff.append("\t").append("Caller: ").append(event.getCallerId()).append("\n");
        StringWriter cqlWriter = new StringWriter();
        try {
            Utils.serializeObject(event.getQuery(), CqlSchemaConstants.CQL_QUERY_QNAME, cqlWriter);
        } catch (Exception ex) {
            cqlWriter.append("ERROR SERIALIZING QUERY: " + ex.getMessage());
            ex.printStackTrace();
        }
        buff.append("\t").append(cqlWriter.getBuffer().toString()).append("\n");
        return buff.toString();
    }

    private void writeToLog(String message) throws IOException {
        if (writer == null) {
            String outputFilename = getConfiguredProperties().getProperty(AUDIT_FILE);
            writer = new BufferedWriter(new FileWriter(outputFilename));
        }
        writer.write(message);
        writer.flush();
    }

    public void finalize() {
        try {
            if (writer != null) {
                writer.close();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

redpajama_set_name: RedPajamaGithub