public void validateCardNumber(Context context, PaymentMethod paymentMethod) throws Exception { // Empty field if (TextUtils.isEmpty(cardNumber)) { throw new Exception(context.getString(R.string.mpsdk_invalid_empty_card)); } Setting setting = Setting.getSettingByBin( paymentMethod.getSettings(), (cardNumber.length() >= MercadoPago.BIN_LENGTH ? cardNumber.substring(0, MercadoPago.BIN_LENGTH) : "")); if (setting == null) { // Invalid bin throw new Exception(context.getString(R.string.mpsdk_invalid_card_bin)); } else { // Validate card length int cardLength = setting.getCardNumber().getLength(); if (cardNumber.trim().length() != cardLength) { throw new Exception(context.getString(R.string.mpsdk_invalid_card_length, cardLength)); } // Validate luhn String luhnAlgorithm = setting.getCardNumber().getValidation(); if (("standard".equals(luhnAlgorithm)) && (!checkLuhn(cardNumber))) { throw new Exception(context.getString(R.string.mpsdk_invalid_card_luhn)); } } }
public void load() { config.load(); DataKey root = config.getKey(""); for (Setting setting : Setting.values()) if (!root.keyExists(setting.path)) root.setRaw(setting.path, setting.get()); else setting.set(root.getRaw(setting.path)); }
/** * called every time a setting is changed saves settings file to * .minecraft/mods/$backendname/guiconfig.properties coming soon: set name of config file * * @param context The context to save. */ @SuppressWarnings("rawtypes") public void save(String context) { if (!settingsLoaded) { return; } try { File path = ModSettings.getAppDir( "/" + ModSettings.contextDatadirs.get(context) + "/" + backendname + "/"); ModSettings.dbgout( "saving context " + context + " (" + path.getAbsolutePath() + " [" + ModSettings.contextDatadirs.get(context) + "])"); if (!path.exists()) { path.mkdirs(); } File file = new File(path, "guiconfig.properties"); Properties p = new Properties(); for (int i = 0; i < Settings.size(); i++) { Setting z = Settings.get(i); p.put(z.backendName, z.toString(context)); } FileOutputStream out = new FileOutputStream(file); p.store(out, ""); } catch (Exception e) { e.printStackTrace(); } }
private Setting cursorToSetting(Cursor cursor) { Setting setting = new Setting(); setting.setId(cursor.getInt(0)); setting.setItem(cursor.getString(1)); setting.setValue(cursor.getString(2)); return setting; }
public static Tuple2<CallGraph, PointerAnalysis> getCGnPA(final Setting setting) throws IllegalArgumentException, CancelException, PDGFormatException, IOException, WalaException, InvalidClassFileException { final String main = setting.main(); final String mainClassSimpleName = main.replace('/', '.').replace('$', '.').substring(1); SDGFactory.Config cfg = setting.jsdgConf(); Analyzer.cfg = cfg; IProgressMonitor progress = new VerboseProgressMonitor(System.out); final Result result = getJoanaSDG(cfg, progress); { progress.beginTask("Saving SDG to " + cfg.outputSDGfile, -1); BufferedOutputStream bOut = new BufferedOutputStream(new FileOutputStream(cfg.outputSDGfile)); SDGSerializer.toPDGFormat(result.sdg, bOut); progress.done(); } Util.dumpCallGraph(result.cg, mainClassSimpleName, null); return new Tuple2<CallGraph, PointerAnalysis>(result.cg, result.pts); }
public void reload() { config.load(); for (Setting setting : Setting.values()) if (root.keyExists(setting.path)) setting.loadFromKey(root); save(); }
/** * must be called after all settings are added for loading/saving to work. loads from * .minecraft/mods/$backendname/guiconfig.properties if it exists. coming soon: set name of config * file * * @param context The context to load from. */ @SuppressWarnings("rawtypes") public void load(String context) { for (; ; ) { try { if (ModSettings.contextDatadirs.get(context) == null) { break; } File path = ModSettings.getAppDir( "/" + ModSettings.contextDatadirs.get(context) + "/" + backendname + "/"); if (!path.exists()) { break; } File file = new File(path, "guiconfig.properties"); if (!file.exists()) { break; } Properties p = new Properties(); p.load(new FileInputStream(file)); for (int i = 0; i < Settings.size(); i++) { ModSettings.dbgout("setting load"); Setting z = Settings.get(i); if (p.containsKey(z.backendName)) { ModSettings.dbgout("setting " + (String) p.get(z.backendName)); z.fromString((String) p.get(z.backendName), context); } } break; } catch (Exception e) { System.out.println(e); break; } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_logger); sPreference = getSharedPreferences("TMsetting", Activity.MODE_PRIVATE); // if (!setting.getLogEnable()) // stopService(new Intent("com.lge.power.tmmonitor.LogService")); setting = LoggerSetting.getInstance(); setting.initiateNodes(device); node = setting.getNodeArray(); countDownTimer = new CountDownTimer(1, 1) { @Override public void onTick(long millisUntilFinished) { // TODO Auto-generated method stub } @Override public void onFinish() { // TODO Auto-generated method stub } }; // textView = (TextView)findViewById(R.id.editText010101); // textView.setText(setting.getFrequency()); textView = (TextView) findViewById(R.id.log_textView020102); textView.setText(getNodeName(node)); textView = (TextView) findViewById(R.id.log_textView020202); textView.setText(getNodeName(node)); }
private void jMenuItem3ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem3ActionPerformed // TODO add your handling code here: Setting setting = new Setting(); setting.setUser(loginModel); setting.setVisible(true); this.dispose(); } // GEN-LAST:event_jMenuItem3ActionPerformed
public void addSetting(String property, String value) { if (StringUtils.isNotBlank(property)) { Setting s = new Setting(); s.setting = property; s.value = value; settings.add(s); } }
/** Used to find any setting based on the key in the appropriate props file */ public Setting getSetting(String key) { synchronized (FACTORY) { for (Setting currSetting : FACTORY) { if (currSetting.getKey().equals(key)) return currSetting; } } return null; // unable the find the setting we are looking for }
public void testGetSettingValue() throws Exception { BeanWithSettings bean = new BirdWithSettings(); assertNull(bean.getSettingValue("towhee/rufous-sided")); Setting rs = bean.getSettings().getSetting("towhee/rufous-sided"); assertNull(rs.getDefaultValue()); bean.setSettingValue("towhee/rufous-sided", "4"); assertEquals("4", bean.getSettingValue("towhee/rufous-sided")); // default value should not change assertNull(rs.getDefaultValue()); }
public void setUp() { Setting animalDog = new SettingImpl("animal"); animalDog.setValue("dog"); animalDog.setIndex(0); Setting animalDogDupe = new SettingImpl("animal"); animalDogDupe.setValue("dog"); animalDogDupe.setIndex(1); Setting animalCat = new SettingImpl("animal"); animalCat.setValue("cat"); animalCat.setIndex(2); SettingMap map1 = new SettingMap(); map1.put("animal", animalDog); uniqueMap1 = new EquivalentSettingMapWrapper(map1); SettingMap map2 = new SettingMap(); map2.put("animal", animalCat); uniqueMap2 = new EquivalentSettingMapWrapper(map2); SettingMap map3 = new SettingMap(); map3.put("animal", animalDogDupe); uniqueMap3 = new EquivalentSettingMapWrapper(map3); }
public Session(Database database, User user, int id) { this.database = database; this.queryTimeout = database.getSettings().maxQueryTimeout; this.queryCacheSize = database.getSettings().queryCacheSize; this.undoLog = new UndoLog(this); this.user = user; this.id = id; Setting setting = database.findSetting(SetTypes.getTypeName(SetTypes.DEFAULT_LOCK_TIMEOUT)); this.lockTimeout = setting == null ? Constants.INITIAL_LOCK_TIMEOUT : setting.getIntValue(); this.currentSchemaName = Constants.SCHEMA_MAIN; }
/** * Get a list of all Text settings for the specified context. * * @param context The context from which to copy from. * @return The list of settings. */ @SuppressWarnings("rawtypes") public ArrayList<SettingText> getAllTextSettings(String context) { ArrayList<SettingText> settings = new ArrayList<SettingText>(); for (Setting setting : Settings) { if (!SettingText.class.isAssignableFrom(setting.getClass())) { continue; } settings.add((SettingText) setting); } return settings; }
/** * Gets a setting by backend name. * * @param backendName The backend name of the setting. * @return The SettingText. */ public SettingText getSettingText(String backendName) { for (Setting setting : Settings) { if (!SettingText.class.isAssignableFrom(setting.getClass())) { continue; } if (setting.backendName.equals(backendName)) { return (SettingText) setting; } } throw new InvalidParameterException("SettingText '" + backendName + "' not found."); }
public void createSettings() { settingBag = new ArrayList<>(); settingBag.add(new Setting("Instant Respawn", Material.MINECART, Rank.PLAYER)); settingBag.add(new Setting("Private Messages", Material.CHEST, Rank.PLAYER)); settingBag.add(new Setting("Public Chat", Material.SIGN, Rank.PLAYER)); settingBag.add(new Setting("Staff Chat", Material.EYE_OF_ENDER, Rank.TRIAL_MOD)); for (Setting setting : settingBag) { Main.debug("Creating " + setting.getName() + " Setting"); } }
// insert new acc public void insertSetting(Setting Setting) { if (Setting != null) { ContentValues cv = new ContentValues(); cv.put(SQLiteDB.SItem, Setting.getItem()); cv.put(SQLiteDB.SValue, Setting.getValue()); try { database.insert(SQLiteDB.TABLE_SETTING, null, cv); } catch (Exception ex) { ex.printStackTrace(); } } }
public Settings(File folder) { config = new YamlStorage(new File(folder, "config.yml"), "Citizens Configuration"); root = config.getKey(""); config.load(); for (Setting setting : Setting.values()) { if (!root.keyExists(setting.path)) { setting.setAtKey(root); } else setting.loadFromKey(root); } save(); }
public void testRegisterShared() { Property scope = randomFrom(Property.NodeScope, Property.IndexScope); expectThrows( IllegalArgumentException.class, () -> new SettingsModule( Settings.EMPTY, Setting.simpleString("index.foo.bar", scope), Setting.simpleString("index.foo.bar", scope))); expectThrows( IllegalArgumentException.class, () -> new SettingsModule( Settings.EMPTY, Setting.simpleString("index.foo.bar", scope, Property.Shared), Setting.simpleString("index.foo.bar", scope))); expectThrows( IllegalArgumentException.class, () -> new SettingsModule( Settings.EMPTY, Setting.simpleString("index.foo.bar", scope), Setting.simpleString("index.foo.bar", scope, Property.Shared))); new SettingsModule( Settings.EMPTY, Setting.simpleString("index.foo.bar", scope, Property.Shared), Setting.simpleString("index.foo.bar", scope, Property.Shared)); }
/** Get lastest id */ public int getLastId() { int id = -1; try { Cursor cursor = database.query(SQLiteDB.TABLE_SETTING, allColumns, null, null, null, null, null); cursor.moveToLast(); Setting s = cursorToSetting(cursor); id = s.getId(); cursor.close(); } catch (Exception ex) { ex.printStackTrace(); } return id; }
/** Update */ public boolean updateSetting(Setting set) { if (set != null) { ContentValues cv = new ContentValues(); cv.put(SQLiteDB.SId, set.getId()); cv.put(SQLiteDB.SItem, set.getItem()); cv.put(SQLiteDB.SValue, set.getValue()); try { database.update(SQLiteDB.TABLE_SETTING, cv, SQLiteDB.SId + "=" + set.getId(), null); } catch (Exception ex) { ex.printStackTrace(); return false; } return true; } return false; }
public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof Setting)) return false; Setting other = (Setting) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.settingType == null && other.getSettingType() == null) || (this.settingType != null && this.settingType.equals(other.getSettingType()))); __equalsCalc = null; return _equals; }
public void testMutuallyExclusiveScopes() { new SettingsModule(Settings.EMPTY, Setting.simpleString("foo.bar", Property.NodeScope)); new SettingsModule(Settings.EMPTY, Setting.simpleString("index.foo.bar", Property.IndexScope)); // Those should fail try { new SettingsModule(Settings.EMPTY, Setting.simpleString("foo.bar")); fail("No scope should fail"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("No scope found for setting")); } // Some settings have both scopes - that's fine too if they have per-node defaults try { new SettingsModule( Settings.EMPTY, Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope), Setting.simpleString("foo.bar", Property.NodeScope)); fail("already registered"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Cannot register setting [foo.bar] twice")); } try { new SettingsModule( Settings.EMPTY, Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope), Setting.simpleString("foo.bar", Property.IndexScope)); fail("already registered"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Cannot register setting [foo.bar] twice")); } }
// delete item public void deleteItem(Setting s) { long id = s.getId(); System.out.println("Comment deleted with id: " + id); try { database.delete(SQLiteDB.TABLE_SETTING, SQLiteDB.SId + " = " + id, null); } catch (Exception ex) { ex.printStackTrace(); } }
public <C> C loadSettingValue(Setting<C> setting) { String v = null; // TODO SystemProperties.getComponentProperty(setting.getComponent().getName(), // setting.getName()); if (v != null) { return setting.getDataType().cast(v, null, null); } return null; }
public static void validateSecurityCode( Context context, String securityCode, PaymentMethod paymentMethod, String bin) throws Exception { if (paymentMethod != null) { Setting setting = Setting.getSettingByBin(paymentMethod.getSettings(), bin); // Validate security code length if (setting != null) { int cvvLength = setting.getSecurityCode().getLength(); if ((cvvLength != 0) && (securityCode.trim().length() != cvvLength)) { throw new Exception(context.getString(R.string.mpsdk_invalid_cvv_length, cvvLength)); } } else { throw new Exception(context.getString(R.string.mpsdk_invalid_field)); } } }
public void setTypeText(int typeId) { if (typeId == 1) { String sale_type = Setting.getSetting(Setting.keySaleType, FilterNewActivity.this); if (sale_type.equals("0")) { saleTypeTextView.setText("任何出售型態"); } else { saleTypeTextView.setText(setSaleTypeText(sale_type)); } } else if (typeId == 2) { String rent_type = Setting.getSetting(Setting.keyRentType, FilterNewActivity.this); if (rent_type.equals("0")) { rentTypeTextView.setText("任何出租型態"); } else { rentTypeTextView.setText(setRentTypeText(rent_type)); } } }
public void testRegisterSettings() { { Settings settings = Settings.builder().put("some.custom.setting", "2.0").build(); SettingsModule module = new SettingsModule( settings, Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope)); assertInstanceBinding(module, Settings.class, (s) -> s == settings); } { Settings settings = Settings.builder().put("some.custom.setting", "false").build(); try { new SettingsModule( settings, Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope)); fail(); } catch (IllegalArgumentException ex) { assertEquals( "Failed to parse value [false] for setting [some.custom.setting]", ex.getMessage()); } } }
public void fieldChange2() { Double value = (Double) textField2.getValue(); log.debug("Changed isoFact to: " + value); if (value.isInfinite() || value.isNaN()) { value = 0.0; } Setting.getElement("/bat/isotope/calc/bg/error").setText(value.toString()); for (int i = 0; i < data.corrList.size(); i++) { data.corrList.get(i).isoErr = value; } data.calcAll(); // makeReg(); // dataSet = Func.getXY(data.get(dataType),null,x,y,x_multi,y_multi); // chart.getXYPlot().setDataset(0,dataSet); log.debug( "Isobar correction factor error set to: " + value + "-" + Setting.getDouble("/bat/isotope/calc/bg/error")); }