/** * Return a collection of intervals that intersect 'marker' Query resulting genes, transcripts and * exons to get ALL types of intervals possible * * @return */ public Markers queryDeep(Marker marker) { if (Config.get().isErrorOnMissingChromo() && isChromosomeMissing(marker)) throw new RuntimeEOFException("Chromosome missing for marker: " + marker); boolean hitChromo = false; Markers hits = new Markers(); Markers intersects = query(marker); if (intersects.size() > 0) { for (Marker m : intersects) { hits.add(m); if (m instanceof Chromosome) { hitChromo = true; // OK (we have to hit a chromosome, otherwise it's an error } else if (m instanceof Gene) { // Analyze Genes Gene gene = (Gene) m; hits.addAll(gene.query(marker)); } } } if (!hitChromo && Config.get().isErrorChromoHit()) throw new RuntimeException("ERROR: Out of chromosome range. " + marker); return hits; }
static String mapHostToRealm(String name) { String result = null; try { String subname = null; Config c = Config.getInstance(); if ((result = c.get("domain_realm", name)) != null) return result; else { for (int i = 1; i < name.length(); i++) { if ((name.charAt(i) == '.') && (i != name.length() - 1)) { // mapping could be .ibm.com = AUSTIN.IBM.COM subname = name.substring(i); result = c.get("domain_realm", subname); if (result != null) { break; } else { subname = name.substring(i + 1); // or mapping could be ibm.com = AUSTIN.IBM.COM result = c.get("domain_realm", subname); if (result != null) { break; } } } } } } catch (KrbException e) { } return result; }
/** Test default value. */ public void testDefaultGet() { final String defaultString = "default value"; assertEquals(defaultString, config.get("unknown", defaultString)); final String missingPropertyName = "missing.property.name"; assertEquals(defaultString, config.get(getClass(), missingPropertyName, defaultString)); final int defaultInt = 42; assertEquals(defaultInt, config.getInt(getClass(), missingPropertyName, defaultInt)); }
/** * Predict the effect of a seqChange * * @param seqChange : Sequence change * @param seqChangeRef : Before analyzing results, we have to change markers using seqChangerRef * to create a new reference 'on the fly' */ public ChangeEffects seqChangeEffect(Variant seqChange, Variant seqChangeRef) { ChangeEffects changeEffects = new ChangeEffects(seqChange, seqChangeRef); // --- // Chromosome missing? // --- if (Config.get().isErrorOnMissingChromo() && isChromosomeMissing(seqChange)) { changeEffects.addErrorWarning(ErrorWarningType.ERROR_CHROMOSOME_NOT_FOUND); return changeEffects; } // --- // Check that this is not a huge deletion. // Huge deletions would crash the rest of the algorithm, so we need to stop them here. // --- if (seqChange.isDel() && (seqChange.size() > HUGE_DELETION_SIZE_THRESHOLD)) { // Get chromosome String chromoName = seqChange.getChromosomeName(); Chromosome chr = genome.getChromosome(chromoName); if (chr.size() > 0) { double ratio = seqChange.size() / ((double) chr.size()); if (ratio > HUGE_DELETION_RATIO_THRESHOLD) { changeEffects.add(chr, EffectType.CHROMOSOME_LARGE_DELETION, ""); return changeEffects; } } } // --- // Query interval tree: Which intervals does seqChange intersect? // --- Markers intersects = query(seqChange); // Show all results boolean hitChromo = false, hitSomething = false; if (intersects.size() > 0) { for (Marker marker : intersects) { if (marker instanceof Chromosome) hitChromo = true; // Do we hit any chromosome? else { // Analyze all markers marker.seqChangeEffect(seqChange, changeEffects, seqChangeRef); hitSomething = true; } } } // Any errors or intergenic (i.e. did not hit any gene) if (!hitChromo) { if (Config.get().isErrorChromoHit()) changeEffects.addErrorWarning(ErrorWarningType.ERROR_OUT_OF_CHROMOSOME_RANGE); } else if (!hitSomething) { if (Config.get().isOnlyRegulation()) changeEffects.setEffectType(EffectType.NONE); else changeEffects.setEffectType(EffectType.INTERGENIC); } return changeEffects; }
private void init() throws IOException { // zooKeeper = new ZooKeeper(SystemConfig.getProperty("zk.quorum"), // Integer.parseInt(SystemConfig.getProperty("zk.session.timeout", "30000")), defaultWatch); String zkQuorum = Config.get().get("zk.quorum", "localhost:2181"); // zooKeeper = new ZooKeeper(StringUtils.join(zkHostList, ","), new // Integer(BaseConfig.getValue("zk.session.timeout", "30000")), defaultWatch); zooKeeper = new ZooKeeperRetry( zkQuorum, new Integer(Config.get().get("zk.session.timeout", "30000")), defaultWatch); }
@Test public void shouldBeAbleToRegisterSettingsClassesAfterInstantiation() throws Exception { // Given Config config = new Config(stringMap("old", "hello!")); // When config.registerSettingsClasses(asList(MySettingsWithDefaults.class, MyMigratingSettings.class)); // Then assertThat(config.get(MyMigratingSettings.newer), equalTo("hello!")); assertThat(config.get(MySettingsWithDefaults.hello), equalTo("Hello, World!")); }
public void reset() { Config config = Config.get(); vibrateOn = config.getBoolean("key_vibrate"); duration = config.getInt("key_vibrate_duration"); if (vibrateOn && (vibrator == null)) { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); } soundOn = config.getBoolean("key_sound"); volume = config.getFloat("key_sound_volume"); if (soundOn && (audioManager == null)) { audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); } isSpeakCommit = config.getBoolean("speak_commit"); isSpeakKey = config.getBoolean("speak_key"); if (mTTS == null && (isSpeakCommit || isSpeakKey)) { mTTS = new TextToSpeech( context, new TextToSpeech.OnInitListener() { public void onInit(int status) { // 初始化結果 } }); } }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // Get the renderer component from parent class JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); // Get icon to use for the list item value Character character = (Character) value; Config.ConfigEntry ce = config.get(character.getName()); Icon icon = null; if (ce == null) { icon = icons.get(NOTOK); label.setToolTipText( "Double-click to enter configuration information for this character, right-click for more options"); } else { if (ce.isOk()) { icon = icons.get(OK); ui.exportAllButton.setEnabled(true); } else { icon = icons.get(NOTOK); } } // Set icon to display for value label.setIcon(icon); return label; }
public TraceLevel getTraceLevel(String id) { TraceLevel level; Integer value; /* ** See if ID has already been processed. */ if ((level = (TraceLevel) levels.get(id)) == null) { String str; int val = 0; /* ** See if ID is defined for trace key. */ if ((str = config.get(id)) != null) try { val = Integer.parseInt(str); } catch (Exception ignore) { } /* ** Save determined value for future reference. */ level = new TraceLevel(val); levels.put(id, level); } return (level); } // getTraceLevel
public static void initStatic() { String temp = null; Config cfg = null; try { cfg = Config.getInstance(); temp = cfg.get("libdefaults", "default_checksum"); if (temp != null) { CKSUMTYPE_DEFAULT = Config.getType(temp); } else { /* * If the default checksum is not * specified in the configuration we * set it to RSA_MD5. We follow the MIT and * SEAM implementation. */ CKSUMTYPE_DEFAULT = CKSUMTYPE_RSA_MD5; } } catch (Exception exc) { if (DEBUG) { System.out.println( "Exception in getting default checksum " + "value from the configuration " + "Setting default checksum to be RSA-MD5"); exc.printStackTrace(); } CKSUMTYPE_DEFAULT = CKSUMTYPE_RSA_MD5; } try { temp = cfg.get("libdefaults", "safe_checksum_type"); if (temp != null) { SAFECKSUMTYPE_DEFAULT = Config.getType(temp); } else { SAFECKSUMTYPE_DEFAULT = CKSUMTYPE_RSA_MD5_DES; } } catch (Exception exc) { if (DEBUG) { System.out.println( "Exception in getting safe default " + "checksum value " + "from the configuration Setting " + "safe default checksum to be RSA-MD5"); exc.printStackTrace(); } SAFECKSUMTYPE_DEFAULT = CKSUMTYPE_RSA_MD5_DES; } }
@Override public Worker create(final Config config, final DependencyResolver dependencies) { final MSMSEvalWorker worker = new MSMSEvalWorker(); worker.setMsmsEvalExecutable( FileUtilities.getAbsoluteFileForExecutables(new File(config.get(MSMS_EVAL_EXECUTABLE)))); worker.setConverter(getConverter()); return worker; }
@Test public void shouldApplyMigrations() { // When Config config = new Config(stringMap("old", "hello!"), MyMigratingSettings.class); // Then assertThat(config.get(MyMigratingSettings.newer), is("hello!")); }
@Override public void onResults(Bundle results) { stop(); destory(); Log.i(TAG, "onResults"); Trime trime = Trime.getService(); if (trime == null) return; ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); String opencc_config = Config.get(context).getString("speech_opencc_config"); for (String result : matches) trime.commitText(Rime.openccConvert(result, opencc_config)); }
/** * Method that initializes all vital prerequisites, including POS Tagger * * @param language Language to be processed with this copy of HeidelTime * @param typeToProcess Domain type to be processed * @param outputType Output type * @param configPath Path to the configuration file for HeidelTimeStandalone * @param posTagger POS Tagger to use for preprocessing * @param doIntervalTagging Whether or not to invoke the IntervalTagger */ public void initialize( Language language, DocumentType typeToProcess, OutputType outputType, String configPath, POSTagger posTagger, Boolean doIntervalTagging) { logger.log( Level.INFO, "HeidelTimeStandalone initialized with language " + this.language.getName()); // set the POS tagger this.posTagger = posTagger; // set doIntervalTagging flag this.doIntervalTagging = doIntervalTagging; // read in configuration in case it's not yet initialized if (!Config.isInitialized()) { if (configPath == null) readConfigFile(CLISwitch.CONFIGFILE.getValue().toString()); else readConfigFile(configPath); } try { heidelTime = new HeidelTime(); heidelTime.initialize( new UimaContextImpl(language, typeToProcess, CLISwitch.VERBOSITY2.getIsActive())); logger.log(Level.INFO, "HeidelTime initialized"); } catch (Exception e) { e.printStackTrace(); logger.log(Level.WARNING, "HeidelTime could not be initialized"); } // Initialize JCas factory ------------- logger.log(Level.FINE, "Initializing JCas factory..."); try { TypeSystemDescription[] descriptions = new TypeSystemDescription[] { UIMAFramework.getXMLParser() .parseTypeSystemDescription( new XMLInputSource( this.getClass() .getClassLoader() .getResource(Config.get(Config.TYPESYSTEMHOME)))) }; jcasFactory = new JCasFactoryImpl(descriptions); logger.log(Level.INFO, "JCas factory initialized"); } catch (Exception e) { e.printStackTrace(); logger.log(Level.WARNING, "JCas factory could not be initialized"); } }
public static void configCheck(ConfigType type) { FileConfiguration config; switch (type) { case linkConfig: config = linkConfig.get(); config.addDefault("Links.YouTube", "http://youtube.com"); config.addDefault("Links.Twitter", "http://twitter.com"); config.addDefault("Links.Website", "http://www.elementum.me"); config.addDefault("Links.Donate", "http://www.elementum.me/donate"); config.addDefault("Links.Vote", "http://"); linkConfig.save(); case opConfig: config = opConfig.get(); config.addDefault("Ops.KickMessage", "&cHa, you thought. Go watch space jam kid."); config.addDefault("Ops.Names", Arrays.asList("Loonyy")); opConfig.save(); case commandsConfig: config = commandConfig.get(); config.addDefault("CommandMessage", "&c&lNot in my house! :)"); config.addDefault("Commands", Arrays.asList("fly")); commandConfig.save(); case respawnConfig: config = respawnConfig.get(); config.addDefault("RespawnLocation.FallbackSpawn", "null"); respawnConfig.save(); } }
public HgvsProtein(VariantEffect variantEffect) { super(variantEffect); codonNum = variantEffect.getCodonNum(); hgvsOneLetterAa = Config.get().isHgvs1LetterAA(); hgvsOld = Config.get().isHgvsOld(); stop = hgvsOld ? 'X' : '*'; lettersPerAa = hgvsOneLetterAa ? 1 : 3; // No marker? Nothing to do if (marker != null) { // Codon numbering // HGVS: the translation initiator Methionine is numbered as +1 if (codonNum >= 0) aaPos = codonNum + 1; aaNew = aaCode(variantEffect.getAaAlt()); aaOld = aaCode(variantEffect.getAaRef()); } else { aaPos = -1; aaNew = aaOld = ""; } }
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // 读取配置文件对象 Config config = new Config(); // 获取配置参数 String host = config.get("smgwip"); String account = config.get("smgwaccount"); String passwd = config.get("smgwpasswd"); String spid = config.get("smgwspid"); String spnum = config.get("smgpspnum"); int port = Integer.parseInt(config.get("smgwport")); String productid = config.get("productid"); // 目标号码:18918911891 String destnum = config.get("destnum"); String content = config.get("longconent"); // 初始化client Client client = new Client(host, port, 2, account, passwd, spid, 0); // 设置submit Submit submit = new Submit(); submit.setSrcTermid(spnum); submit.setDestTermid(destnum); submit.setMsgContent(content.getBytes("iso-10646-ucs-2")); submit.setMsgFormat(8); if (productid != null) submit.setProductID(productid); // 发送短信 Result[] result = client.SendLong(submit); for (int i = 0; i < result.length; i++) { System.out.println("--------------------------------"); System.out.println("Message " + i + ""); System.out.println("Status:" + result[i].ErrorCode); System.out.println("MsgID:" + result[i].ErrorDescription); System.out.println("--------------------------------"); } // 退出 client.Close(); }
private void exportSelectedCharacters() { if (herolabsCharacterList.getSelectedIndex() >= 0) { Character c = (Character) herolabsCharacterList .getModel() .getElementAt(herolabsCharacterList.getSelectedIndex()); Config.ConfigEntry ce = config.get(c.getName()); if (ce != null && ce.isOk()) { exportCharacters(); } else { JOptionPane.showMessageDialog( panel, "The character you selected hasn't been configured yet. Please configure " + "and try again.", "Export Warning", JOptionPane.WARNING_MESSAGE); } } }
/** * Imprime en el formato Osm el nodo con la informacion * * @param id Id del nodo * @param huso Huso geografico para la conversion UTM a Lat/Long * @return Devuelve en un String el nodo listo para imprimir * @throws UnsupportedEncodingException */ public String printNode(Long id) { String s = ""; // Si no pertenece a ningun shape porque se ha visto que no tenia tags representativos // o se ha delimitado la busqueda if (shapes == null || shapes.isEmpty()) { return s; } s = ("<node id=\"" + id + "\" timestamp=\"" + new Timestamp(new Date().getTime()) + "\" version=\"6\" lat=\"" + this.coor.y + "\" lon=\"" + this.coor.x + "\">\n"); if (tags != null) for (int x = 0; x < tags.size(); x++) if (tags.get(x)[0].startsWith("CAT2OSMSHAPEID") && Config.get("PrintShapeIds").equals("1")) s += "<tag k=\"" + tags.get(x)[0] + "\" v=\"" + tags.get(x)[1] + "\"/>\n"; else if (!tags.get(x)[0].startsWith("CAT2OSMSHAPEID")) s += "<tag k=\"" + tags.get(x)[0] + "\" v=\"" + tags.get(x)[1] + "\"/>\n"; s += "<tag k=\"source\" v=\"catastro\"/>\n"; s += "<tag k=\"source:date\" v=\"" + new StringBuffer(Cat2OsmUtils.getFechaArchivos() + "") .insert(4, "-") .toString() .substring(0, 7) + "\"/>\n"; s += ("</node>\n"); return s; }
/** Resolve include statements */ private static boolean resolveIncludes( ParseTree tree, boolean debug, Set<String> alreadyIncluded) { boolean changed = false; if (tree instanceof IncludeFileContext) { // Parent file: The one that is including the other file File parentFile = new File(((IncludeFileContext) tree).getStart().getInputStream().getSourceName()); // Included file name String includedFilename = StatementInclude.includeFileName(tree.getChild(1).getText()); // Find file (look into all include paths) File includedFile = StatementInclude.includeFile(includedFilename, parentFile); if (includedFile == null) { CompilerMessages.get() .add( tree, parentFile, "\n\tIncluded file not found: '" + includedFilename + "'\n\tSearch path: " + Config.get().getIncludePath(), MessageType.ERROR); return false; } // Already included? don't bother String canonicalFileName = Gpr.getCanonicalFileName(includedFile); if (alreadyIncluded.contains(canonicalFileName)) { if (debug) Gpr.debug( "File already included: '" + includedFilename + "'\tCanonical path: '" + canonicalFileName + "'"); return false; } if (!includedFile.canRead()) { CompilerMessages.get() .add( tree, parentFile, "\n\tCannot read included file: '" + includedFilename + "'", MessageType.ERROR); return false; } // Parse ParseTree treeinc = createAst(includedFile, debug, alreadyIncluded); if (treeinc == null) { CompilerMessages.get() .add( tree, parentFile, "\n\tFatal error including file '" + includedFilename + "'", MessageType.ERROR); return false; } // Is a child always a RuleContext? for (int i = 0; i < treeinc.getChildCount(); i++) { ((IncludeFileContext) tree).addChild((RuleContext) treeinc.getChild(i)); } } else { for (int i = 0; i < tree.getChildCount(); i++) changed |= resolveIncludes(tree.getChild(i), debug, alreadyIncluded); } return changed; }
public static void War( String section, String playersection, String targetsection, String playername) { if (serverdata.get(section).get(playersection).get("ene") == null) { serverdata.get(section).get(playersection).put("ene", new HashMap<>()); } if (section.equals("villages")) { ((HashMap) serverdata.get(section).get(playersection).get("ene")) .put(targetsection, Config.get("Village Settings.War Time Delay")); } else { ((HashMap) serverdata.get(section).get(playersection).get("ene")) .put(targetsection, Config.get("Empire Settings.War Time Delay")); } if (serverdata.get(section).get(targetsection).get("ene") == null) { serverdata.get(section).get(targetsection).put("ene", new HashMap<>()); } if (section.equals("villages")) { ((HashMap) serverdata.get(section).get(targetsection).get("ene")) .put(playersection, Config.get("Village Settings.War Time Delay")); } else { ((HashMap) serverdata.get(section).get(targetsection).get("ene")) .put(playersection, Config.get("Empire Settings.War Time Delay")); } if (serverdata.get(section).get(playersection).get("all") != null) { if (((ArrayList) serverdata.get(section).get(playersection).get("all")) .contains(targetsection)) { ((ArrayList) serverdata.get(section).get(playersection).get("all")).remove(targetsection); ((ArrayList) serverdata.get(section).get(targetsection).get("all")).remove(playersection); } } if (serverdata.get(section).get(playersection).get("alr") != null) { if (((ArrayList) serverdata.get(section).get(playersection).get("alr")) .contains(targetsection)) { ((ArrayList) serverdata.get(section).get(playersection).get("alr")).remove(targetsection); } } if (serverdata.get(section).get(targetsection).get("alr") != null) { if (((ArrayList) serverdata.get(section).get(targetsection).get("alr")) .contains(playersection)) { ((ArrayList) serverdata.get(section).get(targetsection).get("alr")).remove(playersection); } } Bukkit.getPlayer(UUID.fromString(playername)) .sendMessage( ChatColor.BLUE + " you have successfully declared war on " + ChatColor.AQUA + targetsection); if (section.equals("villages")) { if ((Bukkit.getOfflinePlayer( UUID.fromString(serverdata.get(section).get(targetsection).get("own").toString()))) .isOnline()) { Bukkit.getPlayer( UUID.fromString(serverdata.get(section).get(targetsection).get("own").toString())) .sendMessage( ChatColor.LIGHT_PURPLE + Bukkit.getPlayer(UUID.fromString(playername)).getName() + ChatColor.DARK_PURPLE + ", owner of the village " + ChatColor.LIGHT_PURPLE + playersection + ChatColor.DARK_PURPLE + ", has declared war on you!"); } temparraylist.clear(); if (serverdata.get(section).get(playersection) != null) { if (serverdata.get(section).get(playersection).get("mem") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get(section).get(playersection).get("mem")); } if (serverdata.get(section).get(playersection).get("man") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get(section).get(playersection).get("man")); } } temparraylist .stream() .filter((p) -> ((Bukkit.getOfflinePlayer(UUID.fromString(p))).isOnline())) .forEach( (p) -> { Bukkit.getPlayer(UUID.fromString(p)) .sendMessage( ChatColor.LIGHT_PURPLE + playersection + ChatColor.DARK_PURPLE + ", Has declared war on you!"); }); temparraylist.clear(); if (serverdata.get(section).get(targetsection) != null) { if (serverdata.get(section).get(targetsection).get("mem") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get(section).get(targetsection).get("mem")); } if (serverdata.get(section).get(targetsection).get("man") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get(section).get(targetsection).get("man")); } } temparraylist .stream() .filter((p) -> ((Bukkit.getOfflinePlayer(UUID.fromString(p))).isOnline())) .forEach( (p) -> { Bukkit.getPlayer(UUID.fromString(p)) .sendMessage( ChatColor.LIGHT_PURPLE + Bukkit.getPlayer(UUID.fromString(playername)).getName() + ChatColor.DARK_PURPLE + ", has declared war on " + ChatColor.LIGHT_PURPLE + targetsection); }); } else { ((ArrayList<String>) serverdata.get("empires").get(targetsection).get("vils")) .stream() .map( (v) -> { if ((Bukkit.getOfflinePlayer( UUID.fromString(serverdata.get("villages").get(v).get("own").toString()))) .isOnline()) { Bukkit.getPlayer( UUID.fromString(serverdata.get("villages").get(v).get("own").toString())) .sendMessage( ChatColor.LIGHT_PURPLE + Bukkit.getPlayer(UUID.fromString(playername)).getName() + ChatColor.DARK_PURPLE + ", leader of the empire " + ChatColor.LIGHT_PURPLE + playersection + ChatColor.DARK_PURPLE + ", has declared war on your empire!"); } return v; }) .map( (v) -> { temparraylist.clear(); return v; }) .map( (v) -> { if (serverdata.get("villages").get(v) != null) { if (serverdata.get("villages").get(v).get("mem") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get("villages").get(v).get("mem")); } if (serverdata.get("villages").get(v).get("man") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get("villages").get(v).get("man")); } } return v; }) .forEach( (_item) -> { temparraylist .stream() .filter((p) -> ((Bukkit.getOfflinePlayer(UUID.fromString(p))).isOnline())) .forEach( (p) -> { Bukkit.getPlayer(UUID.fromString(p)) .sendMessage( ChatColor.LIGHT_PURPLE + playersection + ChatColor.DARK_PURPLE + ", Has declared war on you!"); }); }); ((ArrayList<String>) serverdata.get("empires").get(playersection).get("vils")) .stream() .map( (v) -> { temparraylist.clear(); return v; }) .map( (v) -> { if (serverdata.get("villages").get(v) != null) { if (serverdata.get("villages").get(v).get("mem") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get("villages").get(v).get("mem")); } if (serverdata.get("villages").get(v).get("man") != null) { temparraylist.addAll( (Collection<? extends String>) serverdata.get("villages").get(v).get("man")); } } return v; }) .forEach( (_item) -> { temparraylist .stream() .filter((p) -> ((Bukkit.getOfflinePlayer(UUID.fromString(p))).isOnline())) .forEach( (p) -> { Bukkit.getPlayer(UUID.fromString(p)) .sendMessage( ChatColor.LIGHT_PURPLE + Bukkit.getPlayer(UUID.fromString(playername)).getName() + ChatColor.DARK_PURPLE + ", has declared war on " + ChatColor.LIGHT_PURPLE + targetsection); }); }); } }
@Override public void run() { for (Location l : Storage.blackholes.keySet()) { for (Entity e : Utilities.getNearbyEntities(l, 10, 10, 10)) { if (e instanceof Player) { if (((Player) e).getGameMode().equals(CREATIVE)) { continue; } } if (Storage.blackholes.get(l)) { Vector v = l.clone().subtract(e.getLocation()).toVector(); v.setX(v.getX() + (-.5f + Storage.rnd.nextFloat()) * 10); v.setY(v.getY() + (-.5f + Storage.rnd.nextFloat()) * 10); v.setZ(v.getZ() + (-.5f + Storage.rnd.nextFloat()) * 10); e.setVelocity(v.multiply(.35f)); e.setFallDistance(0); } else { Vector v = e.getLocation().subtract(l.clone()).toVector(); v.setX(v.getX() + (-.5f + Storage.rnd.nextFloat()) * 2); v.setY(v.getY() + Storage.rnd.nextFloat()); v.setZ(v.getZ() + (-.5f + Storage.rnd.nextFloat()) * 2); e.setVelocity(v.multiply(.35f)); } } } // Arrows toRemove.clear(); for (Set<CustomArrow> pro : Storage.advancedProjectiles.values()) { for (CustomArrow a : pro) { a.onFlight(); a.tick++; if (a.entity.isDead() || a.tick > 600) { toRemove.add(a); } } } for (CustomArrow pro : toRemove) { Storage.advancedProjectiles.remove(pro.entity); pro.entity.remove(); } for (Block block : Storage.webs) { if (Storage.rnd.nextInt(175) == 0 && block.getChunk().isLoaded()) { block.setType(AIR); websToRemove.add(block); } } for (Block block : websToRemove) { Storage.webs.remove(block); } websToRemove.clear(); for (LivingEntity ent : Storage.derpingEntities) { Location loc = ent.getLocation(); loc.setYaw(Storage.rnd.nextFloat() * 360F); loc.setPitch(Storage.rnd.nextFloat() * 180F - 90F); ent.teleport(loc); } tick++; // Other stuff for (FallingBlock b : Storage.anthMobs2) { if (!Storage.anthVortex.contains(Storage.anthMobs.get(b))) { for (Entity e : b.getNearbyEntities(7, 7, 7)) { if (e instanceof LivingEntity) { LivingEntity lE = (LivingEntity) e; if (!(lE instanceof Player) && lE instanceof Monster) { b.setVelocity(e.getLocation().subtract(b.getLocation()).toVector().multiply(.25)); if (lE.getLocation().getWorld().equals(b.getLocation().getWorld())) { if (lE.getLocation().distance(b.getLocation()) < 1.2) { EntityDamageEvent evt = new EntityDamageEvent(lE, EntityDamageEvent.DamageCause.SUFFOCATION, 100); Bukkit.getPluginManager().callEvent(evt); lE.setLastDamageCause(evt); if (!evt.isCancelled()) { lE.damage(8f); } } } } } } } } boolean r = Storage.fallBool; Storage.fallBool = !Storage.fallBool; for (FallingBlock b : Storage.anthMobs.keySet()) { if (Storage.anthVortex.contains(Storage.anthMobs.get(b))) { Location loc = Storage.anthMobs.get(b).getLocation(); Vector v; if (b.getLocation().getWorld().equals(Storage.anthMobs.get(b).getLocation().getWorld())) { if (r && b.getLocation().distance(Storage.anthMobs.get(b).getLocation()) < 10) { v = b.getLocation().subtract(loc).toVector(); } else { int x = Storage.rnd.nextInt(12) - 6; int z = Storage.rnd.nextInt(12) - 6; Location tLoc = loc.clone(); tLoc.setX(tLoc.getX() + x); tLoc.setZ(tLoc.getZ() + z); v = tLoc.subtract(b.getLocation()).toVector(); } v.multiply(.05); boolean close = false; for (int x = -3; x < 0; x++) { if (b.getLocation().getBlock().getRelative(0, x, 0).getType() != AIR) { close = true; } } if (close) { v.setY(5); } else { v.setY(-.1); } b.setVelocity(v); } } } for (Arrow e : Storage.tracer.keySet()) { Entity close = null; double distance = 100; int level = Storage.tracer.get(e); level = level + 2; for (Entity e1 : e.getNearbyEntities(level, level, level)) { if (e1.getLocation().getWorld().equals(e.getLocation().getWorld())) { double d = e1.getLocation().distance(e.getLocation()); if (e.getLocation() .getWorld() .equals(((Entity) e.getShooter()).getLocation().getWorld())) { if (d < distance && e1 instanceof LivingEntity && !e1.equals(e.getShooter()) && e.getLocation().distance(((Entity) e.getShooter()).getLocation()) > 15) { distance = d; close = e1; } } } } if (close != null) { Location location = close.getLocation(); org.bukkit.util.Vector v = new org.bukkit.util.Vector(0D, 0D, 0D); Location pos = e.getLocation(); double its = Math.sqrt( (location.getBlockX() - pos.getBlockX()) * (location.getBlockX() - pos.getBlockX()) + (location.getBlockY() - pos.getBlockY()) * (location.getBlockY() - pos.getBlockY()) + (location.getBlockZ() - pos.getBlockZ()) * (location.getBlockZ() - pos.getBlockZ())); if (its == 0) { its = (double) 1; } v.setX((location.getBlockX() - pos.getBlockX()) / its); v.setY((location.getBlockY() - pos.getBlockY()) / its); v.setZ((location.getBlockZ() - pos.getBlockZ()) / its); e.setVelocity(v.multiply(2)); } } for (Guardian g : Storage.guardianMove.keySet()) { if (g.getLocation().distance(Storage.guardianMove.get(g).getLocation()) > 2 && g.getTicksLived() < 160) { g.setVelocity( Storage.guardianMove .get(g) .getLocation() .toVector() .subtract(g.getLocation().toVector())); } else { Storage.guardianMove.remove(g); } } for (Player player : Bukkit.getOnlinePlayers()) { Config config = Config.get(player.getWorld()); for (ItemStack stk : player.getInventory().getArmorContents()) { HashMap<CustomEnchantment, Integer> map = config.getEnchants(stk); for (CustomEnchantment ench : map.keySet()) { ench.onFastScan(player, map.get(ench)); } } HashMap<CustomEnchantment, Integer> map = config.getEnchants(player.getItemInHand()); for (CustomEnchantment ench : map.keySet()) { ench.onFastScanHand(player, map.get(ench)); } } HashSet<Player> toDelete = new HashSet<>(); for (Player player : Storage.hungerPlayers.keySet()) { if (Storage.hungerPlayers.get(player) < 1) { toDelete.add(player); } else { Storage.hungerPlayers.put(player, Storage.hungerPlayers.get(player) - 1); } } for (Player p : toDelete) { Storage.hungerPlayers.remove(p); } toDelete.clear(); for (Player player : Storage.moverBlockDecay.keySet()) { Storage.moverBlockDecay.put(player, Storage.moverBlockDecay.get(player) + 1); if (Storage.moverBlockDecay.get(player) > 5) { Storage.moverBlocks.remove(player); toDelete.add(player); } } for (Player p : toDelete) { Storage.moverBlockDecay.remove(p); } }
/** * Abstract class: it provides all methods and attributes for each instruction type * * @author Trubia Massimo, Russo Daniele */ public abstract class Instruction { protected BitSet32 repr; protected List<Integer> params; protected int paramCount; protected String syntax; protected String name; protected String comment; protected static Memory memory = Memory.getInstance(); protected Register[] TR; // is not static because each instruction has got its own registers protected String fullname; protected static boolean enableForwarding = (Boolean) Config.get("forwarding"); protected String label; protected static final Logger logger = Logger.getLogger(Instruction.class.getName()); /** Creates a new instance of Instruction */ public Instruction() { params = new LinkedList<Integer>(); TR = new Register[5]; repr = new BitSet32(); repr.reset(false); syntax = new String(); // initialization of temporary registers for (int i = 0; i < TR.length; i++) { TR[i] = new Register(); } } /** <pre> * Returns a BitSet32 holding the binary representation of the Instruction * @return the Bitset32 representing the instruction * </pre> * */ public BitSet32 getRepr() { return repr; } /** * Creates a new instance of an Instruction's subclass * * @param name string value to pass in order to instanciate an instruction object * @return the instruction object */ public static Instruction buildInstruction(String name) { Instruction returnedObject = null; for (InstructionEnumerator op : InstructionEnumerator.values()) { if (op.name().equals(name) == true) { returnedObject = op.getObject(); return returnedObject; } } return returnedObject; } public enum InstructionEnumerator { // ALU R-Type 32-bits ADD { Instruction getObject() { ADD newObject = new ADD(); return newObject; } }, ADDU { Instruction getObject() { ADDU newObject = new ADDU(); return newObject; } }, SUB { Instruction getObject() { SUB newObject = new SUB(); return newObject; } }, SUBU { Instruction getObject() { SUBU newObject = new SUBU(); return newObject; } }, DIV { Instruction getObject() { DIV newObject = new DIV(); return newObject; } }, DIVU { Instruction getObject() { DIVU newObject = new DIVU(); return newObject; } }, MULT { Instruction getObject() { MULT newObject = new MULT(); return newObject; } }, MULTU { Instruction getObject() { MULTU newObject = new MULTU(); return newObject; } }, // ALU I-Type 32-bits ADDI { Instruction getObject() { ADDI newObject = new ADDI(); return newObject; } }, ADDIU { Instruction getObject() { ADDIU newObject = new ADDIU(); return newObject; } }, // ALU Shifting 32-bits SLL { Instruction getObject() { SLL newObject = new SLL(); return newObject; } }, SLLV { Instruction getObject() { SLLV newObject = new SLLV(); return newObject; } }, SRA { Instruction getObject() { SRA newObject = new SRA(); return newObject; } }, SRAV { Instruction getObject() { SRAV newObject = new SRAV(); return newObject; } }, SRL { Instruction getObject() { SRL newObject = new SRL(); return newObject; } }, SRLV { Instruction getObject() { SRLV newObject = new SRLV(); return newObject; } }, // ALU R-Type AND { Instruction getObject() { AND newObject = new AND(); return newObject; } }, DADD { Instruction getObject() { DADD newObject = new DADD(); return newObject; } }, DADDU { Instruction getObject() { DADDU newObject = new DADDU(); return newObject; } }, DSUB { Instruction getObject() { DSUB newObject = new DSUB(); return newObject; } }, DSUBU { Instruction getObject() { DSUBU newObject = new DSUBU(); return newObject; } }, OR { Instruction getObject() { OR newObject = new OR(); return newObject; } }, SLT { Instruction getObject() { SLT newObject = new SLT(); return newObject; } }, SLTU { Instruction getObject() { SLTU newObject = new SLTU(); return newObject; } }, XOR { Instruction getObject() { XOR newObject = new XOR(); return newObject; } }, MOVN { Instruction getObject() { MOVN newObject = new MOVN(); return newObject; } }, MOVZ { Instruction getObject() { MOVZ newObject = new MOVZ(); return newObject; } }, DDIV { Instruction getObject() { DDIV newObject = new DDIV(); return newObject; } }, DDIVU { Instruction getObject() { DDIVU newObject = new DDIVU(); return newObject; } }, DMULT { Instruction getObject() { DMULT newObject = new DMULT(); return newObject; } }, DMULTU { Instruction getObject() { DMULTU newObject = new DMULTU(); return newObject; } }, MFLO { Instruction getObject() { MFLO newObject = new MFLO(); return newObject; } }, MFHI { Instruction getObject() { MFHI newObject = new MFHI(); return newObject; } }, // ALU I-Type ANDI { Instruction getObject() { ANDI newObject = new ANDI(); return newObject; } }, DADDI { Instruction getObject() { DADDI newObject = new DADDI(); return newObject; } }, DADDUI { Instruction getObject() { DADDUI newObject = new DADDUI(); return newObject; } }, DADDIU { Instruction getObject() { DADDIU newObject = new DADDIU(); return newObject; } }, LUI { Instruction getObject() { LUI newObject = new LUI(); return newObject; } }, ORI { Instruction getObject() { ORI newObject = new ORI(); return newObject; } }, SLTI { Instruction getObject() { SLTI newObject = new SLTI(); return newObject; } }, SLTIU { Instruction getObject() { SLTIU newObject = new SLTIU(); return newObject; } }, XORI { Instruction getObject() { XORI newObject = new XORI(); return newObject; } }, // ALU Shifting DSLL { Instruction getObject() { DSLL newObject = new DSLL(); return newObject; } }, DSLLV { Instruction getObject() { DSLLV newObject = new DSLLV(); return newObject; } }, DSRA { Instruction getObject() { DSRA newObject = new DSRA(); return newObject; } }, DSRAV { Instruction getObject() { DSRAV newObject = new DSRAV(); return newObject; } }, DSRL { Instruction getObject() { DSRL newObject = new DSRL(); return newObject; } }, DSRLV { Instruction getObject() { DSRLV newObject = new DSRLV(); return newObject; } }, // Load-Signed LB { Instruction getObject() { LB newObject = new LB(); return newObject; } }, LH { Instruction getObject() { LH newObject = new LH(); return newObject; } }, LW { Instruction getObject() { LW newObject = new LW(); return newObject; } }, LD { Instruction getObject() { LD newObject = new LD(); return newObject; } }, // Load-Unsigned LBU { Instruction getObject() { LBU newObject = new LBU(); return newObject; } }, LHU { Instruction getObject() { LHU newObject = new LHU(); return newObject; } }, LWU { Instruction getObject() { LWU newObject = new LWU(); return newObject; } }, // Store SB { Instruction getObject() { SB newObject = new SB(); return newObject; } }, SH { Instruction getObject() { SH newObject = new SH(); return newObject; } }, SW { Instruction getObject() { SW newObject = new SW(); return newObject; } }, SD { Instruction getObject() { SD newObject = new SD(); return newObject; } }, // Unconditional branches J { Instruction getObject() { J newObject = new J(); return newObject; } }, JAL { Instruction getObject() { JAL newObject = new JAL(); return newObject; } }, JALR { Instruction getObject() { JALR newObject = new JALR(); return newObject; } }, JR { Instruction getObject() { JR newObject = new JR(); return newObject; } }, BNE { Instruction getObject() { BNE newObject = new BNE(); return newObject; } }, B { Instruction getObject() { B newObject = new B(); return newObject; } }, // Conditional branches BEQ { Instruction getObject() { BEQ newObject = new BEQ(); return newObject; } }, BNEZ { Instruction getObject() { BNEZ newObject = new BNEZ(); return newObject; } }, BEQZ { Instruction getObject() { BEQZ newObject = new BEQZ(); return newObject; } }, BGEZ { Instruction getObject() { BGEZ newObject = new BGEZ(); return newObject; } }, // Special instructions NOP { Instruction getObject() { NOP newObject = new NOP(); return newObject; } }, BUBBLE { Instruction getObject() { BUBBLE newObject = new BUBBLE(); return newObject; } }, HALT { Instruction getObject() { HALT newObject = new HALT(); return newObject; } }, TRAP { Instruction getObject() { TRAP newObject = new TRAP(); return newObject; } }, SYSCALL { Instruction getObject() { SYSCALL newObject = new SYSCALL(); return newObject; } }, BREAK { Instruction getObject() { BREAK newObject = new BREAK(); return newObject; } }; abstract Instruction getObject(); } /** * * * <pre> * Instruction fetch. * Now it is used in order to generate the Dinero trace-file * </pre> */ public void IF() throws BreakException {} /** * * * <pre> * Decode stage of the Pipeline * In this method all instructions that modify GPRs lock the involved register * </pre> */ public abstract void ID() throws RAWException, IrregularWriteOperationException, IrregularStringOfBitsException, TwosComplementSumException, HaltException, JumpException, BreakException; /** * * * <pre> * Execute stage of the Pipeline * In this stage all Alu Instructions perform their computations and save results in temporary registers * </pre> */ public abstract void EX() throws HaltException, IrregularStringOfBitsException, IntegerOverflowException, TwosComplementSumException, IrregularWriteOperationException, IrregularWriteOperationException, DivisionByZeroException; /** * * * <pre> * Memory stage of the Pipeline * In this stage all Load and Store instructions access memory for getting or putting data * </pre> */ public abstract void MEM() throws HaltException, IrregularStringOfBitsException, MemoryElementNotFoundException, AddressErrorException, IrregularWriteOperationException; /** * * * <pre> * Write Back stage of the Pipeline * In this stage all instructions that modify registers write and unlock them * </pre> */ public abstract void WB() throws HaltException, IrregularStringOfBitsException; /** * * * <pre> * Builds the binary encoding of instructions. * Every instruction is represented by a 32 bit field * </pre> */ public abstract void pack() throws IrregularStringOfBitsException; /** * Gets the number of params to pass at the instruction object * * @return number of params */ public int getNParams() { return paramCount; }; /** * * * <pre> * Gets the syntax of any instruction as string composed by the following simbols * %R Register * %I Immediate * %U Unsigned Immediate * %L Memory Label * %E Program Label used for Jump Instructions * %B Program Label used for Brench Instructions * * examples: * Instruction -----> Syntax * DADD R1,R2,R3 | %R,%R,%R * DADDI R1,R2,-3 | %R,%R,%I * DSLL R1,R2,15 | %R,%R,%U * LD R1,vet(R0) | %R,%L(%R) * J loop | %E * BNE R1,R2,loop | %R,%R,%B * </pre> */ public String getSyntax() { return syntax; } /** * Returns the name of the instruction as string. * * @return the instruction name(e.g. "DADD") */ public String getName() { return name; } /** * * * <pre> * Returns a list with the instruction parameters * e.g. DADD R1,R2,R3 --> params= { 1, 2, 3} * LD R1, var(R0)--> params= { 1, address memory corresponding with var, 0} * </pre> * * @return the list of parameters */ public List<Integer> getParams() { return params; } /** *<pre> * Sets the instruction with a list of parameters * Passed list | Instruction to set * e.g. list= { 1, 2, 3} | DADD R1,R2,R3 * list= { 1, address memory corresponding with var, 0} | LD R1, var(R0) *@param params The list of parameters **/ public void setParams(List<Integer> params) { this.params = params; } /** * Sets the full name of the instruction as string * * @param value full name of the instruction (e.g. "DADD R1,R2,R3") */ public void setFullName(String value) { fullname = value; } /** * Sets the comment of the instruction as string. The comment is the text after every semicolon in * the file .s * * @params value the full name of the instruction (e.g. "DADD R1,R2,R3") */ public void setComment(String comment) { this.comment = comment; } /** * Gets the comment of the instruction as string.The comment is the text after every semicolon in * the file .s * * @return the comment */ public String getComment() { return comment; } /** * Gets the comment of the instruction as string. The comment is the text after every semicolon in * the file .s * * @return the full name of the instruction (e.g. "DADD R1,R2,R3") */ public String getFullName() { return fullname; } public String toString() { return fullname; } /** * Enable forwarding mode * * @param value This variable enable the forwarding modality if it is true */ public static void setEnableForwarding(boolean value) { enableForwarding = value; } /** * Gets the state of EnableForwarding. This modality anticipates writing on registers at EX stage * for Alu instructions or at MEM stage for Load-Store instructions * * @return The forwarding state */ public static boolean getEnableForwarding() { return enableForwarding; } /** * * * <pre> * Gets the label of the instruction. Labels may be assigned to instructions * when they are inserted in the symbol table * </pre> * * @return label of the instruction */ public String getLabel() { return label; } /** * * * <pre> * Sets the label of the instruction. Labels may be assigned to instructions * when they are inserted in the symbol table * </pre> * * @value label of the instruction */ public void setLabel(String value) { label = value; } }
/** * Name of the regions hit by a marker * * @param marker * @param showGeneDetails * @param compareTemplate * @param id : Only use genes or transcripts matching this ID * @return */ public Set<String> regions( Marker marker, boolean showGeneDetails, boolean compareTemplate, String id) { if (Config.get().isErrorOnMissingChromo() && isChromosomeMissing(marker)) throw new RuntimeEOFException("Chromosome missing for marker: " + marker); boolean hitChromo = false; HashSet<String> hits = new HashSet<String>(); Markers intersects = query(marker); if (intersects.size() > 0) { for (Marker markerInt : intersects) { if (markerInt instanceof Chromosome) { hitChromo = true; // OK (we have to hit a chromosome, otherwise it's an error hits.add(markerInt.getClass().getSimpleName()); // Add marker name to the list } else if (markerInt instanceof Gene) { // Analyze Genes Gene gene = (Gene) markerInt; regionsAddHit(hits, gene, marker, showGeneDetails, compareTemplate); // For all transcripts... for (Transcript tr : gene) { if ((id == null) || gene.getId().equals(id) || tr.getId().equals(id)) { // Mathes ID? (...or no ID to match) // Does it intersect this transcript? if (tr.intersects(marker)) { regionsAddHit(hits, tr, marker, showGeneDetails, compareTemplate); // Does it intersect a UTR? for (Utr utr : tr.getUtrs()) if (utr.intersects(marker)) regionsAddHit(hits, utr, marker, showGeneDetails, compareTemplate); // Does it intersect an exon? for (Exon ex : tr) if (ex.intersects(marker)) regionsAddHit(hits, ex, marker, showGeneDetails, compareTemplate); // Does it intersect an intron? for (Intron intron : tr.introns()) if (intron.intersects(marker)) regionsAddHit(hits, intron, marker, showGeneDetails, compareTemplate); } } } } else { // No ID to match? if (id == null) regionsAddHit(hits, markerInt, marker, showGeneDetails, compareTemplate); else { // Is ID from transcript? Transcript tr = (Transcript) markerInt.findParent(Transcript.class); if ((tr != null) && (tr.getId().equals(id))) { regionsAddHit( hits, markerInt, marker, showGeneDetails, compareTemplate); // Transcript ID matches => count } else { // Is ID from gene? Gene gene = (Gene) markerInt.findParent(Gene.class); if ((gene != null) && (gene.getId().equals(id))) regionsAddHit( hits, markerInt, marker, showGeneDetails, compareTemplate); // Gene ID matches => count } } } } } if (!hitChromo) throw new RuntimeException("ERROR: Out of chromosome range. " + marker); return hits; }
/** Test a null resource. */ public void testNullResource() { assertTrue(config.get("null resource") == null); }
/** * Runs a match; configures the controller and list of proxies, and starts running the game in a * separate thread. */ private void runMatch(final Match match, final ProxyWriter proxyWriter) throws Exception { if (Mode.HEADLESS.equals(mode) || Mode.SCRIMMAGE.equals(mode) || Mode.TOURNAMENT.equals(mode)) { this.state = State.RUNNING; this.runUntil = Integer.MAX_VALUE; } // Poll for RUNNING, if mode == Mode.LOCAL while (!State.RUNNING.equals(state)) { try { Thread.sleep(250); } catch (InterruptedException e) { } } long startTime = System.currentTimeMillis(); say("-------------------- Match Starting --------------------"); say(match.toString()); // Compute the header and send it to all listeners. MatchHeader header = match.getHeader(); proxyWriter.enqueue(header); ExtensibleMetadata exHeader = match.getHeaderMetadata(); proxyWriter.enqueue(exHeader); this.state = State.RUNNING; int count = 0; final String throttle = options.get("bc.server.throttle"); final int throttleCount = options.getInt("bc.server.throttle-count"); final boolean doYield = "yield".equals(throttle); final boolean doSleep = "sleep".equals(throttle); // If there are more rounds to be run, run them and // and send the round (and optionally stats) bytes to // recipients. while (match.hasMoreRounds()) { // If not paused/stopped: switch (this.state) { case RUNNING: if (match.getRoundNumber() == runUntil) { Thread.sleep(25); break; } final RoundDelta round = match.getRound(); if (round == null) break; if (GameState.BREAKPOINT.equals(match.getGameState())) { this.state = State.PAUSED; proxyWriter.enqueue(new PauseEvent()); } else if (GameState.DONE.equals(match.getGameState())) { this.state = State.FINISHED; } proxyWriter.enqueue(round); if (count++ == throttleCount) { if (doYield) Thread.yield(); else if (doSleep) Thread.sleep(1); count = 0; } break; case PAUSED: Thread.sleep(250); break; } } // Compute footer data. GameStats gameStats = match.getGameStats(); MatchFooter footer = match.getFooter(); proxyWriter.enqueue(gameStats); proxyWriter.enqueue(footer); say(match.getWinnerString()); say("-------------------- Match Finished --------------------"); double timeDiff = (System.currentTimeMillis() - startTime) / 1000.0; debug(String.format("match completed in %.4g seconds", timeDiff)); this.state = State.FINISHED; }
@Test public void shouldApplyDefaults() { Config config = new Config(new HashMap<String, String>(), MySettingsWithDefaults.class); assertThat(config.get(MySettingsWithDefaults.hello), is("Hello, World!")); }
/** * Figure out what kind of static adapter type was specified. By default it's a 10genDEFAULT app */ protected void _setStaticAdapterType() { /* * app configuration steps could have set this already. If so, don't bother doing anything */ if (_staticAdapterType != AdapterType.UNSET) { log("Static adapter type has already been directly set to " + _staticAdapterType); return; } /* * check to see if overridden in 10gen.properties */ String override = Config.get().getProperty(INIT_ADAPTER_TYPE); if (override != null) { AdapterType t = getAdapterTypeFromString(override); if (t == null) { log( "Static adapter type specified as override [" + override + "] unknown - will use _init file specified or default"); } else { log("Static adapter type overridden by 10gen.properties or env. Value : " + override); _staticAdapterType = t; return; } } /* * if not, use the one from _init file if specified */ _staticAdapterType = AdapterType.DIRECT_10GEN; Object o = getFromInitScope(INIT_ADAPTER_TYPE); if (o == null) { log("Static adapter type not specified in _init file - using default value of DIRECT_10GEN"); return; } if (!(o instanceof JSString)) { log("Static adapter type from _init file not a string - using default value of DIRECT_10GEN"); return; } _staticAdapterType = getAdapterTypeFromString(o.toString()); if (_staticAdapterType == null) { log( "Static adapter type from _init file [" + o.toString() + "] unknown - using default value of DIRECT_10GEN"); _staticAdapterType = AdapterType.DIRECT_10GEN; return; } log("Static adapter type specified in _init file = " + _staticAdapterType); return; }
/** * Establishes part of speech information for cas object. * * @param jcas */ private void establishPartOfSpeechInformation(JCas jcas) { logger.log(Level.FINEST, "Establishing part of speech information..."); PartOfSpeechTagger partOfSpeechTagger = null; Properties settings = new Properties(); switch (language) { case ARABIC: partOfSpeechTagger = new StanfordPOSTaggerWrapper(); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_POS, true); settings.put( PartOfSpeechTagger.STANFORDPOSTAGGER_MODEL_PATH, Config.get(Config.STANFORDPOSTAGGER_MODEL_PATH)); settings.put( PartOfSpeechTagger.STANFORDPOSTAGGER_CONFIG_PATH, Config.get(Config.STANFORDPOSTAGGER_CONFIG_PATH)); break; case VIETNAMESE: partOfSpeechTagger = new JVnTextProWrapper(); settings.put(PartOfSpeechTagger.JVNTEXTPRO_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.JVNTEXTPRO_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.JVNTEXTPRO_ANNOTATE_POS, true); settings.put( PartOfSpeechTagger.JVNTEXTPRO_WORD_MODEL_PATH, Config.get(Config.JVNTEXTPRO_WORD_MODEL_PATH)); settings.put( PartOfSpeechTagger.JVNTEXTPRO_SENT_MODEL_PATH, Config.get(Config.JVNTEXTPRO_SENT_MODEL_PATH)); settings.put( PartOfSpeechTagger.JVNTEXTPRO_POS_MODEL_PATH, Config.get(Config.JVNTEXTPRO_POS_MODEL_PATH)); break; case CROATIAN: partOfSpeechTagger = new HunPosTaggerWrapper(); settings.put(PartOfSpeechTagger.HUNPOS_LANGUAGE, language); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_POS, true); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.HUNPOS_MODEL_PATH, Config.get(Config.HUNPOS_MODEL_PATH)); break; default: if (POSTagger.STANFORDPOSTAGGER.equals(posTagger)) { partOfSpeechTagger = new StanfordPOSTaggerWrapper(); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.STANFORDPOSTAGGER_ANNOTATE_POS, true); settings.put( PartOfSpeechTagger.STANFORDPOSTAGGER_MODEL_PATH, Config.get(Config.STANFORDPOSTAGGER_MODEL_PATH)); settings.put( PartOfSpeechTagger.STANFORDPOSTAGGER_CONFIG_PATH, Config.get(Config.STANFORDPOSTAGGER_CONFIG_PATH)); } else if (POSTagger.TREETAGGER.equals(posTagger)) { partOfSpeechTagger = new TreeTaggerWrapper(); settings.put(PartOfSpeechTagger.TREETAGGER_LANGUAGE, language); settings.put(PartOfSpeechTagger.TREETAGGER_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.TREETAGGER_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.TREETAGGER_ANNOTATE_POS, true); settings.put( PartOfSpeechTagger.TREETAGGER_IMPROVE_GERMAN_SENTENCES, (language == Language.GERMAN)); settings.put( PartOfSpeechTagger.TREETAGGER_CHINESE_TOKENIZER_PATH, Config.get(Config.CHINESE_TOKENIZER_PATH)); } else if (POSTagger.HUNPOS.equals(posTagger)) { partOfSpeechTagger = new HunPosTaggerWrapper(); settings.put(PartOfSpeechTagger.HUNPOS_LANGUAGE, language); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_TOKENS, true); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_POS, true); settings.put(PartOfSpeechTagger.HUNPOS_ANNOTATE_SENTENCES, true); settings.put(PartOfSpeechTagger.HUNPOS_MODEL_PATH, Config.get(Config.HUNPOS_MODEL_PATH)); } else if (POSTagger.NO.equals(posTagger)) { partOfSpeechTagger = new AllLanguagesTokenizerWrapper(); } else { logger.log(Level.FINEST, "Sorry, but you can't use that tagger."); } } partOfSpeechTagger.initialize(settings); partOfSpeechTagger.process(jcas); partOfSpeechTagger.reset(); logger.log(Level.FINEST, "Part of speech information established"); }
/** Test the default config resource. */ public void todoTestDefault() { config.loadResource(RESOURCE); assertEquals("sa", config.get("mangotiger.db.user")); assertEquals("x", config.get("x", "x")); }