List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:pcgen.core.SettingsHandler.java
public static int getPCGenOption(final String optionName, final int defaultValue) { return Integer.decode(getPCGenOption(optionName, String.valueOf(defaultValue))).intValue(); }
From source file:l2next.gameserver.model.Player.java
/** * Retrieve a L2Player from the characters table of the database and add it in _allObjects of the L2World * * @return The L2Player loaded from the database *//*from w w w . j a va 2s . c om*/ public static Player restore(final int objectId) { Player player = null; Connection con = null; Statement statement = null; Statement statement2 = null; PreparedStatement statement3 = null; ResultSet rset = null; ResultSet rset2 = null; ResultSet rset3 = null; try { // Retrieve the L2Player from the characters table of the database con = DatabaseFactory.getInstance().getConnection(); statement = con.createStatement(); statement2 = con.createStatement(); rset = statement.executeQuery("SELECT * FROM `characters` WHERE `obj_Id`=" + objectId + " LIMIT 1"); rset2 = statement2.executeQuery("SELECT `class_id` FROM `character_subclasses` WHERE `char_obj_id`=" + objectId + " AND `type`=" + SubClassType.BASE_CLASS.ordinal() + " LIMIT 1"); if (rset.next() && rset2.next()) { final ClassId classId = ClassId.VALUES[rset2.getInt("class_id")]; final int raceId = rset.getInt("race"); final PlayerTemplate template = PlayerTemplateHolder.getInstance() .getPlayerTemplate(Race.values()[raceId], classId, Sex.VALUES[rset.getInt("sex")]); player = new Player(objectId, template); player.loadVariables(); player.loadInstanceReuses(); player.setPremiumItemList(CharactersPremiumItemsDAO.getInstance().loadPremiumItemList(objectId)); player.bookmarks.setCapacity(rset.getInt("bookmarks")); player.bookmarks.restore(); player._friendList.restore(); player._postFriends = CharacterPostFriendDAO.getInstance().select(player); CharacterGroupReuseDAO.getInstance().select(player); player._login = rset.getString("account_name"); player.setName(rset.getString("char_name")); player.setFace(rset.getInt("face")); player.setHairStyle(rset.getInt("hairStyle")); player.setHairColor(rset.getInt("hairColor")); player.setHeading(0); player.setKarma(rset.getInt("karma")); player.setPvpKills(rset.getInt("pvpkills")); player.setPkKills(rset.getInt("pkkills")); player.setLeaveClanTime(rset.getLong("leaveclan") * 1000L); if (player.getLeaveClanTime() > 0 && player.canJoinClan()) { player.setLeaveClanTime(0); } player.setDeleteClanTime(rset.getLong("deleteclan") * 1000L); if (player.getDeleteClanTime() > 0 && player.canCreateClan()) { player.setDeleteClanTime(0); } player.setNoChannel(rset.getLong("nochannel") * 1000L); if (player.getNoChannel() > 0 && player.getNoChannelRemained() < 0) { player.setNoChannel(0); } player.setOnlineTime(rset.getLong("onlinetime") * 1000L); final int clanId = rset.getInt("clanid"); if (clanId > 0) { player.setClan(ClanTable.getInstance().getClan(clanId)); player.setPledgeType(rset.getInt("pledge_type")); player.setPowerGrade(rset.getInt("pledge_rank")); player.setLvlJoinedAcademy(rset.getInt("lvl_joined_academy")); player.setApprentice(rset.getInt("apprentice")); } player.setCreateTime(rset.getLong("createtime") * 1000L); player.setDeleteTimer(rset.getInt("deletetime")); player.setTitle(rset.getString("title")); if (player.getVar("titlecolor") != null) { player.setTitleColor(Integer.decode("0x" + player.getVar("titlecolor"))); } if (player.getVar("namecolor") == null) { if (player.isGM()) { player.setNameColor(Config.GM_NAME_COLOUR); } else if (player.getClan() != null && player.getClan().getLeaderId() == player.getObjectId()) { player.setNameColor(Config.CLANLEADER_NAME_COLOUR); } else { player.setNameColor(Config.NORMAL_NAME_COLOUR); } } else { player.setNameColor(Integer.decode("0x" + player.getVar("namecolor"))); } if (Config.AUTO_LOOT_INDIVIDUAL) { player._autoLoot = player.getVarB("AutoLoot", Config.AUTO_LOOT); player.AutoLootHerbs = player.getVarB("AutoLootHerbs", Config.AUTO_LOOT_HERBS); } player.setUptime(System.currentTimeMillis()); player.setLastAccess(rset.getLong("lastAccess")); player.setRecomHave(rset.getInt("rec_have")); player.setRecomLeft(rset.getInt("rec_left")); player.setRecomBonusTime(rset.getInt("rec_bonus_time")); if (player.getVar("recLeftToday") != null) { player.setRecomLeftToday(Integer.parseInt(player.getVar("recLeftToday"))); } else { player.setRecomLeftToday(0); } player.setKeyBindings(rset.getBytes("key_bindings")); player.setPcBangPoints(rset.getInt("pcBangPoints")); player.setFame(rset.getInt("fame"), null); CharacterRecipebookDAO.getInstance().restoreRecipeBook(player); if (Config.ENABLE_OLYMPIAD) { player.setHero(Hero.getInstance().isHero(player.getObjectId())); player.setNoble(Olympiad.isNoble(player.getObjectId())); } player.updatePledgeClass(); int reflection = 0; if (player.getVar("jailed") != null && System.currentTimeMillis() / 1000 < Integer.parseInt(player.getVar("jailed")) + 60) { player.setXYZ(-114648, -249384, -2984); /* * NOTUSED*String[] re = player.getVar("jailedFrom").split(";"); Location loc = new * Location(Integer.parseInt(re[0]), Integer.parseInt(re[1]), Integer.parseInt(re[2])); */ player.sitDown(null); player.block(); player._unjailTask = ThreadPoolManager.getInstance().schedule(new UnJailTask(player), Integer.parseInt(player.getVar("jailed")) * 1000L); } else { player.setXYZ(rset.getInt("x"), rset.getInt("y"), rset.getInt("z")); // ? ? ?, // ? (). String jumpSafeLoc = player.getVar("@safe_jump_loc"); if (jumpSafeLoc != null) { player.setLoc(Location.parseLoc(jumpSafeLoc)); player.unsetVar("@safe_jump_loc"); } String ref = player.getVar("reflection"); if (ref != null) { reflection = Integer.parseInt(ref); if (reflection > 0) // , , // { String back = player.getVar("backCoords"); if (back != null) { player.setLoc(Location.parseLoc(back)); player.unsetVar("backCoords"); } reflection = 0; } } } player.setReflection(reflection); EventHolder.getInstance().findEvent(player); // TODO [G1ta0] ? Quest.restoreQuestStates(player); player.getInventory().restore(); //Restore mentoring system player.getMentorSystem().restore(); player.setActiveSubClass(player.getActiveClassId(), false); try { String var = player.getVar("ExpandInventory"); if (var != null) { player.setExpandInventory(Integer.parseInt(var)); } } catch (Exception e) { _log.error("", e); } try { String var = player.getVar("ExpandWarehouse"); if (var != null) { player.setExpandWarehouse(Integer.parseInt(var)); } } catch (Exception e) { _log.error("", e); } try { String var = player.getVar(NO_ANIMATION_OF_CAST_VAR); if (var != null) { player.setNotShowBuffAnim(Boolean.parseBoolean(var)); } } catch (Exception e) { _log.error("", e); } try { String var = player.getVar(NO_TRADERS_VAR); if (var != null) { player.setNotShowTraders(Boolean.parseBoolean(var)); } } catch (Exception e) { _log.error("", e); } try { String var = player.getVar("pet"); if (var != null) { player.setPetControlItem(Integer.parseInt(var)); } } catch (Exception e) { _log.error("", e); } statement3 = con.prepareStatement( "SELECT obj_Id, char_name FROM characters WHERE account_name=? AND obj_Id!=?"); statement3.setString(1, player._login); statement3.setInt(2, objectId); rset3 = statement3.executeQuery(); while (rset3.next()) { final Integer charId = rset3.getInt("obj_Id"); final String charName = rset3.getString("char_name"); player._chars.put(charId, charName); } DbUtils.close(statement3, rset3); // if(!player.isGM()) { GArray<Zone> zones = new GArray<Zone>(); World.getZones(zones, player.getLoc(), player.getReflection()); if (!zones.isEmpty()) { for (Zone zone : zones) { if (zone.getType() == ZoneType.no_restart) { if (System.currentTimeMillis() / 1000L - player.getLastAccess() > zone .getRestartTime()) { player.sendMessage(new CustomMessage( "l2next.gameserver.clientpackets.EnterWorld.TeleportedReasonNoRestart", player)); player.setLoc(TeleportUtils.getRestartLocation(player, RestartType.TO_VILLAGE)); } } else if (zone.getType() == ZoneType.SIEGE) { SiegeEvent<?, ?> siegeEvent = player.getEvent(SiegeEvent.class); if (siegeEvent != null) { player.setLoc(siegeEvent.getEnterLoc(player)); } else { Residence r = ResidenceHolder.getInstance() .getResidence(zone.getParams().getInteger("residence")); player.setLoc(r.getNotOwnerRestartPoint(player)); } } } } zones.clear(); if (DimensionalRiftManager.getInstance().checkIfInRiftZone(player.getLoc(), false)) { player.setLoc(DimensionalRiftManager.getInstance().getRoom(0, 0).getTeleportCoords()); } } player.restoreBlockList(); player._macroses.restore(); // FIXME [VISTALL] ? player.refreshExpertisePenalty(); player.refreshOverloaded(); player.getWarehouse().restore(); player.getFreight().restore(); player.restoreTradeList(); if (player.getVar("storemode") != null) { player.setPrivateStoreType(Integer.parseInt(player.getVar("storemode"))); player.setSitting(true); } player.updateKetraVarka(); player.updateRam(); player.checkRecom(); if (Config.ALT_VITALITY_ENABLED) { player._vitality.restore(); } //player.getSummonList().restore(); } } catch (final Exception e) { _log.error("Could not restore char data!", e); } finally { DbUtils.closeQuietly(statement2, rset2); DbUtils.closeQuietly(statement3, rset3); DbUtils.closeQuietly(con, statement, rset); } return player; }
From source file:net.sf.jabref.importer.HTMLConverter.java
public HTMLConverter() { super();/* ww w . j a v a 2 s .c o m*/ for (String[] aConversionList : conversionList) { if (!(aConversionList[2].isEmpty())) { if (!(aConversionList[1].isEmpty())) { escapedSymbols.put("&" + aConversionList[1] + ";", aConversionList[2]); } if (!(aConversionList[0].isEmpty())) { numSymbols.put(Integer.decode(aConversionList[0]), aConversionList[2]); if (Integer.decode(aConversionList[0]) > 128) { Character c = (char) Integer.decode(aConversionList[0]).intValue(); unicodeSymbols.put(c, aConversionList[2]); // System.err.println(Integer.decode(conversionList[i][0]).toString() + ": " + c.toString() + ": "+ conversionList[i][2]); } } } } for (String[] anAccentList : accentList) { escapedAccents.put(Integer.decode(anAccentList[0]), anAccentList[1]); } }
From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java
private TalktimeHbm createTalktimeHbm(Element ael, boolean useNewIds, Hashtable<Integer, Long> mappingTalktime2) { TalktimeHbm talktime = TalktimeHbm.Factory.newInstance(); try {/* w w w.jav a 2 s. co m*/ talktime.setTalkTimes( XercesHelper.nodeList2string(XercesHelper.findNode(ael, "./talkTimes").getChildNodes())); } catch (Exception exe) { } talktime.setTalkTimeType(getNVal(ael, "talkTimeType")); if (!useNewIds) { talktime.setTalkTimeId(Integer.decode(ael.getAttribute("id")).longValue()); } talktime = getTalktimeHbmDao().create(talktime); return talktime; }
From source file:au.org.emii.portal.composer.MapComposer.java
public void mapMultiQueryLayers(boolean[] geospatialKosher, String baseBiocacheUrl, String baseWSBiocacheUrl, boolean supportDynamic) { Map<String, String> userParams = getQueryParameterMap( Executions.getCurrent().getDesktop().getQueryString()); if (userParams != null) { for (Entry<String, String> entry : userParams.entrySet()) { String key = entry.getKey(); if (layerNameParamPattern.matcher(key).find()) { //we have a layer, retrieve the other bits String layerName = entry.getValue(); String query = userParams.get(key + ".q"); String style = userParams.get(key + ".s"); LOGGER.debug(String.format("Add layer: '%s', query: '%s', style: '%s', key: '%s'", layerName, query, style, key)); //format the query if (query != null && query.contains(",")) { String[] queryComponents = query.split(","); query = StringUtils.join(queryComponents, " OR "); }//from ww w. ja v a 2s. c om if (query != null && style != null && layerName != null) { BiocacheQuery q = new BiocacheQuery(null, null, query, null, true, geospatialKosher, baseBiocacheUrl, baseWSBiocacheUrl, supportDynamic); mapSpecies(q, layerName, StringConstants.SPECIES, q.getOccurrenceCount(), LayerUtilitiesImpl.SPECIES, null, 0, 4, 0.8f, Integer.decode(style), false); } } } } }
From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java
private DepartmentHbm createDepartmentHbm(Element ael, boolean useNewIds, Hashtable<Integer, Long> mappingDepartments2, Hashtable<Integer, Long> mappingPersons2, Hashtable<Integer, Long> mappingAddresses2, Hashtable<Integer, Long> mappingTalktime2) { DepartmentHbm department = DepartmentHbm.Factory.newInstance(); if (!useNewIds) { department.setDepartmentId(Integer.decode(getNVal(ael, "id")).longValue()); }// w w w . j a v a 2 s . c om department.setName(ael.getAttribute("name")); department = getDepartmentHbmDao().create(department); return department; }
From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java
private PersonHbm createPersonHbm(UnitHbm unit, Element ael, boolean useNewIds, Hashtable<Integer, Long> mappingPersons2, Hashtable<Integer, Long> mappingAddresses2, Hashtable<Integer, Long> mappingTalktime2) throws Exception { PersonHbm person = PersonHbm.Factory.newInstance(); try {//from w w w. j ava 2 s . c om person.setImageId(Integer.decode(ael.getAttribute("imageid"))); } catch (Exception exe) { } try { person.setBirthDay(getNVal(ael, "birthDay")); } catch (Exception exe) { } try { person.setCountryJob(getNVal(ael, "countryJob")); person.setFirstname(getNVal(ael, "firstname")); person.setJob(getNVal(ael, "job")); person.setJobTitle(getNVal(ael, "jobTitle")); person.setLastname(getNVal(ael, "lastname")); person.setLinkMedicalAssociation(getNVal(ael, "linkMedicalAssociation")); person.setMedicalAssociation(getNVal(ael, "medicalAssociation")); person.setPosition(new Byte(getNVal(ael, "position")).byteValue()); person.setSalutation(getNVal(ael, "salutation")); person.setSex(new Byte(getNVal(ael, "sex")).byteValue()); person.setTitle(getNVal(ael, "title")); if (!useNewIds) { person.setPersonId(new Integer(ael.getAttribute("id")).longValue()); } person.getUnits().add(unit); person = getPersonHbmDao().create(person); } catch (Exception exe) { log.warn("Error setting values: ", exe); } try { if (log.isDebugEnabled()) log.debug("looking for addresses to import for person " + person.getPersonId()); //$NON-NLS-1$ Iterator itAdr = XercesHelper.findNodes(ael, "./address"); //$NON-NLS-1$ while (itAdr.hasNext()) { Element adrEl = (Element) itAdr.next(); if (log.isDebugEnabled()) log.debug("found address to import"); //$NON-NLS-1$ AddressHbm local = createAddressHbm(adrEl, useNewIds, mappingAddresses); person.addAddress(local); } } catch (Exception exe) { log.warn("Error importing addresses: ", exe); //$NON-NLS-1$ throw new CreateException(exe.getMessage()); } try { if (log.isDebugEnabled()) log.debug("looking for talktimes to import for person " + person.getPersonId()); //$NON-NLS-1$ Iterator itTTimes = XercesHelper.findNodes(ael, "./talktime"); //$NON-NLS-1$ while (itTTimes.hasNext()) { Element elm = (Element) itTTimes.next(); if (log.isDebugEnabled()) log.debug("found talktime to import"); //$NON-NLS-1$ TalktimeHbm local = createTalktimeHbm(elm, useNewIds, mappingTalktime); person.addTalktime(local); } } catch (Exception exe) { log.warn("Error importing talktimes: ", exe); //$NON-NLS-1$ throw new Exception(exe.getMessage()); } return person; }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
private String fnGetTaskOI_ListName(View vSubtask) { StringBuilder sbTaskID = new StringBuilder(); StringBuilder sbTaskOI_ListName = new StringBuilder(); Task t;// w ww .ja v a 2 s . c om t = SysGetTaskFromView(vSubtask); zsprintf(sbTaskID, "%08x", Integer.decode(t.getTaskId())); zstrcpy(sbTaskOI_ListName, "__CM."); zstrcat(sbTaskOI_ListName, sbTaskID.toString()); return sbTaskOI_ListName.toString(); }
From source file:net.sf.jabref.importer.HTMLConverter.java
@Override public String format(String text) { if (text == null) { return null; }/* ww w. j a va 2 s. co m*/ StringBuffer sb = new StringBuffer(); // Deal with the form <sup>k</sup>and <sub>k</sub> // If the result is in text or equation form can be controlled // From the "Advanced settings" tab if (Globals.prefs.getBoolean(JabRefPreferences.USE_CONVERT_TO_EQUATION)) { text = text.replaceAll("<[ ]?sup>([^<]+)</sup>", "\\$\\^\\{$1\\}\\$"); text = text.replaceAll("<[ ]?sub>([^<]+)</sub>", "\\$_\\{$1\\}\\$"); } else { text = text.replaceAll("<[ ]?sup>([^<]+)</sup>", "\\\\textsuperscript\\{$1\\}"); text = text.replaceAll("<[ ]?sub>([^<]+)</sub>", "\\\\textsubscript\\{$1\\}"); } // TODO: maybe rewrite this based on regular expressions instead // Note that (at least) the IEEE Xplore fetcher must be fixed as it relies on the current way to // remove tags for its image alt-tag to equation converter for (int i = 0; i < text.length(); i++) { int c = text.charAt(i); if (c == '<') { i = readTag(text, i); } else { sb.append((char) c); } } text = sb.toString(); // Handle text based HTML entities Set<String> patterns = escapedSymbols.keySet(); for (String pattern : patterns) { text = text.replaceAll(pattern, escapedSymbols.get(pattern)); } // Handle numerical HTML entities Pattern escapedPattern = Pattern.compile("&#([x]*)([0]*)(\\p{XDigit}+);"); Matcher m = escapedPattern.matcher(text); while (m.find()) { // System.err.println("Found pattern: " + m.group(1)); // System.err.println("Found pattern: " + m.group(2)); int num = Integer.decode(m.group(1).replace("x", "#") + m.group(3)); if (numSymbols.containsKey(num)) { text = text.replaceAll("&#" + m.group(1) + m.group(2) + m.group(3) + ";", numSymbols.get(num)); } } escapedPattern = Pattern.compile("(.)&#([x]*)([0]*)(\\p{XDigit}+);"); m = escapedPattern.matcher(text); while (m.find()) { // System.err.println("Found pattern: " + m.group(1)); // System.err.println("Found pattern: " + m.group(2)); int num = Integer.decode(m.group(2).replace("x", "#") + m.group(4)); if (escapedAccents.containsKey(num)) { if ("i".equals(m.group(1))) { text = text.replaceAll(m.group(1) + "&#" + m.group(2) + m.group(3) + m.group(4) + ";", "\\{\\\\" + escapedAccents.get(num) + "\\{\\\\i\\}\\}"); } else if ("j".equals(m.group(1))) { text = text.replaceAll(m.group(1) + "&#" + m.group(2) + m.group(3) + m.group(4) + ";", "\\{\\\\" + escapedAccents.get(num) + "\\{\\\\j\\}\\}"); } else { text = text.replaceAll(m.group(1) + "&#" + m.group(2) + m.group(3) + m.group(4) + ";", "\\{\\\\" + escapedAccents.get(num) + "\\{" + m.group(1) + "\\}\\}"); } } } escapedPattern = Pattern.compile("&#([x]*)([0]*)(\\p{XDigit}+);"); m = escapedPattern.matcher(text); while (m.find()) { // System.err.println("Found pattern: " + m.group(1)); // System.err.println("Found pattern: " + m.group(2)); int num = Integer.decode(m.group(1).replace("x", "#") + m.group(3)); LOGGER.warn("HTML escaped char not converted: " + m.group(1) + m.group(2) + m.group(3) + " = " + Integer.toString(num)); } // Remove $$ in case of two adjacent conversions text = text.replace("$$", ""); // Find non-covered special characters with alphabetic codes escapedPattern = Pattern.compile("&(\\w+);"); m = escapedPattern.matcher(text); while (m.find()) { LOGGER.warn("HTML escaped char not converted: " + m.group(1)); } return text.trim(); }
From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java
private AddressHbm createAddressHbm(Element ael, boolean useNewIds, Hashtable<Integer, Long> mappingAddresses2) { AddressHbm address = AddressHbm.Factory.newInstance(); address.setAddressType(getNVal(ael, "addressType")); address.setBuildingLevel(getNVal(ael, "buildingLevel")); address.setBuildingNr(getNVal(ael, "buildingNr")); address.setCity(getNVal(ael, "city")); address.setCountry(getNVal(ael, "country")); address.setCountryCode(getNVal(ael, "countryCode")); address.setEmail(getNVal(ael, "email")); address.setFax(getNVal(ael, "fax")); address.setHomepage(getNVal(ael, "homepage")); address.setMisc(getNVal(ael, "misc")); address.setMobilePhone(getNVal(ael, "mobilePhone")); address.setPhone1(getNVal(ael, "phone1")); address.setPhone2(getNVal(ael, "phone2")); address.setPostOfficeBox(getNVal(ael, "postOfficeBox")); address.setRoomNr(getNVal(ael, "roomNr")); address.setStreet(getNVal(ael, "street")); address.setStreetNr(getNVal(ael, "streetNr")); address.setZipCode(getNVal(ael, "zipCode")); if (!useNewIds) { address.setAddressId(Integer.decode(ael.getAttribute("id")).longValue()); log.info("AddressID: " + address.getAddressId()); }//w ww.j ava 2 s . c o m address = getAddressHbmDao().create(address); return address; }