repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
kmonaghan/Broadsheet.ie-Android | src/ie/broadsheet/app/requests/PostListRequest.java | // Path: src/ie/broadsheet/app/BroadsheetApplication.java
// public class BroadsheetApplication extends Application {
// private static BroadsheetApplication mApp = null;
//
// private List<Post> posts;
//
// public List<Post> getPosts() {
// return posts;
// }
//
// private Tracker mGaTracker;
//
// private GoogleAnalytics mGaInstance;
//
// public void setPosts(List<Post> posts) {
// if ((this.posts == null) || (posts == null)) {
// this.posts = posts;
// } else if (this.posts.size() > 0) {
// // this.posts.addAll(posts);
// for (Post post : posts) {
// this.posts.add(post);
// }
// } else {
// this.posts = posts;
// }
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Create global configuration and initialize ImageLoader with this configuration
// ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
// ImageLoader.getInstance().init(config);
//
// this.posts = new ArrayList<Post>();
//
// Crashlytics.start(this);
//
// mGaInstance = GoogleAnalytics.getInstance(this);
//
// mGaTracker = mGaInstance.getTracker("UA-5653857-3");
//
// mApp = this;
// }
//
// public Tracker getTracker() {
// return mGaTracker;
// }
//
// public static Context context() {
// return mApp.getApplicationContext();
// }
//
// }
//
// Path: src/ie/broadsheet/app/model/json/PostList.java
// public class PostList implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Key
// private String status;
//
// @Key
// private int count;
//
// @Key
// private int count_total;
//
// @Key
// private int pages;
//
// @Key
// private List<Post> posts;
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public int getCount_total() {
// return count_total;
// }
//
// public void setCount_total(int count_total) {
// this.count_total = count_total;
// }
//
// public int getPages() {
// return pages;
// }
//
// public void setPages(int pages) {
// this.pages = pages;
// }
//
// public List<Post> getPosts() {
// return posts;
// }
//
// public void setPosts(List<Post> posts) {
// this.posts = posts;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + count;
// result = prime * result + count_total;
// result = prime * result + pages;
// result = prime * result + ((posts == null) ? 0 : posts.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PostList other = (PostList) obj;
// if (count != other.count)
// return false;
// if (count_total != other.count_total)
// return false;
// if (pages != other.pages)
// return false;
// if (posts == null) {
// if (other.posts != null)
// return false;
// } else if (!posts.equals(other.posts))
// return false;
// if (status == null) {
// if (other.status != null)
// return false;
// } else if (!status.equals(other.status))
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "PostList [status=" + status + ", count=" + count + ", count_total=" + count_total + ", pages=" + pages
// + ", posts=" + posts + "]";
// }
//
// }
| import ie.broadsheet.app.BroadsheetApplication;
import ie.broadsheet.app.R;
import ie.broadsheet.app.model.json.PostList;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import android.util.Log;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.json.jackson.JacksonFactory;
import com.octo.android.robospice.request.googlehttpclient.GoogleHttpClientSpiceRequest; | package ie.broadsheet.app.requests;
public class PostListRequest extends GoogleHttpClientSpiceRequest<PostList> {
private static final String TAG = "PostListRequest";
private String baseUrl;
private int page = 1;
private int count = 10;
private String searchTerm;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public String getSearchTerm() {
return searchTerm;
}
public void setSearchTerm(String searchTerm) {
this.searchTerm = searchTerm;
}
public PostListRequest() {
super(PostList.class);
| // Path: src/ie/broadsheet/app/BroadsheetApplication.java
// public class BroadsheetApplication extends Application {
// private static BroadsheetApplication mApp = null;
//
// private List<Post> posts;
//
// public List<Post> getPosts() {
// return posts;
// }
//
// private Tracker mGaTracker;
//
// private GoogleAnalytics mGaInstance;
//
// public void setPosts(List<Post> posts) {
// if ((this.posts == null) || (posts == null)) {
// this.posts = posts;
// } else if (this.posts.size() > 0) {
// // this.posts.addAll(posts);
// for (Post post : posts) {
// this.posts.add(post);
// }
// } else {
// this.posts = posts;
// }
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Create global configuration and initialize ImageLoader with this configuration
// ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
// ImageLoader.getInstance().init(config);
//
// this.posts = new ArrayList<Post>();
//
// Crashlytics.start(this);
//
// mGaInstance = GoogleAnalytics.getInstance(this);
//
// mGaTracker = mGaInstance.getTracker("UA-5653857-3");
//
// mApp = this;
// }
//
// public Tracker getTracker() {
// return mGaTracker;
// }
//
// public static Context context() {
// return mApp.getApplicationContext();
// }
//
// }
//
// Path: src/ie/broadsheet/app/model/json/PostList.java
// public class PostList implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @Key
// private String status;
//
// @Key
// private int count;
//
// @Key
// private int count_total;
//
// @Key
// private int pages;
//
// @Key
// private List<Post> posts;
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public int getCount_total() {
// return count_total;
// }
//
// public void setCount_total(int count_total) {
// this.count_total = count_total;
// }
//
// public int getPages() {
// return pages;
// }
//
// public void setPages(int pages) {
// this.pages = pages;
// }
//
// public List<Post> getPosts() {
// return posts;
// }
//
// public void setPosts(List<Post> posts) {
// this.posts = posts;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + count;
// result = prime * result + count_total;
// result = prime * result + pages;
// result = prime * result + ((posts == null) ? 0 : posts.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PostList other = (PostList) obj;
// if (count != other.count)
// return false;
// if (count_total != other.count_total)
// return false;
// if (pages != other.pages)
// return false;
// if (posts == null) {
// if (other.posts != null)
// return false;
// } else if (!posts.equals(other.posts))
// return false;
// if (status == null) {
// if (other.status != null)
// return false;
// } else if (!status.equals(other.status))
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "PostList [status=" + status + ", count=" + count + ", count_total=" + count_total + ", pages=" + pages
// + ", posts=" + posts + "]";
// }
//
// }
// Path: src/ie/broadsheet/app/requests/PostListRequest.java
import ie.broadsheet.app.BroadsheetApplication;
import ie.broadsheet.app.R;
import ie.broadsheet.app.model.json.PostList;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import android.util.Log;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.json.jackson.JacksonFactory;
import com.octo.android.robospice.request.googlehttpclient.GoogleHttpClientSpiceRequest;
package ie.broadsheet.app.requests;
public class PostListRequest extends GoogleHttpClientSpiceRequest<PostList> {
private static final String TAG = "PostListRequest";
private String baseUrl;
private int page = 1;
private int count = 10;
private String searchTerm;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public String getSearchTerm() {
return searchTerm;
}
public void setSearchTerm(String searchTerm) {
this.searchTerm = searchTerm;
}
public PostListRequest() {
super(PostList.class);
| this.baseUrl = BroadsheetApplication.context().getString(R.string.apiURL) + "/?json=1"; |
kmonaghan/Broadsheet.ie-Android | src/ie/broadsheet/app/BaseFragmentActivity.java | // Path: src/ie/broadsheet/app/services/BroadsheetServices.java
// public class BroadsheetServices extends GoogleHttpClientSpiceService {
//
// @Override
// public CacheManager createCacheManager(Application application) {
// CacheManager cacheManager = new CacheManager();
//
// JacksonObjectPersisterFactory jacksonObjectPersisterFactory;
// try {
// jacksonObjectPersisterFactory = new JacksonObjectPersisterFactory(application);
// cacheManager.addPersister(jacksonObjectPersisterFactory);
// } catch (CacheCreationException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// return cacheManager;
// }
//
// }
| import ie.broadsheet.app.services.BroadsheetServices;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.google.analytics.tracking.android.EasyTracker;
import com.octo.android.robospice.SpiceManager; | package ie.broadsheet.app;
public class BaseFragmentActivity extends SherlockFragmentActivity {
private ProgressDialog mProgressDialog;
| // Path: src/ie/broadsheet/app/services/BroadsheetServices.java
// public class BroadsheetServices extends GoogleHttpClientSpiceService {
//
// @Override
// public CacheManager createCacheManager(Application application) {
// CacheManager cacheManager = new CacheManager();
//
// JacksonObjectPersisterFactory jacksonObjectPersisterFactory;
// try {
// jacksonObjectPersisterFactory = new JacksonObjectPersisterFactory(application);
// cacheManager.addPersister(jacksonObjectPersisterFactory);
// } catch (CacheCreationException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// return cacheManager;
// }
//
// }
// Path: src/ie/broadsheet/app/BaseFragmentActivity.java
import ie.broadsheet.app.services.BroadsheetServices;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.google.analytics.tracking.android.EasyTracker;
import com.octo.android.robospice.SpiceManager;
package ie.broadsheet.app;
public class BaseFragmentActivity extends SherlockFragmentActivity {
private ProgressDialog mProgressDialog;
| private SpiceManager spiceManager = new SpiceManager(BroadsheetServices.class); |
kmonaghan/Broadsheet.ie-Android | src/ie/broadsheet/app/dialog/AboutDialog.java | // Path: src/ie/broadsheet/app/BroadsheetApplication.java
// public class BroadsheetApplication extends Application {
// private static BroadsheetApplication mApp = null;
//
// private List<Post> posts;
//
// public List<Post> getPosts() {
// return posts;
// }
//
// private Tracker mGaTracker;
//
// private GoogleAnalytics mGaInstance;
//
// public void setPosts(List<Post> posts) {
// if ((this.posts == null) || (posts == null)) {
// this.posts = posts;
// } else if (this.posts.size() > 0) {
// // this.posts.addAll(posts);
// for (Post post : posts) {
// this.posts.add(post);
// }
// } else {
// this.posts = posts;
// }
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Create global configuration and initialize ImageLoader with this configuration
// ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
// ImageLoader.getInstance().init(config);
//
// this.posts = new ArrayList<Post>();
//
// Crashlytics.start(this);
//
// mGaInstance = GoogleAnalytics.getInstance(this);
//
// mGaTracker = mGaInstance.getTracker("UA-5653857-3");
//
// mApp = this;
// }
//
// public Tracker getTracker() {
// return mGaTracker;
// }
//
// public static Context context() {
// return mApp.getApplicationContext();
// }
//
// }
| import ie.broadsheet.app.BroadsheetApplication;
import ie.broadsheet.app.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.Toast; | package ie.broadsheet.app.dialog;
public class AboutDialog extends DialogFragment implements OnClickListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.about_title).setItems(R.array.about_array, this)
.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
@Override
public void onStart() {
super.onStart();
| // Path: src/ie/broadsheet/app/BroadsheetApplication.java
// public class BroadsheetApplication extends Application {
// private static BroadsheetApplication mApp = null;
//
// private List<Post> posts;
//
// public List<Post> getPosts() {
// return posts;
// }
//
// private Tracker mGaTracker;
//
// private GoogleAnalytics mGaInstance;
//
// public void setPosts(List<Post> posts) {
// if ((this.posts == null) || (posts == null)) {
// this.posts = posts;
// } else if (this.posts.size() > 0) {
// // this.posts.addAll(posts);
// for (Post post : posts) {
// this.posts.add(post);
// }
// } else {
// this.posts = posts;
// }
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Create global configuration and initialize ImageLoader with this configuration
// ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
// ImageLoader.getInstance().init(config);
//
// this.posts = new ArrayList<Post>();
//
// Crashlytics.start(this);
//
// mGaInstance = GoogleAnalytics.getInstance(this);
//
// mGaTracker = mGaInstance.getTracker("UA-5653857-3");
//
// mApp = this;
// }
//
// public Tracker getTracker() {
// return mGaTracker;
// }
//
// public static Context context() {
// return mApp.getApplicationContext();
// }
//
// }
// Path: src/ie/broadsheet/app/dialog/AboutDialog.java
import ie.broadsheet.app.BroadsheetApplication;
import ie.broadsheet.app.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.Toast;
package ie.broadsheet.app.dialog;
public class AboutDialog extends DialogFragment implements OnClickListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.about_title).setItems(R.array.about_array, this)
.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
@Override
public void onStart() {
super.onStart();
| ((BroadsheetApplication) getActivity().getApplication()).getTracker().sendView("About"); |
ehrmann/classifier4j | src/main/java/com/davidehrmann/classifier4J/AbstractCategorizedTrainableClassifier.java | // Path: src/main/java/com/davidehrmann/classifier4J/bayesian/WordsDataSourceException.java
// public class WordsDataSourceException extends ClassifierException {
//
// /**
// *
// */
// private static final long serialVersionUID = 8194847102295629454L;
//
// public WordsDataSourceException(String message) {
// super(message);
// }
//
// public WordsDataSourceException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
| import com.davidehrmann.classifier4j.bayesian.WordsDataSourceException;
| package com.davidehrmann.classifier4j;
public abstract class AbstractCategorizedTrainableClassifier<C,I> extends AbstractClassifier<I> implements ITrainableClassifier<C,I> {
/**
* @see IClassifier#classify(java.lang.String)
*/
protected final C defaultCategory;
public AbstractCategorizedTrainableClassifier() {
this(null);
}
public AbstractCategorizedTrainableClassifier(C defaultCategory) {
this.defaultCategory = defaultCategory;
}
| // Path: src/main/java/com/davidehrmann/classifier4J/bayesian/WordsDataSourceException.java
// public class WordsDataSourceException extends ClassifierException {
//
// /**
// *
// */
// private static final long serialVersionUID = 8194847102295629454L;
//
// public WordsDataSourceException(String message) {
// super(message);
// }
//
// public WordsDataSourceException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: src/main/java/com/davidehrmann/classifier4J/AbstractCategorizedTrainableClassifier.java
import com.davidehrmann.classifier4j.bayesian.WordsDataSourceException;
package com.davidehrmann.classifier4j;
public abstract class AbstractCategorizedTrainableClassifier<C,I> extends AbstractClassifier<I> implements ITrainableClassifier<C,I> {
/**
* @see IClassifier#classify(java.lang.String)
*/
protected final C defaultCategory;
public AbstractCategorizedTrainableClassifier() {
this(null);
}
public AbstractCategorizedTrainableClassifier(C defaultCategory) {
this.defaultCategory = defaultCategory;
}
| public double classify(I input) throws WordsDataSourceException, ClassifierException {
|
ehrmann/classifier4j | src/test/java/com/davidehrmann/classifier4J/bayesian/WordProbabilityTest.java | // Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
// /**
// * Default value to use if the implementation cannot work out how
// * well a string matches.
// */
// public static double NEUTRAL_PROBABILITY = 0.5d;
//
// /**
// * The minimum likelihood that a string matches
// */
// public static double LOWER_BOUND = 0.01d;
//
// /**
// * The maximum likelihood that a string matches
// */
// public static double UPPER_BOUND = 0.99d;
//
// /**
// * Default cutoff value used by default implementation of
// * isMatch. Any match probability greater than or equal to this
// * value will be classified as a match.
// *
// * The value is 0.9d
// *
// */
// public static double DEFAULT_CUTOFF = 0.9d;
//
// /**
// *
// * Sets the cutoff below which the input is not considered a match
// *
// * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
// */
// public void setMatchCutoff(double cutoff);
//
// /**
// *
// * Function to determine the probability string matches a criteria.
// *
// * @param input the string to classify
// * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public double classify(I input) throws ClassifierException;
//
// /**
// *
// * Function to determine if a string matches a criteria.
// *
// * @param input the string to classify
// * @return true if the input string has a probability >= the cutoff probability of
// * matching
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public boolean isMatch(I input) throws ClassifierException;
//
// /**
// * Convenience method which takes a match probability
// * (calculated by {@link IClassifier#classify(java.lang.String)})
// * and checks if it would be classified as a match or not
// *
// * @param matchProbability
// * @return true if match, false otherwise
// */
// public boolean isMatch(double matchProbability);
// }
| import junit.textui.TestRunner;
import com.davidehrmann.classifier4j.IClassifier;
import junit.framework.TestCase;
| assertEquals(0.96d, wp.getProbability(), 0);
wp = new WordProbability("aWord", 10, 30);
assertEquals("aWord", wp.getWord());
assertEquals(10, wp.getMatchingCount());
assertEquals(30, wp.getNonMatchingCount());
assertEquals(0.25d, wp.getProbability(), 0d);
try {
wp.setMatchingCount(-10);
fail("Shouldn't be able to set -ve matchingCount");
}
catch(IllegalArgumentException e) {
assertTrue(true);
}
try {
wp.setNonMatchingCount(-10);
fail("Shouldn't be able to set -ve nonMatchingCount");
}
catch(IllegalArgumentException e) {
assertTrue(true);
}
}
public void testCalculateProbability() {
WordProbability wp = null;
wp = new WordProbability("", 10, 10);
| // Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
// /**
// * Default value to use if the implementation cannot work out how
// * well a string matches.
// */
// public static double NEUTRAL_PROBABILITY = 0.5d;
//
// /**
// * The minimum likelihood that a string matches
// */
// public static double LOWER_BOUND = 0.01d;
//
// /**
// * The maximum likelihood that a string matches
// */
// public static double UPPER_BOUND = 0.99d;
//
// /**
// * Default cutoff value used by default implementation of
// * isMatch. Any match probability greater than or equal to this
// * value will be classified as a match.
// *
// * The value is 0.9d
// *
// */
// public static double DEFAULT_CUTOFF = 0.9d;
//
// /**
// *
// * Sets the cutoff below which the input is not considered a match
// *
// * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
// */
// public void setMatchCutoff(double cutoff);
//
// /**
// *
// * Function to determine the probability string matches a criteria.
// *
// * @param input the string to classify
// * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public double classify(I input) throws ClassifierException;
//
// /**
// *
// * Function to determine if a string matches a criteria.
// *
// * @param input the string to classify
// * @return true if the input string has a probability >= the cutoff probability of
// * matching
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public boolean isMatch(I input) throws ClassifierException;
//
// /**
// * Convenience method which takes a match probability
// * (calculated by {@link IClassifier#classify(java.lang.String)})
// * and checks if it would be classified as a match or not
// *
// * @param matchProbability
// * @return true if match, false otherwise
// */
// public boolean isMatch(double matchProbability);
// }
// Path: src/test/java/com/davidehrmann/classifier4J/bayesian/WordProbabilityTest.java
import junit.textui.TestRunner;
import com.davidehrmann.classifier4j.IClassifier;
import junit.framework.TestCase;
assertEquals(0.96d, wp.getProbability(), 0);
wp = new WordProbability("aWord", 10, 30);
assertEquals("aWord", wp.getWord());
assertEquals(10, wp.getMatchingCount());
assertEquals(30, wp.getNonMatchingCount());
assertEquals(0.25d, wp.getProbability(), 0d);
try {
wp.setMatchingCount(-10);
fail("Shouldn't be able to set -ve matchingCount");
}
catch(IllegalArgumentException e) {
assertTrue(true);
}
try {
wp.setNonMatchingCount(-10);
fail("Shouldn't be able to set -ve nonMatchingCount");
}
catch(IllegalArgumentException e) {
assertTrue(true);
}
}
public void testCalculateProbability() {
WordProbability wp = null;
wp = new WordProbability("", 10, 10);
| assertEquals(IClassifier.NEUTRAL_PROBABILITY, wp.getProbability(), 0);
|
ehrmann/classifier4j | src/main/java/com/davidehrmann/classifier4J/tokenizer/SimpleStringTokenizer.java | // Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
// /**
// * Default value to use if the implementation cannot work out how
// * well a string matches.
// */
// public static double NEUTRAL_PROBABILITY = 0.5d;
//
// /**
// * The minimum likelihood that a string matches
// */
// public static double LOWER_BOUND = 0.01d;
//
// /**
// * The maximum likelihood that a string matches
// */
// public static double UPPER_BOUND = 0.99d;
//
// /**
// * Default cutoff value used by default implementation of
// * isMatch. Any match probability greater than or equal to this
// * value will be classified as a match.
// *
// * The value is 0.9d
// *
// */
// public static double DEFAULT_CUTOFF = 0.9d;
//
// /**
// *
// * Sets the cutoff below which the input is not considered a match
// *
// * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
// */
// public void setMatchCutoff(double cutoff);
//
// /**
// *
// * Function to determine the probability string matches a criteria.
// *
// * @param input the string to classify
// * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public double classify(I input) throws ClassifierException;
//
// /**
// *
// * Function to determine if a string matches a criteria.
// *
// * @param input the string to classify
// * @return true if the input string has a probability >= the cutoff probability of
// * matching
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public boolean isMatch(I input) throws ClassifierException;
//
// /**
// * Convenience method which takes a match probability
// * (calculated by {@link IClassifier#classify(java.lang.String)})
// * and checks if it would be classified as a match or not
// *
// * @param matchProbability
// * @return true if match, false otherwise
// */
// public boolean isMatch(double matchProbability);
// }
//
// Path: src/main/java/com/davidehrmann/classifier4J/util/ToStringBuilder.java
// public class ToStringBuilder implements Serializable {
// StringBuffer output = new StringBuffer("");
//
// /**
// * @param classifier
// */
// public ToStringBuilder(Object o) {
// if (o == null) {
// throw new IllegalArgumentException("Object cannot be null");
// }
// output = new StringBuffer(o.getClass().getName() + " " );
// }
//
//
// public ToStringBuilder append(String name, Object o) {
// if (o == null) {
// output.append(name + ": null");
// } else {
// output.append(name + ": " + o.toString());
// }
// return this;
// }
//
// public ToStringBuilder append(String name, double num) {
// output.append(name + ": " + num);
// return this;
// }
//
// public String toString() {
// return output.toString();
// }
//
//
// }
| import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.davidehrmann.classifier4j.IClassifier;
import com.davidehrmann.classifier4j.util.ToStringBuilder;
| } else if (tokenizerConfig == BREAK_ON_WHITESPACE) {
regexp = "\\s+";
} else {
throw new IllegalStateException("Illegal tokenizer configuration. customTokenizerRegExp = null & tokenizerConfig = " + tokenizerConfig);
}
ArrayList<String> words = new ArrayList<String>(input.length() / 4);
int lastEnd = 0;
Matcher matcher = Pattern.compile(regexp).matcher(input);
while (matcher.find()) {
int start = matcher.start();
if (start != lastEnd) {
words.add(input.substring(lastEnd, start));
}
lastEnd = matcher.end();
}
if (lastEnd < input.length()) {
words.add(input.substring(lastEnd));
}
return words.toArray(new String[words.size()]);
}
public String toString() {
| // Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
// /**
// * Default value to use if the implementation cannot work out how
// * well a string matches.
// */
// public static double NEUTRAL_PROBABILITY = 0.5d;
//
// /**
// * The minimum likelihood that a string matches
// */
// public static double LOWER_BOUND = 0.01d;
//
// /**
// * The maximum likelihood that a string matches
// */
// public static double UPPER_BOUND = 0.99d;
//
// /**
// * Default cutoff value used by default implementation of
// * isMatch. Any match probability greater than or equal to this
// * value will be classified as a match.
// *
// * The value is 0.9d
// *
// */
// public static double DEFAULT_CUTOFF = 0.9d;
//
// /**
// *
// * Sets the cutoff below which the input is not considered a match
// *
// * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
// */
// public void setMatchCutoff(double cutoff);
//
// /**
// *
// * Function to determine the probability string matches a criteria.
// *
// * @param input the string to classify
// * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public double classify(I input) throws ClassifierException;
//
// /**
// *
// * Function to determine if a string matches a criteria.
// *
// * @param input the string to classify
// * @return true if the input string has a probability >= the cutoff probability of
// * matching
// *
// * @throws ClassifierException If a non-recoverable problem occurs
// */
// public boolean isMatch(I input) throws ClassifierException;
//
// /**
// * Convenience method which takes a match probability
// * (calculated by {@link IClassifier#classify(java.lang.String)})
// * and checks if it would be classified as a match or not
// *
// * @param matchProbability
// * @return true if match, false otherwise
// */
// public boolean isMatch(double matchProbability);
// }
//
// Path: src/main/java/com/davidehrmann/classifier4J/util/ToStringBuilder.java
// public class ToStringBuilder implements Serializable {
// StringBuffer output = new StringBuffer("");
//
// /**
// * @param classifier
// */
// public ToStringBuilder(Object o) {
// if (o == null) {
// throw new IllegalArgumentException("Object cannot be null");
// }
// output = new StringBuffer(o.getClass().getName() + " " );
// }
//
//
// public ToStringBuilder append(String name, Object o) {
// if (o == null) {
// output.append(name + ": null");
// } else {
// output.append(name + ": " + o.toString());
// }
// return this;
// }
//
// public ToStringBuilder append(String name, double num) {
// output.append(name + ": " + num);
// return this;
// }
//
// public String toString() {
// return output.toString();
// }
//
//
// }
// Path: src/main/java/com/davidehrmann/classifier4J/tokenizer/SimpleStringTokenizer.java
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.davidehrmann.classifier4j.IClassifier;
import com.davidehrmann.classifier4j.util.ToStringBuilder;
} else if (tokenizerConfig == BREAK_ON_WHITESPACE) {
regexp = "\\s+";
} else {
throw new IllegalStateException("Illegal tokenizer configuration. customTokenizerRegExp = null & tokenizerConfig = " + tokenizerConfig);
}
ArrayList<String> words = new ArrayList<String>(input.length() / 4);
int lastEnd = 0;
Matcher matcher = Pattern.compile(regexp).matcher(input);
while (matcher.find()) {
int start = matcher.start();
if (start != lastEnd) {
words.add(input.substring(lastEnd, start));
}
lastEnd = matcher.end();
}
if (lastEnd < input.length()) {
words.add(input.substring(lastEnd));
}
return words.toArray(new String[words.size()]);
}
public String toString() {
| ToStringBuilder toStringBuilder = new ToStringBuilder(this);
|
rhavyn/norbert | java-network/src/main/java/com/linkedin/norbert/network/javaapi/BaseNetworkClient.java | // Path: java-cluster/src/main/java/com/linkedin/norbert/cluster/javaapi/Node.java
// public interface Node {
// int getId();
// String getUrl();
// Set<Integer> getPartitions();
// boolean isAvailable();
// }
| import java.util.concurrent.Future;
import com.google.protobuf.Message;
import com.linkedin.norbert.cluster.ClusterDisconnectedException;
import com.linkedin.norbert.cluster.InvalidNodeException;
import com.linkedin.norbert.cluster.javaapi.Node; | /*
* Copyright 2009-2010 LinkedIn, Inc
*
* 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 com.linkedin.norbert.network.javaapi;
public interface BaseNetworkClient {
/**
* Registers a request/response message pair with the <code>NetworkClient</code>. Requests and their associated
* responses must be registered or an <code>InvalidMessageException</code> will be thrown when an attempt to send
* a <code>Message</code> is made.
*
* @param requestMessage an instance of an outgoing request message
* @param responseMessage an instance of the expected response message or null if this is a one way message
*/
void registerRequest(Message requestMessage, Message responseMessage);
/**
* Sends a message to the specified node in the cluster.
*
* @param message the message to send
* @param node the node to send the message to
*
* @return a future which will become available when a response to the message is received
* @throws InvalidNodeException thrown if the node specified is not currently available
* @throws ClusterDisconnectedException thrown if the cluster is not connected when the method is called
*/ | // Path: java-cluster/src/main/java/com/linkedin/norbert/cluster/javaapi/Node.java
// public interface Node {
// int getId();
// String getUrl();
// Set<Integer> getPartitions();
// boolean isAvailable();
// }
// Path: java-network/src/main/java/com/linkedin/norbert/network/javaapi/BaseNetworkClient.java
import java.util.concurrent.Future;
import com.google.protobuf.Message;
import com.linkedin.norbert.cluster.ClusterDisconnectedException;
import com.linkedin.norbert.cluster.InvalidNodeException;
import com.linkedin.norbert.cluster.javaapi.Node;
/*
* Copyright 2009-2010 LinkedIn, Inc
*
* 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 com.linkedin.norbert.network.javaapi;
public interface BaseNetworkClient {
/**
* Registers a request/response message pair with the <code>NetworkClient</code>. Requests and their associated
* responses must be registered or an <code>InvalidMessageException</code> will be thrown when an attempt to send
* a <code>Message</code> is made.
*
* @param requestMessage an instance of an outgoing request message
* @param responseMessage an instance of the expected response message or null if this is a one way message
*/
void registerRequest(Message requestMessage, Message responseMessage);
/**
* Sends a message to the specified node in the cluster.
*
* @param message the message to send
* @param node the node to send the message to
*
* @return a future which will become available when a response to the message is received
* @throws InvalidNodeException thrown if the node specified is not currently available
* @throws ClusterDisconnectedException thrown if the cluster is not connected when the method is called
*/ | Future<Message> sendMessageToNode(Message message, Node node) throws InvalidNodeException, ClusterDisconnectedException; |
idega/com.idega.block.survey | src/java/com/idega/block/survey/data/SurveyReplyBMPBean.java | // Path: src/java/com/idega/block/survey/business/SurveyConstants.java
// public class SurveyConstants {
// public static final int SURVEY_ANSWER_MAX_LENGTH = 500;
// }
| import java.sql.Timestamp;
import java.util.Collection;
import javax.ejb.FinderException;
import com.idega.block.survey.business.SurveyConstants;
import com.idega.data.GenericEntity;
import com.idega.data.IDOException;
import com.idega.data.query.CountColumn;
import com.idega.data.query.InCriteria;
import com.idega.data.query.MatchCriteria;
import com.idega.data.query.SelectQuery;
import com.idega.data.query.Table;
import com.idega.data.query.WildCardColumn; | /*
* Created on 2.1.2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.idega.block.survey.data;
/**
* Title: SurveyReplyBMPBean Description: Copyright: Copyright (c) 2004 Company:
* idega Software
*
* @author 2004 - idega team - <br>
* <a href="mailto:[email protected]">Gudmundur Agust Saemundsson</a><br>
* @version 1.0
*/
public class SurveyReplyBMPBean extends GenericEntity implements SurveyReply {
private static final String ENTITY_NAME = "SU_SURVEY_REPLY";
// PARTICIPANT_KEY could either be generated key or encrypted representative
// string (e.g. e-mail)
private final static String COLUMN_PARTICIPANT_KEY = "PARTICIPANT_KEY";
private static final String COLUMN_ANSWER = "ANSWER";
private final static String COLUMN_SURVEY_ID = "SU_SURVEY_ID";
private final static String COLUMN_QUESTION_ID = "SU_QUESTION_ID";
private final static String COLUMN_ANSWER_ID = "SU_ANSWER_ID";
private final static String COLUMN_PARTICIPANT = "participant_id";
private final static String COLUMN_ENTRY_DATE = "entry_date";
public String getEntityName() {
return ENTITY_NAME;
}
public void initializeAttributes() {
addAttribute(this.getIDColumnName());
addAttribute(COLUMN_PARTICIPANT_KEY, "Participant key", String.class,
255);
addManyToOneRelationship(COLUMN_SURVEY_ID, SurveyEntity.class);
addManyToOneRelationship(COLUMN_QUESTION_ID, SurveyQuestion.class);
addManyToOneRelationship(COLUMN_ANSWER_ID, SurveyAnswer.class);
addAttribute(COLUMN_ANSWER, "Answer", String.class, | // Path: src/java/com/idega/block/survey/business/SurveyConstants.java
// public class SurveyConstants {
// public static final int SURVEY_ANSWER_MAX_LENGTH = 500;
// }
// Path: src/java/com/idega/block/survey/data/SurveyReplyBMPBean.java
import java.sql.Timestamp;
import java.util.Collection;
import javax.ejb.FinderException;
import com.idega.block.survey.business.SurveyConstants;
import com.idega.data.GenericEntity;
import com.idega.data.IDOException;
import com.idega.data.query.CountColumn;
import com.idega.data.query.InCriteria;
import com.idega.data.query.MatchCriteria;
import com.idega.data.query.SelectQuery;
import com.idega.data.query.Table;
import com.idega.data.query.WildCardColumn;
/*
* Created on 2.1.2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.idega.block.survey.data;
/**
* Title: SurveyReplyBMPBean Description: Copyright: Copyright (c) 2004 Company:
* idega Software
*
* @author 2004 - idega team - <br>
* <a href="mailto:[email protected]">Gudmundur Agust Saemundsson</a><br>
* @version 1.0
*/
public class SurveyReplyBMPBean extends GenericEntity implements SurveyReply {
private static final String ENTITY_NAME = "SU_SURVEY_REPLY";
// PARTICIPANT_KEY could either be generated key or encrypted representative
// string (e.g. e-mail)
private final static String COLUMN_PARTICIPANT_KEY = "PARTICIPANT_KEY";
private static final String COLUMN_ANSWER = "ANSWER";
private final static String COLUMN_SURVEY_ID = "SU_SURVEY_ID";
private final static String COLUMN_QUESTION_ID = "SU_QUESTION_ID";
private final static String COLUMN_ANSWER_ID = "SU_ANSWER_ID";
private final static String COLUMN_PARTICIPANT = "participant_id";
private final static String COLUMN_ENTRY_DATE = "entry_date";
public String getEntityName() {
return ENTITY_NAME;
}
public void initializeAttributes() {
addAttribute(this.getIDColumnName());
addAttribute(COLUMN_PARTICIPANT_KEY, "Participant key", String.class,
255);
addManyToOneRelationship(COLUMN_SURVEY_ID, SurveyEntity.class);
addManyToOneRelationship(COLUMN_QUESTION_ID, SurveyQuestion.class);
addManyToOneRelationship(COLUMN_ANSWER_ID, SurveyAnswer.class);
addAttribute(COLUMN_ANSWER, "Answer", String.class, | SurveyConstants.SURVEY_ANSWER_MAX_LENGTH); |
pmarches/jStellarAPI | src/test/java/jstellarapi/core/DenominatedIssuedCurrencyTest.java | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
| import org.junit.Test;
import static org.junit.Assert.*;
import java.math.BigDecimal;
import jstellarapi.core.DenominatedIssuedCurrency; | package jstellarapi.core;
public class DenominatedIssuedCurrencyTest {
@Test
public void testToJSON() { | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
// Path: src/test/java/jstellarapi/core/DenominatedIssuedCurrencyTest.java
import org.junit.Test;
import static org.junit.Assert.*;
import java.math.BigDecimal;
import jstellarapi.core.DenominatedIssuedCurrency;
package jstellarapi.core;
public class DenominatedIssuedCurrencyTest {
@Test
public void testToJSON() { | DenominatedIssuedCurrency STRAmount = DenominatedIssuedCurrency.ONE_STR; |
pmarches/jStellarAPI | src/main/java/jstellarapi/connection/OrderBookEntry.java | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
| import jstellarapi.core.DenominatedIssuedCurrency;
import org.json.simple.JSONObject; | package jstellarapi.connection;
public class OrderBookEntry implements JSONSerializable {
String accountStr; | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
// Path: src/main/java/jstellarapi/connection/OrderBookEntry.java
import jstellarapi.core.DenominatedIssuedCurrency;
import org.json.simple.JSONObject;
package jstellarapi.connection;
public class OrderBookEntry implements JSONSerializable {
String accountStr; | DenominatedIssuedCurrency takerGetsAmount; |
pmarches/jStellarAPI | src/main/java/jstellarapi/connection/ExchangeOffer.java | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
| import jstellarapi.core.DenominatedIssuedCurrency;
import org.json.simple.JSONObject; | package jstellarapi.connection;
public class ExchangeOffer implements JSONSerializable {
public long sequenceNumber; | // Path: src/main/java/jstellarapi/core/DenominatedIssuedCurrency.java
// public class DenominatedIssuedCurrency implements JSONSerializable {
// public BigDecimal amount;
// public BigInteger microStrAmount;
// public StellarAddress issuer;
// public String currency;
// public static final int MIN_SCALE = -96;
// public static final int MAX_SCALE = 80;
// public static final BigInteger MICROSTR_PER_STR = BigInteger.valueOf(1_000_000);
// public static final DenominatedIssuedCurrency ONE_STR=new DenominatedIssuedCurrency(BigInteger.ONE);
// public static final DenominatedIssuedCurrency FEE = new DenominatedIssuedCurrency(BigInteger.TEN);
//
// public DenominatedIssuedCurrency(){ //FIXME get rid of this
// }
//
// public DenominatedIssuedCurrency(String amount, StellarAddress issuer, String currencyStr){
// this(new BigDecimal(amount).stripTrailingZeros(), issuer, currencyStr);
// }
//
// public DenominatedIssuedCurrency(BigDecimal amount, StellarAddress issuer, String currencyStr){
// int oldScale=amount.scale();
// if(oldScale<MIN_SCALE || oldScale>MAX_SCALE){
// int newScale=MAX_SCALE-(amount.precision()-amount.scale());
// if(newScale<MIN_SCALE || newScale>MAX_SCALE){
// throw new RuntimeException("newScale "+newScale+" is out of range");
// }
// amount=amount.setScale(newScale);
// }
// this.amount = amount;
// this.issuer = issuer;
// this.currency = currencyStr;
// if(issuer==null || currencyStr==null){
// throw new Error("Issuer or currency canot be null for non-STR currency");
// }
// }
//
// public DenominatedIssuedCurrency(BigInteger micro_stellarAmount) {
// this.microStrAmount=micro_stellarAmount;
// }
//
// public DenominatedIssuedCurrency(String amountInMicroSTR) {
// microStrAmount=new BigInteger(amountInMicroSTR);
// }
//
// public boolean isNative() {
// return issuer==null;
// }
//
// public boolean isNegative() {
// return amount.signum()==-1;
// }
//
// @Override
// public String toString() {
// if(issuer==null || currency==null){
// return new BigDecimal(microStrAmount).movePointLeft(6).stripTrailingZeros().toPlainString()+" STR";
// }
// return amount.stripTrailingZeros().toPlainString()+"/"+currency+"/"+issuer;
// }
//
// @Override
// public void copyFrom(JSONObject jsonDenomination) {
// issuer = new StellarAddress(((String) jsonDenomination.get("issuer")));
// String currencyStr = ((String) jsonDenomination.get("currency"));
// currency = currencyStr;
//
// String amountStr = (String) jsonDenomination.get("value");
// amount=new BigDecimal(amountStr);
// }
//
// public void copyFrom(Object jsonObject) {
// if(jsonObject instanceof String){
// amount=new BigDecimal((String) jsonObject);
// }
// else{
// copyFrom((JSONObject) jsonObject);
// }
// }
//
// @SuppressWarnings("unchecked")
// public Object toJSON(){
// if(isNative()){
// return microStrAmount.toString();
// }
// else{
// JSONObject jsonThis = new JSONObject();
// jsonThis.put("value", amount.toPlainString());
// jsonThis.put("issuer", issuer.toString());
// jsonThis.put("currency", currency);
// return jsonThis;
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((amount == null) ? 0 : amount.hashCode());
// result = prime * result
// + ((currency == null) ? 0 : currency.hashCode());
// result = prime * result
// + ((issuer == null) ? 0 : issuer.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// DenominatedIssuedCurrency other = (DenominatedIssuedCurrency) obj;
// if (amount == null) {
// if (other.amount != null)
// return false;
// } else if (amount.compareTo(other.amount)!=0)
// return false;
// if (currency == null) {
// if (other.currency != null)
// return false;
// } else if (!currency.equals(other.currency))
// return false;
// if (issuer == null) {
// if (other.issuer != null)
// return false;
// } else if (!issuer.equals(other.issuer))
// return false;
// return true;
// }
//
// public long toMicroSTR() {
// if(isNative()==false){
// throw new RuntimeException("Cannot get micro STR on a non-STR currency");
// }
// return this.microStrAmount.longValue();
// }
// }
// Path: src/main/java/jstellarapi/connection/ExchangeOffer.java
import jstellarapi.core.DenominatedIssuedCurrency;
import org.json.simple.JSONObject;
package jstellarapi.connection;
public class ExchangeOffer implements JSONSerializable {
public long sequenceNumber; | public DenominatedIssuedCurrency takerGets; |
pmarches/jStellarAPI | src/main/java/jstellarapi/core/StellarTransaction.java | // Path: src/main/java/jstellarapi/serialization/StellarBinaryObject.java
// public class StellarBinaryObject {
// HashMap<BinaryFormatField, Object> fields = new HashMap<BinaryFormatField, Object>();
// static StellarBinarySerializer binSer=new StellarBinarySerializer();
//
// public StellarBinaryObject(){
// }
//
// public StellarBinaryObject(StellarBinaryObject serObjToSign) {
// this.fields.putAll(serObjToSign.fields);
// }
//
// public StellarBinaryObject getUnsignedCopy(){
// StellarBinaryObject copy = new StellarBinaryObject(this);
// copy.removeField(BinaryFormatField.TxnSignature);
// return copy;
// }
//
// public byte[] generateHashFromBinaryObject() {
// byte[] bytesToSign = binSer.writeBinaryObject(this).array();
//
// //Prefix bytesToSign with the magic hashing prefix (32bit) 'STX\0'
// byte[] prefixedBytesToHash = new byte[bytesToSign.length+4];
// prefixedBytesToHash[0]=(byte) 'S';
// prefixedBytesToHash[1]=(byte) 'T';
// prefixedBytesToHash[2]=(byte) 'X';
// prefixedBytesToHash[3]=(byte) 0;
// System.arraycopy(bytesToSign, 0, prefixedBytesToHash, 4, bytesToSign.length);
// //Hash256
// byte[] hashOfBytes = StellarDeterministicKeyGenerator.halfSHA512(prefixedBytesToHash);
// return hashOfBytes;
// }
//
// public byte[] getTransactionHash(){
// //Convert to bytes again
// byte[] signedBytes = binSer.writeBinaryObject(this).array();
// //Prefix bytesToSign with the magic sigining prefix (32bit) 'TXN\0'
// byte[] prefixedSignedBytes = new byte[signedBytes.length+4];
// prefixedSignedBytes[0]=(byte) 'T';
// prefixedSignedBytes[1]=(byte) 'X';
// prefixedSignedBytes[2]=(byte) 'N';
// prefixedSignedBytes[3]=(byte) 0;
// System.arraycopy(signedBytes, 0, prefixedSignedBytes, 4, signedBytes.length);
//
// //Hash again, this wields the TransactionID
// byte[] hashOfTransaction = StellarDeterministicKeyGenerator.halfSHA512(prefixedSignedBytes);
// return hashOfTransaction;
// }
//
// public Object getField(BinaryFormatField transactiontype) {
// Object obj = fields.get(transactiontype);
// if(obj==null){
// return null; //TODO refactor with Maybe object?
// }
// return obj;
// }
//
// public void putField(BinaryFormatField field, Object value){
// fields.put(field, value);
// }
//
// public TransactionTypes getTransactionType() {
// Object txTypeObj = getField(BinaryFormatField.TransactionType);
// if(txTypeObj==null){
// throw new NullPointerException("No transaction type field found");
// }
// return TransactionTypes.fromType((int) txTypeObj);
// }
//
// public String toJSONString() {
// JSONObject root = new JSONObject();
// for(Entry<BinaryFormatField, Object> field:fields.entrySet()){
// PrimitiveTypes primitive = field.getKey().primitive;
// if(primitive==PrimitiveTypes.UINT8 || primitive==PrimitiveTypes.UINT16
// || primitive==PrimitiveTypes.UINT32 || primitive==PrimitiveTypes.UINT64){
// root.put(field.getKey().toString(), field.getValue());
// }
// else{
// root.put(field.getKey().toString(), field.getValue().toString());
// }
// }
// return root.toJSONString();
// }
//
// public List<BinaryFormatField> getSortedField() {
// ArrayList<BinaryFormatField> sortedFields = new ArrayList<BinaryFormatField>(fields.keySet());
// Collections.sort(sortedFields);
// return sortedFields;
// }
//
// public Object removeField(BinaryFormatField fieldToBeRemoved) {
// return fields.remove(fieldToBeRemoved);
// }
//
// @Override
// public String toString() {
// return "StellarBinaryObject [fields=" + fields + "]";
// }
//
// }
| import jstellarapi.serialization.StellarBinaryObject; | package jstellarapi.core;
public class StellarTransaction {
long ledgerIndex;
public StellarTransaction() {
}
| // Path: src/main/java/jstellarapi/serialization/StellarBinaryObject.java
// public class StellarBinaryObject {
// HashMap<BinaryFormatField, Object> fields = new HashMap<BinaryFormatField, Object>();
// static StellarBinarySerializer binSer=new StellarBinarySerializer();
//
// public StellarBinaryObject(){
// }
//
// public StellarBinaryObject(StellarBinaryObject serObjToSign) {
// this.fields.putAll(serObjToSign.fields);
// }
//
// public StellarBinaryObject getUnsignedCopy(){
// StellarBinaryObject copy = new StellarBinaryObject(this);
// copy.removeField(BinaryFormatField.TxnSignature);
// return copy;
// }
//
// public byte[] generateHashFromBinaryObject() {
// byte[] bytesToSign = binSer.writeBinaryObject(this).array();
//
// //Prefix bytesToSign with the magic hashing prefix (32bit) 'STX\0'
// byte[] prefixedBytesToHash = new byte[bytesToSign.length+4];
// prefixedBytesToHash[0]=(byte) 'S';
// prefixedBytesToHash[1]=(byte) 'T';
// prefixedBytesToHash[2]=(byte) 'X';
// prefixedBytesToHash[3]=(byte) 0;
// System.arraycopy(bytesToSign, 0, prefixedBytesToHash, 4, bytesToSign.length);
// //Hash256
// byte[] hashOfBytes = StellarDeterministicKeyGenerator.halfSHA512(prefixedBytesToHash);
// return hashOfBytes;
// }
//
// public byte[] getTransactionHash(){
// //Convert to bytes again
// byte[] signedBytes = binSer.writeBinaryObject(this).array();
// //Prefix bytesToSign with the magic sigining prefix (32bit) 'TXN\0'
// byte[] prefixedSignedBytes = new byte[signedBytes.length+4];
// prefixedSignedBytes[0]=(byte) 'T';
// prefixedSignedBytes[1]=(byte) 'X';
// prefixedSignedBytes[2]=(byte) 'N';
// prefixedSignedBytes[3]=(byte) 0;
// System.arraycopy(signedBytes, 0, prefixedSignedBytes, 4, signedBytes.length);
//
// //Hash again, this wields the TransactionID
// byte[] hashOfTransaction = StellarDeterministicKeyGenerator.halfSHA512(prefixedSignedBytes);
// return hashOfTransaction;
// }
//
// public Object getField(BinaryFormatField transactiontype) {
// Object obj = fields.get(transactiontype);
// if(obj==null){
// return null; //TODO refactor with Maybe object?
// }
// return obj;
// }
//
// public void putField(BinaryFormatField field, Object value){
// fields.put(field, value);
// }
//
// public TransactionTypes getTransactionType() {
// Object txTypeObj = getField(BinaryFormatField.TransactionType);
// if(txTypeObj==null){
// throw new NullPointerException("No transaction type field found");
// }
// return TransactionTypes.fromType((int) txTypeObj);
// }
//
// public String toJSONString() {
// JSONObject root = new JSONObject();
// for(Entry<BinaryFormatField, Object> field:fields.entrySet()){
// PrimitiveTypes primitive = field.getKey().primitive;
// if(primitive==PrimitiveTypes.UINT8 || primitive==PrimitiveTypes.UINT16
// || primitive==PrimitiveTypes.UINT32 || primitive==PrimitiveTypes.UINT64){
// root.put(field.getKey().toString(), field.getValue());
// }
// else{
// root.put(field.getKey().toString(), field.getValue().toString());
// }
// }
// return root.toJSONString();
// }
//
// public List<BinaryFormatField> getSortedField() {
// ArrayList<BinaryFormatField> sortedFields = new ArrayList<BinaryFormatField>(fields.keySet());
// Collections.sort(sortedFields);
// return sortedFields;
// }
//
// public Object removeField(BinaryFormatField fieldToBeRemoved) {
// return fields.remove(fieldToBeRemoved);
// }
//
// @Override
// public String toString() {
// return "StellarBinaryObject [fields=" + fields + "]";
// }
//
// }
// Path: src/main/java/jstellarapi/core/StellarTransaction.java
import jstellarapi.serialization.StellarBinaryObject;
package jstellarapi.core;
public class StellarTransaction {
long ledgerIndex;
public StellarTransaction() {
}
| public StellarTransaction(StellarBinaryObject rbo) { |
pmarches/jStellarAPI | src/main/java/jstellarapi/core/StellarIdentifier.java | // Path: src/main/java/jstellarapi/keys/StellarBase58.java
// public class StellarBase58 {
// private static final String ALPHABET = "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz";
// private static final BigInteger BASE = BigInteger.valueOf(58);
//
// public static String encode(byte[] input) {
// // TODO: This could be a lot more efficient.
// BigInteger bi = new BigInteger(1, input);
// StringBuffer s = new StringBuffer();
// while (bi.compareTo(BASE) >= 0) {
// BigInteger mod = bi.mod(BASE);
// s.insert(0, ALPHABET.charAt(mod.intValue()));
// bi = bi.subtract(mod).divide(BASE);
// }
// s.insert(0, ALPHABET.charAt(bi.intValue()));
// // Convert leading zeros too.
// for (byte anInput : input) {
// if (anInput == 0)
// s.insert(0, ALPHABET.charAt(0));
// else
// break;
// }
// return s.toString();
// }
//
// public static byte[] decode(String input) {
// byte[] bytes = decodeToBigInteger(input).toByteArray();
// // We may have got one more byte than we wanted, if the high bit of the next-to-last byte was not zero. This
// // is because BigIntegers are represented with twos-compliment notation, thus if the high bit of the last
// // byte happens to be 1 another 8 zero bits will be added to ensure the number parses as positive. Detect
// // that case here and chop it off.
// boolean stripSignByte = bytes.length > 1 && bytes[0] == 0 && bytes[1] < 0;
// // Count the leading zeros, if any.
// int leadingZeros = 0;
// for (int i = 0; input.charAt(i) == ALPHABET.charAt(0); i++) {
// leadingZeros++;
// }
// // Now cut/pad correctly. Java 6 has a convenience for this, but Android can't use it.
// byte[] tmp = new byte[bytes.length - (stripSignByte ? 1 : 0) + leadingZeros];
// System.arraycopy(bytes, stripSignByte ? 1 : 0, tmp, leadingZeros, tmp.length - leadingZeros);
// return tmp;
// }
//
// public static BigInteger decodeToBigInteger(String input) {
// BigInteger bi = BigInteger.valueOf(0);
// // Work backwards through the string.
// for (int i = input.length() - 1; i >= 0; i--) {
// int alphaIndex = ALPHABET.indexOf(input.charAt(i));
// if (alphaIndex == -1) {
// throw new RuntimeException("Illegal character " + input.charAt(i) + " at " + i);
// }
// bi = bi.add(BigInteger.valueOf(alphaIndex).multiply(BASE.pow(input.length() - 1 - i)));
// }
// return bi;
// }
// }
| import java.io.Serializable;
import java.util.Arrays;
import jstellarapi.keys.StellarBase58;
import org.bouncycastle.crypto.digests.SHA256Digest; | package jstellarapi.core;
public class StellarIdentifier implements Serializable {
private static final long serialVersionUID = -6009723401818144454L;
String humanReadableIdentifier;
byte[] payloadBytes;
int identifierType;
/**
* @param payloadBytes
* @param identifierType : See ripple_data/protocol/RippleAddress.h
*/
public StellarIdentifier(byte[] payloadBytes, int identifierType){
this.payloadBytes = payloadBytes;
this.identifierType = identifierType;
}
public StellarIdentifier(String stringID) {
this.humanReadableIdentifier = stringID; | // Path: src/main/java/jstellarapi/keys/StellarBase58.java
// public class StellarBase58 {
// private static final String ALPHABET = "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz";
// private static final BigInteger BASE = BigInteger.valueOf(58);
//
// public static String encode(byte[] input) {
// // TODO: This could be a lot more efficient.
// BigInteger bi = new BigInteger(1, input);
// StringBuffer s = new StringBuffer();
// while (bi.compareTo(BASE) >= 0) {
// BigInteger mod = bi.mod(BASE);
// s.insert(0, ALPHABET.charAt(mod.intValue()));
// bi = bi.subtract(mod).divide(BASE);
// }
// s.insert(0, ALPHABET.charAt(bi.intValue()));
// // Convert leading zeros too.
// for (byte anInput : input) {
// if (anInput == 0)
// s.insert(0, ALPHABET.charAt(0));
// else
// break;
// }
// return s.toString();
// }
//
// public static byte[] decode(String input) {
// byte[] bytes = decodeToBigInteger(input).toByteArray();
// // We may have got one more byte than we wanted, if the high bit of the next-to-last byte was not zero. This
// // is because BigIntegers are represented with twos-compliment notation, thus if the high bit of the last
// // byte happens to be 1 another 8 zero bits will be added to ensure the number parses as positive. Detect
// // that case here and chop it off.
// boolean stripSignByte = bytes.length > 1 && bytes[0] == 0 && bytes[1] < 0;
// // Count the leading zeros, if any.
// int leadingZeros = 0;
// for (int i = 0; input.charAt(i) == ALPHABET.charAt(0); i++) {
// leadingZeros++;
// }
// // Now cut/pad correctly. Java 6 has a convenience for this, but Android can't use it.
// byte[] tmp = new byte[bytes.length - (stripSignByte ? 1 : 0) + leadingZeros];
// System.arraycopy(bytes, stripSignByte ? 1 : 0, tmp, leadingZeros, tmp.length - leadingZeros);
// return tmp;
// }
//
// public static BigInteger decodeToBigInteger(String input) {
// BigInteger bi = BigInteger.valueOf(0);
// // Work backwards through the string.
// for (int i = input.length() - 1; i >= 0; i--) {
// int alphaIndex = ALPHABET.indexOf(input.charAt(i));
// if (alphaIndex == -1) {
// throw new RuntimeException("Illegal character " + input.charAt(i) + " at " + i);
// }
// bi = bi.add(BigInteger.valueOf(alphaIndex).multiply(BASE.pow(input.length() - 1 - i)));
// }
// return bi;
// }
// }
// Path: src/main/java/jstellarapi/core/StellarIdentifier.java
import java.io.Serializable;
import java.util.Arrays;
import jstellarapi.keys.StellarBase58;
import org.bouncycastle.crypto.digests.SHA256Digest;
package jstellarapi.core;
public class StellarIdentifier implements Serializable {
private static final long serialVersionUID = -6009723401818144454L;
String humanReadableIdentifier;
byte[] payloadBytes;
int identifierType;
/**
* @param payloadBytes
* @param identifierType : See ripple_data/protocol/RippleAddress.h
*/
public StellarIdentifier(byte[] payloadBytes, int identifierType){
this.payloadBytes = payloadBytes;
this.identifierType = identifierType;
}
public StellarIdentifier(String stringID) {
this.humanReadableIdentifier = stringID; | byte[] stridBytes = StellarBase58.decode(stringID); |
pmarches/jStellarAPI | src/test/java/jstellarapi/core/StellarSeedAddressTest.java | // Path: src/main/java/jstellarapi/core/StellarPrivateKey.java
// public class StellarPrivateKey extends StellarIdentifier {
// StellarPublicKey publicKey;
//
// public StellarPrivateKey(byte[] privateKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// }
//
// public StellarPrivateKey(byte[] privateKeyBytes, byte[] publicKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// publicKey=new StellarPublicKey(publicKeyBytes);
// }
//
// public static byte[] bigIntegerToBytes(BigInteger biToConvert, int nbBytesToReturn){
// //toArray will return the minimum number of bytes required to encode the biginteger in two's complement.
// //Could be less than the expected number of bytes
// byte[] twosComplement = biToConvert.toByteArray();
// byte[] bytesToReturn=new byte[nbBytesToReturn];
//
// if((biToConvert.bitLength()+7)/8!=twosComplement.length){
// //Two's complement representation has a sign bit set on the most significant byte
// byte[] twosComplementWithoutSign = new byte[twosComplement.length-1];
// System.arraycopy(twosComplement, 1, twosComplementWithoutSign, 0, twosComplementWithoutSign.length);
// twosComplement=twosComplementWithoutSign;
// }
//
// int nbBytesOfPaddingRequired=nbBytesToReturn-twosComplement.length;
// if(nbBytesOfPaddingRequired<0){
// throw new RuntimeException("nbBytesToReturn "+nbBytesToReturn+" is too small");
// }
// System.arraycopy(twosComplement, 0, bytesToReturn, nbBytesOfPaddingRequired, twosComplement.length);
//
// return bytesToReturn;
// }
//
// public StellarPrivateKey(BigInteger privateKeyForAccount) {
// super(bigIntegerToBytes(privateKeyForAccount, 32), 34);
// }
//
// public StellarPublicKey getPublicKey(){
// if(publicKey!=null){
// return publicKey;
// }
//
// GroupElement A = StellarPublicKey.ed25519.getB().scalarMultiply(payloadBytes);
// byte[] encodedAndCompressedPublicKeyBytes=A.toByteArray();
// publicKey = new StellarPublicKey(encodedAndCompressedPublicKeyBytes);
// return publicKey;
// }
//
// public ECPrivateKeyParameters getECPrivateKey(){
// //Or return the BigInteger instead?
// BigInteger privateBI=new BigInteger(1, this.payloadBytes);
// ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(privateBI, StellarDeterministicKeyGenerator.SECP256K1_PARAMS);
// return privKey;
// }
// }
//
// Path: src/main/java/jstellarapi/core/StellarSeedAddress.java
// public class StellarSeedAddress extends StellarIdentifier {
// private static final long serialVersionUID = 1845189349528742766L;
// protected StellarPrivateKey privateKey;
//
// public StellarSeedAddress(byte[] payloadBytes) {
// super(payloadBytes, 33);
// if(payloadBytes.length!=32){
// throw new RuntimeException("The seed bytes should be 32 bytes in length. They can be random bytes, or the first 256bit of the SHA512 hash of the passphrase");
// }
// }
//
// public StellarSeedAddress(String stringID) {
// super(stringID);
// }
//
// public StellarPrivateKey getPrivateKey() {
// if(privateKey==null){
// EdDSAPrivateKeySpec keySpec=new EdDSAPrivateKeySpec(payloadBytes, StellarPublicKey.ed25519);
// byte[] publicKeyBytes=keySpec.getA().toByteArray();
// byte[] privateBytes=keySpec.geta();
// privateKey=new StellarPrivateKey(privateBytes, publicKeyBytes);
// }
// return privateKey;
// }
//
// public StellarAddress getPublicStellarAddress() {
// return getPrivateKey().getPublicKey().getAddress();
// }
// }
| import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import javax.xml.bind.DatatypeConverter;
import jstellarapi.core.StellarPrivateKey;
import jstellarapi.core.StellarSeedAddress;
import org.junit.Test; | package jstellarapi.core;
public class StellarSeedAddressTest {
@Test
public void testBigIntegerToBytes() { | // Path: src/main/java/jstellarapi/core/StellarPrivateKey.java
// public class StellarPrivateKey extends StellarIdentifier {
// StellarPublicKey publicKey;
//
// public StellarPrivateKey(byte[] privateKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// }
//
// public StellarPrivateKey(byte[] privateKeyBytes, byte[] publicKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// publicKey=new StellarPublicKey(publicKeyBytes);
// }
//
// public static byte[] bigIntegerToBytes(BigInteger biToConvert, int nbBytesToReturn){
// //toArray will return the minimum number of bytes required to encode the biginteger in two's complement.
// //Could be less than the expected number of bytes
// byte[] twosComplement = biToConvert.toByteArray();
// byte[] bytesToReturn=new byte[nbBytesToReturn];
//
// if((biToConvert.bitLength()+7)/8!=twosComplement.length){
// //Two's complement representation has a sign bit set on the most significant byte
// byte[] twosComplementWithoutSign = new byte[twosComplement.length-1];
// System.arraycopy(twosComplement, 1, twosComplementWithoutSign, 0, twosComplementWithoutSign.length);
// twosComplement=twosComplementWithoutSign;
// }
//
// int nbBytesOfPaddingRequired=nbBytesToReturn-twosComplement.length;
// if(nbBytesOfPaddingRequired<0){
// throw new RuntimeException("nbBytesToReturn "+nbBytesToReturn+" is too small");
// }
// System.arraycopy(twosComplement, 0, bytesToReturn, nbBytesOfPaddingRequired, twosComplement.length);
//
// return bytesToReturn;
// }
//
// public StellarPrivateKey(BigInteger privateKeyForAccount) {
// super(bigIntegerToBytes(privateKeyForAccount, 32), 34);
// }
//
// public StellarPublicKey getPublicKey(){
// if(publicKey!=null){
// return publicKey;
// }
//
// GroupElement A = StellarPublicKey.ed25519.getB().scalarMultiply(payloadBytes);
// byte[] encodedAndCompressedPublicKeyBytes=A.toByteArray();
// publicKey = new StellarPublicKey(encodedAndCompressedPublicKeyBytes);
// return publicKey;
// }
//
// public ECPrivateKeyParameters getECPrivateKey(){
// //Or return the BigInteger instead?
// BigInteger privateBI=new BigInteger(1, this.payloadBytes);
// ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(privateBI, StellarDeterministicKeyGenerator.SECP256K1_PARAMS);
// return privKey;
// }
// }
//
// Path: src/main/java/jstellarapi/core/StellarSeedAddress.java
// public class StellarSeedAddress extends StellarIdentifier {
// private static final long serialVersionUID = 1845189349528742766L;
// protected StellarPrivateKey privateKey;
//
// public StellarSeedAddress(byte[] payloadBytes) {
// super(payloadBytes, 33);
// if(payloadBytes.length!=32){
// throw new RuntimeException("The seed bytes should be 32 bytes in length. They can be random bytes, or the first 256bit of the SHA512 hash of the passphrase");
// }
// }
//
// public StellarSeedAddress(String stringID) {
// super(stringID);
// }
//
// public StellarPrivateKey getPrivateKey() {
// if(privateKey==null){
// EdDSAPrivateKeySpec keySpec=new EdDSAPrivateKeySpec(payloadBytes, StellarPublicKey.ed25519);
// byte[] publicKeyBytes=keySpec.getA().toByteArray();
// byte[] privateBytes=keySpec.geta();
// privateKey=new StellarPrivateKey(privateBytes, publicKeyBytes);
// }
// return privateKey;
// }
//
// public StellarAddress getPublicStellarAddress() {
// return getPrivateKey().getPublicKey().getAddress();
// }
// }
// Path: src/test/java/jstellarapi/core/StellarSeedAddressTest.java
import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import javax.xml.bind.DatatypeConverter;
import jstellarapi.core.StellarPrivateKey;
import jstellarapi.core.StellarSeedAddress;
import org.junit.Test;
package jstellarapi.core;
public class StellarSeedAddressTest {
@Test
public void testBigIntegerToBytes() { | byte[] b1=StellarPrivateKey.bigIntegerToBytes(BigInteger.valueOf(0b10000000), 1); |
pmarches/jStellarAPI | src/test/java/jstellarapi/core/StellarSeedAddressTest.java | // Path: src/main/java/jstellarapi/core/StellarPrivateKey.java
// public class StellarPrivateKey extends StellarIdentifier {
// StellarPublicKey publicKey;
//
// public StellarPrivateKey(byte[] privateKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// }
//
// public StellarPrivateKey(byte[] privateKeyBytes, byte[] publicKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// publicKey=new StellarPublicKey(publicKeyBytes);
// }
//
// public static byte[] bigIntegerToBytes(BigInteger biToConvert, int nbBytesToReturn){
// //toArray will return the minimum number of bytes required to encode the biginteger in two's complement.
// //Could be less than the expected number of bytes
// byte[] twosComplement = biToConvert.toByteArray();
// byte[] bytesToReturn=new byte[nbBytesToReturn];
//
// if((biToConvert.bitLength()+7)/8!=twosComplement.length){
// //Two's complement representation has a sign bit set on the most significant byte
// byte[] twosComplementWithoutSign = new byte[twosComplement.length-1];
// System.arraycopy(twosComplement, 1, twosComplementWithoutSign, 0, twosComplementWithoutSign.length);
// twosComplement=twosComplementWithoutSign;
// }
//
// int nbBytesOfPaddingRequired=nbBytesToReturn-twosComplement.length;
// if(nbBytesOfPaddingRequired<0){
// throw new RuntimeException("nbBytesToReturn "+nbBytesToReturn+" is too small");
// }
// System.arraycopy(twosComplement, 0, bytesToReturn, nbBytesOfPaddingRequired, twosComplement.length);
//
// return bytesToReturn;
// }
//
// public StellarPrivateKey(BigInteger privateKeyForAccount) {
// super(bigIntegerToBytes(privateKeyForAccount, 32), 34);
// }
//
// public StellarPublicKey getPublicKey(){
// if(publicKey!=null){
// return publicKey;
// }
//
// GroupElement A = StellarPublicKey.ed25519.getB().scalarMultiply(payloadBytes);
// byte[] encodedAndCompressedPublicKeyBytes=A.toByteArray();
// publicKey = new StellarPublicKey(encodedAndCompressedPublicKeyBytes);
// return publicKey;
// }
//
// public ECPrivateKeyParameters getECPrivateKey(){
// //Or return the BigInteger instead?
// BigInteger privateBI=new BigInteger(1, this.payloadBytes);
// ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(privateBI, StellarDeterministicKeyGenerator.SECP256K1_PARAMS);
// return privKey;
// }
// }
//
// Path: src/main/java/jstellarapi/core/StellarSeedAddress.java
// public class StellarSeedAddress extends StellarIdentifier {
// private static final long serialVersionUID = 1845189349528742766L;
// protected StellarPrivateKey privateKey;
//
// public StellarSeedAddress(byte[] payloadBytes) {
// super(payloadBytes, 33);
// if(payloadBytes.length!=32){
// throw new RuntimeException("The seed bytes should be 32 bytes in length. They can be random bytes, or the first 256bit of the SHA512 hash of the passphrase");
// }
// }
//
// public StellarSeedAddress(String stringID) {
// super(stringID);
// }
//
// public StellarPrivateKey getPrivateKey() {
// if(privateKey==null){
// EdDSAPrivateKeySpec keySpec=new EdDSAPrivateKeySpec(payloadBytes, StellarPublicKey.ed25519);
// byte[] publicKeyBytes=keySpec.getA().toByteArray();
// byte[] privateBytes=keySpec.geta();
// privateKey=new StellarPrivateKey(privateBytes, publicKeyBytes);
// }
// return privateKey;
// }
//
// public StellarAddress getPublicStellarAddress() {
// return getPrivateKey().getPublicKey().getAddress();
// }
// }
| import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import javax.xml.bind.DatatypeConverter;
import jstellarapi.core.StellarPrivateKey;
import jstellarapi.core.StellarSeedAddress;
import org.junit.Test; | package jstellarapi.core;
public class StellarSeedAddressTest {
@Test
public void testBigIntegerToBytes() {
byte[] b1=StellarPrivateKey.bigIntegerToBytes(BigInteger.valueOf(0b10000000), 1);
assertEquals(1, b1.length);
assertEquals(128, 0xFF&b1[0]);
}
@Test
public void testStellarSeedAddressStringFirstReport() { | // Path: src/main/java/jstellarapi/core/StellarPrivateKey.java
// public class StellarPrivateKey extends StellarIdentifier {
// StellarPublicKey publicKey;
//
// public StellarPrivateKey(byte[] privateKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// }
//
// public StellarPrivateKey(byte[] privateKeyBytes, byte[] publicKeyBytes) {
// super(privateKeyBytes, 101);
// if(privateKeyBytes.length!=32){
// throw new RuntimeException("The private key must be of length 32 bytes");
// }
// publicKey=new StellarPublicKey(publicKeyBytes);
// }
//
// public static byte[] bigIntegerToBytes(BigInteger biToConvert, int nbBytesToReturn){
// //toArray will return the minimum number of bytes required to encode the biginteger in two's complement.
// //Could be less than the expected number of bytes
// byte[] twosComplement = biToConvert.toByteArray();
// byte[] bytesToReturn=new byte[nbBytesToReturn];
//
// if((biToConvert.bitLength()+7)/8!=twosComplement.length){
// //Two's complement representation has a sign bit set on the most significant byte
// byte[] twosComplementWithoutSign = new byte[twosComplement.length-1];
// System.arraycopy(twosComplement, 1, twosComplementWithoutSign, 0, twosComplementWithoutSign.length);
// twosComplement=twosComplementWithoutSign;
// }
//
// int nbBytesOfPaddingRequired=nbBytesToReturn-twosComplement.length;
// if(nbBytesOfPaddingRequired<0){
// throw new RuntimeException("nbBytesToReturn "+nbBytesToReturn+" is too small");
// }
// System.arraycopy(twosComplement, 0, bytesToReturn, nbBytesOfPaddingRequired, twosComplement.length);
//
// return bytesToReturn;
// }
//
// public StellarPrivateKey(BigInteger privateKeyForAccount) {
// super(bigIntegerToBytes(privateKeyForAccount, 32), 34);
// }
//
// public StellarPublicKey getPublicKey(){
// if(publicKey!=null){
// return publicKey;
// }
//
// GroupElement A = StellarPublicKey.ed25519.getB().scalarMultiply(payloadBytes);
// byte[] encodedAndCompressedPublicKeyBytes=A.toByteArray();
// publicKey = new StellarPublicKey(encodedAndCompressedPublicKeyBytes);
// return publicKey;
// }
//
// public ECPrivateKeyParameters getECPrivateKey(){
// //Or return the BigInteger instead?
// BigInteger privateBI=new BigInteger(1, this.payloadBytes);
// ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(privateBI, StellarDeterministicKeyGenerator.SECP256K1_PARAMS);
// return privKey;
// }
// }
//
// Path: src/main/java/jstellarapi/core/StellarSeedAddress.java
// public class StellarSeedAddress extends StellarIdentifier {
// private static final long serialVersionUID = 1845189349528742766L;
// protected StellarPrivateKey privateKey;
//
// public StellarSeedAddress(byte[] payloadBytes) {
// super(payloadBytes, 33);
// if(payloadBytes.length!=32){
// throw new RuntimeException("The seed bytes should be 32 bytes in length. They can be random bytes, or the first 256bit of the SHA512 hash of the passphrase");
// }
// }
//
// public StellarSeedAddress(String stringID) {
// super(stringID);
// }
//
// public StellarPrivateKey getPrivateKey() {
// if(privateKey==null){
// EdDSAPrivateKeySpec keySpec=new EdDSAPrivateKeySpec(payloadBytes, StellarPublicKey.ed25519);
// byte[] publicKeyBytes=keySpec.getA().toByteArray();
// byte[] privateBytes=keySpec.geta();
// privateKey=new StellarPrivateKey(privateBytes, publicKeyBytes);
// }
// return privateKey;
// }
//
// public StellarAddress getPublicStellarAddress() {
// return getPrivateKey().getPublicKey().getAddress();
// }
// }
// Path: src/test/java/jstellarapi/core/StellarSeedAddressTest.java
import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import javax.xml.bind.DatatypeConverter;
import jstellarapi.core.StellarPrivateKey;
import jstellarapi.core.StellarSeedAddress;
import org.junit.Test;
package jstellarapi.core;
public class StellarSeedAddressTest {
@Test
public void testBigIntegerToBytes() {
byte[] b1=StellarPrivateKey.bigIntegerToBytes(BigInteger.valueOf(0b10000000), 1);
assertEquals(1, b1.length);
assertEquals(128, 0xFF&b1[0]);
}
@Test
public void testStellarSeedAddressStringFirstReport() { | StellarSeedAddress seedFirstReported = new StellarSeedAddress("ss1i94tYmAPsGZNHtHiBxTB2okf8Q"); |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/GsObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* GS ObjectIntHashMap
*/
public class GsObjectIntMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/GsObjectIntMapTest.java
import org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* GS ObjectIntHashMap
*/
public class GsObjectIntMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/HppcIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectIdentityHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest; | package tests.maptests.identity_object;
/**
* HPPC IdentityMap version
*/
public class HppcIdentityMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/HppcIdentityMapTest.java
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectIdentityHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
package tests.maptests.identity_object;
/**
* HPPC IdentityMap version
*/
public class HppcIdentityMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/HppcIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectIdentityHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest; | package tests.maptests.identity_object;
/**
* HPPC IdentityMap version
*/
public class HppcIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjIdentityMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/HppcIdentityMapTest.java
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectIdentityHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
package tests.maptests.identity_object;
/**
* HPPC IdentityMap version
*/
public class HppcIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjIdentityMapRemoveTest();
}
| private static class HppcIdentityMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/GsIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.prim_object;
/**
* GS IntObjectHashMap
*/
public class GsIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/prim_object/GsIntObjectMapTest.java
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.prim_object;
/**
* GS IntObjectHashMap
*/
public class GsIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/TroveMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.TIntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.primitive;
/**
* Trove TIntIntHashMap test
*/
public class TroveMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/TroveMapTest.java
import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.TIntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.primitive;
/**
* Trove TIntIntHashMap test
*/
public class TroveMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/JDKIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.IdentityHashMap;
import java.util.Map; | package tests.maptests.identity_object;
/**
* JDK identity map test - strictly for identical keys during both populating and querying
*/
public class JDKIdentityMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/JDKIdentityMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.IdentityHashMap;
import java.util.Map;
package tests.maptests.identity_object;
/**
* JDK identity map test - strictly for identical keys during both populating and querying
*/
public class JDKIdentityMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/JDKIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.IdentityHashMap;
import java.util.Map; | package tests.maptests.identity_object;
/**
* JDK identity map test - strictly for identical keys during both populating and querying
*/
public class JDKIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JDKIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkIdentityMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/JDKIdentityMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.IdentityHashMap;
import java.util.Map;
package tests.maptests.identity_object;
/**
* JDK identity map test - strictly for identical keys during both populating and querying
*/
public class JDKIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JDKIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkIdentityMapRemoveTest();
}
| private static class JDKIdentityMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/FastUtilObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* FastUtil Object2IntOpenHashMap
*/
public class FastUtilObjectIntMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/FastUtilObjectIntMapTest.java
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* FastUtil Object2IntOpenHashMap
*/
public class FastUtilObjectIntMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/TroveObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* Trove TObjectIntHashMap
*/
public class TroveObjectIntMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/TroveObjectIntMapTest.java
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* Trove TObjectIntHashMap
*/
public class TroveObjectIntMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/MapTestRunner.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.article_examples.*;
import tests.maptests.identity_object.*;
import tests.maptests.object.*;
import tests.maptests.object_prim.*;
import tests.maptests.prim_object.*;
import tests.maptests.primitive.*;
import java.util.*;
import java.util.concurrent.TimeUnit; | .param("m_className", testClass.getCanonicalName())
.param("m_testType", testSetName)
//.verbosity(VerboseMode.SILENT)
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opt).run();
for ( RunResult rr : res )
{
System.out.println( testClass.getCanonicalName() + " (" + mapSize + ") = " + rr.getAggregatedResult().getPrimaryResult().getScore() );
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, Integer.toString((int) rr.getAggregatedResult().getPrimaryResult().getScore()) );
}
if ( res.isEmpty() ) {
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, "-1");
}
}
}
final String res = formatResults(results, MAP_SIZES, tests);
System.out.println( "Results for test type = " + testSetName + ":\n" + res);
return res;
}
private static void testBillion( final List<Class<?>> tests ) throws IllegalAccessException, InstantiationException {
final int mapSize = 1000 * 1000 * 1000;
for ( final Class<?> klass : tests )
{
System.gc(); | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/MapTestRunner.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.article_examples.*;
import tests.maptests.identity_object.*;
import tests.maptests.object.*;
import tests.maptests.object_prim.*;
import tests.maptests.prim_object.*;
import tests.maptests.primitive.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
.param("m_className", testClass.getCanonicalName())
.param("m_testType", testSetName)
//.verbosity(VerboseMode.SILENT)
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opt).run();
for ( RunResult rr : res )
{
System.out.println( testClass.getCanonicalName() + " (" + mapSize + ") = " + rr.getAggregatedResult().getPrimaryResult().getScore() );
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, Integer.toString((int) rr.getAggregatedResult().getPrimaryResult().getScore()) );
}
if ( res.isEmpty() ) {
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, "-1");
}
}
}
final String res = formatResults(results, MAP_SIZES, tests);
System.out.println( "Results for test type = " + testSetName + ":\n" + res);
return res;
}
private static void testBillion( final List<Class<?>> tests ) throws IllegalAccessException, InstantiationException {
final int mapSize = 1000 * 1000 * 1000;
for ( final Class<?> klass : tests )
{
System.gc(); | final IMapTest obj = (IMapTest) klass.newInstance(); |
mikvor/hashmapTest | src/main/java/tests/MapTestRunner.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.article_examples.*;
import tests.maptests.identity_object.*;
import tests.maptests.object.*;
import tests.maptests.object_prim.*;
import tests.maptests.prim_object.*;
import tests.maptests.primitive.*;
import java.util.*;
import java.util.concurrent.TimeUnit; | public static int[] getKeys( final int mapSize )
{
if ( mapSize == s_mapSize )
return s_keys;
s_mapSize = mapSize;
s_keys = null; //should be done separately so we don't keep 2 arrays in memory
s_keys = new int[ mapSize ];
final Random r = new Random( 1234 );
for ( int i = 0; i < mapSize; ++i )
s_keys[ i ] = r.nextInt();
return s_keys;
}
}
@Param("1")
public int m_mapSize;
@Param("dummy")
public String m_className;
@Param( {"get", "put", "remove"} )
public String m_testType;
private IMapTest m_impl;
@Setup
public void setup()
{
try { | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/MapTestRunner.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.article_examples.*;
import tests.maptests.identity_object.*;
import tests.maptests.object.*;
import tests.maptests.object_prim.*;
import tests.maptests.prim_object.*;
import tests.maptests.primitive.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
public static int[] getKeys( final int mapSize )
{
if ( mapSize == s_mapSize )
return s_keys;
s_mapSize = mapSize;
s_keys = null; //should be done separately so we don't keep 2 arrays in memory
s_keys = new int[ mapSize ];
final Random r = new Random( 1234 );
for ( int i = 0; i < mapSize; ++i )
s_keys[ i ] = r.nextInt();
return s_keys;
}
}
@Param("1")
public int m_mapSize;
@Param("dummy")
public String m_className;
@Param( {"get", "put", "remove"} )
public String m_testType;
private IMapTest m_impl;
@Setup
public void setup()
{
try { | final ITestSet testSet = (ITestSet) Class.forName( m_className ).newInstance(); |
mikvor/hashmapTest | src/main/java/tests/maptests/object/KolobokeMutableObjTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* Koloboke mutable object map test
*/
public class KolobokeMutableObjTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/KolobokeMutableObjTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* Koloboke mutable object map test
*/
public class KolobokeMutableObjTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/KolobokeMutableObjTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* Koloboke mutable object map test
*/
public class KolobokeMutableObjTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeMutableObjGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeMutableObjPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeMutableObjRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
//made not static due to NotNullKeys subclass. If that test is removed, we need to rollback to static classes here | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/KolobokeMutableObjTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* Koloboke mutable object map test
*/
public class KolobokeMutableObjTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeMutableObjGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeMutableObjPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeMutableObjRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
//made not static due to NotNullKeys subclass. If that test is removed, we need to rollback to static classes here | private class KolobokeMutableObjGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/KolobokeMutableObjTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | return new KolobokeMutableObjRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
//made not static due to NotNullKeys subclass. If that test is removed, we need to rollback to static classes here
private class KolobokeMutableObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for (int i = 0; i < m_keys.length; ++i)
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/KolobokeMutableObjTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
return new KolobokeMutableObjRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
//made not static due to NotNullKeys subclass. If that test is removed, we need to rollback to static classes here
private class KolobokeMutableObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for (int i = 0; i < m_keys.length; ++i)
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private class KolobokeMutableObjPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; | package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{ | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java
import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{ | abstract public IntIntMap makeMap( final int size, final float fillFactor ); |
mikvor/hashmapTest | src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; | package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{
abstract public IntIntMap makeMap( final int size, final float fillFactor );
@Override | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java
import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{
abstract public IntIntMap makeMap( final int size, final float fillFactor );
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; | package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{
abstract public IntIntMap makeMap( final int size, final float fillFactor );
@Override
public IMapTest getTest() {
return new IntIntMapGetTest();
}
@Override
public IMapTest putTest() {
return new IntIntMapPutTest();
}
@Override
public IMapTest removeTest() {
return new IntIntMapRemoveTest();
}
| // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java
import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
package tests.maptests.article_examples;
public abstract class BaseIntIntMapTest implements ITestSet
{
abstract public IntIntMap makeMap( final int size, final float fillFactor );
@Override
public IMapTest getTest() {
return new IntIntMapGetTest();
}
@Override
public IMapTest putTest() {
return new IntIntMapPutTest();
}
@Override
public IMapTest removeTest() {
return new IntIntMapRemoveTest();
}
| private class IntIntMapGetTest extends AbstractPrimPrimGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java | // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; |
@Override
public IMapTest putTest() {
return new IntIntMapPutTest();
}
@Override
public IMapTest removeTest() {
return new IntIntMapRemoveTest();
}
private class IntIntMapGetTest extends AbstractPrimPrimGetTest {
private IntIntMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
| // Path: src/main/java/map/intint/IntIntMap.java
// public interface IntIntMap {
// public int get( final int key );
// public int put( final int key, final int value );
// public int remove( final int key );
// public int size();
// }
//
// Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/article_examples/BaseIntIntMapTest.java
import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
@Override
public IMapTest putTest() {
return new IntIntMapPutTest();
}
@Override
public IMapTest removeTest() {
return new IntIntMapRemoveTest();
}
private class IntIntMapGetTest extends AbstractPrimPrimGetTest {
private IntIntMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
| private class IntIntMapPutTest extends AbstractPrimPrimPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/TroveObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* Trove THashMap<Integer, Integer> test
*/
public class TroveObjMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/TroveObjMapTest.java
import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* Trove THashMap<Integer, Integer> test
*/
public class TroveObjMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/TroveObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* Trove THashMap<Integer, Integer> test
*/
public class TroveObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/TroveObjMapTest.java
import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* Trove THashMap<Integer, Integer> test
*/
public class TroveObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjMapRemoveTest();
}
| private static class TroveObjMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/TroveObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | @Override
public IMapTest putTest() {
return new TroveObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjMapRemoveTest();
}
private static class TroveObjMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new THashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/TroveObjMapTest.java
import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
@Override
public IMapTest putTest() {
return new TroveObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjMapRemoveTest();
}
private static class TroveObjMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new THashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class TroveObjMapPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/AgronaObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.agrona.collections.Object2IntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* Agrona Object2IntHashMap test
*/
public class AgronaObjectIntMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/AgronaObjectIntMapTest.java
import org.agrona.collections.Object2IntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* Agrona Object2IntHashMap test
*/
public class AgronaObjectIntMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/FastUtilObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* FastUtil Object2ObjectOpenHashMap test
*/
public class FastUtilObjMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/FastUtilObjMapTest.java
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* FastUtil Object2ObjectOpenHashMap test
*/
public class FastUtilObjMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/FastUtilObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* FastUtil Object2ObjectOpenHashMap test
*/
public class FastUtilObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilObjGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/FastUtilObjMapTest.java
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* FastUtil Object2ObjectOpenHashMap test
*/
public class FastUtilObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilObjGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
| private static class FastUtilObjGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/FastUtilObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; |
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
private static class FastUtilObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectOpenHashMap<>( m_keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/FastUtilObjMapTest.java
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
private static class FastUtilObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectOpenHashMap<>( m_keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class FastUtilObjPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/KolobokeIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.koloboke.collect.Equivalence;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* Koloboke pure IdentityMap version
*/
public class KolobokeIdentityMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/KolobokeIdentityMapTest.java
import com.koloboke.collect.Equivalence;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* Koloboke pure IdentityMap version
*/
public class KolobokeIdentityMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/KolobokeIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.koloboke.collect.Equivalence;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* Koloboke pure IdentityMap version
*/
public class KolobokeIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().withKeyEquivalence( Equivalence.identity() ).
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/KolobokeIdentityMapTest.java
import com.koloboke.collect.Equivalence;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* Koloboke pure IdentityMap version
*/
public class KolobokeIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().withKeyEquivalence( Equivalence.identity() ).
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
| private static class KolobokeIdentityMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/GsIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.eclipse.collections.api.block.HashingStrategy;
import org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* GS IdentityMap version
*/
public class GsIdentityMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/GsIdentityMapTest.java
import org.eclipse.collections.api.block.HashingStrategy;
import org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* GS IdentityMap version
*/
public class GsIdentityMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/GsIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.eclipse.collections.api.block.HashingStrategy;
import org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* GS IdentityMap version
*/
public class GsIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new UnifiedMapWithHashingStrategy<>(new HashingStrategy<T>() {
@Override
public int computeHashCode(T object) {
return System.identityHashCode( object );
}
@Override
public boolean equals(T object1, T object2) {
return object1 == object2;
}
}, size, fillFactor );
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/GsIdentityMapTest.java
import org.eclipse.collections.api.block.HashingStrategy;
import org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* GS IdentityMap version
*/
public class GsIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new UnifiedMapWithHashingStrategy<>(new HashingStrategy<T>() {
@Override
public int computeHashCode(T object) {
return System.identityHashCode( object );
}
@Override
public boolean equals(T object1, T object2) {
return object1 == object2;
}
}, size, fillFactor );
}
| private static class GsIdentityMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/AgronaIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.agrona.collections.Int2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.prim_object;
/**
* Agrona Int2ObjectHashMap test
*/
public class AgronaIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/prim_object/AgronaIntObjectMapTest.java
import org.agrona.collections.Int2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.prim_object;
/**
* Agrona Int2ObjectHashMap test
*/
public class AgronaIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/KolobokeObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjIntMap;
import com.koloboke.collect.map.hash.HashObjIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* Koloboke object-2-int map
*/
public class KolobokeObjectIntMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/KolobokeObjectIntMapTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjIntMap;
import com.koloboke.collect.map.hash.HashObjIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* Koloboke object-2-int map
*/
public class KolobokeObjectIntMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/TroveIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.IdentityHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* Trove IdentityHashMap version
*/
public class TroveIdentityMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/TroveIdentityMapTest.java
import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.IdentityHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* Trove IdentityHashMap version
*/
public class TroveIdentityMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/TroveIdentityMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.IdentityHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* Trove IdentityHashMap version
*/
public class TroveIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveIdentityObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveIdentityObjMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/TroveIdentityMapTest.java
import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.IdentityHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* Trove IdentityHashMap version
*/
public class TroveIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveIdentityObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveIdentityObjMapRemoveTest();
}
| private static class TroveIdentityMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/HppcObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | package tests.maptests.object;
/**
* HPPC ObjectObjectHashMap test
*/
public class HppcObjMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/HppcObjMapTest.java
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
package tests.maptests.object;
/**
* HPPC ObjectObjectHashMap test
*/
public class HppcObjMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/HppcObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | package tests.maptests.object;
/**
* HPPC ObjectObjectHashMap test
*/
public class HppcObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/HppcObjMapTest.java
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
package tests.maptests.object;
/**
* HPPC ObjectObjectHashMap test
*/
public class HppcObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjMapRemoveTest();
}
| private static class HppcObjMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/HppcObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | @Override
public IMapTest putTest() {
return new HppcObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjMapRemoveTest();
}
private static class HppcObjMapGetTest extends AbstractObjKeyGetTest {
private ObjectObjectMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new ObjectObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/HppcObjMapTest.java
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
@Override
public IMapTest putTest() {
return new HppcObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjMapRemoveTest();
}
private static class HppcObjMapGetTest extends AbstractObjKeyGetTest {
private ObjectObjectMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new ObjectObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class HppcObjMapPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/TroveIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.prim_object;
/**
* Trove TIntObjectHashMap
*/
public class TroveIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/prim_object/TroveIntObjectMapTest.java
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.prim_object;
/**
* Trove TIntObjectHashMap
*/
public class TroveIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/AgronaObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | package tests.maptests.object;
/**
* Agrona Object2ObjectHashMap test
*/
public class AgronaObjMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/AgronaObjMapTest.java
import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
package tests.maptests.object;
/**
* Agrona Object2ObjectHashMap test
*/
public class AgronaObjMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/AgronaObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | package tests.maptests.object;
/**
* Agrona Object2ObjectHashMap test
*/
public class AgronaObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new AgronaObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjMapRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/AgronaObjMapTest.java
import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
package tests.maptests.object;
/**
* Agrona Object2ObjectHashMap test
*/
public class AgronaObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new AgronaObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjMapRemoveTest();
}
| private static class AgronaObjMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/AgronaObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest; | @Override
public IMapTest putTest() {
return new AgronaObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjMapRemoveTest();
}
private static class AgronaObjMapGetTest extends AbstractObjKeyGetTest {
private Object2ObjectHashMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/AgronaObjMapTest.java
import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
@Override
public IMapTest putTest() {
return new AgronaObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjMapRemoveTest();
}
private static class AgronaObjMapGetTest extends AbstractObjKeyGetTest {
private Object2ObjectHashMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class AgronaObjMapPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/FastUtilIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.prim_object;
/**
* FastUtil Int2ObjectOpenHashMap test
*/
public class FastUtilIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/prim_object/FastUtilIntObjectMapTest.java
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.prim_object;
/**
* FastUtil Int2ObjectOpenHashMap test
*/
public class FastUtilIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/KolobokeMutableMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntIntMap;
import com.koloboke.collect.map.hash.HashIntIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.primitive;
/**
* Koloboke HashIntIntMaps.newMutableMap test
*/
public class KolobokeMutableMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/KolobokeMutableMapTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntIntMap;
import com.koloboke.collect.map.hash.HashIntIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.primitive;
/**
* Koloboke HashIntIntMaps.newMutableMap test
*/
public class KolobokeMutableMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/GsMutableMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import org.eclipse.collections.api.map.primitive.IntIntMap;
import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.primitive;
/**
* GS IntIntHashMap test. Fixed fill factor = 0.5
*/
public class GsMutableMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/GsMutableMapTest.java
import org.eclipse.collections.api.map.primitive.IntIntMap;
import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.primitive;
/**
* GS IntIntHashMap test. Fixed fill factor = 0.5
*/
public class GsMutableMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/HppcMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import com.carrotsearch.hppc.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.primitive;
/**
* HPPC IntIntOpenHashMap test
*/
public class HppcMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/HppcMapTest.java
import com.carrotsearch.hppc.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.primitive;
/**
* HPPC IntIntOpenHashMap test
*/
public class HppcMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object_prim/HppcObjectIntMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import com.carrotsearch.hppc.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.object_prim;
/**
* HPPC ObjectIntHashMap
*/
public class HppcObjectIntMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/object_prim/HppcObjectIntMapTest.java
import com.carrotsearch.hppc.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.object_prim;
/**
* HPPC ObjectIntHashMap
*/
public class HppcObjectIntMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/GsObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* GS UnifiedMap test
*/
public class GsObjMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/GsObjMapTest.java
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* GS UnifiedMap test
*/
public class GsObjMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/GsObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; | package tests.maptests.object;
/**
* GS UnifiedMap test
*/
public class GsObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsObjGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/GsObjMapTest.java
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
package tests.maptests.object;
/**
* GS UnifiedMap test
*/
public class GsObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsObjGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjRemoveTest();
}
| private static class GsObjGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/GsObjMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map; |
@Override
public IMapTest putTest() {
return new GsObjPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjRemoveTest();
}
private static class GsObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new UnifiedMap<>( keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/GsObjMapTest.java
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
@Override
public IMapTest putTest() {
return new GsObjPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjRemoveTest();
}
private static class GsObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new UnifiedMap<>( keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class GsObjPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/map/objobj/ObjObjMap.java | // Path: src/main/java/map/intint/Tools.java
// public class Tools {
//
// /** Taken from FastUtil implementation */
//
// /** Return the least power of two greater than or equal to the specified value.
// *
// * <p>Note that this function will return 1 when the argument is 0.
// *
// * @param x a long integer smaller than or equal to 2<sup>62</sup>.
// * @return the least power of two greater than or equal to the specified value.
// */
// public static long nextPowerOfTwo( long x ) {
// if ( x == 0 ) return 1;
// x--;
// x |= x >> 1;
// x |= x >> 2;
// x |= x >> 4;
// x |= x >> 8;
// x |= x >> 16;
// return ( x | x >> 32 ) + 1;
// }
//
// /** Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>.
// *
// * @param expected the expected number of elements in a hash table.
// * @param f the load factor.
// * @return the minimum possible size for a backing array.
// * @throws IllegalArgumentException if the necessary size is larger than 2<sup>30</sup>.
// */
// public static int arraySize( final int expected, final float f ) {
// final long s = Math.max( 2, nextPowerOfTwo( (long)Math.ceil( expected / f ) ) );
// if ( s > (1 << 30) ) throw new IllegalArgumentException( "Too large (" + expected + " expected elements with load factor " + f + ")" );
// return (int)s;
// }
//
// //taken from FastUtil
// private static final int INT_PHI = 0x9E3779B9;
//
// public static int phiMix( final int x ) {
// final int h = x * INT_PHI;
// return h ^ (h >> 16);
// }
//
//
// }
| import map.intint.Tools;
import java.util.Arrays; | package map.objobj;
/**
* Object-2-object map based on IntIntMap4a
*/
public class ObjObjMap<K, V>
{
private static final Object FREE_KEY = new Object();
private static final Object REMOVED_KEY = new Object();
/** Keys and values */
private Object[] m_data;
/** Value for the null key (if inserted into a map) */
private Object m_nullValue;
private boolean m_hasNull;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
/** Mask to wrap the actual array pointer */
private int m_mask2;
public ObjObjMap( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" ); | // Path: src/main/java/map/intint/Tools.java
// public class Tools {
//
// /** Taken from FastUtil implementation */
//
// /** Return the least power of two greater than or equal to the specified value.
// *
// * <p>Note that this function will return 1 when the argument is 0.
// *
// * @param x a long integer smaller than or equal to 2<sup>62</sup>.
// * @return the least power of two greater than or equal to the specified value.
// */
// public static long nextPowerOfTwo( long x ) {
// if ( x == 0 ) return 1;
// x--;
// x |= x >> 1;
// x |= x >> 2;
// x |= x >> 4;
// x |= x >> 8;
// x |= x >> 16;
// return ( x | x >> 32 ) + 1;
// }
//
// /** Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>.
// *
// * @param expected the expected number of elements in a hash table.
// * @param f the load factor.
// * @return the minimum possible size for a backing array.
// * @throws IllegalArgumentException if the necessary size is larger than 2<sup>30</sup>.
// */
// public static int arraySize( final int expected, final float f ) {
// final long s = Math.max( 2, nextPowerOfTwo( (long)Math.ceil( expected / f ) ) );
// if ( s > (1 << 30) ) throw new IllegalArgumentException( "Too large (" + expected + " expected elements with load factor " + f + ")" );
// return (int)s;
// }
//
// //taken from FastUtil
// private static final int INT_PHI = 0x9E3779B9;
//
// public static int phiMix( final int x ) {
// final int h = x * INT_PHI;
// return h ^ (h >> 16);
// }
//
//
// }
// Path: src/main/java/map/objobj/ObjObjMap.java
import map.intint.Tools;
import java.util.Arrays;
package map.objobj;
/**
* Object-2-object map based on IntIntMap4a
*/
public class ObjObjMap<K, V>
{
private static final Object FREE_KEY = new Object();
private static final Object REMOVED_KEY = new Object();
/** Keys and values */
private Object[] m_data;
/** Value for the null key (if inserted into a map) */
private Object m_nullValue;
private boolean m_hasNull;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
/** Mask to wrap the actual array pointer */
private int m_mask2;
public ObjObjMap( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" ); | final int capacity = Tools.arraySize(size, fillFactor); |
mikvor/hashmapTest | src/main/java/tests/maptests/object/JdkMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map; | package tests.maptests.object;
/**
* JDK Map<Integer, Integer> tests
*/
public class JdkMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/JdkMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map;
package tests.maptests.object;
/**
* JDK Map<Integer, Integer> tests
*/
public class JdkMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/JdkMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map; | package tests.maptests.object;
/**
* JDK Map<Integer, Integer> tests
*/
public class JdkMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JdkMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkMapRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( size, fillFactor );
}
//classes are non static due to a subclass presence | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/JdkMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map;
package tests.maptests.object;
/**
* JDK Map<Integer, Integer> tests
*/
public class JdkMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JdkMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkMapRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( size, fillFactor );
}
//classes are non static due to a subclass presence | private class JdkMapGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/object/JdkMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map; | public IMapTest removeTest() {
return new JdkMapRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( size, fillFactor );
}
//classes are non static due to a subclass presence
private class JdkMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyPutTest.java
// public abstract class AbstractObjKeyPutTest implements IMapTest {
// protected Integer[] m_keys;
// protected Integer[] m_keys2;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
// m_fillFactor = fillFactor;
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// m_keys2 = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys2[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/object/JdkMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map;
public IMapTest removeTest() {
return new JdkMapRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( size, fillFactor );
}
//classes are non static due to a subclass presence
private class JdkMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private class JdkMapPutTest extends AbstractObjKeyPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; | package tests.maptests.prim_object;
/**
* Koloboke int-2-object map test
*/
public class KolobokeIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
package tests.maptests.prim_object;
/**
* Koloboke int-2-object map test
*/
public class KolobokeIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; | package tests.maptests.prim_object;
/**
* Koloboke int-2-object map test
*/
public class KolobokeIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeIntObjectRemoveTest();
}
private static <T> HashIntObjMap<T> makeMap(final int size, final float fillFactor )
{
return HashIntObjMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor)).newMutableMap( size );
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
package tests.maptests.prim_object;
/**
* Koloboke int-2-object map test
*/
public class KolobokeIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeIntObjectRemoveTest();
}
private static <T> HashIntObjMap<T> makeMap(final int size, final float fillFactor )
{
return HashIntObjMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor)).newMutableMap( size );
}
| private static class KolobokeIntObjectGetTest extends AbstractPrimPrimGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
| import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest; |
@Override
public IMapTest removeTest() {
return new KolobokeIntObjectRemoveTest();
}
private static <T> HashIntObjMap<T> makeMap(final int size, final float fillFactor )
{
return HashIntObjMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor)).newMutableMap( size );
}
private static class KolobokeIntObjectGetTest extends AbstractPrimPrimGetTest {
private HashIntObjMap<Integer> m_map;
@Override
public void setup(final int[] keys, float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf);
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put(key % oneFailOutOf == 0 ? key + 1 : key, Integer.valueOf(key));
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimGetTest.java
// public abstract class AbstractPrimPrimGetTest implements IMapTest {
// protected int[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_keys = keys;
// }
// }
//
// Path: src/main/java/tests/maptests/primitive/AbstractPrimPrimPutTest.java
// public abstract class AbstractPrimPrimPutTest implements IMapTest {
// protected int[] m_keys;
// protected float m_fillFactor;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
// m_fillFactor = fillFactor;
// m_keys = keys;
// }
// }
// Path: src/main/java/tests/maptests/prim_object/KolobokeIntObjectMapTest.java
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
@Override
public IMapTest removeTest() {
return new KolobokeIntObjectRemoveTest();
}
private static <T> HashIntObjMap<T> makeMap(final int size, final float fillFactor )
{
return HashIntObjMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor)).newMutableMap( size );
}
private static class KolobokeIntObjectGetTest extends AbstractPrimPrimGetTest {
private HashIntObjMap<Integer> m_map;
@Override
public void setup(final int[] keys, float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf);
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put(key % oneFailOutOf == 0 ? key + 1 : key, Integer.valueOf(key));
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
| private static class KolobokeIntObjectPutTest extends AbstractPrimPrimPutTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/prim_object/HppcIntObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import com.carrotsearch.hppc.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.prim_object;
/**
* HPPC IntObjectHashMap test
*/
public class HppcIntObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/prim_object/HppcIntObjectMapTest.java
import com.carrotsearch.hppc.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.prim_object;
/**
* HPPC IntObjectHashMap test
*/
public class HppcIntObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/FastUtilRef2ObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* FastUtil IdentityHashMap version
*/
public class FastUtilRef2ObjectMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/FastUtilRef2ObjectMapTest.java
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* FastUtil IdentityHashMap version
*/
public class FastUtilRef2ObjectMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/identity_object/FastUtilRef2ObjectMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
| import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map; | package tests.maptests.identity_object;
/**
* FastUtil IdentityHashMap version
*/
public class FastUtilRef2ObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilRef2ObjectGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilRef2ObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilRef2ObjRemoveTest();
}
| // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
//
// Path: src/main/java/tests/maptests/object_prim/AbstractObjKeyGetTest.java
// public abstract class AbstractObjKeyGetTest implements IMapTest {
// protected Integer[] m_keys;
//
// @Override
// public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
// m_keys = new Integer[ keys.length ];
// for ( int i = 0; i < keys.length; ++i )
// m_keys[ i ] = new Integer( keys[ i ] );
// }
// }
// Path: src/main/java/tests/maptests/identity_object/FastUtilRef2ObjectMapTest.java
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
package tests.maptests.identity_object;
/**
* FastUtil IdentityHashMap version
*/
public class FastUtilRef2ObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilRef2ObjectGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilRef2ObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilRef2ObjRemoveTest();
}
| private static class FastUtilRef2ObjectGetTest extends AbstractObjKeyGetTest { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/AgronaMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import org.agrona.collections.Int2IntHashMap; | package tests.maptests.primitive;
/**
* Agrona Int2IntHashMap test
*/
public class AgronaMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/AgronaMapTest.java
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import org.agrona.collections.Int2IntHashMap;
package tests.maptests.primitive;
/**
* Agrona Int2IntHashMap test
*/
public class AgronaMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override | public IMapTest getTest() { |
mikvor/hashmapTest | src/main/java/tests/maptests/primitive/FastUtilMapTest.java | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
| import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet; | package tests.maptests.primitive;
/**
* FastUtil Int2IntOpenHashMap test
*/
public class FastUtilMapTest implements ITestSet
{
@Override | // Path: src/main/java/tests/maptests/IMapTest.java
// public interface IMapTest {
// public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
//
// public int test();
// }
//
// Path: src/main/java/tests/maptests/ITestSet.java
// public interface ITestSet {
// public IMapTest getTest();
// public IMapTest putTest();
// public IMapTest removeTest();
// }
// Path: src/main/java/tests/maptests/primitive/FastUtilMapTest.java
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
package tests.maptests.primitive;
/**
* FastUtil Int2IntOpenHashMap test
*/
public class FastUtilMapTest implements ITestSet
{
@Override | public IMapTest getTest() { |
monitorjbl/pr-harmony | src/test/java/ut/com/monitorjbl/plugins/UserUtilsTest.java | // Path: src/test/java/ut/com/monitorjbl/plugins/TestUtils.java
// public static ApplicationUser mockApplicationUser(String name) {
// ApplicationUser user = mock(ApplicationUser.class);
// when(user.getSlug()).thenReturn(name);
// return user;
// }
| import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.util.Page;
import com.atlassian.bitbucket.util.PageRequest;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
import static com.monitorjbl.plugins.TestUtils.mockApplicationUser;
import static java.util.Collections.emptyList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package com.monitorjbl.plugins;
public class UserUtilsTest {
@Mock
private UserService userService;
@InjectMocks
UserUtils sut;
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
MockitoAnnotations.initMocks(this); | // Path: src/test/java/ut/com/monitorjbl/plugins/TestUtils.java
// public static ApplicationUser mockApplicationUser(String name) {
// ApplicationUser user = mock(ApplicationUser.class);
// when(user.getSlug()).thenReturn(name);
// return user;
// }
// Path: src/test/java/ut/com/monitorjbl/plugins/UserUtilsTest.java
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.util.Page;
import com.atlassian.bitbucket.util.PageRequest;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
import static com.monitorjbl.plugins.TestUtils.mockApplicationUser;
import static java.util.Collections.emptyList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package com.monitorjbl.plugins;
public class UserUtilsTest {
@Mock
private UserService userService;
@InjectMocks
UserUtils sut;
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
MockitoAnnotations.initMocks(this); | ApplicationUser userA = mockApplicationUser("userA"); |
monitorjbl/pr-harmony | src/test/java/ut/com/monitorjbl/plugins/config/ConfigServletTest.java | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
| import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.monitorjbl.plugins.UserUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import javax.servlet.http.HttpServletResponse;
import java.io.Writer;
import java.util.Map;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.monitorjbl.plugins.config;
@SuppressWarnings("unchecked")
public class ConfigServletTest {
@Mock
private UserManager userManager;
@Mock | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
// Path: src/test/java/ut/com/monitorjbl/plugins/config/ConfigServletTest.java
import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.monitorjbl.plugins.UserUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import javax.servlet.http.HttpServletResponse;
import java.io.Writer;
import java.util.Map;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.monitorjbl.plugins.config;
@SuppressWarnings("unchecked")
public class ConfigServletTest {
@Mock
private UserManager userManager;
@Mock | private UserUtils userUtils; |
monitorjbl/pr-harmony | src/main/java/com/monitorjbl/plugins/config/ConfigServlet.java | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
| import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.project.ProjectService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI; | package com.monitorjbl.plugins.config;
public class ConfigServlet extends HttpServlet {
public static final String SERVLET_PATH = "/plugins/servlet/pr-harmony/";
private static final Logger logger = LoggerFactory.getLogger(ConfigServlet.class);
private final UserManager userManager; | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
// Path: src/main/java/com/monitorjbl/plugins/config/ConfigServlet.java
import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.project.ProjectService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
package com.monitorjbl.plugins.config;
public class ConfigServlet extends HttpServlet {
public static final String SERVLET_PATH = "/plugins/servlet/pr-harmony/";
private static final Logger logger = LoggerFactory.getLogger(ConfigServlet.class);
private final UserManager userManager; | private final UserUtils userUtils; |
monitorjbl/pr-harmony | src/main/java/com/monitorjbl/plugins/config/UserResource.java | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
| import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet; | package com.monitorjbl.plugins.config;
@Path("/users/{projectKey}/{repoSlug}")
public class UserResource {
private final ConfigDao configDao; | // Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
// private static final int RESULTS_PER_REQUEST = 25;
// private final UserService userService;
//
// public UserUtils(UserService userService) {
// this.userService = userService;
// }
//
// public List<User> dereferenceUsers(Iterable<String> users) {
// List<User> list = newArrayList();
// for(String u : users) {
// Optional<User> user = getUserByName(u);
// if(user.isPresent()) {
// list.add(user.get());
// }
// }
// return list;
// }
//
// public Optional<User> getUserByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
// }
//
// public String getUserDisplayNameByName(String username) {
// ApplicationUser user = userService.getUserByName(username);
// return user.getDisplayName() == null ? username : user.getDisplayName();
// }
//
// public ApplicationUser getApplicationUserByName(String username) {
// return userService.getUserByName(username);
// }
//
// public List<String> dereferenceGroups(List<String> groups) {
// List<String> users = newArrayList();
// for(String group : groups) {
// List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
// for(int i = 1; results.size() > 0; i++) {
// users.addAll(results.stream()
// .map(ApplicationUser::getSlug)
// .collect(Collectors.toList()));
// results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
// }
// }
// return users;
// }
//
//
// }
// Path: src/main/java/com/monitorjbl/plugins/config/UserResource.java
import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
package com.monitorjbl.plugins.config;
@Path("/users/{projectKey}/{repoSlug}")
public class UserResource {
private final ConfigDao configDao; | private final UserUtils utils; |
monitorjbl/pr-harmony | src/main/java/com/monitorjbl/plugins/UserUtils.java | // Path: src/main/java/com/monitorjbl/plugins/config/User.java
// @XmlRootElement
// @XmlAccessorType(XmlAccessType.FIELD)
// public class User {
// private String slug;
// private String name;
//
// public User() {
// }
//
// public User(String slug, String name) {
// this.slug = slug;
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (name != null ? !name.equals(user.name) : user.name != null) return false;
// if (slug != null ? !slug.equals(user.slug) : user.slug != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = slug != null ? slug.hashCode() : 0;
// result = 31 * result + (name != null ? name.hashCode() : 0);
// return result;
// }
// }
| import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.util.PageRequestImpl;
import com.monitorjbl.plugins.config.User;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.google.common.collect.Lists.newArrayList; | package com.monitorjbl.plugins;
public class UserUtils {
private static final int RESULTS_PER_REQUEST = 25;
private final UserService userService;
public UserUtils(UserService userService) {
this.userService = userService;
}
| // Path: src/main/java/com/monitorjbl/plugins/config/User.java
// @XmlRootElement
// @XmlAccessorType(XmlAccessType.FIELD)
// public class User {
// private String slug;
// private String name;
//
// public User() {
// }
//
// public User(String slug, String name) {
// this.slug = slug;
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (name != null ? !name.equals(user.name) : user.name != null) return false;
// if (slug != null ? !slug.equals(user.slug) : user.slug != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = slug != null ? slug.hashCode() : 0;
// result = 31 * result + (name != null ? name.hashCode() : 0);
// return result;
// }
// }
// Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.util.PageRequestImpl;
import com.monitorjbl.plugins.config.User;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.google.common.collect.Lists.newArrayList;
package com.monitorjbl.plugins;
public class UserUtils {
private static final int RESULTS_PER_REQUEST = 25;
private final UserService userService;
public UserUtils(UserService userService) {
this.userService = userService;
}
| public List<User> dereferenceUsers(Iterable<String> users) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/util/Util.java | // Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_NOT_INITIALIZED = "SHERPA_SERVER_NOT_INITIALIZED->";
//
// Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_SERVER = "SHERPA_SERVER->";
| import static com.khs.sherpa.util.Constants.SHERPA_NOT_INITIALIZED;
import static com.khs.sherpa.util.Constants.SHERPA_SERVER;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import com.khs.sherpa.annotation.Endpoint; | package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Util {
public static String msg(String msg) { | // Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_NOT_INITIALIZED = "SHERPA_SERVER_NOT_INITIALIZED->";
//
// Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_SERVER = "SHERPA_SERVER->";
// Path: src/main/java/com/khs/sherpa/util/Util.java
import static com.khs.sherpa.util.Constants.SHERPA_NOT_INITIALIZED;
import static com.khs.sherpa.util.Constants.SHERPA_SERVER;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import com.khs.sherpa.annotation.Endpoint;
package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Util {
public static String msg(String msg) { | return SHERPA_SERVER+msg; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/util/Util.java | // Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_NOT_INITIALIZED = "SHERPA_SERVER_NOT_INITIALIZED->";
//
// Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_SERVER = "SHERPA_SERVER->";
| import static com.khs.sherpa.util.Constants.SHERPA_NOT_INITIALIZED;
import static com.khs.sherpa.util.Constants.SHERPA_SERVER;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import com.khs.sherpa.annotation.Endpoint; | package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Util {
public static String msg(String msg) {
return SHERPA_SERVER+msg;
}
public static String errmsg(String msg) { | // Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_NOT_INITIALIZED = "SHERPA_SERVER_NOT_INITIALIZED->";
//
// Path: src/main/java/com/khs/sherpa/util/Constants.java
// public final static String SHERPA_SERVER = "SHERPA_SERVER->";
// Path: src/main/java/com/khs/sherpa/util/Util.java
import static com.khs.sherpa.util.Constants.SHERPA_NOT_INITIALIZED;
import static com.khs.sherpa.util.Constants.SHERPA_SERVER;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import com.khs.sherpa.annotation.Endpoint;
package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Util {
public static String msg(String msg) {
return SHERPA_SERVER+msg;
}
public static String errmsg(String msg) { | return SHERPA_NOT_INITIALIZED+msg; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/DateParamParser.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
| import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class DateParamParser implements ApplicationContextAware, ParamParser<Date> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_DATE_FORMAT";
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
// Path: src/main/java/com/khs/sherpa/parser/DateParamParser.java
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class DateParamParser implements ApplicationContextAware, ParamParser<Date> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_DATE_FORMAT";
| private ApplicationContext applicationContext; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/JsonParamParser.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
| import java.util.Calendar;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
import com.khs.sherpa.json.service.JsonProvider; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class JsonParamParser implements ApplicationContextAware, ParamParser<Object> {
private JsonProvider jsonProvider;
public boolean isValid(Class<?> clazz) {
return !clazz.isAssignableFrom(Boolean.class) &&
!clazz.isAssignableFrom(boolean.class) &&
!clazz.isAssignableFrom(Calendar.class) &&
!clazz.isAssignableFrom(Date.class) &&
!clazz.isAssignableFrom(Double.class) &&
!clazz.isAssignableFrom(double.class) &&
!clazz.isAssignableFrom(float.class) &&
!clazz.isAssignableFrom(Float.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class);
}
public Object parse(String value, Param annotation, Class<?> clazz) {
return jsonProvider.toObject(value, clazz);
}
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
// Path: src/main/java/com/khs/sherpa/parser/JsonParamParser.java
import java.util.Calendar;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
import com.khs.sherpa.json.service.JsonProvider;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class JsonParamParser implements ApplicationContextAware, ParamParser<Object> {
private JsonProvider jsonProvider;
public boolean isValid(Class<?> clazz) {
return !clazz.isAssignableFrom(Boolean.class) &&
!clazz.isAssignableFrom(boolean.class) &&
!clazz.isAssignableFrom(Calendar.class) &&
!clazz.isAssignableFrom(Date.class) &&
!clazz.isAssignableFrom(Double.class) &&
!clazz.isAssignableFrom(double.class) &&
!clazz.isAssignableFrom(float.class) &&
!clazz.isAssignableFrom(Float.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class);
}
public Object parse(String value, Param annotation, Class<?> clazz) {
return jsonProvider.toObject(value, clazz);
}
| public void setApplicationContext(ApplicationContext applicationContext) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/JsonParamParser.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
| import java.util.Calendar;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
import com.khs.sherpa.json.service.JsonProvider; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class JsonParamParser implements ApplicationContextAware, ParamParser<Object> {
private JsonProvider jsonProvider;
public boolean isValid(Class<?> clazz) {
return !clazz.isAssignableFrom(Boolean.class) &&
!clazz.isAssignableFrom(boolean.class) &&
!clazz.isAssignableFrom(Calendar.class) &&
!clazz.isAssignableFrom(Date.class) &&
!clazz.isAssignableFrom(Double.class) &&
!clazz.isAssignableFrom(double.class) &&
!clazz.isAssignableFrom(float.class) &&
!clazz.isAssignableFrom(Float.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class);
}
public Object parse(String value, Param annotation, Class<?> clazz) {
return jsonProvider.toObject(value, clazz);
}
public void setApplicationContext(ApplicationContext applicationContext) {
try {
this.jsonProvider = applicationContext.getManagedBean(JsonProvider.class); | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
// Path: src/main/java/com/khs/sherpa/parser/JsonParamParser.java
import java.util.Calendar;
import java.util.Date;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
import com.khs.sherpa.json.service.JsonProvider;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class JsonParamParser implements ApplicationContextAware, ParamParser<Object> {
private JsonProvider jsonProvider;
public boolean isValid(Class<?> clazz) {
return !clazz.isAssignableFrom(Boolean.class) &&
!clazz.isAssignableFrom(boolean.class) &&
!clazz.isAssignableFrom(Calendar.class) &&
!clazz.isAssignableFrom(Date.class) &&
!clazz.isAssignableFrom(Double.class) &&
!clazz.isAssignableFrom(double.class) &&
!clazz.isAssignableFrom(float.class) &&
!clazz.isAssignableFrom(Float.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class) &&
!clazz.isAssignableFrom(Integer.class) &&
!clazz.isAssignableFrom(int.class);
}
public Object parse(String value, Param annotation, Class<?> clazz) {
return jsonProvider.toObject(value, clazz);
}
public void setApplicationContext(ApplicationContext applicationContext) {
try {
this.jsonProvider = applicationContext.getManagedBean(JsonProvider.class); | } catch (NoSuchManagedBeanExcpetion e) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/CalendarParamParser.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
| import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class CalendarParamParser implements ApplicationContextAware, ParamParser<Calendar> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_CALENDAR_FORMAT";
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
// Path: src/main/java/com/khs/sherpa/parser/CalendarParamParser.java
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class CalendarParamParser implements ApplicationContextAware, ParamParser<Calendar> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_CALENDAR_FORMAT";
| private ApplicationContext applicationContext; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/StringParamParser.java | // Path: src/main/java/com/khs/sherpa/annotation/Encode.java
// public class Encode {
//
// public static final String XML = "XML";
// public static final String HTML = "HTML";
// public static final String CSV = "CSV";
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
| import org.apache.commons.lang3.StringEscapeUtils;
import com.khs.sherpa.annotation.Encode;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class StringParamParser implements ApplicationContextAware, ParamParser<String> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_STRING_FORMAT";
| // Path: src/main/java/com/khs/sherpa/annotation/Encode.java
// public class Encode {
//
// public static final String XML = "XML";
// public static final String HTML = "HTML";
// public static final String CSV = "CSV";
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
// Path: src/main/java/com/khs/sherpa/parser/StringParamParser.java
import org.apache.commons.lang3.StringEscapeUtils;
import com.khs.sherpa.annotation.Encode;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class StringParamParser implements ApplicationContextAware, ParamParser<String> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_STRING_FORMAT";
| private ApplicationContext applicationContext; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/parser/StringParamParser.java | // Path: src/main/java/com/khs/sherpa/annotation/Encode.java
// public class Encode {
//
// public static final String XML = "XML";
// public static final String HTML = "HTML";
// public static final String CSV = "CSV";
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
| import org.apache.commons.lang3.StringEscapeUtils;
import com.khs.sherpa.annotation.Encode;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware; | package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class StringParamParser implements ApplicationContextAware, ParamParser<String> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_STRING_FORMAT";
private ApplicationContext applicationContext;
public String parse(String value, Param annotation, Class<?> clazz) {
String format = annotation.format();
if(format == null || format.equals("")) {
format = (String) applicationContext.getAttribute(DEFAULT);
}
return this.applyEncoding(value, format);
}
public boolean isValid(Class<?> clazz) {
return clazz.isAssignableFrom(String.class);
}
private String applyEncoding(String value,String format) {
String result = value;
if (format != null) { | // Path: src/main/java/com/khs/sherpa/annotation/Encode.java
// public class Encode {
//
// public static final String XML = "XML";
// public static final String HTML = "HTML";
// public static final String CSV = "CSV";
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/context/ApplicationContextAware.java
// public interface ApplicationContextAware {
//
// public void setApplicationContext(ApplicationContext applicationContext);
//
// }
// Path: src/main/java/com/khs/sherpa/parser/StringParamParser.java
import org.apache.commons.lang3.StringEscapeUtils;
import com.khs.sherpa.annotation.Encode;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
package com.khs.sherpa.parser;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class StringParamParser implements ApplicationContextAware, ParamParser<String> {
public static final String DEFAULT = "com.khs.sherpa.DEFUALT_STRING_FORMAT";
private ApplicationContext applicationContext;
public String parse(String value, Param annotation, Class<?> clazz) {
String format = annotation.format();
if(format == null || format.equals("")) {
format = (String) applicationContext.getAttribute(DEFAULT);
}
return this.applyEncoding(value, format);
}
public boolean isValid(Class<?> clazz) {
return clazz.isAssignableFrom(String.class);
}
private String applyEncoding(String value,String format) {
String result = value;
if (format != null) { | if (format.equals(Encode.XML)) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/json/service/Authentication.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
| import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion; | package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Authentication {
// private static final Logger LOG = Logger.getLogger(SherpaServlet.class.getName());
private UserService userService;
private SessionTokenService tokenService;
private ActivityService activityService;
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
// Path: src/main/java/com/khs/sherpa/json/service/Authentication.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Authentication {
// private static final Logger LOG = Logger.getLogger(SherpaServlet.class.getName());
private UserService userService;
private SessionTokenService tokenService;
private ActivityService activityService;
| public Authentication(ApplicationContext context) throws NoSuchManagedBeanExcpetion { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/json/service/Authentication.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
| import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion; | package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Authentication {
// private static final Logger LOG = Logger.getLogger(SherpaServlet.class.getName());
private UserService userService;
private SessionTokenService tokenService;
private ActivityService activityService;
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
//
// Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
// Path: src/main/java/com/khs/sherpa/json/service/Authentication.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class Authentication {
// private static final Logger LOG = Logger.getLogger(SherpaServlet.class.getName());
private UserService userService;
private SessionTokenService tokenService;
private ActivityService activityService;
| public Authentication(ApplicationContext context) throws NoSuchManagedBeanExcpetion { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/util/MethodUtil.java | // Path: src/main/java/com/khs/sherpa/annotation/MethodRequest.java
// public enum MethodRequest {
// GET,PUT,POST,DELETE
// }
//
// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
| import java.lang.reflect.Method;
import com.khs.sherpa.annotation.Action;
import com.khs.sherpa.annotation.MethodRequest;
import com.khs.sherpa.exception.SherpaRuntimeException; | package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class MethodUtil {
public static Method validateHttpMethods(Method[] methods, String httpMethod) {
Method method = null;
for(Method m: methods) {
Method newMethod = null;
if(m.isAnnotationPresent(Action.class)) {
if(m.getAnnotation(Action.class).method().length == 0) {
newMethod = m;
} else { | // Path: src/main/java/com/khs/sherpa/annotation/MethodRequest.java
// public enum MethodRequest {
// GET,PUT,POST,DELETE
// }
//
// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
// Path: src/main/java/com/khs/sherpa/util/MethodUtil.java
import java.lang.reflect.Method;
import com.khs.sherpa.annotation.Action;
import com.khs.sherpa.annotation.MethodRequest;
import com.khs.sherpa.exception.SherpaRuntimeException;
package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class MethodUtil {
public static Method validateHttpMethods(Method[] methods, String httpMethod) {
Method method = null;
for(Method m: methods) {
Method newMethod = null;
if(m.isAnnotationPresent(Action.class)) {
if(m.getAnnotation(Action.class).method().length == 0) {
newMethod = m;
} else { | for(MethodRequest r: m.getAnnotation(Action.class).method()) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/util/MethodUtil.java | // Path: src/main/java/com/khs/sherpa/annotation/MethodRequest.java
// public enum MethodRequest {
// GET,PUT,POST,DELETE
// }
//
// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
| import java.lang.reflect.Method;
import com.khs.sherpa.annotation.Action;
import com.khs.sherpa.annotation.MethodRequest;
import com.khs.sherpa.exception.SherpaRuntimeException; | package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class MethodUtil {
public static Method validateHttpMethods(Method[] methods, String httpMethod) {
Method method = null;
for(Method m: methods) {
Method newMethod = null;
if(m.isAnnotationPresent(Action.class)) {
if(m.getAnnotation(Action.class).method().length == 0) {
newMethod = m;
} else {
for(MethodRequest r: m.getAnnotation(Action.class).method()) {
if(r.toString().equalsIgnoreCase(httpMethod)) {
newMethod = m;
}
}
}
} else {
newMethod = m;
}
if(newMethod == null) {
continue;
}
if(method != null) { | // Path: src/main/java/com/khs/sherpa/annotation/MethodRequest.java
// public enum MethodRequest {
// GET,PUT,POST,DELETE
// }
//
// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
// Path: src/main/java/com/khs/sherpa/util/MethodUtil.java
import java.lang.reflect.Method;
import com.khs.sherpa.annotation.Action;
import com.khs.sherpa.annotation.MethodRequest;
import com.khs.sherpa.exception.SherpaRuntimeException;
package com.khs.sherpa.util;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class MethodUtil {
public static Method validateHttpMethods(Method[] methods, String httpMethod) {
Method method = null;
for(Method m: methods) {
Method newMethod = null;
if(m.isAnnotationPresent(Action.class)) {
if(m.getAnnotation(Action.class).method().length == 0) {
newMethod = m;
} else {
for(MethodRequest r: m.getAnnotation(Action.class).method()) {
if(r.toString().equalsIgnoreCase(httpMethod)) {
newMethod = m;
}
}
}
} else {
newMethod = m;
}
if(newMethod == null) {
continue;
}
if(method != null) { | throw new SherpaRuntimeException("To many methods found for method ["+method.getName()+"]"); |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/context/factory/ManagedBeanFactory.java | // Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
| import java.util.Collection;
import java.util.Map;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion; | package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public interface ManagedBeanFactory {
/**
* @param type
* @return
*/
public boolean containsManagedBean(Class<?> type);
/**
* @param name
* @return
*/
public boolean containsManagedBean(String name);
/**
* @param type
* @return
* @throws NoSuchManagedBeanExcpetion
*/ | // Path: src/main/java/com/khs/sherpa/exception/NoSuchManagedBeanExcpetion.java
// public class NoSuchManagedBeanExcpetion extends SherpaException {
//
// public NoSuchManagedBeanExcpetion() {
// super();
// }
//
// public NoSuchManagedBeanExcpetion(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public NoSuchManagedBeanExcpetion(String arg0) {
// super(arg0);
// }
//
// public NoSuchManagedBeanExcpetion(Throwable arg0) {
// super(arg0);
// }
//
// private static final long serialVersionUID = 3764129759598703541L;
//
// }
// Path: src/main/java/com/khs/sherpa/context/factory/ManagedBeanFactory.java
import java.util.Collection;
import java.util.Map;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public interface ManagedBeanFactory {
/**
* @param type
* @return
*/
public boolean containsManagedBean(Class<?> type);
/**
* @param name
* @return
*/
public boolean containsManagedBean(String name);
/**
* @param type
* @return
* @throws NoSuchManagedBeanExcpetion
*/ | public <T> T getManagedBean(Class<T> type) throws NoSuchManagedBeanExcpetion; |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/json/service/DefaultActivityService.java | // Path: src/main/java/com/khs/sherpa/util/Util.java
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
| import static com.khs.sherpa.util.Util.msg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class DefaultActivityService implements ActivityService {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultActivityService.class);
public void logActivity(String userid, String activity) { | // Path: src/main/java/com/khs/sherpa/util/Util.java
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
// Path: src/main/java/com/khs/sherpa/json/service/DefaultActivityService.java
import static com.khs.sherpa.util.Util.msg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public class DefaultActivityService implements ActivityService {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultActivityService.class);
public void logActivity(String userid, String activity) { | LOGGER.info(msg(userid+":"+activity)); |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/util/JsonUtil.java | // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
| import java.io.IOException;
import java.io.OutputStream;
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.json.service.JsonProvider; | JsonUtil.map(object, provider, out);
}
}
public static void map(Object object, JsonProvider provider, OutputStream out) {
try {
if(object != null) {
out.write(provider.toJson(object).getBytes());
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void error(String msg, JsonProvider provider, OutputStream out, String callback) {
if (callback != null) {
JsonUtil.mapJsonp(new Result("ERROR", msg), provider, out, callback);
} else {
JsonUtil.map(new Result("ERROR", msg), provider, out);
}
}
public static void error(String msg, JsonProvider provider, OutputStream out) {
map(new Result("ERROR", msg), provider, out);
}
public static void info(String msg, JsonProvider provider, OutputStream out) {
map(new Result("INFO", msg), provider, out);
}
| // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/json/service/JsonProvider.java
// public interface JsonProvider {
//
// public String toJson(Object object);
//
// public <T> T toObject(String json, Class<T> type);
// }
// Path: src/main/java/com/khs/sherpa/util/JsonUtil.java
import java.io.IOException;
import java.io.OutputStream;
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.json.service.JsonProvider;
JsonUtil.map(object, provider, out);
}
}
public static void map(Object object, JsonProvider provider, OutputStream out) {
try {
if(object != null) {
out.write(provider.toJson(object).getBytes());
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void error(String msg, JsonProvider provider, OutputStream out, String callback) {
if (callback != null) {
JsonUtil.mapJsonp(new Result("ERROR", msg), provider, out, callback);
} else {
JsonUtil.map(new Result("ERROR", msg), provider, out);
}
}
public static void error(String msg, JsonProvider provider, OutputStream out) {
map(new Result("ERROR", msg), provider, out);
}
public static void info(String msg, JsonProvider provider, OutputStream out) {
map(new Result("INFO", msg), provider, out);
}
| public static void error(SherpaRuntimeException ex, JsonProvider provider, OutputStream out) { |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/json/service/DefaultUserService.java | // Path: src/main/java/com/khs/sherpa/exception/SherpaInvalidUsernamePassword.java
// public class SherpaInvalidUsernamePassword extends SherpaRuntimeException {
//
// private static final long serialVersionUID = -4589238647338717425L;
//
// public SherpaInvalidUsernamePassword() {
// super();
// }
//
// public SherpaInvalidUsernamePassword(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaInvalidUsernamePassword(String arg0) {
// super(arg0);
// }
//
// public SherpaInvalidUsernamePassword(Throwable arg0) {
// super(arg0);
// }
//
// }
| import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.exception.SherpaInvalidUsernamePassword; | package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
/**
* Test user service implementation ,everyone is authenticated Override by defining in sherpa.properties or use and IOC mechanism
*
* @author dpitt
*
*/
public class DefaultUserService implements UserService {
public String[] authenticate(String username, String password, HttpServletRequest request, HttpServletResponse response) {
// Default always fails authentication | // Path: src/main/java/com/khs/sherpa/exception/SherpaInvalidUsernamePassword.java
// public class SherpaInvalidUsernamePassword extends SherpaRuntimeException {
//
// private static final long serialVersionUID = -4589238647338717425L;
//
// public SherpaInvalidUsernamePassword() {
// super();
// }
//
// public SherpaInvalidUsernamePassword(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaInvalidUsernamePassword(String arg0) {
// super(arg0);
// }
//
// public SherpaInvalidUsernamePassword(Throwable arg0) {
// super(arg0);
// }
//
// }
// Path: src/main/java/com/khs/sherpa/json/service/DefaultUserService.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.khs.sherpa.exception.SherpaInvalidUsernamePassword;
package com.khs.sherpa.json.service;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
/**
* Test user service implementation ,everyone is authenticated Override by defining in sherpa.properties or use and IOC mechanism
*
* @author dpitt
*
*/
public class DefaultUserService implements UserService {
public String[] authenticate(String username, String password, HttpServletRequest request, HttpServletResponse response) {
// Default always fails authentication | throw new SherpaInvalidUsernamePassword("Authentication Error Invalid Credentials"); |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/context/factory/ManagedBean.java | // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
//
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
//
// public static String errmsg(String msg) {
// return SHERPA_NOT_INITIALIZED+msg;
// }
//
// public static URL getResource(String resource) {
// ClassLoader cl = Thread.currentThread().getContextClassLoader();
// return cl.getResource(resource);
// }
//
// public static Properties getProperties(String resource) throws IOException {
// return getProperties(Util.getResource(resource));
// }
//
// public static Properties getProperties(URL url) throws IOException {
// Properties properties = new Properties();
// properties.load(url.openStream());
// return properties;
// }
//
// public static <T> T[] append(T[] arr, T element) {
// final int N = arr.length;
// arr = Arrays.copyOf(arr, N + 1);
// arr[N] = element;
// return arr;
// }
//
// public static String getObjectName(Class<?> type) {
// String name = null;
// if(type.isAnnotationPresent(Endpoint.class)) {
// name = type.getAnnotation(Endpoint.class).value();
// }
//
// if(StringUtils.isEmpty(name)) {
// name = type.getSimpleName();
// }
// return name;
// }
//
// }
| import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util; | package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
abstract class ManagedBean {
private Class<?> type;
private String name;
public abstract boolean isSingletone();
public abstract boolean isPrototype();
public abstract Object getInstance();
public ManagedBean(Class<?> type) {
this.type = type; | // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
//
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
//
// public static String errmsg(String msg) {
// return SHERPA_NOT_INITIALIZED+msg;
// }
//
// public static URL getResource(String resource) {
// ClassLoader cl = Thread.currentThread().getContextClassLoader();
// return cl.getResource(resource);
// }
//
// public static Properties getProperties(String resource) throws IOException {
// return getProperties(Util.getResource(resource));
// }
//
// public static Properties getProperties(URL url) throws IOException {
// Properties properties = new Properties();
// properties.load(url.openStream());
// return properties;
// }
//
// public static <T> T[] append(T[] arr, T element) {
// final int N = arr.length;
// arr = Arrays.copyOf(arr, N + 1);
// arr[N] = element;
// return arr;
// }
//
// public static String getObjectName(Class<?> type) {
// String name = null;
// if(type.isAnnotationPresent(Endpoint.class)) {
// name = type.getAnnotation(Endpoint.class).value();
// }
//
// if(StringUtils.isEmpty(name)) {
// name = type.getSimpleName();
// }
// return name;
// }
//
// }
// Path: src/main/java/com/khs/sherpa/context/factory/ManagedBean.java
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util;
package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
abstract class ManagedBean {
private Class<?> type;
private String name;
public abstract boolean isSingletone();
public abstract boolean isPrototype();
public abstract Object getInstance();
public ManagedBean(Class<?> type) {
this.type = type; | this.name = Util.getObjectName(type); |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/context/factory/ManagedBean.java | // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
//
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
//
// public static String errmsg(String msg) {
// return SHERPA_NOT_INITIALIZED+msg;
// }
//
// public static URL getResource(String resource) {
// ClassLoader cl = Thread.currentThread().getContextClassLoader();
// return cl.getResource(resource);
// }
//
// public static Properties getProperties(String resource) throws IOException {
// return getProperties(Util.getResource(resource));
// }
//
// public static Properties getProperties(URL url) throws IOException {
// Properties properties = new Properties();
// properties.load(url.openStream());
// return properties;
// }
//
// public static <T> T[] append(T[] arr, T element) {
// final int N = arr.length;
// arr = Arrays.copyOf(arr, N + 1);
// arr[N] = element;
// return arr;
// }
//
// public static String getObjectName(Class<?> type) {
// String name = null;
// if(type.isAnnotationPresent(Endpoint.class)) {
// name = type.getAnnotation(Endpoint.class).value();
// }
//
// if(StringUtils.isEmpty(name)) {
// name = type.getSimpleName();
// }
// return name;
// }
//
// }
| import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util; | package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
abstract class ManagedBean {
private Class<?> type;
private String name;
public abstract boolean isSingletone();
public abstract boolean isPrototype();
public abstract Object getInstance();
public ManagedBean(Class<?> type) {
this.type = type;
this.name = Util.getObjectName(type);
}
public Class<?> getType() {
return type;
}
public void setType(Class<?> type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Object createInstance() {
try {
return type.newInstance();
} catch (Exception e) { | // Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
//
// private static final long serialVersionUID = 3997371687805128093L;
//
// public SherpaRuntimeException() {
// super();
// }
//
// public SherpaRuntimeException(String arg0, Throwable arg1) {
// super(arg0, arg1);
// }
//
// public SherpaRuntimeException(String arg0) {
// super(arg0);
// }
//
// public SherpaRuntimeException(Throwable arg0) {
// super(arg0);
// }
//
// }
//
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
//
// public static String msg(String msg) {
// return SHERPA_SERVER+msg;
// }
//
// public static String errmsg(String msg) {
// return SHERPA_NOT_INITIALIZED+msg;
// }
//
// public static URL getResource(String resource) {
// ClassLoader cl = Thread.currentThread().getContextClassLoader();
// return cl.getResource(resource);
// }
//
// public static Properties getProperties(String resource) throws IOException {
// return getProperties(Util.getResource(resource));
// }
//
// public static Properties getProperties(URL url) throws IOException {
// Properties properties = new Properties();
// properties.load(url.openStream());
// return properties;
// }
//
// public static <T> T[] append(T[] arr, T element) {
// final int N = arr.length;
// arr = Arrays.copyOf(arr, N + 1);
// arr[N] = element;
// return arr;
// }
//
// public static String getObjectName(Class<?> type) {
// String name = null;
// if(type.isAnnotationPresent(Endpoint.class)) {
// name = type.getAnnotation(Endpoint.class).value();
// }
//
// if(StringUtils.isEmpty(name)) {
// name = type.getSimpleName();
// }
// return name;
// }
//
// }
// Path: src/main/java/com/khs/sherpa/context/factory/ManagedBean.java
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util;
package com.khs.sherpa.context.factory;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
abstract class ManagedBean {
private Class<?> type;
private String name;
public abstract boolean isSingletone();
public abstract boolean isPrototype();
public abstract Object getInstance();
public ManagedBean(Class<?> type) {
this.type = type;
this.name = Util.getObjectName(type);
}
public Class<?> getType() {
return type;
}
public void setType(Class<?> type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Object createInstance() {
try {
return type.newInstance();
} catch (Exception e) { | throw new SherpaRuntimeException("Unable to create Managed Bean [" + type + "]"); |
in-the-keyhole/khs-sherpa | src/main/java/com/khs/sherpa/servlet/request/SherpaRequest.java | // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
| import com.khs.sherpa.context.ApplicationContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | package com.khs.sherpa.servlet.request;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public interface SherpaRequest {
Object getAttribute(String name);
void setAttribute(String name, Object object);
void doService(HttpServletRequest request, HttpServletResponse response);
| // Path: src/main/java/com/khs/sherpa/context/ApplicationContext.java
// public interface ApplicationContext extends ManagedBeanFactory {
//
// public static final String CONTEXT_PATH = "com.khs.sherpa.SHREPA.CONTEXT";
// public static final String SHERPA_CONTEXT = "com.khs.sherpa.SHREPA.CONTEXT";
//
// public static final String SETTINGS_JSONP = "com.khs.sherpa.SETTGINS.JSONP";
// public static final String SETTINGS_ADMIN_USER = "com.khs.sherpa.SETTGINS.ADMIN_USER";
// public static final String SETTINGS_ENDPOINT_AUTH = "com.khs.sherpa.SETTGINS.ENDPOINT_AUTH";
//
//
// public void setAttribute(String key, Object value);
//
// public Object getAttribute(String key);
//
// public ManagedBeanFactory getManagedBeanFactory();
//
// }
// Path: src/main/java/com/khs/sherpa/servlet/request/SherpaRequest.java
import com.khs.sherpa.context.ApplicationContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
package com.khs.sherpa.servlet.request;
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
public interface SherpaRequest {
Object getAttribute(String name);
void setAttribute(String name, Object object);
void doService(HttpServletRequest request, HttpServletResponse response);
| void setApplicationContext(ApplicationContext applicationContext); |
Cazsius/Spice-of-Life-Carrot-Edition | src/main/java/com/cazsius/solcarrot/command/FoodListCommand.java | // Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// public static final String MOD_ID = "solcarrot";
//
// public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//
// private static final String PROTOCOL_VERSION = "1.0";
// public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// .named(resourceLocation("main"))
// .clientAcceptedVersions(PROTOCOL_VERSION::equals)
// .serverAcceptedVersions(PROTOCOL_VERSION::equals)
// .networkProtocolVersion(() -> PROTOCOL_VERSION)
// .simpleChannel();
//
// public static ResourceLocation resourceLocation(String path) {
// return new ResourceLocation(MOD_ID, path);
// }
//
// // TODO: not sure if this is even implemented anymore
// @SubscribeEvent
// public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// // This complains if jar not signed, even if certificateFingerprint is blank
// LOGGER.warn("Invalid Fingerprint!");
// }
//
// @SubscribeEvent
// public static void setUp(FMLCommonSetupEvent event) {
// channel.messageBuilder(FoodListMessage.class, 0)
// .encoder(FoodListMessage::write)
// .decoder(FoodListMessage::new)
// .consumer(FoodListMessage::handle)
// .add();
// }
//
// public SOLCarrot() {
// SOLCarrotConfig.setUp();
// }
// }
//
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java
// public final class Localization {
// public static String keyString(String domain, IForgeRegistryEntry entry, String path) {
// final ResourceLocation location = entry.getRegistryName();
// assert location != null;
// return keyString(domain, location.getPath() + "." + path);
// }
//
// /** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */
// public static String keyString(String domain, String path) {
// return domain + "." + SOLCarrot.MOD_ID + "." + path;
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// return I18n.format(keyString(domain, entry, path), args);
// }
//
// public static ITextComponent localizedComponent(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// return new TranslationTextComponent(keyString(domain, entry, path), args);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localized(String domain, String path, Object... args) {
// return I18n.format(keyString(domain, path), args);
// }
//
// public static ITextComponent localizedComponent(String domain, String path, Object... args) {
// return new TranslationTextComponent(keyString(domain, path), args);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localizedQuantity(String domain, String path, int number) {
// return number == 1
// ? I18n.format(keyString(domain, path + ".singular"))
// : I18n.format(keyString(domain, path + ".plural"), number);
// }
//
// public static ITextComponent localizedQuantityComponent(String domain, String path, int number) {
// return number == 1
// ? new TranslationTextComponent(keyString(domain, path + ".singular"))
// : new TranslationTextComponent(keyString(domain, path + ".plural"), number);
// }
//
// public static String formatBigNumber(int number) {
// if (number < 1000) {
// return "" + number;
// } else if (number < 10_000) {
// return Math.round(number / 1000F) + "." + Math.round((number % 1000) / 100F) + "k";
// } else {
// return Math.round(number / 1000F) + "k";
// }
// }
//
// private Localization() {}
// }
| import com.cazsius.solcarrot.SOLCarrot;
import com.cazsius.solcarrot.lib.Localization;
import com.cazsius.solcarrot.tracking.*;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import static net.minecraft.command.Commands.argument;
import static net.minecraft.command.Commands.literal; | return Command.SINGLE_SUCCESS;
}
static int clearFoodList(CommandContext<CommandSource> context, PlayerEntity target) {
boolean isOp = context.getSource().hasPermissionLevel(2);
boolean isTargetingSelf = isTargetingSelf(context, target);
if (!isOp && isTargetingSelf)
throw new CommandException(localizedComponent("no_permissions"));
FoodList.get(target).clearFood();
CapabilityHandler.syncFoodList(target);
ITextComponent feedback = localizedComponent("clear.success");
sendFeedback(context.getSource(), feedback);
if (!isTargetingSelf) {
target.sendMessage(feedback.setStyle(feedbackStyle));
}
return Command.SINGLE_SUCCESS;
}
static void sendFeedback(CommandSource source, ITextComponent message) {
source.sendFeedback(message.setStyle(feedbackStyle), true);
}
static boolean isTargetingSelf(CommandContext<CommandSource> context, PlayerEntity target) {
return target.isEntityEqual(context.getSource().getEntity());
}
static ITextComponent localizedComponent(String path, Object... args) { | // Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// public static final String MOD_ID = "solcarrot";
//
// public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//
// private static final String PROTOCOL_VERSION = "1.0";
// public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// .named(resourceLocation("main"))
// .clientAcceptedVersions(PROTOCOL_VERSION::equals)
// .serverAcceptedVersions(PROTOCOL_VERSION::equals)
// .networkProtocolVersion(() -> PROTOCOL_VERSION)
// .simpleChannel();
//
// public static ResourceLocation resourceLocation(String path) {
// return new ResourceLocation(MOD_ID, path);
// }
//
// // TODO: not sure if this is even implemented anymore
// @SubscribeEvent
// public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// // This complains if jar not signed, even if certificateFingerprint is blank
// LOGGER.warn("Invalid Fingerprint!");
// }
//
// @SubscribeEvent
// public static void setUp(FMLCommonSetupEvent event) {
// channel.messageBuilder(FoodListMessage.class, 0)
// .encoder(FoodListMessage::write)
// .decoder(FoodListMessage::new)
// .consumer(FoodListMessage::handle)
// .add();
// }
//
// public SOLCarrot() {
// SOLCarrotConfig.setUp();
// }
// }
//
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java
// public final class Localization {
// public static String keyString(String domain, IForgeRegistryEntry entry, String path) {
// final ResourceLocation location = entry.getRegistryName();
// assert location != null;
// return keyString(domain, location.getPath() + "." + path);
// }
//
// /** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */
// public static String keyString(String domain, String path) {
// return domain + "." + SOLCarrot.MOD_ID + "." + path;
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// return I18n.format(keyString(domain, entry, path), args);
// }
//
// public static ITextComponent localizedComponent(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// return new TranslationTextComponent(keyString(domain, entry, path), args);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localized(String domain, String path, Object... args) {
// return I18n.format(keyString(domain, path), args);
// }
//
// public static ITextComponent localizedComponent(String domain, String path, Object... args) {
// return new TranslationTextComponent(keyString(domain, path), args);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static String localizedQuantity(String domain, String path, int number) {
// return number == 1
// ? I18n.format(keyString(domain, path + ".singular"))
// : I18n.format(keyString(domain, path + ".plural"), number);
// }
//
// public static ITextComponent localizedQuantityComponent(String domain, String path, int number) {
// return number == 1
// ? new TranslationTextComponent(keyString(domain, path + ".singular"))
// : new TranslationTextComponent(keyString(domain, path + ".plural"), number);
// }
//
// public static String formatBigNumber(int number) {
// if (number < 1000) {
// return "" + number;
// } else if (number < 10_000) {
// return Math.round(number / 1000F) + "." + Math.round((number % 1000) / 100F) + "k";
// } else {
// return Math.round(number / 1000F) + "k";
// }
// }
//
// private Localization() {}
// }
// Path: src/main/java/com/cazsius/solcarrot/command/FoodListCommand.java
import com.cazsius.solcarrot.SOLCarrot;
import com.cazsius.solcarrot.lib.Localization;
import com.cazsius.solcarrot.tracking.*;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import static net.minecraft.command.Commands.argument;
import static net.minecraft.command.Commands.literal;
return Command.SINGLE_SUCCESS;
}
static int clearFoodList(CommandContext<CommandSource> context, PlayerEntity target) {
boolean isOp = context.getSource().hasPermissionLevel(2);
boolean isTargetingSelf = isTargetingSelf(context, target);
if (!isOp && isTargetingSelf)
throw new CommandException(localizedComponent("no_permissions"));
FoodList.get(target).clearFood();
CapabilityHandler.syncFoodList(target);
ITextComponent feedback = localizedComponent("clear.success");
sendFeedback(context.getSource(), feedback);
if (!isTargetingSelf) {
target.sendMessage(feedback.setStyle(feedbackStyle));
}
return Command.SINGLE_SUCCESS;
}
static void sendFeedback(CommandSource source, ITextComponent message) {
source.sendFeedback(message.setStyle(feedbackStyle), true);
}
static boolean isTargetingSelf(CommandContext<CommandSource> context, PlayerEntity target) {
return target.isEntityEqual(context.getSource().getEntity());
}
static ITextComponent localizedComponent(String path, Object... args) { | return Localization.localizedComponent("command", localizationPath(path), args); |
Subsets and Splits