<commit_before>package com.rho.audiocapture;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.graphics.Rect;
import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;
import android.media.MediaRecorder.OnInfoListener;
import android.os.Environment;

import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.api.IMethodResult;
import com.rhomobile.rhodes.extmanager.IRhoConfig;
import com.rhomobile.rhodes.extmanager.IRhoExtManager;
import com.rhomobile.rhodes.extmanager.IRhoExtension;
import com.rhomobile.rhodes.extmanager.IRhoWebView;
import com.rhomobile.rhodes.extmanager.RhoExtManager;

public class AudioCapture extends AudioCaptureBase implements IAudioCapture {
    
    private static final String TAG = AudioCapture.class.getSimpleName();
    
    private IMethodResult storedMethodResult=null;
    
    private String filepath=null;
    
    private Map<String, String> mActualPropertyMap = new HashMap<String, String>();
    
     private boolean stopApi=false;
    
    private AudioCaptureExt ext=null;
    private void initWithDefaultValues()
    {
    	ext=new AudioCaptureExt();
    	RhoExtManager.getInstance().registerExtension("audiocapture", ext);
    	
    	if(mActualPropertyMap.size()==0)
    	{
    		mActualPropertyMap.put("maxDuration", "20000");
    								
        	//mActualPropertyMap.put("fileName", "AudioCapture");
    		mActualPropertyMap.put("fileName", "");
        	mActualPropertyMap.put("encoder","AAC");
        	mActualPropertyMap.put("source", "mic");
    	}
    	
    }
    
   @Override
    public void getAllProperties(IMethodResult result) {
    	
    	//super.getAllProperties(result);
    	
    	
    	Map<String, Object> props = new HashMap<String, Object>();
    	Iterator entries = mActualPropertyMap.entrySet().iterator();
    	while (entries.hasNext()) {
    	  Entry thisEntry = (Entry) entries.next();
    	  String key = (String) thisEntry.getKey();
    	  Object value = thisEntry.getValue();
    	  props.put(key, value);
    	  
    	}
    	result.set(props);
    }
    
    @Override
    public void getEncoder(IMethodResult result) {
    	
    	//super.getEncoder(result);
    	
    	result.set(mActualPropertyMap.get("encoder"));
    	
    	
    	
    }
    
    @Override
    public void getFileName(IMethodResult result) {
    	
    	//super.getFileName(result);
    	
    	result.set(mActualPropertyMap.get("fileName"));
    }
    
    @Override
    public void getMaxDuration(IMethodResult result) {
    	
    	//super.getMaxDuration(result);
    	try{
    	result.set(Integer.parseInt(mActualPropertyMap.get("maxDuration")));
    	}
    	catch(NumberFormatException e)
    	{
    		System.out.println("getMaxDuration,error="+e.getMessage());
    		Logger.E(TAG, "Error in getMaxDuration= "+e.getMessage());
    		result.set(0);
    	}
    }
    
    @Override
    public void getProperties(List<String> arrayofNames, IMethodResult result) {
    	
    	//super.getProperties(arrayofNames, result);
    	
    	Map<String, Object> props = new HashMap<String, Object>();
        for (String name: arrayofNames)
        {
        	if(name.equalsIgnoreCase("maxDuration"))
        	{
        		try{
        		props.put(name,Integer.parseInt(mActualPropertyMap.get(name)) );
        		}
        		catch(NumberFormatException e)
        		{
        			System.out.println("getProperties()..error="+e.getMessage());
        			Logger.E(TAG, "Error in getProperties= "+e.getMessage());
        			props.put(name,0 );
        		}
        	}
        	else
                props.put(name,mActualPropertyMap.get(name) );
        }
        result.set(props);
    }
    
    @Override
    public void getProperty(String propertyName, IMethodResult result) {
    	
    	//super.getProperty(propertyName, result);
    	
    	try{
    	if(propertyName.equalsIgnoreCase("maxDuration"))
    		result.set(Integer.parseInt(mActualPropertyMap.get(propertyName)));
    	else
    	result.set(mActualPropertyMap.get(propertyName));
    	}
    	catch(NumberFormatException e)
    	{
    		Logger.E(TAG, "Error getProperty="+e.getMessage());
    		result.set(0);
    	}
    }<commit_msg>Update AudioCapture.java<commit_after>package com.rho.audiocapture;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.graphics.Rect;
import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;
import android.media.MediaRecorder.OnInfoListener;
import android.os.Environment;

import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.api.IMethodResult;
import com.rhomobile.rhodes.extmanager.IRhoConfig;
import com.rhomobile.rhodes.extmanager.IRhoExtManager;
import com.rhomobile.rhodes.extmanager.IRhoExtension;
import com.rhomobile.rhodes.extmanager.IRhoWebView;
import com.rhomobile.rhodes.extmanager.RhoExtManager;

public class AudioCapture extends AudioCaptureBase implements IAudioCapture {
    
