Search in sources :

Example 51 with Entry

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());
        }
    }
}
Also used : Entry(java.util.Map.Entry) PersonNatureAttr(org.ansj.domain.PersonNatureAttr)

Example 52 with Entry

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;
}
Also used : Entry(java.util.Map.Entry) JDBC4PreparedStatement(com.mysql.jdbc.JDBC4PreparedStatement)

Example 53 with Entry

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();
}
Also used : Status(net.minecraftforge.common.ForgeVersion.Status) InjectedModContainer(net.minecraftforge.fml.common.InjectedModContainer) ModContainer(net.minecraftforge.fml.common.ModContainer) InputStream(java.io.InputStream) InjectedModContainer(net.minecraftforge.fml.common.InjectedModContainer) Gson(com.google.gson.Gson) ComparableVersion(net.minecraftforge.fml.common.versioning.ComparableVersion) URL(java.net.URL) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 54 with Entry

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;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PersistentRegistryManager(net.minecraftforge.fml.common.registry.PersistentRegistryManager) NBTTagList(net.minecraft.nbt.NBTTagList) Entry(java.util.Map.Entry) ResourceLocation(net.minecraft.util.ResourceLocation) Map(java.util.Map)

Example 55 with Entry

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();
}
Also used : Entry(java.util.Map.Entry) File(java.io.File) JournaledFile(com.android.internal.util.JournaledFile)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103