use of java.util.Map.Entry in project ansj_seg by NLPchina.
the class PersonAttrLibrary method init2.
// name_freq
private void init2() {
Map<String, int[][]> personFreqMap = MyStaticValue.getPersonFreqMap();
Set<Entry<String, int[][]>> entrySet = personFreqMap.entrySet();
PersonNatureAttr pna = null;
for (Entry<String, int[][]> entry : entrySet) {
pna = pnMap.get(entry.getKey());
if (pna == null) {
pna = new PersonNatureAttr();
pna.setlocFreq(entry.getValue());
pnMap.put(entry.getKey(), pna);
} else {
pna.setlocFreq(entry.getValue());
}
}
}
use of java.util.Map.Entry in project DataX by alibaba.
the class AdsInsertProxy method generateDmlSql.
private String generateDmlSql(Connection connection, Record record, String mode) throws SQLException {
String sql = null;
StringBuilder sqlSb = new StringBuilder();
if (mode.equalsIgnoreCase(Constant.INSERTMODE)) {
sqlSb.append(this.insertSqlPrefix);
sqlSb.append("(");
int columnsSize = this.columns.size();
for (int i = 0; i < columnsSize; i++) {
if ((i + 1) != columnsSize) {
sqlSb.append("?,");
} else {
sqlSb.append("?");
}
}
sqlSb.append(")");
//mysql impl warn: if a database access error occurs or this method is called on a closed connection
PreparedStatement statement = connection.prepareStatement(sqlSb.toString());
for (int i = 0; i < this.columns.size(); i++) {
int preparedParamsIndex = i;
if (Constant.STREAMMODE.equalsIgnoreCase(this.writeMode)) {
if (preparedParamsIndex >= this.opColumnIndex) {
preparedParamsIndex = i + 1;
}
}
String columnName = this.columns.get(i);
int columnSqltype = this.userConfigColumnsMetaData.get(columnName).getLeft();
prepareColumnTypeValue(statement, columnSqltype, record.getColumn(preparedParamsIndex), i, columnName);
}
sql = ((JDBC4PreparedStatement) statement).asSql();
DBUtil.closeDBResources(statement, null);
} else {
sqlSb.append(this.deleteSqlPrefix);
sqlSb.append("(");
Set<Entry<String, Integer>> primaryEntrySet = this.primaryKeyNameIndexMap.entrySet();
int entrySetSize = primaryEntrySet.size();
int i = 0;
for (Entry<String, Integer> eachEntry : primaryEntrySet) {
if ((i + 1) != entrySetSize) {
sqlSb.append(String.format(" (%s = ?) and ", eachEntry.getKey()));
} else {
sqlSb.append(String.format(" (%s = ?) ", eachEntry.getKey()));
}
i++;
}
sqlSb.append(")");
//mysql impl warn: if a database access error occurs or this method is called on a closed connection
PreparedStatement statement = connection.prepareStatement(sqlSb.toString());
i = 0;
//ads的real time表只能是1级分区、且分区列类型是long, 但是这里是需要主键删除的
for (Entry<String, Integer> each : primaryEntrySet) {
String columnName = each.getKey();
int columnSqlType = this.userConfigColumnsMetaData.get(columnName).getLeft();
int primaryKeyInUserConfigIndex = this.primaryKeyNameIndexMap.get(columnName);
if (primaryKeyInUserConfigIndex >= this.opColumnIndex) {
primaryKeyInUserConfigIndex++;
}
prepareColumnTypeValue(statement, columnSqlType, record.getColumn(primaryKeyInUserConfigIndex), i, columnName);
i++;
}
sql = ((JDBC4PreparedStatement) statement).asSql();
DBUtil.closeDBResources(statement, null);
}
return sql;
}
use of java.util.Map.Entry in project MinecraftForge by MinecraftForge.
the class ForgeVersion method startVersionCheck.
public static void startVersionCheck() {
new Thread("Forge Version Check") {
@Override
public void run() {
if (!ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, "Global", true).getBoolean()) {
FMLLog.log("ForgeVersionCheck", Level.INFO, "Global Forge version check system disabled, no further processing.");
return;
}
for (Entry<ModContainer, URL> entry : gatherMods().entrySet()) {
ModContainer mod = entry.getKey();
if (ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, mod.getModId(), true).getBoolean()) {
process(mod, entry.getValue());
} else {
FMLLog.log("ForgeVersionCheck", Level.INFO, "[%s] Skipped version check", mod.getModId());
}
}
}
private void process(ModContainer mod, URL url) {
try {
FMLLog.log("ForgeVersionCheck", Level.INFO, "[%s] Starting version check at %s", mod.getModId(), url.toString());
Status status = PENDING;
ComparableVersion target = null;
InputStream con = url.openStream();
String data = new String(ByteStreams.toByteArray(con), "UTF-8");
con.close();
FMLLog.log("ForgeVersionCheck", Level.DEBUG, "[%s] Received version check data:\n%s", mod.getModId(), data);
@SuppressWarnings("unchecked") Map<String, Object> json = new Gson().fromJson(data, Map.class);
@SuppressWarnings("unchecked") Map<String, String> promos = (Map<String, String>) json.get("promos");
String display_url = (String) json.get("homepage");
String rec = promos.get(MinecraftForge.MC_VERSION + "-recommended");
String lat = promos.get(MinecraftForge.MC_VERSION + "-latest");
ComparableVersion current = new ComparableVersion(mod.getVersion());
if (rec != null) {
ComparableVersion recommended = new ComparableVersion(rec);
int diff = recommended.compareTo(current);
if (diff == 0)
status = UP_TO_DATE;
else if (diff < 0) {
status = AHEAD;
if (lat != null) {
ComparableVersion latest = new ComparableVersion(lat);
if (current.compareTo(latest) < 0) {
status = OUTDATED;
target = latest;
}
}
} else {
status = OUTDATED;
target = recommended;
}
} else if (lat != null) {
ComparableVersion latest = new ComparableVersion(lat);
if (current.compareTo(latest) < 0) {
status = BETA_OUTDATED;
target = latest;
} else
status = BETA;
} else
status = BETA;
FMLLog.log("ForgeVersionCheck", Level.INFO, "[%s] Found status: %s Target: %s", mod.getModId(), status, target);
Map<ComparableVersion, String> changes = new LinkedHashMap<ComparableVersion, String>();
@SuppressWarnings("unchecked") Map<String, String> tmp = (Map<String, String>) json.get(MinecraftForge.MC_VERSION);
if (tmp != null) {
List<ComparableVersion> ordered = new ArrayList<ComparableVersion>();
for (String key : tmp.keySet()) {
ComparableVersion ver = new ComparableVersion(key);
if (ver.compareTo(current) > 0 && (target == null || ver.compareTo(target) < 1)) {
ordered.add(ver);
}
}
Collections.sort(ordered);
for (ComparableVersion ver : ordered) {
changes.put(ver, tmp.get(ver.toString()));
}
}
if (mod instanceof InjectedModContainer)
mod = ((InjectedModContainer) mod).wrappedContainer;
results.put(mod, new CheckResult(status, target, changes, display_url));
} catch (Exception e) {
FMLLog.log("ForgeVersionCheck", Level.DEBUG, e, "Failed to process update information");
status = FAILED;
}
}
}.start();
}
use of java.util.Map.Entry in project MinecraftForge by MinecraftForge.
the class FMLContainer method getDataForWriting.
@Override
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) {
NBTTagCompound fmlData = new NBTTagCompound();
NBTTagList modList = new NBTTagList();
for (ModContainer mc : Loader.instance().getActiveModList()) {
NBTTagCompound mod = new NBTTagCompound();
mod.setString("ModId", mc.getModId());
mod.setString("ModVersion", mc.getVersion());
modList.appendTag(mod);
}
fmlData.setTag("ModList", modList);
NBTTagCompound registries = new NBTTagCompound();
fmlData.setTag("Registries", registries);
FMLLog.fine("Gathering id map for writing to world save %s", info.getWorldName());
PersistentRegistryManager.GameDataSnapshot dataSnapshot = PersistentRegistryManager.takeSnapshot();
for (Map.Entry<ResourceLocation, PersistentRegistryManager.GameDataSnapshot.Entry> e : dataSnapshot.entries.entrySet()) {
NBTTagCompound data = new NBTTagCompound();
registries.setTag(e.getKey().toString(), data);
NBTTagList ids = new NBTTagList();
for (Entry<ResourceLocation, Integer> item : e.getValue().ids.entrySet()) {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("K", item.getKey().toString());
tag.setInteger("V", item.getValue());
ids.appendTag(tag);
}
data.setTag("ids", ids);
NBTTagList aliases = new NBTTagList();
for (Entry<ResourceLocation, ResourceLocation> entry : e.getValue().aliases.entrySet()) {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("K", entry.getKey().toString());
tag.setString("V", entry.getValue().toString());
aliases.appendTag(tag);
}
data.setTag("aliases", aliases);
NBTTagList subs = new NBTTagList();
for (ResourceLocation entry : e.getValue().substitutions) {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("K", entry.toString());
subs.appendTag(tag);
}
data.setTag("substitutions", subs);
int[] blocked = new int[e.getValue().blocked.size()];
int idx = 0;
for (Integer i : e.getValue().blocked) {
blocked[idx++] = i;
}
data.setIntArray("blocked", blocked);
NBTTagList dummied = new NBTTagList();
for (ResourceLocation entry : e.getValue().dummied) {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("K", entry.toString());
dummied.appendTag(tag);
}
data.setTag("dummied", dummied);
}
return fmlData;
}
use of java.util.Map.Entry in project android_frameworks_base by ParanoidAndroid.
the class Settings method removeUserLPr.
void removeUserLPr(int userId) {
Set<Entry<String, PackageSetting>> entries = mPackages.entrySet();
for (Entry<String, PackageSetting> entry : entries) {
entry.getValue().removeUser(userId);
}
mPreferredActivities.remove(userId);
File file = getUserPackagesStateFile(userId);
file.delete();
file = getUserPackagesStateBackupFile(userId);
file.delete();
}
Aggregations