<commit_before>/*
 * Copyright (C) 2010 Stanford University
 *
 * 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 edu.stanford.junction.props2;
import org.json.JSONObject;
import org.json.JSONException;
import java.util.*;
import edu.stanford.junction.api.activity.JunctionExtra;
import edu.stanford.junction.api.messaging.MessageHeader;
import edu.stanford.junction.extra.JSONObjWrapper;

public class PropDaemon extends Prop{
	
	static class AnyState implements IPropState{
		private String state;
		public AnyState(String state){
			this.state = state;
		}
		public IPropState applyOperation(JSONObject operation){ return this; }
		public JSONObject toJSON(){ 
			try{
				if(this.state == null){ 
					return new JSONObject("null"); 
				}
				else { 
					return new JSONObject(this.state); 
				}
			}
			catch(JSONException e){
				e.printStackTrace(System.err);
				return null;
			}
		}
		public IPropState copy(){ return new AnyState(this.state); }
	}

	public PropDaemon(String propName, IPropState state, long seqNum){
		super(propName, state, seqNum);
	}

	public PropDaemon(String propName){
		this(propName, new AnyState(null), 0);
	}

	@Override
	protected IPropState reifyState(JSONObject obj){
		return new AnyState(obj.toString());
	}

	@Override
	public IProp newFresh(){
		return new PropDaemon(this.propName);
	}

	/**
	 * Ignore state operations.
	 */
	@Override
	protected void handleReceivedOp(JSONObject opMsg){}

	@Override
	protected int helloInterval(){
		return 5000;
	}

	@Override
	protected int syncRequestInterval(){
		return 10000;
	}





	/**
	 * Conveniance runner for PropDaemon
	 * Expects two arguments: junction-url propName
	 */
	public static void main(String[] args){
		
	}


}<commit_msg>Add PropDaemon sketch, with main runner.<commit_after>/*
 * Copyright (C) 2010 Stanford University
 *
 * 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 edu.stanford.junction.props2;
import org.json.JSONObject;
import org.json.JSONException;
import java.util.*;
import edu.stanford.junction.api.activity.JunctionExtra;
import edu.stanford.junction.api.messaging.MessageHeader;
import edu.stanford.junction.extra.JSONObjWrapper;

public class PropDaemon extends Prop{
	
	static class AnyState implements IPropState{
		private String state;
		public AnyState(String state){
			this.state = state;
		}
		public IPropState applyOperation(JSONObject operation){ return this; }
		public JSONObject toJSON(){ 
			try{
				if(this.state == null){ 
					return new JSONObject("null"); 
				}
				else { 
					return new JSONObject(this.state); 
				}
			}
			catch(JSONException e){
				e.printStackTrace(System.err);
				return null;
			}
		}
		public IPropState copy(){ return new AnyState(this.state); }
	}

	public PropDaemon(String propName, IPropState state, long seqNum){
		super(propName, state, seqNum);
	}

	public PropDaemon(String propName){
		this(propName, new AnyState(null), 0);
	}

	@Override
	protected IPropState reifyState(JSONObject obj){
		return new AnyState(obj.toString());
	}

	@Override
	public IProp newFresh(){
		return new PropDaemon(this.propName);
	}

	/**
	 * Ignore state operations.
	 */
	@Override
	protected void handleReceivedOp(JSONObject opMsg){}

	@Override
	protected int helloInterval(){
		return 5000;
	}

	@Override
	protected int syncRequestInterval(){
		return 10000;
	}

	/**
	 * Conveniance runner for PropDaemon
	 * Expects two arguments: junction-url propName
	 */
	public static void main(String[] args){
		if(args.length != 2){
			System.out.println("Usage: PROGRAM junction-url propName");
			System.exit(0);
		}
		String urlStr = args[0];
		String propName = args[1];
		
	}

}
{'fraction_non_alphanumeric': 0.09884959522795057, 'fraction_numerical': 0.008947592671495527, 'mean_word_length': 3.9213836477987423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5997939', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1373, 'n_words': 442}