<commit_before>package com.jme.scene.model.XMLparser;

import com.jme.util.BinaryFileReader;
import com.jme.scene.Node;
import com.jme.scene.Controller;
import com.jme.scene.TriMesh;
import com.jme.scene.model.Face;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.system.JmeException;

import java.net.URL;
import java.io.OutputStream;
import java.io.IOException;
import java.io.File;


/**
 * Started Date: Jun 14, 2004
 * 
 * @author <NAME>
 */
public class Md2ToXML {

    Node nodeToReturn;
    /**
     * This class's only public function.  It creates a node from a .md2 file and then writes that node to the given
     * OutputStream in XML format
     * @param file A URL pointing to the .md2 file
     * @param o The stream to write it's XML equivalent to
     * @throws java.io.IOException If anything funky goes wrong with reading information
     */
    public void writeFiletoStream(URL file,OutputStream o) throws IOException {
        new XMLWriter(o).writeScene(new Md2ConverterCopy(file));
    }

    /**
     * 95% a Copy/paste of the .md2 loader by Mark Powell modifyed for efficiency (use of empty TriMesh) and
     * VertexController as well as a few tiny adjustments here and there on memory.
     *
     * @author <NAME>
     * @author <NAME>
     */
    private class Md2ConverterCopy extends TriMesh{
        private BinaryFileReader bis = null;

        private Header header;

        private Vector2f[] texCoords;
        private Md2Face[] triangles;
        private Md2Frame[] frames;

        //holds each keyframe.
        private TriMesh[] triMesh;
        //controller responsible for handling keyframe morphing.
        private KeyframeController controller;

<commit_msg>Adds null checking<commit_after>package com.jme.scene.model.XMLparser;

import com.jme.util.BinaryFileReader;
import com.jme.scene.Node;
import com.jme.scene.Controller;
import com.jme.scene.TriMesh;
import com.jme.scene.model.Face;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.system.JmeException;

import java.net.URL;
import java.io.*;


/**
 * Started Date: Jun 14, 2004
 * 
 * @author <NAME>
 */
public class Md2ToXML {

    Node nodeToReturn;
    /**
     * This class's only public function.  It creates a node from a .md2 file and then writes that node to the given
     * OutputStream in XML format
     * @param file A URL pointing to the .md2 file
     * @param o The stream to write it's XML equivalent to
     * @throws java.io.IOException If anything funky goes wrong with reading information
     */
    public void writeFiletoStream(URL file,Writer o) throws IOException {
        if (file==null)
            throw new NullPointerException("Unable to load null URL streams");
        new XMLWriter(o).writeScene(new Md2ConverterCopy(file));
    }

    /**
     * 95% a Copy/paste of the .md2 loader by Mark Powell modifyed for efficiency (use of empty TriMesh) and
     * VertexController as well as a few tiny adjustments here and there on memory.
     *
     * @author <NAME>
     * @author <NAME>
     */
    private class Md2ConverterCopy extends TriMesh{
        private BinaryFileReader bis = null;

        private Header header;

        private Vector2f[] texCoords;
        private Md2Face[] triangles;
        private Md2Frame[] frames;

        //holds each keyframe.
        private TriMesh[] triMesh;
        //controller responsible for handling keyframe morphing.
        private KeyframeController controller;


{'fraction_non_alphanumeric': 0.08442669709070165, 'fraction_numerical': 0.010838562464346835, 'mean_word_length': 2.927211646136618, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2360108', 'n_tokens_mistral': 1053, 'n_tokens_neox': 997, 'n_words': 354}