static ScenarioForEvalData createPlanfall(ScenarioForEvalData nullfall) { // (construct the policy case. The base case can be used to simplify things ...) // The policy case is initialized as a complete copy of the base case: ScenarioForEvalData planfall = nullfall.createDeepCopy(); // we are now looking at one specific OD relation (for this scenario, there is only one!) Values planfallForOD = planfall.getByODRelation("AB"); { // modify the travel times for the rail mode: ValuesForAMode railValues = planfallForOD.getByMode(Mode.rail); railValues .getByDemandSegment(DemandSegment.PV_NON_COMMERCIAL) .incByEntry(Attribute.hrs, -0.1); railValues.getByDemandSegment(DemandSegment.GV).incByEntry(Attribute.hrs, -0.1); // modify some demand (presumably as a result): double delta = 100.; // double delta = 0. ; railValues.getByDemandSegment(DemandSegment.GV).incByEntry(Attribute.XX, delta); planfall .getByODRelation("AB") .getByMode(Mode.road) .getByDemandSegment(DemandSegment.GV) .incByEntry(Attribute.XX, -delta); } return planfall; }
/** This method tests the {@code areEqual} method for another type of value and {@code Float}s. */ @Test public void test_are_equal_for_float_and_string() { assertThat(Values.areEqual(1F, "1")).isTrue(); assertThat(Values.areEqual(2F, "1")).isFalse(); assertThat(Values.areEqual(1.5F, "1.5")).isTrue(); assertThat(Values.areEqual(2.5F, "1.5")).isFalse(); }
/** * This method tests the {@code areEqual} method for another type of value and {@code Double}s. */ @Test public void test_are_equal_for_double_and_string() { assertThat(Values.areEqual(1D, "1")).isTrue(); assertThat(Values.areEqual(2D, "1")).isFalse(); assertThat(Values.areEqual(1.5D, "1.5")).isTrue(); assertThat(Values.areEqual(2.5D, "1.5")).isFalse(); }
/** * This method tests the {@code areEqual} method for another type of value and {@code * BigDecimal}s. */ @Test public void test_are_equal_for_bigdecimal_and_string() { assertThat(Values.areEqual(new BigDecimal("1"), "1")).isTrue(); assertThat(Values.areEqual(new BigDecimal("2"), "1")).isFalse(); assertThat(Values.areEqual(new BigDecimal("1.5"), "1.5")).isTrue(); assertThat(Values.areEqual(new BigDecimal("2.5"), "1.5")).isFalse(); }
static ScenarioForEvalData createNullfall() { // set up the base case: ScenarioForEvalData nullfall = new ScenarioForEvalData(); // construct values for one OD relation: Values nullfallForOD = new Values(); nullfall.setValuesForODRelation("AB", nullfallForOD); { // construct values for the road mode for this OD relation: ValuesForAMode roadValues = nullfallForOD.getByMode(Mode.road); { // // passenger traffic: // ValuesForAUserType pvValues = roadValues.getByType(Type.PV) ; // pvValues.setByEntry( Entry.amount, 1000. ) ; // number of persons // pvValues.setByEntry( Entry.km, 10. ) ; // pvValues.setByEntry( Entry.hrs, 1. ) ; } { // freight traffic: Attributes gvValues = roadValues.getByDemandSegment(DemandSegment.GV); gvValues.setByEntry(Attribute.XX, 1000.); // tons gvValues.setByEntry(Attribute.km, 10.); gvValues.setByEntry(Attribute.hrs, 1.); } // rail values are just a copy of the road values: ValuesForAMode railValues = roadValues.createDeepCopy(); nullfallForOD.setValuesForMode(Mode.rail, railValues); } // return the base case: return nullfall; }
ScannerFilter(String[] inclusionsx, String[] exclusionsx, File dirName) { project = new Project(); project.setBaseDir(dirName); fileSet = new FileSet(); fileSet.setProject(project); fileSet.setDir(dirName); fileSet.appendIncludes(Values.trimCopy(inclusionsx)); fileSet.appendExcludes(Values.trimCopy(exclusionsx)); fileSet.appendExcludes(DEFAULT_EXCLUDES); }
public static void main(String args[]) throws IOException { Values object = new Values(); try { object.fetchmessages(); } catch (IOException e) { e.printStackTrace(); } object.dispaly(4); }
/** * Save the descriptor configuration. * * <p>{@inheritDoc} */ @Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { // Get the values and check them. String deploy = Values.textOrElse(req.getParameter("dimensionsbuildnotifier.deployState"), null); String action = Values.textOrElse(req.getParameter("dimensionsbuildnotifier.actionState"), null); this.save(); return super.configure(req, formData); }
// new row added at runtime, so no starting values public VariableRow(int scope) { startValues = new Values(); // just to avoid NPEs endValues = new Values(); endValues.name = ""; endValues.dataType = "string"; endValues.scope = scope; endValues.value = ""; endValues.attributes = new YAttributeMap(); initialiseValidity(); }
private static int effectiveIndex(Array array, Procedure proc, Object[] args, int[] work) throws Throwable { Object mapval = proc.applyN(args); if (mapval instanceof Values) { Values mapvals = (Values) mapval; for (int i = 0, j = 0; (i = mapvals.nextPos(i)) != 0; j++) { work[j] = ((Number) mapvals.getPosPrevious(i)).intValue(); } } else work[0] = ((Number) mapval).intValue(); if (array instanceof GeneralArray) return ((GeneralArray) array).resolve(work); else return work[0]; }
/** get all the unique values for the filters */ public static Object values(Request req, Response res) { Values ret = new Values(); ret.commit = StatsMain.store.commit.stream().map(c -> c.a).collect(Collectors.toSet()); ret.instanceType = StatsMain.store.instanceType.stream().map(c -> c.a).collect(Collectors.toSet()); ret.graphId = StatsMain.store.graphId.stream().map(c -> c.a).collect(Collectors.toSet()); ret.jobId = StatsMain.store.jobId.stream().map(c -> c.a).collect(Collectors.toSet()); return ret; }
public Values copy() { Values copy = new Values(); copy.name = name; copy.dataType = dataType; copy.scope = scope; copy.index = index; copy.value = value; copy.inputBinding = inputBinding; copy.outputBinding = outputBinding; copy.attributes = new YAttributeMap(attributes); copy.logPredicate = cloneLogPredicate(); return copy; }
@Override public void onReceive(Context appContext, Intent intent) { context = appContext; loc = Localizator.geoLocate(context); if (loc != null) { URLForecast = Conversor.getUrlForecast(loc); /* * Toast.makeText(context, * "¡Vibration Mode On porque el tiempo se ha terminado!", * Toast.LENGTH_LONG).show(); */ // Define la vibracion del telefono /* * Vibrator vibrator = (Vibrator) context * .getSystemService(Context.VIBRATOR_SERVICE); * vibrator.vibrate(1000); */ prefs = context.getSharedPreferences(Values.getPrefs(), Context.MODE_PRIVATE); prefs.edit().putBoolean("active", true).commit(); check_server(); } else { Log.e(LogDavid, "LOC NULL"); if (!Localizator.isProviderEnabled(appContext)) { Notifications notif = new Notifications(appContext); notif.providerDisabled(); } else { } } }
public static UpdateLogFrameJS toJavaScript(UpdateLogFrame updateLogFrame) { final UpdateLogFrameJS updateLogFrameJS = Values.createJavaScriptObject(UpdateLogFrameJS.class); updateLogFrameJS.setProjectId(updateLogFrame.getProjectId()); updateLogFrameJS.setLogFrame(updateLogFrame.getLogFrame()); return updateLogFrameJS; }
/** This method tests the {@code areEqual} method for {@code TimeValue}s. */ @Test public void test_are_equal_for_times() throws Exception { assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:06")).isTrue(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:00")), "09:01:00")).isTrue(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:00")), "09:01")).isTrue(); assertThat(Values.areEqual(getValue(null, null), (String) null)).isTrue(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:05")).isFalse(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:02:06")).isFalse(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "10:01:06")).isFalse(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:06.000000003")) .isFalse(); assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), (String) null)).isFalse(); }
private boolean necesaryUpdate() { prefs = context.getSharedPreferences(Values.getPrefs(), Context.MODE_PRIVATE); long date_last_update = prefs.getLong("date_update", 0) * 1000; if ((System.currentTimeMillis() - date_last_update) < Values.elapsed_time / 2) { return false; } Log.d(LogDavid, "UPDATE_NECESARY"); return true; }
public static UpdateProjectTeamMembersJs toJavascript( UpdateProjectTeamMembers updateProjectTeamMembers) { UpdateProjectTeamMembersJs updateProjectTeamMembersJs = Values.createJavaScriptObject(UpdateProjectTeamMembersJs.class); updateProjectTeamMembersJs.setProjectId(updateProjectTeamMembers.getProjectId()); updateProjectTeamMembersJs.setTeamMembers(updateProjectTeamMembers.getTeamMembers()); updateProjectTeamMembersJs.setTeamMemberProfiles( updateProjectTeamMembers.getTeamMemberProfiles()); return updateProjectTeamMembersJs; }
/** Create population */ public Population(Map map) { this.individuals = new ArrayList<>(); this.size = Values.getPopulationSize(); this.map = map; // create all individual for (int i = 0; i < this.size; i++) { // create an individual this.individuals.add(new Individual(map.getCountries())); } }
void executeInsert(Table table) { table.buildInsert(sqlBuilder); SqlStatement stmt = generatedList.isEmpty() ? trx.prepare(sqlBuilder) : trx.prepareAndGenerateKeys(sqlBuilder); for (Values values : valuesList) { ValuesBinder binder = stmt.valuesBinder(); values.bind(binder); stmt.addBatch(); } stmt.executeBatch(); if (!generatedList.isEmpty()) { Result generatedKeys = stmt.generatedKeys(); for (Generated lazy : generatedList) { if (generatedKeys.next()) { lazy.extract(generatedKeys); } } } }
/** Constructor. */ public PTAModelChecker(Prism prism, ModulesFile modulesFile, PropertiesFile propertiesFile) throws PrismException { this.prism = prism; mainLog = prism.getMainLog(); this.modulesFile = modulesFile; this.propertiesFile = propertiesFile; // Get combined constant values from model/properties constantValues = new Values(); constantValues.addValues(modulesFile.getConstantValues()); if (propertiesFile != null) constantValues.addValues(propertiesFile.getConstantValues()); // Build a combined label list and expand any constants // (note labels in model are ignored (removed) during PTA translation so need to store here) labelList = new LabelList(); for (int i = 0; i < modulesFile.getLabelList().size(); i++) { labelList.addLabel( modulesFile.getLabelList().getLabelNameIdent(i), modulesFile.getLabelList().getLabel(i).deepCopy()); } for (int i = 0; i < propertiesFile.getLabelList().size(); i++) { labelList.addLabel( propertiesFile.getLabelList().getLabelNameIdent(i), propertiesFile.getLabelList().getLabel(i).deepCopy()); } labelList = (LabelList) labelList.replaceConstants(constantValues); // Build mapping from all (original model) variables to non-clocks only int numVars = modulesFile.getNumVars(); nonClockVarMap = new int[numVars]; int count = 0; for (int i = 0; i < numVars; i++) { if (modulesFile.getVarType(i) instanceof TypeClock) { nonClockVarMap[i] = -1; } else { nonClockVarMap[i] = count++; } } }
public final Values values() throws ParseException { Values values; Value value; value = value(); values = new Values(value.units, value.value); label_4: while (true) { switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case COMA:; break; default: jj_la1[12] = jj_gen; break label_4; } jj_consume_token(COMA); value = value(); values.addValues(value.value); } { if (true) return values; } throw new Error("Missing return statement in function"); }
public void writeObject(Object value) { if (value instanceof Values) { Values.writeValues(value, this); return; } if (value instanceof KNode) { KNode node = (KNode) value; writeObject(((NodeTree) node.sequence).typedValue(node.ipos)); return; } Object old = table.get(value, null); if (old != null) return; table.put(value, value); base.writeObject(value); }
@Override public PCollection<T> apply(PCollection<T> in) { WithKeys<IdT, T> withKeys = WithKeys.of(fn); if (representativeType != null) { withKeys = withKeys.withKeyType(representativeType); } return in.apply(withKeys) .apply( Combine.<IdT, T, T>perKey( new Combine.BinaryCombineFn<T>() { @Override public T apply(T left, T right) { return left; } })) .apply(Values.<T>create()); }
public static OrgUnitJS toJavaScript(OrgUnitDTO orgUnitDTO) { final OrgUnitJS orgUnitJS = Values.createJavaScriptObject(OrgUnitJS.class); orgUnitJS.setId(orgUnitDTO.getId()); orgUnitJS.setName(orgUnitDTO.getName()); orgUnitJS.setFullName(orgUnitDTO.getFullName()); orgUnitJS.setOrgUnitModel(orgUnitDTO.getOrgUnitModel()); orgUnitJS.setPlannedBudget(orgUnitDTO.getPlannedBudget()); orgUnitJS.setSpendBudget(orgUnitDTO.getSpendBudget()); orgUnitJS.setReceivedBudget(orgUnitDTO.getReceivedBudget()); orgUnitJS.setParent(orgUnitDTO.getParentOrgUnit()); orgUnitJS.setChildren(toArray(orgUnitDTO.getChildrenOrgUnits())); orgUnitJS.setCalendarId(orgUnitDTO.getCalendarId()); orgUnitJS.setDeleted(orgUnitDTO.getDeleted()); orgUnitJS.setOfficeLocationCountry(orgUnitDTO.getOfficeLocationCountry()); return orgUnitJS; }
private void check_server() { JsonParser jsonParser = new JsonParser(URLForecast); WeatherAsyncTask weatherAsyncTask = new WeatherAsyncTask(); Editor edit; try { if (necesaryUpdate()) { Log.d(LogDavid, "NECESITO ACTUALIZAR"); Weather weathers[] = weatherAsyncTask.execute(jsonParser).get(); int n = Conversor.getNextWeather(weathers); Weather weather = weathers[n]; if (n > 0) save_weather(weathers[n - 1]); else save_weather(weathers[0]); /* * Toast toast2 = Toast.makeText(context, R.string.success, * Toast.LENGTH_SHORT); toast2.show(); */ // if (weather.getRain_threehours() > 0 || weather.getSnow_threehours() > 0) { if (notificationNeeded(weather)) { Log.d(LogDavid, "NECESITO AVISAR"); if (Conversor.ifNotificationAllowed(prefs)) { Log.d(LogDavid, "PUEDO AVISAR"); Notifications notif = new Notifications(context); notif.notify(weather); } else { Log.d(LogDavid, "NO PUEDO AVISAR"); } } else { Log.d(LogDavid, "NO NECESITO AVISAR - PREVIOUS FALSE"); edit = prefs.edit(); edit.putBoolean(Values.getPrevNotif(), false); edit.commit(); } } else { Log.d(LogDavid, "NO ACTUALIZO"); } } catch (Exception e) { Log.e(LogDavid, "Error Refresh: " + e.toString()); e.printStackTrace(); } }
/** * Returns an iterator for the values in the map. Remove is supported. Note that the same iterator * instance is returned each time this method is called. Use the {@link OrderedMapValues} * constructor for nested or multithreaded iteration. */ public Values<V> values() { if (values1 == null) { values1 = new OrderedMapValues(this); values2 = new OrderedMapValues(this); } if (!values1.valid) { values1.reset(); values1.valid = true; values2.valid = false; return values1; } values2.reset(); values2.valid = true; values1.valid = false; return values2; }
/** * Returns an iterator for the values in the map. Remove is supported. Note that the same iterator * instance is returned each time this method is called. Use the {@link Entries} constructor for * nested or multithreaded iteration. */ public Values<V> values() { if (valuesIter1 == null) { valuesIter1 = new Values(this); valuesIter2 = new Values(this); } if (!valuesIter1.valid) { valuesIter1.index = 0; valuesIter1.valid = true; valuesIter2.valid = false; return valuesIter1; } valuesIter2.index = 0; valuesIter2.valid = true; valuesIter1.valid = false; return valuesIter2; }
/** This method tests the {@code areEqual} method for another type of value and {@code Long}s. */ @Test public void test_are_equal_for_long_and_string() { assertThat(Values.areEqual((long) 1, "1")).isTrue(); assertThat(Values.areEqual((long) 2, "1")).isFalse(); }
/** * This method tests the {@code areEqual} method for another type of value and {@code * BigInteger}s. */ @Test public void test_are_equal_for_biginteger_and_string() { assertThat(Values.areEqual(new BigInteger("1"), "1")).isTrue(); assertThat(Values.areEqual(new BigInteger("2"), "1")).isFalse(); }
/** This method should fail because the expected value is null. */ @Test public void should_fail_because_string_is_null_with_bigdecimal() { assertThat(Values.areEqual(new BigDecimal("1"), (String) null)).isFalse(); }