code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
static public String safeSqlQueryIntegerValue(String in) throws Exception {
int intValue = Integer.parseInt(in);
return ""+intValue;
} | java |
static public String safeSqlQueryIdentifier(String in) throws Exception {
if( null == in ) {
throw new Exception("Null string passed as identifier");
}
if( in.indexOf('\0') >= 0 ) {
throw new Exception("Null character found in identifier");
}
// All quotes should be escaped
in = in.replace("\"", "\... | java |
static public String extractStringResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception {
int count = rsmd.getColumnCount();
if( index > count || index < 1 ) {
throw new Exception("Invalid index");
}
int type = rsmd.getColumnType(index);
switch (type) {
case java.sql.Types.VARCHAR... | java |
static public int extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception {
int count = rsmd.getColumnCount();
if( index > count || index < 1 ) {
throw new Exception("Invalid index");
}
int type = rsmd.getColumnType(index);
switch (type) {
case java.sql.Types.INTEGER:
c... | java |
static public void addKnownString(String mimeType, String knownString) {
Map<String,String> map = getKnownStrings();
if( null != mimeType && null != knownString ) {
map.put(knownString.trim(), mimeType.trim());
}
} | java |
private static IIOMetadataNode getOrCreateChildNode(IIOMetadataNode parentNode, String name)
{
NodeList nodeList = parentNode.getElementsByTagName(name);
if (nodeList.getLength() > 0)
{
return (IIOMetadataNode) nodeList.item(0);
}
IIOMetadataNode childNode = new I... | java |
private static void setDPI(IIOMetadata metadata, int dpi, String formatName)
throws IIOInvalidTreeException
{
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(MetaUtil.STANDARD_METADATA_FORMAT);
IIOMetadataNode dimension = getOrCreateChildNode(root, "Dimension");
// ... | java |
static void updateMetadata(IIOMetadata metadata, int dpi) throws IIOInvalidTreeException
{
MetaUtil.debugLogMetadata(metadata, MetaUtil.JPEG_NATIVE_FORMAT);
// https://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
... | java |
public String nextToken() throws JSONException {
char c;
char q;
StringBuilder sb = new StringBuilder();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
... | java |
public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException {
// can't use the new constructor for Android support
// JSONObject jo = new JSONObject(properties == null ? 0 : properties.size());
JSONObject jo = new JSONObject();
if (properties != null && !p... | java |
private void performSubmittedInlineWork(Work work) throws Exception {
String attachmentName = work.getAttachmentName();
FileConversionContext conversionContext =
new FileConversionContextImpl(work,documentDbDesign,mediaDir);
DocumentDescriptor docDescriptor = conversionContext.getDocument();
Attachment... | java |
static void debugLogMetadata(IIOMetadata metadata, String format)
{
if (!logger.isDebugEnabled())
{
return;
}
// see http://docs.oracle.com/javase/7/docs/api/javax/imageio/
// metadata/doc-files/standard_metadata.html
IIOMetadataNode root = (IIOMetada... | java |
static public FSEntry getPositionedBuffer(String path, byte[] content) throws Exception {
List<String> pathFrags = FSEntrySupport.interpretPath(path);
// Start at leaf and work our way back
int index = pathFrags.size() - 1;
FSEntry root = new FSEntryBuffer(pathFrags.get(index), content);
--index;
whil... | java |
static public Result insertElements(Tree tree, List<TreeElement> elements, NowReference now) throws Exception {
ResultImpl result = new ResultImpl(tree);
TreeNodeRegular regularRootNode = tree.getRegularRootNode();
TreeNodeOngoing ongoingRootNode = tree.getOngoingRootNode();
for(TreeElement element : elem... | java |
public NunaliitGeometry getOriginalGometry() throws Exception {
NunaliitGeometryImpl result = null;
JSONObject jsonDoc = getJSONObject();
JSONObject nunalitt_geom = jsonDoc.optJSONObject(CouchNunaliitConstants.DOC_KEY_GEOMETRY);
if( null != nunalitt_geom ){
// By default, the wkt is the geometry
St... | java |
static public String getDocumentIdentifierFromSubmission(JSONObject submissionDoc) throws Exception {
JSONObject submissionInfo = submissionDoc.getJSONObject("nunaliit_submission");
JSONObject originalReserved = submissionInfo.optJSONObject("original_reserved");
JSONObject submittedReserved = submissionInfo.optJS... | java |
static public JSONObject getSubmittedDocumentFromSubmission(JSONObject submissionDoc) throws Exception {
JSONObject submissionInfo = submissionDoc.getJSONObject("nunaliit_submission");
JSONObject doc = submissionInfo.getJSONObject("submitted_doc");
JSONObject reserved = submissionInfo.optJSONObject("submitted_... | java |
static public JSONObject getApprovedDocumentFromSubmission(JSONObject submissionDoc) throws Exception {
JSONObject submissionInfo = submissionDoc.getJSONObject("nunaliit_submission");
// Check if an approved version of the document is available
JSONObject doc = submissionInfo.optJSONObject("approved_doc");
if(... | java |
static public JSONObject recreateDocumentFromDocAndReserved(JSONObject doc, JSONObject reserved) throws Exception {
JSONObject result = JSONSupport.copyObject( doc );
// Re-insert attributes that start with '_'
if( null != reserved ) {
Iterator<?> it = reserved.keys();
while( it.hasNext() ){
Object k... | java |
private void removeUndesiredFiles(JSONObject doc, File dir) throws Exception {
Set<String> keysKept = new HashSet<String>();
// Loop through each child of directory
File[] children = dir.listFiles();
for(File child : children){
String name = child.getName();
String extension = "";
Matcher matcherNam... | java |
synchronized static private byte[] getSecret() throws Exception {
if( null == secret ) {
Date now = new Date();
long nowValue = now.getTime();
byte[] nowBytes = new byte[8];
nowBytes[0] = (byte)((nowValue >> 0) & 0xff);
nowBytes[1] = (byte)((nowValue >> 8) & 0xff);
nowBytes[2] = (byte)((nowVal... | java |
static public void sendAuthRequiredError(HttpServletResponse response, String realm) throws IOException {
response.setHeader("WWW-Authenticate", "Basic realm=\""+realm+"\"");
response.setHeader("Cache-Control", "no-cache,must-revalidate");
response.setDateHeader("Expires", (new Date()).getTime());
response.send... | java |
static public String userToCookieString(boolean loggedIn, User user) throws Exception {
JSONObject cookieObj = new JSONObject();
cookieObj.put("logged", loggedIn);
JSONObject userObj = user.toJSON();
cookieObj.put("user", userObj);
StringWriter sw = new StringWriter();
cookieObj.write(sw);
String... | java |
static public FSEntry findDescendant(FSEntry root, String path) throws Exception {
if( null == root ) {
throw new Exception("root parameter should not be null");
}
List<String> pathFrags = interpretPath(path);
// Iterate through path fragments, navigating through
// the offered children
FSEntry see... | java |
static public List<String> interpretPath(String path) throws Exception {
if( null == path ) {
throw new Exception("path parameter should not be null");
}
if( path.codePointAt(0) == '/' ) {
throw new Exception("absolute path is not acceptable");
}
// Verify path
List<String> pathFragments = new Vector... | java |
protected List<I> rankItems(final Map<I, Double> userItems) {
List<I> sortedItems = new ArrayList<>();
if (userItems == null) {
return sortedItems;
}
Map<Double, Set<I>> itemsByRank = new HashMap<>();
for (Map.Entry<I, Double> e : userItems.entrySet()) {
I... | java |
protected List<Double> rankScores(final Map<I, Double> userItems) {
List<Double> sortedScores = new ArrayList<>();
if (userItems == null) {
return sortedScores;
}
for (Map.Entry<I, Double> e : userItems.entrySet()) {
double pref = e.getValue();
if (Dou... | java |
public static void runLenskitRecommenders(final Set<String> paths, final Properties properties) {
for (AbstractRunner<Long, Long> rec : instantiateLenskitRecommenders(paths, properties)) {
RecommendationRunner.run(rec);
}
} | java |
public static void runMahoutRecommenders(final Set<String> paths, final Properties properties) {
for (AbstractRunner<Long, Long> rec : instantiateMahoutRecommenders(paths, properties)) {
RecommendationRunner.run(rec);
}
} | java |
public static void runRanksysRecommenders(final Set<String> paths, final Properties properties) {
for (AbstractRunner<Long, Long> rec : instantiateRanksysRecommenders(paths, properties)) {
RecommendationRunner.run(rec);
}
} | java |
public static void listAllFiles(final Set<String> setOfPaths, final String inputPath) {
if (inputPath == null) {
return;
}
File[] files = new File(inputPath).listFiles();
if (files == null) {
return;
}
for (File file : files) {
if (file... | java |
@Override
public double getValueAt(final U user, final int at) {
if (userRecallAtCutoff.containsKey(at) && userRecallAtCutoff.get(at).containsKey(user)) {
return userRecallAtCutoff.get(at).get(user) / userTotalRecall.get(user);
}
return Double.NaN;
} | java |
public static void getAllRecommendationFiles(final Set<String> recommendationFiles, final File path, final String prefix, final String suffix) {
if (path == null) {
return;
}
File[] files = path.listFiles();
if (files == null) {
return;
}
for (File... | java |
@Override
public void compute() {
if (!Double.isNaN(getValue())) {
// since the data cannot change, avoid re-doing the calculations
return;
}
iniCompute();
Map<U, List<Double>> data = processDataAsPredictedDifferencesToTest();
int testItems = 0;
... | java |
@Override
public TemporalDataModelIF<Long, Long> run(final RUN_OPTIONS opts) throws RecommenderException, TasteException, IOException {
if (isAlreadyRecommended()) {
return null;
}
DataModel trainingModel = new FileDataModel(new File(getProperties().getProperty(RecommendationRunn... | java |
public void split(final String inFile, final String outPath, boolean perUser, long seed, String delimiter, boolean isTemporalData) {
try {
if (delimiter == null)
delimiter = this.delimiter;
DataModelIF<Long, Long>[] splits = new CrossValidationSplitter<Long, Long>(this.numFolds, p... | java |
public void recommend(final String inPath, final String outPath) throws IOException, TasteException {
for (int i = 0; i < this.numFolds; i++) {
org.apache.mahout.cf.taste.model.DataModel trainModel;
org.apache.mahout.cf.taste.model.DataModel testModel;
trainModel = new FileDataModel(... | java |
public void buildEvaluationModels(final String splitPath, final String predictionsPath, final String outPath) {
for (int i = 0; i < this.numFolds; i++) {
File trainingFile = new File(Paths.get(splitPath, "train_" + i + FILE_EXT).toString());
File testFile = new File(Paths.get(splitPath, "test_" ... | java |
@Override
public Double getUserItemPreference(U u, I i) {
if (userItemPreferences.containsKey(u) && userItemPreferences.get(u).containsKey(i)) {
return userItemPreferences.get(u).get(i);
}
return Double.NaN;
} | java |
@Override
public Iterable<I> getUserItems(U u) {
if (userItemPreferences.containsKey(u)) {
return userItemPreferences.get(u).keySet();
}
return Collections.emptySet();
} | java |
@Override
public void addPreference(final U u, final I i, final Double d) {
// update direct map
Map<I, Double> userPreferences = userItemPreferences.get(u);
if (userPreferences == null) {
userPreferences = new HashMap<>();
userItemPreferences.put(u, userPreferences);... | java |
public static void writeData(final long user, final List<Preference<Long, Long>> recommendations, final String path, final String fileName, final boolean append, final TemporalDataModelIF<Long, Long> model) {
BufferedWriter out = null;
try {
File dir = null;
if (path != null) {
... | java |
public static void main(final String[] args) throws Exception {
String propertyFile = System.getProperty("propertyFile");
final Properties properties = new Properties();
try {
properties.load(new FileInputStream(propertyFile));
} catch (IOException ie) {
ie.print... | java |
@SuppressWarnings("unchecked")
public static void run(final Properties properties)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
System.out.println("Parsing started: recommendation file");
Fi... | java |
@SuppressWarnings("unchecked")
public static <U, I> void generateOutput(final DataModelIF<U, I> testModel, final int[] rankingCutoffs,
final EvaluationMetric<U> metric, final String metricName,
final Boolean perUser, final File resultsFile, final Boolean overwrite, final Boolean append) thro... | java |
public static void run(final Properties properties)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
// read splits
System.out.println("Parsing started: training file");
File trainingFile = ... | java |
public static void generateOutput(final DataModelIF<Long, Long> testModel, final File userRecommendationFile,
final EvaluationStrategy<Long, Long> strategy, final EvaluationStrategy.OUTPUT_FORMAT format,
final File rankingFile, final File groundtruthFile, final Boolean overwrite)
thr... | java |
public double getPValue(final String method) {
double p = Double.NaN;
if ("t".equals(method)) {
double[] baselineValues = new double[baselineMetricPerDimension.values().size()];
int i = 0;
for (Double d : baselineMetricPerDimension.values()) {
baselin... | java |
private static void fillDefaultProperties(final Properties props) {
System.out.println("Setting default properties...");
// parser
props.put(ParserRunner.DATASET_FILE, "./data/ml-100k/ml-100k/u.data");
props.put(ParserRunner.DATASET_PARSER, "net.recommenders.rival.split.parser.MovielensP... | java |
@Override
public void compute() {
if (!Double.isNaN(getValue())) {
// since the data cannot change, avoid re-doing the calculations
return;
}
iniCompute();
Map<U, List<Pair<I, Double>>> data = processDataAsRankedTestRelevance();
userDcgAtCutoff = new ... | java |
protected double computeDCG(final double rel, final int rank) {
double dcg = 0.0;
if (rel >= getRelevanceThreshold()) {
switch (type) {
default:
case EXP:
dcg = (Math.pow(2.0, rel) - 1.0) / (Math.log(rank + 1) / Math.log(2));
... | java |
@Override
public double getValueAt(final int at) {
if (userDcgAtCutoff.containsKey(at) && userIdcgAtCutoff.containsKey(at)) {
int n = 0;
double ndcg = 0.0;
for (U u : userIdcgAtCutoff.get(at).keySet()) {
double udcg = getValueAt(u, at);
if ... | java |
@Override
public double getValueAt(final U user, final int at) {
if (userDcgAtCutoff.containsKey(at) && userDcgAtCutoff.get(at).containsKey(user)
&& userIdcgAtCutoff.containsKey(at) && userIdcgAtCutoff.get(at).containsKey(user)) {
double idcg = userIdcgAtCutoff.get(at).get(user);... | java |
public Recommender buildRecommender(final DataModel dataModel, final String recType)
throws RecommenderException {
return buildRecommender(dataModel, recType, null, DEFAULT_N, NOFACTORS, NOITER, null);
} | java |
public TemporalDataModelIF<Long, Long> parseData(final File f, final String token, final boolean isTemporal) throws IOException {
TemporalDataModelIF<Long, Long> dataset = DataModelFactory.getDefaultTemporalModel();
BufferedReader br = SimpleParser.getBufferedReader(f);
String line = br.readLin... | java |
public void download() {
URL dataURL = null;
String fileName = folder + "/" + url.substring(url.lastIndexOf("/") + 1);
if (new File(fileName).exists()) {
return;
}
try {
dataURL = new URL(url);
} catch (MalformedURLException e) {
e.prin... | java |
public void downloadAndUnzip() {
URL dataURL = null;
String fileName = folder + "/" + url.substring(url.lastIndexOf("/") + 1);
File compressedData = new File(fileName);
if (!new File(fileName).exists()) {
try {
dataURL = new URL(url);
} catch (Malf... | java |
public static void recommend(final int nFolds, final String inPath, final String outPath) {
for (int i = 0; i < nFolds; i++) {
org.apache.mahout.cf.taste.model.DataModel trainModel;
org.apache.mahout.cf.taste.model.DataModel testModel;
try {
trainModel = new F... | java |
public static void evaluate(final int nFolds, final String splitPath, final String recPath) {
double ndcgRes = 0.0;
double precisionRes = 0.0;
double rmseRes = 0.0;
for (int i = 0; i < nFolds; i++) {
File testFile = new File(splitPath + "test_" + i + ".csv");
File... | java |
public static void run(final Properties properties) throws IOException {
// read parameters for output (do this at the beginning to avoid unnecessary reading)
File outputFile = new File(properties.getProperty(OUTPUT_FILE));
Boolean overwrite = Boolean.parseBoolean(properties.getProperty(OUTPUT_O... | java |
public static void readLine(final String format, final String line, final Map<String, Map<String, Double>> mapMetricUserValue, final Set<String> usersToAvoid) {
String[] toks = line.split("\t");
// default (also trec_eval) format: metric \t user|all \t value
if (format.equals("default")) {
... | java |
public static void run(final Properties properties)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
// read splits
System.out.println("Parsing started: training file");
File trainingFile = ... | java |
public static EvaluationStrategy<Long, Long> instantiateStrategy(final Properties properties, final DataModelIF<Long, Long> trainingModel, final DataModelIF<Long, Long> testModel)
throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException ... | java |
public static TemporalDataModelIF<Long, Long> run(final Properties properties) throws ClassNotFoundException, IllegalAccessException,
InstantiationException, InvocationTargetException, NoSuchMethodException, IOException {
System.out.println("Parsing started");
TemporalDataModelIF<Long, Long>... | java |
protected Set<Long> getModelTrainingDifference(final DataModelIF<Long, Long> model, final Long user) {
final Set<Long> items = new HashSet<Long>();
if (training.getUserItems(user) != null) {
final Set<Long> trainingItems = new HashSet<>();
for (Long i : training.getUserItems(user... | java |
protected void printRanking(final String user, final Map<Long, Double> scoredItems, final PrintStream out, final OUTPUT_FORMAT format) {
final Map<Double, Set<Long>> preferenceMap = new HashMap<Double, Set<Long>>();
for (Map.Entry<Long, Double> e : scoredItems.entrySet()) {
long item = e.get... | java |
public static <U, I> void saveDataModel(final DataModelIF<U, I> dm, final String outfile, final boolean overwrite, final String delimiter)
throws FileNotFoundException, UnsupportedEncodingException {
if (new File(outfile).exists() && !overwrite) {
System.out.println("Ignoring " + outfile... | java |
public static <U, I> void saveDataModel(final TemporalDataModelIF<U, I> dm, final String outfile, final boolean overwrite, String delimiter)
throws FileNotFoundException, UnsupportedEncodingException {
if (new File(outfile).exists() && !overwrite) {
System.out.println("Ignoring " + outfi... | java |
public void setFileName() {
String type = "";
// lenskit does not provide a factorizer class. This check is to actually see if it's a Mahout or Lenskit SVD.
if (properties.containsKey(RecommendationRunner.FACTORIZER) || properties.containsKey(RecommendationRunner.SIMILARITY)) {
if (p... | java |
@SuppressWarnings("unchecked")
public static void prepareStrategy(final String splitPath, final String recPath, final String outPath) {
int i = 0;
File trainingFile = new File(splitPath + "train_" + i + ".csv");
File testFile = new File(splitPath + "test_" + i + ".csv");
File recFile... | java |
public static <U, I> void run(final Properties properties, final TemporalDataModelIF<U, I> data, final boolean doDataClear)
throws FileNotFoundException, UnsupportedEncodingException {
System.out.println("Start splitting");
TemporalDataModelIF<U, I>[] splits;
// read parameters
... | java |
public static <U, I> Splitter<U, I> instantiateSplitter(final Properties properties) {
// read parameters
String splitterClassName = properties.getProperty(DATASET_SPLITTER);
Boolean perUser = Boolean.parseBoolean(properties.getProperty(SPLIT_PERUSER));
Boolean doSplitPerItems = Boolean.... | java |
@Override
public Iterable<Long> getUserItemTimestamps(U u, I i) {
if (userItemTimestamps.containsKey(u) && userItemTimestamps.get(u).containsKey(i)) {
return userItemTimestamps.get(u).get(i);
}
return null;
} | java |
@Override
public void addTimestamp(final U u, final I i, final Long t) {
Map<I, Set<Long>> userTimestamps = userItemTimestamps.get(u);
if (userTimestamps == null) {
userTimestamps = new HashMap<>();
userItemTimestamps.put(u, userTimestamps);
}
Set<Long> timest... | java |
public static void readLine(final String line, final Map<Long, List<Pair<Long, Double>>> mapUserRecommendations) {
String[] toks = line.split("\t");
// mymedialite format: user \t [item:score,item:score,...]
if (line.contains(":") && line.contains(",")) {
Long user = Long.parseLong(t... | java |
protected double getNumberOfRelevantItems(final U user) {
int n = 0;
if (getTest().getUserItems(user) != null) {
for (I i : getTest().getUserItems(user)) {
if (getTest().getUserItemPreference(user, i) >= relevanceThreshold) {
n++;
}
... | java |
@Override
public double getValueAt(final int at) {
if (userPrecAtCutoff.containsKey(at)) {
int n = 0;
double prec = 0.0;
for (U u : userPrecAtCutoff.get(at).keySet()) {
double uprec = getValueAt(u, at);
if (!Double.isNaN(uprec)) {
... | java |
public static double considerEstimatedPreference(final ErrorStrategy errorStrategy, final double recValue) {
boolean consider = true;
double v = recValue;
switch (errorStrategy) {
default:
case CONSIDER_EVERYTHING:
break;
case NOT_CONSIDER_NAN:... | java |
@Override
public double getValueAt(final int at) {
if (userMAPAtCutoff.containsKey(at)) {
int n = 0;
double map = 0.0;
for (U u : userMAPAtCutoff.get(at).keySet()) {
double uMAP = getValueAt(u, at);
if (!Double.isNaN(uMAP)) {
... | java |
@SuppressWarnings("unchecked")
public static void run(final Properties properties)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
EvaluationStrategy.OUTPUT_FORMAT recFormat;
if (properties.get... | java |
public static void getAllPredictionFiles(final Set<String> predictionFiles, final File path, final String predictionPrefix) {
if (path == null) {
return;
}
File[] files = path.listFiles();
if (files == null) {
return;
}
for (File file : files) {
... | java |
public static void main(final String[] args) {
String propertyFile = System.getProperty("file");
if (propertyFile == null) {
System.out.println("Property file not given, exiting.");
System.exit(0);
}
final Properties properties = new Properties();
try {
... | java |
public static void run(final AbstractRunner rr) {
time = System.currentTimeMillis();
boolean statsExist = false;
statPath = rr.getCanonicalFileName();
statsExist = rr.isAlreadyRecommended();
try {
rr.run(AbstractRunner.RUN_OPTIONS.OUTPUT_RECS);
} catch (Except... | java |
public static AbstractRunner<Long, Long> instantiateRecommender(final Properties properties) {
if (properties.getProperty(RECOMMENDER) == null) {
System.out.println("No recommenderClass specified, exiting.");
return null;
}
if (properties.getProperty(TRAINING_SET) == null... | java |
public static void writeStats(final String path, final String statLabel, final long stat) {
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path, true), "UTF-8"));
out.write(statLabel + "\t" + stat + "\n");
out.flu... | java |
public static boolean areEqual(byte[] array1, byte[] array2) {
if (array1.length != array2.length) return false;
for (int i=0; i<array1.length; ++i)
if (array1[i] != array2[i]) return false;
return true;
} | java |
public static boolean isZero(byte[] bytes) {
int x = 0;
for (int i = 0; i < bytes.length; i++) {
x |= bytes[i];
}
return x == 0;
} | java |
public Position decodePosition(double time, SurfacePositionV0Msg msg) {
if (last_pos == null)
return null;
return decodePosition(time, msg, last_pos);
} | java |
public Position decodePosition(SurfacePositionV0Msg msg, Position reference) {
return decodePosition(System.currentTimeMillis()/1000.0, msg, reference);
} | java |
public Position decodePosition(double time, Position receiver, SurfacePositionV0Msg msg, Position reference) {
Position ret = decodePosition(time, msg, reference);
if (ret != null && receiver != null && !withinReasonableRange(receiver, ret)) {
ret.setReasonable(false);
num_reasonable = 0;
}
return ret;
} | java |
public void gc() {
List<Integer> toRemove = new ArrayList<Integer>();
for (Integer transponder : decoderData.keySet())
if (decoderData.get(transponder).posDec.getLastUsedTime()<latestTimestamp-3600000)
toRemove.add(transponder);
for (Integer transponder : toRemove)
decoderData.remove(transponder);
} | java |
private static int grayToBin(int gray, int bitlength) {
int result = 0;
for (int i = bitlength-1; i >= 0; --i)
result = result|((((0x1<<(i+1))&result)>>>1)^((1<<i)&gray));
return result;
} | java |
private static char[] mapChar (byte[] digits) {
char[] result = new char[digits.length];
for (int i=0; i<digits.length; i++)
result[i] = mapChar(digits[i]);
return result;
} | java |
public double[] toECEF () {
double lon0r = toRadians(this.longitude);
double lat0r = toRadians(this.latitude);
double height = tools.feet2Meters(altitude);
double v = a / Math.sqrt(1 - e2*Math.sin(lat0r)*Math.sin(lat0r));
return new double[] {
(v + height) * Math.cos(lat0r) * Math.cos(lon0r), // x
(... | java |
public static Position fromECEF (double x, double y, double z) {
double p = sqrt(x*x + y*y);
double th = atan2(a * z, b * p);
double lon = atan2(y, x);
double lat = atan2(
(z + (a*a - b*b) / (b*b) * b * pow(sin(th), 3)),
p - e2 * a * pow(cos(th), 3));
double N = a / sqrt(1 - pow(sqrt(e2) * sin(lat), ... | java |
public Double distance3d(Position other) {
if (other == null || latitude == null || longitude == null || altitude == null)
return null;
double[] xyz1 = this.toECEF();
double[] xyz2 = other.toECEF();
return Math.sqrt(
Math.pow(xyz2[0] - xyz1[0], 2) +
Math.pow(xyz2[1] - xyz1[1], 2) +
Math.pow... | java |
public PagedResult<AutomationRule> listAutomationRules(long sheetId, PaginationParameters pagination) throws SmartsheetException {
String path = "sheets/" + sheetId + "/automationrules";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (pagination != null) {
pa... | java |
public AutomationRule updateAutomationRule(long sheetId, AutomationRule automationRule) throws SmartsheetException {
Util.throwIfNull(automationRule);
return this.updateResource("sheets/" + sheetId + "/automationrules/" + automationRule.getId(),
AutomationRule.class, automationRule);
... | java |
public String newAuthorizationURL(EnumSet<AccessScope> scopes, String state) {
Util.throwIfNull(scopes);
if(state == null){state = "";}
// Build a map of parameters for the URL
HashMap<String,Object> params = new HashMap<String, Object>();
params.put("response_type", "code");
... | java |
public Token obtainNewToken(AuthorizationResult authorizationResult) throws OAuthTokenException, JSONSerializerException, HttpClientException,
URISyntaxException, InvalidRequestException {
if(authorizationResult == null){
throw new IllegalArgumentException();
}
// Prepa... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.