private void exportParameters() { synchronized (exported_parameters) { if (!exported_parameters_dirty) { return; } exported_parameters_dirty = false; try { TreeMap<String, String> tm = new TreeMap<String, String>(); Set<String> exported_keys = new HashSet<String>(); for (String[] entry : exported_parameters.values()) { String key = entry[0]; String value = entry[1]; exported_keys.add(key); if (value != null) { tm.put(key, value); } } for (Map.Entry<String, String> entry : imported_parameters.entrySet()) { String key = entry.getKey(); if (!exported_keys.contains(key)) { tm.put(key, entry.getValue()); } } File parent_dir = new File(SystemProperties.getUserPath()); File props = new File(parent_dir, "exported_params.properties"); PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(props), "UTF-8")); try { for (Map.Entry<String, String> entry : tm.entrySet()) { pw.println(entry.getKey() + "=" + entry.getValue()); } } finally { pw.close(); } } catch (Throwable e) { e.printStackTrace(); } } }
static { TreeMap<String, Object> v = new TreeMap<String, Object>(); v.put("wdBalloonPrintOrientationAuto", wdBalloonPrintOrientationAuto); v.put("wdBalloonPrintOrientationPreserve", wdBalloonPrintOrientationPreserve); v.put("wdBalloonPrintOrientationForceLandscape", wdBalloonPrintOrientationForceLandscape); values = Collections.synchronizedMap(Collections.unmodifiableMap(v)); }
/** * 得到用户的信息,支持批量操作,返回默认信息(uid,name,tinyurl,headhurl,zidou,star) * * @param userIds 需要查询的用户的ID,多个ID用逗号隔开。 * @param auth Auth接口类型,表示accessToken或sessionKey,传入如下值: * <ul> * <li>new AccessToken(accessToken) * <li>new SessionKey(sessionKey) * </ul> * * @return JSONArray */ public JSONArray getInfo(String userIds, Auth auth) { TreeMap<String, String> params = new TreeMap<String, String>(); params.put(auth.getKey(), auth.getValue()); params.put("method", "users.getInfo"); params.put("uids", userIds); return this.getResultJSONArray(params); }
static { TreeMap v = new TreeMap(); v.put("WshRunning", WshRunning); v.put("WshFinished", WshFinished); v.put("WshFailed", WshFailed); values = Collections.synchronizedMap(Collections.unmodifiableMap(v)); }
/** * Finds the ObjectName of the theoretical parent * * @param file the parent file of the branch we're looking for * @return the ObjectName or null if one was not found Root Parent: * com.heliosapm.watchtower.deployment:type=branch,root=deploy Sample Child: * com.heliosapm.watchtower.deployment:type=branch,foo=bar */ protected static ObjectName findParent(File file) { if (file == null || !file.isDirectory()) return null; int cnt = 1; TreeMap<Integer, String[]> parents = new TreeMap<Integer, String[]>(); String[] dirPair = dirPair(file); if (dirPair.length != 2) { ObjectName parent = JMXHelper.objectName( new StringBuilder("com.heliosapm.watchtower.deployment:type=branch,root=") .append(file.getName())); if (JMXHelper.isRegistered(parent)) return parent; return null; } parents.put(0, dirPair); while (true) { file = file.getParentFile(); if (file == null) break; dirPair = dirPair(file); if (dirPair.length != 2) break; parents.put(cnt, dirPair); cnt++; } StringBuilder b = new StringBuilder(OBJECT_NAME_BASE); for (String[] pair : parents.values()) { b.append(",").append(pair[0]).append("=").append(pair[1]); } try { return JMXHelper.objectName(b); } catch (Exception ex) { ex.printStackTrace(System.err); return null; } }
private Map<String, Ref> readAdvertisedImpl(final BufferedReader br) throws IOException, PackProtocolException { final TreeMap<String, Ref> avail = new TreeMap<String, Ref>(); for (; ; ) { String line = br.readLine(); if (line == null) break; final int tab = line.indexOf('\t'); if (tab < 0) throw invalidAdvertisement(line); String name; final ObjectId id; name = line.substring(tab + 1); id = ObjectId.fromString(line.substring(0, tab)); if (name.endsWith("^{}")) { name = name.substring(0, name.length() - 3); final Ref prior = avail.get(name); if (prior == null) throw outOfOrderAdvertisement(name); if (prior.getPeeledObjectId() != null) throw duplicateAdvertisement(name + "^{}"); avail.put(name, new Ref(Ref.Storage.NETWORK, name, prior.getObjectId(), id, true)); } else { final Ref prior = avail.put(name, new Ref(Ref.Storage.NETWORK, name, id)); if (prior != null) throw duplicateAdvertisement(name); } } return avail; }
protected TreeMap<Integer, String> createInitialLocationsForGA( TreeMap<Id, LinkRetailersImpl> availableLinks) { TreeMap<Integer, String> locations = new TreeMap<Integer, String>(); int intCount = 0; for (ActivityFacility af : this.retailerFacilities.values()) { locations.put( Integer.valueOf(intCount), NetworkUtils.getNearestLink( ((NetworkImpl) this.controler.getScenario().getNetwork()), af.getCoord()) .getId() .toString()); ++intCount; log.info( "The facility with Id: " + af.getId() + " has been added, this is located on the link: " + af.getLinkId()); } for (LinkRetailersImpl l : availableLinks.values()) { if (locations.containsValue(l.getId().toString())) { log.info("The Link: " + l.getId() + " is already on the list"); } else { locations.put(Integer.valueOf(intCount), l.getId().toString()); ++intCount; log.info("The Link: " + l.getId() + " has been added"); } } log.info("Initial Locations (with Free Links) = " + locations); return locations; }
public static boolean addVSensorInstance(VirtualSensor sensorPool) { try { if (logger.isInfoEnabled()) logger.info( (new StringBuilder("Testing the pool for :")) .append(sensorPool.getConfig().getName()) .toString()); sensorPool.returnVS(sensorPool.borrowVS()); } catch (Exception e) { logger.error(e.getMessage(), e); sensorPool.closePool(); logger.error( "GSN can't load the virtual sensor specified at " + sensorPool.getConfig().getFileName() + " because the initialization of the virtual sensor failed (see above exception)."); logger.error("Please fix the following error"); return false; } TreeMap<String, Boolean> vsNameToOutputStructureFields = new TreeMap<String, Boolean>(); vsNamesToOutputStructureFields.put( sensorPool.getConfig().getName(), vsNameToOutputStructureFields); for (DataField fields : sensorPool.getConfig().getOutputStructure()) vsNameToOutputStructureFields.put(fields.getName(), Boolean.TRUE); vsNameToOutputStructureFields.put("timed", Boolean.TRUE); vsNameTOVSConfig.put(sensorPool.getConfig().getName(), sensorPool.getConfig()); fileNameToVSInstance.put(sensorPool.getConfig().getFileName(), sensorPool); return true; }
/** * Saves value to raster * * @param dLat Latitude. * @param dLon Longitude. * @param dValue Value to be written */ public void put(double dLat, double dLon, double dValue) { // ico1 = indices IndexCoordinate ico1; // checking mask // if(plyMask!=null && !plyMask.contains(dLat, dLon)){ // return; // } // updating index maps if (!mapDate.containsKey(tim1)) { mapDate.put(tim1, iDateIndex); iDateIndex++; } if (!mapVert.containsKey(dVert)) { mapVert.put(dVert, iVertIndex); iVertIndex++; } // saving value ico1 = convertGeoCoordinateToIndexCoordinate(new GeoCoordinate(dLat, dLon, tim1, dVert)); this.put(ico1.iLat, ico1.iLon, ico1.iTime, ico1.iVert, dValue); // updating list of coordinates lstCoords.add(new GeoCoordinate(mapLat.floorKey(dLat), mapLon.floorKey(dLon), tim1, dVert)); }
public void prepare() { int i = 0; for (Map<String, Object> data : trainParser.getData()) { for (StimuliChooser chooser : stimuliChoosers) { chooser.feed(data); } System.out.println("PHASE 1 " + i++); } i = 0; for (Map<String, Object> data : trainParser.getData()) { for (StimuliChooser chooser : stimuliChoosers) { chooser.reFeed(data); } System.out.println("PHASE 2 " + i++); } for (StimuliChooser chooser : stimuliChoosers) { stimuliScores.put(chooser.getScore(), chooser); } for (Map.Entry<Double, StimuliChooser> e : stimuliScores.entrySet()) { String id = e.getValue().getTarget() + ":" + e.getValue().getAllObservables(); allScores.put(id, e.getKey()); } }
/** * 認証Tokenが有効かどうかをチェックする * * @throws IOException */ public boolean checkToken() throws IOException { // alreay has Token? SharedPreferences preference = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); this.token = preference.getString("token", null); if (this.token == null) { return false; } // check Token validated. // http://flickr.com/services/rest/?method=flickr.auth.checkToken&auth_token=sdkjlsa983&api_key=987654321&frob=1a2b3c4d5e&api_sig=7f3870be274f6c49b3e31a0c6728957f. TreeMap<String, Object> map = new TreeMap<String, Object>(); map.put(paramApiKey, apiKey); map.put(paramMethod, AUTH_CHECK_TOKEN); map.put(paramResponseFormat, jsonFormat); // map.put(paramFlob, frob); map.put(paramAuthToken, this.token); map.put(paramApiSig, makeToken(map)); RestRequestData request = new RestRequestData(); request.setUrl(baseUrl); request.setPath(servicePath + "/" + restPath + "/"); request.setQueryParam(map); URL url = RestfulLib.makeUrl(request); String response = RestfulLib.httpGetRequest(url.toString()); return parseCheckToken(response); }
/** * @author ddefrancesco * @param rawMap * @return TreeMap<Integer, String> _tm * @category Utility method. * <p>This method builds the generic part of footer that embeds IVA descriptions, totals both * net and gross. The resulting map will be used by buildIvaDataMap(TreeMap<Integer, String> * rawMap) and buildTotaliDataMap(TreeMap<Integer, String> rawMap). */ private TreeMap<Integer, String> buildFooterDataMap(TreeMap<Integer, String> rawMap) { Iterator<Entry<Integer, String>> mit = rawMap.entrySet().iterator(); Integer fromKey = 0; Integer toKey = 0; Integer spa1Key = 0; Integer spa2Key = 0; String line = ""; TreeMap<Integer, String> _tm = new TreeMap<Integer, String>(); int k = 0; while (mit.hasNext()) { Entry<Integer, String> entry = (Entry<Integer, String>) mit.next(); if (entry.getValue().startsWith("!SPA 2;INL 0")) { fromKey = entry.getKey(); line = rawMap.get(fromKey + 1); } if (entry.getValue().startsWith("!SPA 1") && entry.getKey() > 12) spa1Key = entry.getKey(); if (entry.getValue().startsWith("!SPA 2") && !entry.getValue().contains(";INL 0") && entry.getKey() > 12) spa2Key = entry.getKey(); } _tm.put(new Integer(0), line); _tm.put(new Integer(1), rawMap.get(spa1Key - 1)); _tm.put(new Integer(2), rawMap.get(spa2Key + 1)); return _tm; }
/** * Read callback implementation * * @param rc return code * @param ledgerId Ledger identifier * @param entryId Entry identifier * @param bb Data * @param ctx Control object */ public void readEntryComplete(int rc, long ledgerId, long entryId, ByteBuffer bb, Object ctx) { if (rc == 0) { bb.rewind(); /* * Collect new vote */ if (!votes.containsKey(entryId)) { votes.put(entryId, new ArrayList<ByteBuffer>()); } votes.get(entryId).add(bb); /* * Extract hint */ bb.position(16); long hint = bb.getLong(); LOG.info("Received a response: " + rc + ", " + entryId + ", " + hint); if (!hints.containsKey(hint)) { hints.put(hint, 0); } hints.put(hint, hints.get(hint) + 1); synchronized (counter) { if (counter.incrementAndGet() >= minimum) ; counter.notify(); } } else { LOG.debug("rc != 0"); } }
static { TreeMap<String, Object> v = new TreeMap<String, Object>(); v.put("acNull", acNull); v.put("acADP", acADP); v.put("acMDB", acMDB); values = Collections.synchronizedMap(Collections.unmodifiableMap(v)); }
public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pr = new PrintWriter(new OutputStreamWriter(System.out)); // br = new BufferedReader(new FileReader("in.txt")); // pr = new PrintWriter(new FileWriter("out.txt")); int n = readInt(); int k = readInt(); int[] boy = new int[n]; TreeMap<Integer, Integer> girl = new TreeMap<Integer, Integer>(); for (int i = 0; i < n; i++) { boy[i] = readInt(); } for (int i = 0; i < n; i++) { int in = readInt(); if (!girl.containsKey(in)) girl.put(in, 0); girl.put(in, girl.get(in) + 1); } Arrays.sort(boy); int ans = 0; for (int i = 0; i < n; i++) { Integer next = girl.ceilingKey(boy[i] - k); if (next != null && Math.abs(next - boy[i]) <= k) { ans++; girl.put(next, girl.get(next) - 1); if (girl.get(next) == 0) girl.remove(next); } } System.out.println(ans); pr.close(); }
public Map toExternalFormat(Map attributeValueToObjectMap) { if (attributeValueToObjectMap.isEmpty()) { return attributeValueToObjectMap; } // Turn the values into ranges. Validations have already ensured that // the values are unique and contain no nulls. [Bob Boseko] Assert.isTrue(attributeValueToObjectMap instanceof SortedMap); TreeMap newMap = new Range.RangeTreeMap(); Object previousValue = null; for (Iterator i = attributeValueToObjectMap.keySet().iterator(); i.hasNext(); ) { Object value = i.next(); try { if (previousValue == null) { // Let the default style handle values from negative infinity to // the first value. [Bob Boseko] continue; } // Make one side inclusive and the other exclusive to ensure no // overlaps. [Bob Boseko] newMap.put( new Range(previousValue, true, value, false), attributeValueToObjectMap.get(previousValue)); } finally { previousValue = value; } } newMap.put( new Range(previousValue, true, new Range.PositiveInfinity(), false), attributeValueToObjectMap.get(previousValue)); return newMap; }
/** * Obtains a {@code PeriodFields} from a {@code Duration} based on the standard durations of * seconds and nanoseconds. * * <p>The conversion will create an instance with two units - the {@code ISOChronology} seconds * and nanoseconds units. This matches the {@link #toDuration()} method. * * @param duration the duration to create from, not null * @return the {@code PeriodFields} instance, not null */ public static PeriodFields of(Duration duration) { checkNotNull(duration, "Duration must not be null"); TreeMap<PeriodUnit, PeriodField> internalMap = createMap(); internalMap.put(SECONDS, PeriodField.of(duration.getSeconds(), SECONDS)); internalMap.put(NANOS, PeriodField.of(duration.getNanoOfSecond(), NANOS)); return create(internalMap); }
static { TreeMap<String, Object> v = new TreeMap<String, Object>(); v.put("xlLinkInfoOLELinks", xlLinkInfoOLELinks); v.put("xlLinkInfoPublishers", xlLinkInfoPublishers); v.put("xlLinkInfoSubscribers", xlLinkInfoSubscribers); values = Collections.synchronizedMap(Collections.unmodifiableMap(v)); }
/** * Adds new point p with value m to this histogram. * * @param p * @param m */ public void update(double p, long m) { Long mi = bin.get(p); if (mi != null) { // we found the same p so increment that counter bin.put(p, mi + m); } else { bin.put(p, m); // if bin size exceeds maximum bin size then trim down to max size while (bin.size() > maxBinSize) { // find points p1, p2 which have smallest difference Iterator<Double> keys = bin.keySet().iterator(); double p1 = keys.next(); double p2 = keys.next(); double smallestDiff = p2 - p1; double q1 = p1, q2 = p2; while (keys.hasNext()) { p1 = p2; p2 = keys.next(); double diff = p2 - p1; if (diff < smallestDiff) { smallestDiff = diff; q1 = p1; q2 = p2; } } // merge those two long k1 = bin.remove(q1); long k2 = bin.remove(q2); bin.put((q1 * k1 + q2 * k2) / (k1 + k2), k1 + k2); } } }
public int converter(String str) { TreeMap<Integer, String> hm = new TreeMap<>(); { hm.put(new Integer(1000), "M"); hm.put(new Integer(900), "CM"); hm.put(new Integer(500), "D"); hm.put(new Integer(400), "CD"); hm.put(new Integer(100), "C"); hm.put(new Integer(90), "XC"); hm.put(new Integer(50), "L"); hm.put(new Integer(40), "XL"); hm.put(new Integer(10), "X"); hm.put(new Integer(9), "IX"); hm.put(new Integer(5), "V"); hm.put(new Integer(4), "IV"); hm.put(new Integer(1), "I"); } NavigableMap<Integer, String> nmap = hm.descendingMap(); int tmpResult = 0; int index = 0; for (Entry<Integer, String> entry : nmap.entrySet()) { while ((str.length() >= index + entry.getValue().length()) && str.substring(index, index + entry.getValue().length()).equals(entry.getValue())) { tmpResult += entry.getKey(); index += entry.getValue().length(); } } result = tmpResult; return result; }
private boolean isNotSeparatorRoom(Room separatorRoom, Room joinerRoom) { if (separatorRoom == null) return false; if (separatorRoom.isRotatable() && separatorRoom != joinerRoom) { separatorRoom.rotateRightRotatedType(); rotationMap.put( separatorRoom.getDistance() - Math.abs(separatorRoom.getRotation()), separatorRoom); return false; } if (separatorRoom.isRotatable() && separatorRoom == joinerRoom && separatorRoom.getExit() != null) { if (separatorRoom.getRotatedType() == RoomType.TYPE_7) { separatorRoom.rotateRightRotatedType(); } else if (separatorRoom.getRotatedType() == RoomType.TYPE_8 && separatorRoom.getEntrance() == Direction.LEFT) { separatorRoom.rotateLeftRotatedType(); } else if (separatorRoom.getRotatedType() == RoomType.TYPE_8 && separatorRoom.getEntrance() == Direction.RIGHT) { separatorRoom.rotateRightRotatedType(); } else if (separatorRoom.getRotatedType() == RoomType.TYPE_9 && separatorRoom.getEntrance() == Direction.TOP) { separatorRoom.rotateLeftRotatedType(); } else if (separatorRoom.getRotatedType() == RoomType.TYPE_9 && separatorRoom.getEntrance() == Direction.LEFT) { separatorRoom.rotateRightRotatedType(); } rotationMap.put( separatorRoom.getDistance() - Math.abs(separatorRoom.getRotation()), separatorRoom); return false; } return true; }
public TreeMap<String, Integer> getOccurrencesOfTagsAfterTurnLength(int min) throws IOException { TreeMap<String, Integer> occurrences = new TreeMap<String, Integer>(); File[] files = inputDir.listFiles(); int totalTurns = 0; for (File curFile : files) { if (!curFile.getName().endsWith(datafileExtension)) continue; System.out.print("Processing file: " + curFile + " ..."); BufferedReader in = new BufferedReader(new FileReader(curFile)); String line = in.readLine(); while ((line = in.readLine()) != null) { String[] values = line.split("\\|", -1); if (values[0].equalsIgnoreCase("server") || values[1].equalsIgnoreCase("server") || values[2].equalsIgnoreCase("server") || values[9].isEmpty()) continue; String curTurn = values[8]; String spellingCorrected = fixSpelling(curTurn); float distance = 0.0f; if (spellingCorrected.trim().isEmpty()) { // System.out.println("EMPTY. SKIPPING THIS."); continue; } List<ArrayList<? extends HasWord>> sentences = MaxentTagger.tokenizeText(new StringReader(spellingCorrected)); if (sentences.isEmpty()) { continue; } totalTurns++; for (ArrayList<? extends HasWord> sent : sentences) { ArrayList<TaggedWord> taggedSentence = tagger.tagSentence(sent); boolean lastSentence = (sent == sentences.get(sentences.size() - 1)); if (lastSentence) { taggedSentence.add(new TaggedWord("", "EOT")); } for (int i = 0; i < taggedSentence.size(); i++) { TaggedWord cur = taggedSentence.get(i); distance++; if (distance >= min) { if (occurrences.containsKey(cur.tag())) { occurrences.put(cur.tag(), occurrences.get(cur.tag()) + 1); } else { occurrences.put(cur.tag(), 1); } } } } } } System.out.println("there were " + totalTurns + " turns in total."); return occurrences; }
private void writeToPubsub( Time batchTime, int partitionId, Iterator<AggregateResult> aggregateResultIterator) throws IOException { String timestamp = ISODateTimeFormat.dateTime().print(batchTime.milliseconds()); String batchId = getFormatterPrefix().print(batchTime.milliseconds()) + batchTime.milliseconds() + "-" + partitionId; TreeMap<String, Object> batchMap = new TreeMap<>(); batchMap.put("batch_id", batchId); List<Map<String, Object>> batches = new LinkedList<>(); while (aggregateResultIterator.hasNext()) { AggregateResult aggrResult = aggregateResultIterator.next(); TreeMap<String, Object> map = new TreeMap<>(); map.putAll(aggrResult.getDimensions()); map.putAll(aggrResult.getMetrics()); map.put(WINDOW_TIMESTAMP_KEY, timestamp); batches.add(map); } if (batches.isEmpty()) return; batchMap.put("aggregated_result", batches); pubsubManager.writeAggregatedOutput(topic, objectMapper.writeValueAsString(batchMap)); }
public CustomersResource() { System.out.println("[CustomerResource] Instantiated " + this); Customer customer1 = new Customer(); customer1.setId(1111); customer1.setName("CustomerOne"); customer1.setAddress("Bombay, India"); Customer customer2 = new Customer(); customer2.setId(2222); customer2.setName("CustomerTwo"); customer2.setAddress("Pune, India"); Customer customer3 = new Customer(); customer3.setId(3333); customer3.setName("CustomerThree"); customer3.setAddress("Bangalore, India"); customerMap.put(customer1.getId(), customer1); customerMap.put(customer2.getId(), customer2); customerMap.put(customer3.getId(), customer3); if (testBean != null) { System.out.println("[CustomersResource] testBean NOT NULL " + testBean); testBean.setCustomerMap(customerMap); } else { System.out.println("[CustomersResource] testBean IS NULL"); } }
public void createArbitraryClusterTree(int clusterStep, int child1Id, int child2Id, int newId) { if (getRootClusters() == null) { setRootClusters(leafNodeClusters); pointersToClusterLevels = new TreeMap<>(); pointersToClusterLevels.put(0, new ArrayList<>(leafNodeClusters.values())); } NodeCluster nc1 = rootClusters.get(child1Id); NodeCluster nc2 = rootClusters.get(child2Id); NodeCluster newCluster = new NodeCluster( nc1, nc2, this.getInternalFlowMethod(), this.getInternalFlowMethodParameters(), clusterStep, newId); newCluster.freezeCluster(); flowValues.add(newCluster.getDeltaFlow()); rootClusters = updateClusterTree(rootClusters, newCluster); updateLinksAndNodes(newCluster); clusterSteps = clusterStep; logger.info( String.format( "Step %05d of %05d: c1: %05d + c2: %05d = %05d, flow = %08.2f, deltaFlow = %08.2f", clusterSteps, this.leafNodeClusters.size(), newCluster.getChild1().getId(), newCluster.getChild2().getId(), newCluster.getId(), newCluster.getInternalFlow(), newCluster.getDeltaFlow())); pointersToClusterLevels.put(clusterSteps, new ArrayList<>(rootClusters.values())); }
public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int t = in.nextInt(); TreeMap<Long, Long> tmap = new TreeMap<>(); long res = 0; while (t-- > 0) { res = 0; int n = in.nextInt(); long m = in.nextLong(); tmap.clear(); long[] arr = new long[n]; res = in.nextLong(); arr[0] = res % m; res = Long.MIN_VALUE; tmap.put(arr[0], arr[0]); for (int i = 1; i < arr.length; i++) { arr[i] = in.nextLong(); arr[i] %= m; arr[i] += arr[i - 1]; arr[i] %= m; if (tmap.higherEntry(arr[i]) == null) { res = Math.max(res, arr[i]); tmap.put(arr[i], arr[i]); continue; } long val = tmap.higherEntry(arr[i]).getValue(); res = Math.max(res, (arr[i] - val + m) % m); tmap.put(arr[i], arr[i]); } System.out.println(res); } }
/** * 判断用户是否已对App授权 * * @param userId 用户ID * @return boolean */ public boolean isAppUser(long userId) { TreeMap<String, String> params = new TreeMap<String, String>(); params.put("method", "users.isAppUser"); params.put("uid", String.valueOf(userId)); return this.getResultBoolean(params); }
/** * Get a message from out I18n data file. * * @param message - message title. Such as 'noPlayer' * @return - What the set message really is */ public String getColoredMessage(final String message) { if (messageCache.containsKey(message)) { return messageCache.get(message); } try { try { final String translatedMessage = ChatColor.translateAlternateColorCodes(colorCode, customMessages.getString(message)); messageCache.put(message, translatedMessage); return translatedMessage; } catch (final MissingResourceException ex) { final String translatedMessage = ChatColor.translateAlternateColorCodes(colorCode, messages.getString(message)); messageCache.put(message, translatedMessage); return translatedMessage; } } catch (final MissingResourceException ex) { return defaultBundle.getString(message); } }
/** * 得到当前session的用户ID。 * * @param auth Auth接口类型,表示accessToken或sessionKey,传入如下值: * <ul> * <li>new AccessToken(accessToken) * <li>new SessionKey(sessionKey) * </ul> * * @return int */ public int getLoggedInUser(Auth auth) { TreeMap<String, String> params = new TreeMap<String, String>(); params.put(auth.getKey(), auth.getValue()); params.put("method", "users.getLoggedInUser"); String uid = this.getResultValue(params, "uid"); return Integer.parseInt(uid); }
public void restore() { _listByIndex.clear(); _listByClassId.clear(); List<SubClass> subclasses = CharacterSubclassDAO.getInstance().restore(_owner); int lastFreeIndex = 2; for (SubClass sub : subclasses) { if (sub == null) // Невозможно, но хай будет. continue; if (size() >= MAX_SUB_COUNT) { _log.warn( "SubClassList:restore: Limit is subclass! Player: " + _owner.getName() + "(" + _owner.getObjectId() + ")"); break; } if (sub.isActive()) { _activeSubClass = sub; } if (sub.isBase()) { _baseSubClass = sub; sub.setIndex(1); } else { sub.setIndex(lastFreeIndex); lastFreeIndex++; } if (_listByIndex.containsKey(sub.getIndex())) _log.warn( "SubClassList:restore: Duplicate index in player subclasses! Player: " + _owner.getName() + "(" + _owner.getObjectId() + ")"); _listByIndex.put(sub.getIndex(), sub); if (_listByClassId.containsKey(sub.getClassId())) _log.warn( "SubClassList:restore: Duplicate class_id in player subclasses! Player: " + _owner.getName() + "(" + _owner.getObjectId() + ")"); _listByClassId.put(sub.getClassId(), sub); } _lastFreeIndex = lastFreeIndex; if (_listByIndex.size() != _listByClassId.size()) // Невозможно, но хай будет. _log.warn( "SubClassList:restore: The size of the lists do not match! Player: " + _owner.getName() + "(" + _owner.getObjectId() + ")"); }