    private static final String TAG = AudioCapture.class.getSimpleName();
    
    private IMethodResult storedMethodResult=null;
    
    private String filepath=null;
    
    private Map<String, String> mActualPropertyMap = new HashMap<String, String>();
    
     private boolean stopApi=false;
    
    private AudioCaptureExt ext=null;
    private void initWithDefaultValues()
    {
    	ext=new AudioCaptureExt();
    	RhoExtManager.getInstance().registerExtension("audiocapture", ext);
    	
    	if(mActualPropertyMap.size()==0)
    	{
    		mActualPropertyMap.put("maxDuration", "20000");
    								
        	//mActualPropertyMap.put("fileName", "AudioCapture");
    		mActualPropertyMap.put("fileName", "");
        	mActualPropertyMap.put("encoder","AAC");
        	mActualPropertyMap.put("source", "mic");
    	}
    	
    }
    
   @Override
    public void getAllProperties(IMethodResult result) {
    	
    	//super.getAllProperties(result);
    	
    	
    	Map<String, Object> props = new HashMap<String, Object>();
    	Iterator entries = mActualPropertyMap.entrySet().iterator();
    	while (entries.hasNext()) {
    	  Entry thisEntry = (Entry) entries.next();
    	  String key = (String) thisEntry.getKey();
    	  Object value = thisEntry.getValue();
    	  props.put(key, value);
    	  
    	}
    	result.set(props);
    }
    
    @Override
    public void getEncoder(IMethodResult result) {
    	
    	//super.getEncoder(result);
    	
    	result.set(mActualPropertyMap.get("encoder"));
    	
    	
    	
    }
    
    @Override
    public void getFileName(IMethodResult result) {
    	
    	//super.getFileName(result);
    	
    	result.set(mActualPropertyMap.get("fileName"));
    }
    
    @Override
    public void getMaxDuration(IMethodResult result) {
    	
    	//super.getMaxDuration(result);
    	try{
    	result.set(Integer.parseInt(mActualPropertyMap.get("maxDuration")));
    	}
    	catch(NumberFormatException e)
    	{
    		System.out.println("getMaxDuration,error="+e.getMessage());
    		Logger.E(TAG, "Error in getMaxDuration= "+e.getMessage());
    		result.set(0);
    	}
    }
    
    @Override
    public void getProperties(List<String> arrayofNames, IMethodResult result) {
    	
    	//super.getProperties(arrayofNames, result);
    	
    	Map<String, Object> props = new HashMap<String, Object>();
        for (String name: arrayofNames)
        {
        	if(name.equalsIgnoreCase("maxDuration"))
        	{
        		try{
        		props.put(name,Integer.parseInt(mActualPropertyMap.get(name)) );
        		}
        		catch(NumberFormatException e)
        		{
        			System.out.println("getProperties()..error="+e.getMessage());
        			Logger.E(TAG, "Error in getProperties= "+e.getMessage());
        			props.put(name,0 );
        		}
        	}
        	else
                props.put(name,mActualPropertyMap.get(name) );
        }
        result.set(props);
    }
    
    @Override
    public void getProperty(String propertyName, IMethodResult result) {
    	
    	//super.getProperty(propertyName, result);
    	
    /*	try{
    	if(propertyName.equalsIgnoreCase("maxDuration"))
    		result.set(Integer.parseInt(mActualPropertyMap.get(propertyName)));
    	else
    	result.set(mActualPropertyMap.get(propertyName));
    	}
    	catch(NumberFormatException e)
    	{
    		Logger.E(TAG, "Error getProperty="+e.getMessage());
    		result.set(0);
    	}*/
    	
    	
    	result.set(mActualPropertyMap.get(propertyName));
    }
{'fraction_non_alphanumeric': 0.11647597254004577, 'fraction_numerical': 0.002059496567505721, 'mean_word_length': 2.852357866901719, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6350663', 'n_tokens_mistral': 2783, 'n_tokens_neox': 2791, 'n_words': 414}