<commit_before>package org.pentaho.di.shared;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.vfs.FileObject;
import org.pentaho.di.cluster.ClusterSchema;
import org.pentaho.di.cluster.SlaveServer;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.logging.LogWriter;
import org.pentaho.di.core.variables.KettleVariables;
import org.pentaho.di.core.vfs.KettleVFS;
import org.pentaho.di.core.xml.XMLHandler;
import org.pentaho.di.partition.PartitionSchema;
import org.pentaho.di.trans.step.StepMeta;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;


/**
 * Based on a piece of XML, this factory will give back a list of objects.
 * In other words, it does XML de-serialisation
 * 
 * @author Matt
 *
 */
public class SharedObjects
{
    private class SharedEntry
    {
        public String className;
        public String objectName;
        
        /**
         * @param className
         * @param objectName
         */
        public SharedEntry(String className, String objectName)
        {
            this.className = className;
            this.objectName = objectName;
        }
        
        public boolean equals(Object obj)
        {
            SharedEntry sharedEntry = (SharedEntry) obj;
            return className.equals(sharedEntry.className) && objectName.equals(objectName);
        }
        
        public int hashCode()
        {
            return className.hashCode() ^ objectName.hashCode();
        }
        
    }
    private static final String XML_TAG = "sharedobjects";
    
    private String filename;

    private Map<SharedEntry, SharedObjectInterface> objectsMap;

    public SharedObjects(String sharedObjectsFile) throws KettleXMLException
    {
        try
        {
            this.filename = createFilename(sharedObjectsFile);
            this.objectsMap = new Hashtable<SharedEntry, SharedObjectInterface>();
    
            // Extra information
            FileObject file = KettleVFS.getFileObject(filename);
            
            // If we have a shared file, load the content, otherwise, just keep this one empty
            if (file.exists()) 
            {
                LogWriter.getInstance().logDetailed("SharedObjects", "Reading the shared objects file ["+file+"]");
                Document document = XMLHandler.loadXMLFile(file);
                Node sharedObjectsNode = XMLHandler.getSubNode(document, XML_TAG);
                if (sharedObjectsNode!=null)
                {
                    List<SlaveServer> privateSlaveServers = new ArrayList<SlaveServer>();
                    List<DatabaseMeta> privateDatabases = new ArrayList<DatabaseMeta>();
                    
                    NodeList childNodes = sharedObjectsNode.getChildNodes();
                    // First load databases & slaves
                    //
                    for (int i=0;i<childNodes.getLength();i++)
                    {
                        Node node = childNodes.item(i);
                        String nodeName = node.getNodeName();
                        
                        SharedObjectInterface isShared = null;<commit_msg>JDK 1.5 changes: Collection parameters and generics<commit_after>package org.pentaho.di.shared;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.vfs.FileObject;
import org.pentaho.di.cluster.ClusterSchema;
import org.pentaho.di.cluster.SlaveServer;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.logging.LogWriter;
import org.pentaho.di.core.variables.KettleVariables;
import org.pentaho.di.core.vfs.KettleVFS;
import org.pentaho.di.core.xml.XMLHandler;
import org.pentaho.di.partition.PartitionSchema;
import org.pentaho.di.trans.step.StepMeta;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;


/**
 * Based on a piece of XML, this factory will give back a list of objects.
 * In other words, it does XML de-serialisation
 * 
 * @author Matt
 *
 */
public class SharedObjects
{
    private class SharedEntry
    {
        public String className;
        public String objectName;
        
        /**
         * @param className
         * @param objectName
         */
        public SharedEntry(String className, String objectName)
        {
            this.className = className;
            this.objectName = objectName;
        }
        
        public boolean equals(Object obj)
        {
            SharedEntry sharedEntry = (SharedEntry) obj;
            return className.equals(sharedEntry.className) && objectName.equals(objectName);
        }
        
        public int hashCode()
        {
            return className.hashCode() ^ objectName.hashCode();
        }
        
    }
    private static final String XML_TAG = "sharedobjects";
    
    private String filename;


    private Map<SharedEntry, SharedObjectInterface> objectsMap;

    public SharedObjects(String sharedObjectsFile) throws KettleXMLException
    {
        try
        {
            this.filename = createFilename(sharedObjectsFile);
            this.objectsMap = new Hashtable<SharedEntry, SharedObjectInterface>();
    
            // Extra information
            FileObject file = KettleVFS.getFileObject(filename);
            
            // If we have a shared file, load the content, otherwise, just keep this one empty
            if (file.exists()) 
            {
                LogWriter.getInstance().logDetailed("SharedObjects", "Reading the shared objects file ["+file+"]");
                Document document = XMLHandler.loadXMLFile(file);
                Node sharedObjectsNode = XMLHandler.getSubNode(document, XML_TAG);
                if (sharedObjectsNode!=null)
                {
                    List<SharedObjectInterface> privateSlaveServers = new ArrayList<SharedObjectInterface>();
                    List<SharedObjectInterface> privateDatabases = new ArrayList<SharedObjectInterface>();

                    
                    NodeList childNodes = sharedObjectsNode.getChildNodes();
                    // First load databases & slaves
                    //
                    for (int i=0;i<childNodes.getLength();i++)
                    {
                        Node node = childNodes.item(i);
                        String nodeName = node.getNodeName();
                        
                        SharedObjectInterface isShared = null;
{'fraction_non_alphanumeric': 0.0887877063175868, 'fraction_numerical': 0.0014228799089356858, 'mean_word_length': 2.1920980926430516, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7579853', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1788, 'n_words': 417}