Example usage for java.util Map.Entry get

List of usage examples for java.util Map.Entry get

Introduction

In this page you can find the example usage for java.util Map.Entry get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.apache.hadoop.hbase.master.DefaultLoadBalancer.java

/**
 * Generate a global load balancing plan according to the specified map of
 * server information to the most loaded regions of each server.
 *
 * The load balancing invariant is that all servers are within 1 region of the
 * average number of regions per server.  If the average is an integer number,
 * all servers will be balanced to the average.  Otherwise, all servers will
 * have either floor(average) or ceiling(average) regions.
 *
 * HBASE-3609 Modeled regionsToMove using Guava's MinMaxPriorityQueue so that
 *   we can fetch from both ends of the queue. 
 * At the beginning, we check whether there was empty region server 
 *   just discovered by Master. If so, we alternately choose new / old
 *   regions from head / tail of regionsToMove, respectively. This alternation
 *   avoids clustering young regions on the newly discovered region server.
 *   Otherwise, we choose new regions from head of regionsToMove.
 *   //from   w ww .ja va  2s.com
 * Another improvement from HBASE-3609 is that we assign regions from
 *   regionsToMove to underloaded servers in round-robin fashion.
 *   Previously one underloaded server would be filled before we move onto
 *   the next underloaded server, leading to clustering of young regions.
 *   
 * Finally, we randomly shuffle underloaded servers so that they receive
 *   offloaded regions relatively evenly across calls to balanceCluster().
 *         
 * The algorithm is currently implemented as such:
 *
 * <ol>
 * <li>Determine the two valid numbers of regions each server should have,
 *     <b>MIN</b>=floor(average) and <b>MAX</b>=ceiling(average).
 *
 * <li>Iterate down the most loaded servers, shedding regions from each so
 *     each server hosts exactly <b>MAX</b> regions.  Stop once you reach a
 *     server that already has &lt;= <b>MAX</b> regions.
 *     <p>
 *     Order the regions to move from most recent to least.
 *
 * <li>Iterate down the least loaded servers, assigning regions so each server
 *     has exactly </b>MIN</b> regions.  Stop once you reach a server that
 *     already has &gt;= <b>MIN</b> regions.
 *
 *     Regions being assigned to underloaded servers are those that were shed
 *     in the previous step.  It is possible that there were not enough
 *     regions shed to fill each underloaded server to <b>MIN</b>.  If so we
 *     end up with a number of regions required to do so, <b>neededRegions</b>.
 *
 *     It is also possible that we were able to fill each underloaded but ended
 *     up with regions that were unassigned from overloaded servers but that
 *     still do not have assignment.
 *
 *     If neither of these conditions hold (no regions needed to fill the
 *     underloaded servers, no regions leftover from overloaded servers),
 *     we are done and return.  Otherwise we handle these cases below.
 *
 * <li>If <b>neededRegions</b> is non-zero (still have underloaded servers),
 *     we iterate the most loaded servers again, shedding a single server from
 *     each (this brings them from having <b>MAX</b> regions to having
 *     <b>MIN</b> regions).
 *
 * <li>We now definitely have more regions that need assignment, either from
 *     the previous step or from the original shedding from overloaded servers.
 *     Iterate the least loaded servers filling each to <b>MIN</b>.
 *
 * <li>If we still have more regions that need assignment, again iterate the
 *     least loaded servers, this time giving each one (filling them to
 *     </b>MAX</b>) until we run out.
 *
 * <li>All servers will now either host <b>MIN</b> or <b>MAX</b> regions.
 *
 *     In addition, any server hosting &gt;= <b>MAX</b> regions is guaranteed
 *     to end up with <b>MAX</b> regions at the end of the balancing.  This
 *     ensures the minimal number of regions possible are moved.
 * </ol>
 *
 * TODO: We can at-most reassign the number of regions away from a particular
 *       server to be how many they report as most loaded.
 *       Should we just keep all assignment in memory?  Any objections?
 *       Does this mean we need HeapSize on HMaster?  Or just careful monitor?
 *       (current thinking is we will hold all assignments in memory)
 *
 * @param clusterState Map of regionservers and their load/region information to
 *                   a list of their most loaded regions
 * @return a list of regions to be moved, including source and destination,
 *         or null if cluster is already balanced
 */
public List<RegionPlan> balanceCluster(Map<ServerName, List<HRegionInfo>> clusterState) {
    boolean emptyRegionServerPresent = false;
    long startTime = System.currentTimeMillis();

    int numServers = clusterState.size();
    if (numServers == 0) {
        LOG.debug("numServers=0 so skipping load balancing");
        return null;
    }
    NavigableMap<ServerAndLoad, List<HRegionInfo>> serversByLoad = new TreeMap<ServerAndLoad, List<HRegionInfo>>();
    int numRegions = 0;
    // Iterate so we can count regions as we build the map
    for (Map.Entry<ServerName, List<HRegionInfo>> server : clusterState.entrySet()) {
        List<HRegionInfo> regions = server.getValue();
        int sz = regions.size();
        if (sz == 0)
            emptyRegionServerPresent = true;
        numRegions += sz;
        serversByLoad.put(new ServerAndLoad(server.getKey(), sz), regions);
    }
    // Check if we even need to do any load balancing
    float average = (float) numRegions / numServers; // for logging
    // HBASE-3681 check sloppiness first
    int floor = (int) Math.floor(average * (1 - slop));
    int ceiling = (int) Math.ceil(average * (1 + slop));
    if (serversByLoad.lastKey().getLoad() <= ceiling && serversByLoad.firstKey().getLoad() >= floor) {
        // Skipped because no server outside (min,max) range
        LOG.info("Skipping load balancing because balanced cluster; " + "servers=" + numServers + " "
                + "regions=" + numRegions + " average=" + average + " " + "mostloaded="
                + serversByLoad.lastKey().getLoad() + " leastloaded=" + serversByLoad.firstKey().getLoad());
        return null;
    }
    int min = numRegions / numServers;
    int max = numRegions % numServers == 0 ? min : min + 1;

    // Using to check balance result.
    StringBuilder strBalanceParam = new StringBuilder();
    strBalanceParam.append("Balance parameter: numRegions=").append(numRegions).append(", numServers=")
            .append(numServers).append(", max=").append(max).append(", min=").append(min);
    LOG.debug(strBalanceParam.toString());

    // Balance the cluster
    // TODO: Look at data block locality or a more complex load to do this
    MinMaxPriorityQueue<RegionPlan> regionsToMove = MinMaxPriorityQueue.orderedBy(rpComparator).create();
    List<RegionPlan> regionsToReturn = new ArrayList<RegionPlan>();

    // Walk down most loaded, pruning each to the max
    int serversOverloaded = 0;
    // flag used to fetch regions from head and tail of list, alternately
    boolean fetchFromTail = false;
    Map<ServerName, BalanceInfo> serverBalanceInfo = new TreeMap<ServerName, BalanceInfo>();
    for (Map.Entry<ServerAndLoad, List<HRegionInfo>> server : serversByLoad.descendingMap().entrySet()) {
        ServerAndLoad sal = server.getKey();
        int regionCount = sal.getLoad();
        if (regionCount <= max) {
            serverBalanceInfo.put(sal.getServerName(), new BalanceInfo(0, 0));
            break;
        }
        serversOverloaded++;
        List<HRegionInfo> regions = server.getValue();
        int numToOffload = Math.min(regionCount - max, regions.size());
        // account for the out-of-band regions which were assigned to this server
        // after some other region server crashed 
        Collections.sort(regions, riComparator);
        int numTaken = 0;
        for (int i = 0; i <= numToOffload;) {
            HRegionInfo hri = regions.get(i); // fetch from head
            if (fetchFromTail) {
                hri = regions.get(regions.size() - 1 - i);
            }
            i++;
            // Don't rebalance meta regions.
            if (hri.isMetaRegion())
                continue;
            regionsToMove.add(new RegionPlan(hri, sal.getServerName(), null));
            numTaken++;
            if (numTaken >= numToOffload)
                break;
            // fetch in alternate order if there is new region server
            if (emptyRegionServerPresent) {
                fetchFromTail = !fetchFromTail;
            }
        }
        serverBalanceInfo.put(sal.getServerName(), new BalanceInfo(numToOffload, (-1) * numTaken));
    }
    int totalNumMoved = regionsToMove.size();

    // Walk down least loaded, filling each to the min
    int neededRegions = 0; // number of regions needed to bring all up to min
    fetchFromTail = false;

    Map<ServerName, Integer> underloadedServers = new HashMap<ServerName, Integer>();
    for (Map.Entry<ServerAndLoad, List<HRegionInfo>> server : serversByLoad.entrySet()) {
        int regionCount = server.getKey().getLoad();
        if (regionCount >= min) {
            break;
        }
        underloadedServers.put(server.getKey().getServerName(), min - regionCount);
    }
    // number of servers that get new regions
    int serversUnderloaded = underloadedServers.size();
    int incr = 1;
    List<ServerName> sns = Arrays
            .asList(underloadedServers.keySet().toArray(new ServerName[serversUnderloaded]));
    Collections.shuffle(sns, RANDOM);
    while (regionsToMove.size() > 0) {
        int cnt = 0;
        int i = incr > 0 ? 0 : underloadedServers.size() - 1;
        for (; i >= 0 && i < underloadedServers.size(); i += incr) {
            if (regionsToMove.isEmpty())
                break;
            ServerName si = sns.get(i);
            int numToTake = underloadedServers.get(si);
            if (numToTake == 0)
                continue;

            addRegionPlan(regionsToMove, fetchFromTail, si, regionsToReturn);
            if (emptyRegionServerPresent) {
                fetchFromTail = !fetchFromTail;
            }

            underloadedServers.put(si, numToTake - 1);
            cnt++;
            BalanceInfo bi = serverBalanceInfo.get(si);
            if (bi == null) {
                bi = new BalanceInfo(0, 0);
                serverBalanceInfo.put(si, bi);
            }
            bi.setNumRegionsAdded(bi.getNumRegionsAdded() + 1);
        }
        if (cnt == 0)
            break;
        // iterates underloadedServers in the other direction
        incr = -incr;
    }
    for (Integer i : underloadedServers.values()) {
        // If we still want to take some, increment needed
        neededRegions += i;
    }

    // If none needed to fill all to min and none left to drain all to max,
    // we are done
    if (neededRegions == 0 && regionsToMove.isEmpty()) {
        long endTime = System.currentTimeMillis();
        LOG.info("Calculated a load balance in " + (endTime - startTime) + "ms. " + "Moving " + totalNumMoved
                + " regions off of " + serversOverloaded + " overloaded servers onto " + serversUnderloaded
                + " less loaded servers");
        return regionsToReturn;
    }

    // Need to do a second pass.
    // Either more regions to assign out or servers that are still underloaded

    // If we need more to fill min, grab one from each most loaded until enough
    if (neededRegions != 0) {
        // Walk down most loaded, grabbing one from each until we get enough
        for (Map.Entry<ServerAndLoad, List<HRegionInfo>> server : serversByLoad.descendingMap().entrySet()) {
            BalanceInfo balanceInfo = serverBalanceInfo.get(server.getKey().getServerName());
            int idx = balanceInfo == null ? 0 : balanceInfo.getNextRegionForUnload();
            if (idx >= server.getValue().size())
                break;
            HRegionInfo region = server.getValue().get(idx);
            if (region.isMetaRegion())
                continue; // Don't move meta regions.
            regionsToMove.add(new RegionPlan(region, server.getKey().getServerName(), null));
            totalNumMoved++;
            if (--neededRegions == 0) {
                // No more regions needed, done shedding
                break;
            }
        }
    }

    // Now we have a set of regions that must be all assigned out
    // Assign each underloaded up to the min, then if leftovers, assign to max

    // Walk down least loaded, assigning to each to fill up to min
    for (Map.Entry<ServerAndLoad, List<HRegionInfo>> server : serversByLoad.entrySet()) {
        int regionCount = server.getKey().getLoad();
        if (regionCount >= min)
            break;
        BalanceInfo balanceInfo = serverBalanceInfo.get(server.getKey().getServerName());
        if (balanceInfo != null) {
            regionCount += balanceInfo.getNumRegionsAdded();
        }
        if (regionCount >= min) {
            continue;
        }
        int numToTake = min - regionCount;
        int numTaken = 0;
        while (numTaken < numToTake && 0 < regionsToMove.size()) {
            addRegionPlan(regionsToMove, fetchFromTail, server.getKey().getServerName(), regionsToReturn);
            numTaken++;
            if (emptyRegionServerPresent) {
                fetchFromTail = !fetchFromTail;
            }
        }
    }

    // If we still have regions to dish out, assign underloaded to max
    if (0 < regionsToMove.size()) {
        for (Map.Entry<ServerAndLoad, List<HRegionInfo>> server : serversByLoad.entrySet()) {
            int regionCount = server.getKey().getLoad();
            if (regionCount >= max) {
                break;
            }
            addRegionPlan(regionsToMove, fetchFromTail, server.getKey().getServerName(), regionsToReturn);
            if (emptyRegionServerPresent) {
                fetchFromTail = !fetchFromTail;
            }
            if (regionsToMove.isEmpty()) {
                break;
            }
        }
    }

    long endTime = System.currentTimeMillis();

    if (!regionsToMove.isEmpty() || neededRegions != 0) {
        // Emit data so can diagnose how balancer went astray.
        LOG.warn("regionsToMove=" + totalNumMoved + ", numServers=" + numServers + ", serversOverloaded="
                + serversOverloaded + ", serversUnderloaded=" + serversUnderloaded);
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<ServerName, List<HRegionInfo>> e : clusterState.entrySet()) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(e.getKey().toString());
            sb.append(" ");
            sb.append(e.getValue().size());
        }
        LOG.warn("Input " + sb.toString());
    }

    // All done!
    LOG.info("Done. Calculated a load balance in " + (endTime - startTime) + "ms. " + "Moving " + totalNumMoved
            + " regions off of " + serversOverloaded + " overloaded servers onto " + serversUnderloaded
            + " less loaded servers");

    return regionsToReturn;
}

From source file:base.BasePlayer.FileRead.java

static void removeNonListVariants() {

    VarNode node = FileRead.head.getNext();
    VarNode tempNode;/*w w w.j a v a  2 s .c om*/
    Map.Entry<String, ArrayList<SampleNode>> entry;
    int mutcount = 0;
    while (node != null) {

        if (!node.inVarList || Main.drawCanvas.hideNode(node)) {
            tempNode = node.getNext();
            node.removeNode();
            node = tempNode;
        } else {
            for (int v = 0; v < node.vars.size(); v++) {
                entry = node.vars.get(v);
                mutcount = 0;
                for (int m = 0; m < entry.getValue().size(); m++) {
                    if (entry.getValue().get(m).alleles != null) {
                        break;
                    }
                    if (!Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                        if (VariantHandler.onlyselected.isSelected()) {
                            if (!entry.getValue().get(m).getSample().equals(Main.drawCanvas.selectedSample)) {
                                entry.getValue().remove(m);
                                m--;
                                continue;
                            }
                        }
                        mutcount++;
                    } else {
                        entry.getValue().remove(m);
                        m--;
                    }
                }
            }
            if (mutcount == 0) {
                tempNode = node.getNext();
                node.removeNode();
                node = tempNode;
            } else {
                node = node.getNext();
            }
        }
    }
    node = null;
    tempNode = null;
    entry = null;
    Main.drawCanvas.current = FileRead.head;

    Draw.updatevars = true;
    Main.drawCanvas.repaint();
}

From source file:base.BasePlayer.FileRead.java

VarNode annotateVariant(VarNode vardraw) {

    if (Main.drawCanvas.hideNode(vardraw)) {

        returnnode = vardraw.getNext();/*from w  ww  .j  ava2s .  c o m*/
        if (VariantHandler.allChroms.isSelected()) {
            vardraw.removeNode();
        }
        return returnnode;
    }

    Map.Entry<String, ArrayList<SampleNode>> entry = null;
    String base = null, amino = null;
    int pretrack = -1, preI = -1;

    Main.drawCanvas.loadbarAll = (int) ((vardraw.getPosition()
            / (double) (Main.drawCanvas.splits.get(0).chromEnd)) * 100);
    Main.drawCanvas.loadBarSample = Main.drawCanvas.loadbarAll;
    boolean recessivefound = false;
    for (int v = 0; v < vardraw.vars.size(); v++) {
        entry = vardraw.vars.get(v);

        if (Main.drawCanvas.hideNodeVar(vardraw, entry)) {
            if (VariantHandler.allChroms.isSelected()) {
                vardraw.vars.remove(v);
                v--;
            }
            continue;
        }
        if (Main.drawCanvas.annotationOn) {
            if (vardraw.vars.size() == 1 && vardraw.vars.get(0).getValue().size() == 1
                    && vardraw.vars.get(0).getValue().get(0).getSample().annotation) {
                if (VariantHandler.allChroms.isSelected()) {
                    vardraw.vars.remove(v);
                    v--;
                }
                continue;
            }
        }
        recessivefound = false;

        base = entry.getKey();
        mutcount = 0;
        if (!VariantHandler.none.isSelected()) {
            if (VariantHandler.recessiveHomo.isSelected()) {
                if (!checkRecessiveHomo(vardraw, entry))
                    continue;
            } else if (VariantHandler.denovo.isSelected()) {
                if (!checkDeNovo(vardraw, entry))
                    continue;
            } else if (VariantHandler.dominant.isSelected()) {
                if (!checkDominant(vardraw, entry))
                    continue;
            } else if (VariantHandler.xLinked.isSelected()) {
                if (!checkXlinked(vardraw, entry))
                    continue;
            } else if (VariantHandler.compound.isSelected()) {
                if (!checkCompound(vardraw, entry))
                    continue;
            } else if (VariantHandler.recessive.isSelected()) {
                recessivefound = checkRecessiveHomo(vardraw, entry);
                if (!recessivefound) {
                    if (Main.chromosomeDropdown.getSelectedItem().equals("X")) {
                        recessivefound = checkXlinked(vardraw, entry);
                    }
                }
                if (!recessivefound) {
                    if (!checkCompound(vardraw, entry)) {
                        continue;
                    }
                }
            }
        }

        for (int m = 0; m < entry.getValue().size(); m++) {
            if (entry.getValue().get(m).alleles != null) {
                break;
            }

            if (Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                if (VariantHandler.allChroms.isSelected()) {
                    entry.getValue().remove(m);
                    m--;

                }
                continue;
            }
            if (entry.getValue().get(m).getSample().annotation) {
                continue;
            }

            sample = entry.getValue().get(m).getSample();
            if (VariantHandler.onlyselected.isSelected()) {
                if (!sample.equals(Main.drawCanvas.selectedSample)) {
                    continue;
                }
            }
            sample.varcount++;
            mutcount++;
            VariantHandler.stattable.variants++;
            if (vardraw.coding) {
                sample.coding++;
            }
            sample.callrates += entry.getValue().get(m).getAlleleFraction();

            if (entry.getValue().get(m).isHomozygous()) {
                sample.homozygotes++;
            } else {
                sample.heterozygotes++;
            }
            if (entry.getKey().length() > 1) {
                if (entry.getKey().contains("del")) {
                    sample.indels++;
                } else {
                    sample.ins++;
                }
            } else {
                //TODO
                //System.out.println((int)(MethodLibrary.round(entry.getValue().get(m).getAlleleFraction(),4)*10000));
                //array[entry.getValue().get(m).getSample().getIndex()][(int)(MethodLibrary.round(entry.getValue().get(m).getAlleleFraction(),5)*10000)]++;
                /*if(sample.getName().contains("161")) {
                   if(Main.getBase.get(vardraw.getRefBase()).equals("C")) {
                      if(base.equals("A")) {
                System.out.println(vardraw.getChrom() +":" +vardraw.getPosition());
                      }                  
                   }
                }*/
                if (VariantHandler.onlyStats.isSelected()) {
                    if (VariantHandler.outputContexts.isSelected()) {
                        String context = Main.chromDraw.getSeq(Main.drawCanvas.splits.get(0).chrom,
                                vardraw.getPosition() - 1, vardraw.getPosition() + 2, Main.referenceFile)
                                .toString();

                        //boolean set = false;
                        if (contexts == null) {
                            contexts = new HashMap<String, Integer[]>();
                            //contextQuals =  new HashMap<String, Float[]>();
                        }
                        /*
                        if(base.equals("T")) {
                           if(context.endsWith("CG")) {   
                              set = true;
                           }
                        }   
                        if(base.equals("A")) {
                           if(context.startsWith("CG")) {   
                              set = true;
                           }
                        }*/
                        //   if(set) {

                        basecontext = base + context;

                        if (contexts.containsKey(base + context)) {
                            if (contexts.get(base + context)[sample.getIndex()] == null) {
                                contexts.get(base + context)[sample.getIndex()] = 1;
                                //contextQuals.get(base+context)[0]++;                              
                                //   contextQuals.get(base+context)[1] += entry.getValue().get(m).getQuality();
                            } else {
                                contexts.get(base + context)[sample.getIndex()]++;
                                //contextQuals.get(base+context)[0]++;                              
                                //contextQuals.get(base+context)[1] += entry.getValue().get(m).getQuality();
                            }
                        } else {
                            if (contexts.containsKey(MethodLibrary.reverseComplement(base)
                                    + MethodLibrary.reverseComplement(context))) {
                                if (contexts.get(MethodLibrary.reverseComplement(base)
                                        + MethodLibrary.reverseComplement(context))[sample
                                                .getIndex()] == null) {
                                    contexts.get(MethodLibrary.reverseComplement(base)
                                            + MethodLibrary.reverseComplement(context))[sample.getIndex()] = 1;
                                    //contextQuals.get(MethodLibrary.reverseComplement(base)+MethodLibrary.reverseComplement(context))[0] = 1F;                              
                                    //contextQuals.get(MethodLibrary.reverseComplement(base)+MethodLibrary.reverseComplement(context))[1] = entry.getValue().get(m).getQuality();
                                } else {
                                    contexts.get(MethodLibrary.reverseComplement(base)
                                            + MethodLibrary.reverseComplement(context))[sample.getIndex()]++;
                                    //contextQuals.get(MethodLibrary.reverseComplement(base)+MethodLibrary.reverseComplement(context))[0]++;                              
                                    //contextQuals.get(MethodLibrary.reverseComplement(base)+MethodLibrary.reverseComplement(context))[1] += entry.getValue().get(m).getQuality();
                                }
                            } else {
                                contexts.put(base + context, new Integer[Main.drawCanvas.sampleList.size()]);
                                contexts.get(base + context)[sample.getIndex()] = 1;
                                //contextQuals.put(base+context, new Float[2]);
                                //contextQuals.get(base+context)[0] = 1F;                              
                                //contextQuals.get(base+context)[1] = entry.getValue().get(m).getQuality();
                            }
                        }
                    }
                    //      } 
                }

                sample.snvs++;

                try {
                    if (!Main.getBase.get(vardraw.getRefBase()).equals("N") && !entry.getKey().equals("N")
                            && !entry.getKey().equals(".")) {

                        sample.mutationTypes[Main.mutTypes
                                .get(Main.getBase.get(vardraw.getRefBase()) + entry.getKey())]++;

                    }
                } catch (Exception e) {

                    System.out.println(
                            sample.getName() + " " + vardraw.getPosition() + " " + (char) vardraw.getRefBase()
                                    + " " + Main.getBase.get(vardraw.getRefBase()) + " " + entry.getKey());
                    e.printStackTrace();
                }
                if (((char) vardraw.getRefBase() == 'A' && entry.getKey().equals("G"))
                        || ((char) vardraw.getRefBase() == 'G' && entry.getKey().equals("A"))
                        || ((char) vardraw.getRefBase() == 'C' && entry.getKey().equals("T"))
                        || ((char) vardraw.getRefBase() == 'T' && entry.getKey().equals("C"))) {
                    sample.sitioRate++;
                } else {
                    sample.versioRate++;
                }
            }
        }
        if (mutcount == 0) {
            continue;
        }
        // INTRONIC

        if (VariantHandler.intronic.isSelected() && vardraw.isInGene() && vardraw.getTranscripts() != null
                && vardraw.getExons() == null) {

            for (int t = 0; t < vardraw.getTranscripts().size(); t++) {

                for (int i = 0; i < entry.getValue().size(); i++) {
                    if (entry.getValue().get(i).alleles != null) {
                        break;
                    }
                    if (entry.getValue().get(i).getSample().annotation) {
                        continue;
                    }
                    if (Main.drawCanvas.hideVar(entry.getValue().get(i), entry.getKey().length() > 1)) {
                        if (VariantHandler.allChroms.isSelected()) {
                            entry.getValue().remove(i);
                            i--;
                        }
                        continue;
                    }
                    if (VariantHandler.onlyselected.isSelected()) {
                        if (!entry.getValue().get(i).getSample().equals(Main.drawCanvas.selectedSample)) {
                            continue;
                        }
                    }
                    if (!vardraw.getTranscripts().get(t).getGene().samples
                            .contains(entry.getValue().get(i).getSample())) {
                        vardraw.getTranscripts().get(t).getGene().samples
                                .add(entry.getValue().get(i).getSample());
                    }
                }

                if (!VariantHandler.onlyStats.isSelected()) {
                    boolean add = true;
                    if (VariantHandler.recessive.isSelected()) {

                        if (!recessivefound) {
                            add = checkCompoundGene(vardraw.getTranscripts().get(t).getGene(), vardraw);
                        }
                    } else if (VariantHandler.compound.isSelected()) {
                        add = checkCompoundGene(vardraw.getTranscripts().get(t).getGene(), vardraw);

                    }
                    if (add && vardraw.getTranscripts().get(t).getGene().mutations == 0
                            && vardraw.getTranscripts().get(t).getGene().samples
                                    .size() >= VariantHandler.geneSlider.getValue()) {
                        VariantHandler.table.addEntry(vardraw.getTranscripts().get(t).getGene());
                        VariantHandler.table.revalidate();
                        VariantHandler.table.repaint();
                    }
                }
                vardraw.getTranscripts().get(t).getGene().intronic += mutcount;
                vardraw.inVarList = true;

                if (vardraw.inVarList) {

                    if (!vardraw.getTranscripts().get(t).getGene().varnodes.contains(vardraw)) {
                        if (!VariantHandler.onlyStats.isSelected()) {
                            vardraw.getTranscripts().get(t).getGene().varnodes.add(vardraw);
                        }
                        preI = -1;
                    }
                    if (v != preI) {
                        VariantHandler.table.variants += mutcount;
                        vardraw.getTranscripts().get(t).getGene().mutations += mutcount;
                        preI = v;
                    }

                }
            }
        }
        /*if(vardraw.getPosition() == 70117871) {
           System.out.println(vardraw.getExons());
        }*/

        if (vardraw != null && vardraw.getExons() != null) {
            ArrayList<Gene> calcgene = new ArrayList<Gene>();
            for (int exon = 0; exon < vardraw.getExons().size(); exon++) {

                amino = Main.chromDraw.getAminoChange(vardraw, base, vardraw.getExons().get(exon));

                if (amino.contains("UTR")) {

                    if (VariantHandler.utr.isSelected()) {
                        if (!VariantHandler.table.genearray
                                .contains(vardraw.getExons().get(exon).getTranscript().getGene())
                                && vardraw.getExons().get(exon).getTranscript().getGene().samples
                                        .size() >= VariantHandler.geneSlider.getValue()) {
                            if (!VariantHandler.onlyStats.isSelected()) {
                                boolean add = true;
                                if (VariantHandler.recessive.isSelected()) {

                                    if (!recessivefound) {
                                        add = checkCompoundGene(
                                                vardraw.getExons().get(exon).getTranscript().getGene(),
                                                vardraw);
                                    }
                                } else if (VariantHandler.compound.isSelected()) {
                                    add = checkCompoundGene(
                                            vardraw.getExons().get(exon).getTranscript().getGene(), vardraw);

                                }
                                if (add) {
                                    VariantHandler.table
                                            .addEntry(vardraw.getExons().get(exon).getTranscript().getGene());
                                }
                            }
                        }

                        vardraw.inVarList = true;
                        vardraw.getExons().get(exon).getTranscript().getGene().utr += mutcount;

                    } else {
                        continue;
                    }
                }

                if (VariantHandler.nonsense.isSelected()) {
                    if (!MethodLibrary.aminoEffect(amino).contains("nonsense")) {
                        continue;
                    }
                }
                if (VariantHandler.synonymous.isSelected()) {

                    if (MethodLibrary.aminoEffect(amino).contains("synonymous")) {

                        continue;
                    }
                }

                for (int i = 0; i < entry.getValue().size(); i++) {
                    if (entry.getValue().get(i).alleles != null) {
                        break;
                    }
                    if (entry.getValue().get(i).getSample().annotation) {
                        continue;
                    }
                    if (Main.drawCanvas.hideVar(entry.getValue().get(i), entry.getKey().length() > 1)) {
                        continue;
                    }
                    if (VariantHandler.onlyselected.isSelected()) {
                        if (!entry.getValue().get(i).getSample().equals(Main.drawCanvas.selectedSample)) {
                            continue;
                        }
                    }
                    if (!vardraw.getExons().get(exon).getTranscript().getGene().samples
                            .contains(entry.getValue().get(i).getSample())) {
                        if (!VariantHandler.onlyStats.isSelected()) {
                            vardraw.getExons().get(exon).getTranscript().getGene().samples
                                    .add(entry.getValue().get(i).getSample());
                        }
                    }
                }
                boolean add = true;
                if (!VariantHandler.onlyStats.isSelected()) {
                    if (VariantHandler.recessive.isSelected()) {

                        if (!recessivefound) {
                            add = checkCompoundGene(vardraw.getExons().get(exon).getTranscript().getGene(),
                                    vardraw);
                        }
                    } else if (VariantHandler.compound.isSelected()) {
                        add = checkCompoundGene(vardraw.getExons().get(exon).getTranscript().getGene(),
                                vardraw);

                    }

                    if (add && !VariantHandler.table.genearray
                            .contains(vardraw.getExons().get(exon).getTranscript().getGene())
                            && vardraw.getExons().get(exon).getTranscript().getGene().samples
                                    .size() >= VariantHandler.geneSlider.getValue()) {
                        VariantHandler.table.addEntry(vardraw.getExons().get(exon).getTranscript().getGene());
                    }
                }
                if (MethodLibrary.aminoEffect(amino).contains("nonsense")) {
                    if (!calcgene.contains(vardraw.getExons().get(exon).getTranscript().getGene())) {
                        for (int i = 0; i < entry.getValue().size(); i++) {
                            if (entry.getValue().get(i).alleles != null) {
                                break;
                            }
                            if (entry.getValue().get(i).getSample().annotation) {
                                continue;
                            }
                            if (Main.drawCanvas.hideVar(entry.getValue().get(i), entry.getKey().length() > 1)) {
                                continue;
                            }
                            entry.getValue().get(i).getSample().nonsense++;
                            if (entry.getKey().length() > 1) {
                                entry.getValue().get(i).getSample().fshift++;
                            }
                            if (amino.contains("spl")) {
                                entry.getValue().get(i).getSample().splice++;
                            } else {
                                entry.getValue().get(i).getSample().nonsyn++;
                            }
                        }

                    }
                    vardraw.getExons().get(exon).getTranscript().getGene().nonsense += mutcount;

                } else if (MethodLibrary.aminoEffect(amino).contains("missense")) {
                    if (!calcgene.contains(vardraw.getExons().get(exon).getTranscript().getGene())) {
                        for (int i = 0; i < entry.getValue().size(); i++) {
                            if (entry.getValue().get(i).alleles != null) {
                                break;
                            }
                            if (entry.getValue().get(i).getSample().annotation) {
                                continue;
                            }
                            if (Main.drawCanvas.hideVar(entry.getValue().get(i), entry.getKey().length() > 1)) {
                                continue;
                            }
                            if (entry.getKey().length() > 1) {
                                entry.getValue().get(i).getSample().inframe++;
                            }
                            entry.getValue().get(i).getSample().missense++;
                            entry.getValue().get(i).getSample().nonsyn++;
                        }
                    }
                    vardraw.getExons().get(exon).getTranscript().getGene().missense += mutcount;
                } else if (MethodLibrary.aminoEffect(amino).contains("synonymous")) {
                    if (!calcgene.contains(vardraw.getExons().get(exon).getTranscript().getGene())) {
                        for (int i = 0; i < entry.getValue().size(); i++) {
                            if (entry.getValue().get(i).alleles != null) {
                                break;
                            }
                            if (entry.getValue().get(i).getSample().annotation) {
                                continue;
                            }
                            if (Main.drawCanvas.hideVar(entry.getValue().get(i), entry.getKey().length() > 1)) {
                                continue;
                            }
                            entry.getValue().get(i).getSample().syn++;
                        }
                    }
                    vardraw.getExons().get(exon).getTranscript().getGene().synonymous += mutcount;
                }

                vardraw.inVarList = true;
                if (!vardraw.getExons().get(exon).getTranscript().getGene().varnodes.contains(vardraw)) {
                    if (!VariantHandler.onlyStats.isSelected()) {
                        vardraw.getExons().get(exon).getTranscript().getGene().varnodes.add(vardraw);
                    }
                    preI = -1;

                }
                if (v != preI) {
                    vardraw.getExons().get(exon).getTranscript().getGene().mutations += mutcount;
                    VariantHandler.table.variants += mutcount;
                    preI = v;
                }

                VariantHandler.table.revalidate();
                VariantHandler.table.repaint();
                if (!calcgene.contains(vardraw.getExons().get(exon).getTranscript().getGene())) {
                    calcgene.add(vardraw.getExons().get(exon).getTranscript().getGene());
                }
            }
        }
        preI = v;

        if (!vardraw.isInGene() && VariantHandler.intergenic.isSelected()) {

            /*
            for(int v = 0; v<vardraw.vars.size(); v++) {
                entry = vardraw.vars.get(v);
               if(Main.drawCanvas.hideNodeVar(vardraw, entry)) {
                  continue;
               }         
                       
               base = entry.getKey();
               mutcount = 0;
                       
               for(int m = 0; m<entry.getValue().size(); m++) {
                     if(entry.getValue().get(m).alleles != null) {
             break;
                     }
                          
                     if(Main.drawCanvas.hideVar(entry.getValue().get(m))) {
             continue;
                     }
                     mutcount++;
                             
               }            
             */

            if (mutcount > 0) {

                if (VariantHandler.table.genearray.size() == 0
                        || !VariantHandler.table.genearray
                                .get(VariantHandler.table.genearray.size() - 1).intergenic
                        || !VariantHandler.table.genearray.get(VariantHandler.table.genearray.size() - 1)
                                .getName().equals(vardraw.getTranscripts().get(0).getGene().getName())) {
                    Gene addgene = null;
                    try {
                        addgene = new Gene(vardraw.getTranscripts().get(0).getGene());

                    } catch (Exception e) {
                        e.printStackTrace();
                        //Main.drawCanvas.ready("all");
                        break;
                    }
                    addgene.intergenic = true;
                    addgene.mutations = mutcount;
                    VariantHandler.table.variants += mutcount;
                    if (!VariantHandler.onlyStats.isSelected()) {
                        addgene.varnodes.add(vardraw);
                        boolean add = true;
                        if (VariantHandler.recessive.isSelected()) {

                            if (!recessivefound) {
                                add = checkCompoundGene(addgene, vardraw);
                            }
                        } else if (VariantHandler.compound.isSelected()) {
                            add = checkCompoundGene(addgene, vardraw);

                        }
                        if (add) {
                            VariantHandler.table.addEntry(addgene);
                        }
                    }
                    for (int m = 0; m < entry.getValue().size(); m++) {
                        if (entry.getValue().get(m).alleles != null) {
                            break;
                        }
                        if (entry.getValue().get(m).getSample().annotation) {
                            continue;
                        }
                        if (Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                            continue;
                        }
                        if (!addgene.samples.contains(entry.getValue().get(m).getSample())) {
                            if (!VariantHandler.onlyStats.isSelected()) {
                                addgene.samples.add(entry.getValue().get(m).getSample());
                            }
                        }
                    }
                } else {
                    if (!VariantHandler.onlyStats.isSelected()) {

                        VariantHandler.table.genearray
                                .get(VariantHandler.table.genearray.size() - 1).mutations += mutcount;
                        if (!VariantHandler.table.genearray
                                .get(VariantHandler.table.genearray.size() - 1).varnodes.contains(vardraw)) {
                            VariantHandler.table.genearray
                                    .get(VariantHandler.table.genearray.size() - 1).varnodes.add(vardraw);
                        }

                    }
                    VariantHandler.table.variants += mutcount;
                    for (int m = 0; m < entry.getValue().size(); m++) {
                        if (entry.getValue().get(m).alleles != null) {
                            break;
                        }
                        if (entry.getValue().get(m).getSample().annotation) {
                            continue;
                        }
                        if (Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                            continue;
                        }
                        if (!VariantHandler.table.genearray
                                .get(VariantHandler.table.genearray.size() - 1).samples
                                        .contains(entry.getValue().get(m).getSample())) {
                            if (!VariantHandler.onlyStats.isSelected()) {
                                VariantHandler.table.genearray
                                        .get(VariantHandler.table.genearray.size() - 1).samples
                                                .add(entry.getValue().get(m).getSample());
                            }
                        }
                    }
                    //      }

                }
                vardraw.inVarList = true;
            }

        }
        //TODO TAHAN 
        //   System.out.println(vardraw.getTranscripts().get(0).getGenename() +"..." +vardraw.getTranscripts().get(1).getGenename() );
    }

    if (!vardraw.inVarList) {
        returnnode = vardraw.getNext();
        if (VariantHandler.allChroms.isSelected()) {
            vardraw.removeNode();
        }
        return returnnode;

    } else {
        mutcount = 0;
        for (int v = 0; v < vardraw.vars.size(); v++) {
            entry = vardraw.vars.get(v);

            if (Main.drawCanvas.hideNodeVar(vardraw, entry)) {
                if (VariantHandler.allChroms.isSelected()) {
                    vardraw.vars.remove(v);
                    v--;
                }
                continue;
            }

            base = entry.getKey();

            for (int m = 0; m < entry.getValue().size(); m++) {
                if (entry.getValue().get(m).alleles != null) {
                    break;
                }
                if (entry.getValue().get(m).getSample().annotation) {
                    continue;
                }
                if (Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                    if (VariantHandler.allChroms.isSelected()) {
                        entry.getValue().remove(m);
                        m--;
                    }
                    continue;
                }

                mutcount++;
            }
        }

        if (VariantHandler.commonSlider.getValue() > 1 && VariantHandler.clusterSize > 0) {

            if (Main.drawCanvas.clusterNodes.size() == 0) {

                ClusterNode cluster = new ClusterNode();
                cluster.nodecount = mutcount;
                cluster.ID = vardraw.clusterId;
                vardraw.clusterNode = cluster;
                cluster.varnodes.add(vardraw);
                cluster.width = 1;
                Main.drawCanvas.clusterNodes.add(cluster);

            } else if (Main.drawCanvas.clusterNodes
                    .get(Main.drawCanvas.clusterNodes.size() - 1).ID != vardraw.clusterId) {

                Main.drawCanvas.clusterNodes
                        .get(Main.drawCanvas.clusterNodes.size() - 1).width = Main.drawCanvas.clusterNodes
                                .get(Main.drawCanvas.clusterNodes.size() - 1).varnodes
                                        .get(Main.drawCanvas.clusterNodes
                                                .get(Main.drawCanvas.clusterNodes.size() - 1).varnodes.size()
                                                - 1)
                                        .getPosition()
                                - Main.drawCanvas.clusterNodes
                                        .get(Main.drawCanvas.clusterNodes.size() - 1).varnodes.get(0)
                                                .getPosition()
                                + 1;
                ClusterNode cluster = new ClusterNode();
                cluster.nodecount += mutcount;
                cluster.ID = vardraw.clusterId;
                vardraw.clusterNode = cluster;
                cluster.varnodes.add(vardraw);
                cluster.width = 1;
                Main.drawCanvas.clusterNodes.add(cluster);
            } else {

                vardraw.clusterNode = Main.drawCanvas.clusterNodes.get(Main.drawCanvas.clusterNodes.size() - 1);
                Main.drawCanvas.clusterNodes.get(Main.drawCanvas.clusterNodes.size() - 1).nodecount += mutcount;
                Main.drawCanvas.clusterNodes.get(Main.drawCanvas.clusterNodes.size() - 1).varnodes.add(vardraw);
            }

            VariantHandler.clusterTable.variants += mutcount;

        }
        if (!VariantHandler.writetofile.isSelected()) {
            if (vardraw != null && vardraw.inVarList && vardraw.bedhit && vardraw.getBedHits() != null) {

                pretrack = -1;
                for (int i = 0; i < vardraw.getBedHits().size(); i++) {

                    vardraw.getBedHits().get(i).inVarlist = true;

                    if (pretrack != vardraw.getBedHits().get(i).getTrack().trackIndex) {
                        vardraw.getBedHits().get(i).getTrack().getTable().variants += mutcount;
                        pretrack = vardraw.getBedHits().get(i).getTrack().trackIndex;
                    }
                    if (vardraw.getBedHits().get(i).getTrack().getTable().bedarray == null) {
                        vardraw.getBedHits().get(i).getTrack().getTable().bedarray = new ArrayList<BedNode>();
                    }
                    if (!vardraw.getBedHits().get(i).getTrack().getTable().bedarray
                            .contains(vardraw.getBedHits().get(i))) {

                        vardraw.getBedHits().get(i).mutations += mutcount;

                        vardraw.getBedHits().get(i).getTrack().getTable().bedarray
                                .add(vardraw.getBedHits().get(i));
                        vardraw.getBedHits().get(i).getTrack().getTable()
                                .setPreferredSize(new Dimension(
                                        vardraw.getBedHits().get(i).getTrack().getTable().tablescroll
                                                .getViewport().getWidth(),
                                        (vardraw.getBedHits().get(i).getTrack().getTable().getTableSize() + 2
                                                + samplecount)
                                                * vardraw.getBedHits().get(i).getTrack().getTable().rowHeight));
                        vardraw.getBedHits().get(i).getTrack().getTable().revalidate();

                        //   vardraw.inVarList = true;
                    } else {
                        vardraw.getBedHits().get(i).mutations += mutcount;
                        //   vardraw.inVarList = true;

                    }
                }
            }
        }
    }
    if (VariantHandler.writetofile.isSelected()) {

        writeToFile(vardraw, output, outputgz);
    }
    lastVar = vardraw;

    return vardraw.getNext();
    //   }
}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * Dokumentation anzeigen//  w w  w  .j  av a2s.  c  o m
 * 
 * @throws Exception
 */

private void showDocumentation() throws Exception {
    this.debug(3, "showDocumentation");

    StringBuffer sqlStmt = new StringBuffer(
            "select \"TITLE\",\"APPLICATION\",\"SECTION\",\"NAME\",\"VALUE\",\"DISPLAY_TYPE\",\"INPUT_TYPE\" from "
                    + this.settings.source);

    String sqlAnd = " where ";

    String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries")
            .split(";");
    String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries")
            .split(";");

    if (this.settings.section.equals(this.settings.entrySchemaSection)) {
        this.settings.section = this.settings.entrySchemaSection;
    }

    if (!this.settings.application.equals("")) {
        sqlStmt.append(sqlAnd + " \"" + this.settings.entryApplication + "\" = "
                + this.dbQuoted(this.settings.application));
        sqlAnd = " and ";
    }
    if (!this.settings.section.equals("")) {
        sqlStmt.append(
                sqlAnd + " \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section));
        sqlAnd = " and ";
    }

    sqlStmt.append(" order by \"" + this.settings.entryApplication + "\",\"" + this.settings.entrySection
            + "\",\"" + this.settings.entryName + "\"");

    try {
        Vector results = this.connection.getArrayAsVector(sqlStmt.toString());

        LinkedHashMap applications = new LinkedHashMap();
        LinkedHashMap sections = new LinkedHashMap();
        LinkedHashMap entries = new LinkedHashMap();

        for (Enumeration el = results.elements(); el.hasMoreElements();) {
            HashMap result = (HashMap) el.nextElement();
            if (result.get("application").toString().equals(result.get("section").toString())
                    && result.get("application").toString().equals(result.get("name").toString())) {

                applications.put(result.get("application").toString(), result);

            } else if (result.get("section").toString().equals(result.get("name").toString())
                    && !result.get("section").toString().equals(result.get("application").toString())) {

                String key = result.get("application").toString();
                LinkedHashMap section = new LinkedHashMap();

                if (sections.containsKey(key)) {
                    section = (LinkedHashMap) sections.get(key);
                }
                section.put(result.get("section").toString(), result);
                sections.put(key, section);

            } else {
                String appKey = result.get("application").toString();
                String secKey = result.get("section").toString();

                LinkedHashMap section = new LinkedHashMap();
                LinkedHashMap entry = new LinkedHashMap();

                if (entries.containsKey(appKey)) {
                    section = (LinkedHashMap) entries.get(appKey);
                    if (section.containsKey(secKey)) {
                        entry = (LinkedHashMap) section.get(secKey);
                    }
                }
                entry.put(result.get("name").toString(), result);
                section.put(secKey, entry);
                entries.put(appKey, section);

            }

        }
        //out.print(entries);

        results = null;
        this.styleBorder = "1\" bgcolor=\"#ffffff\" bordercolorlight=\"#D2D2D2\" bordercolordark=\"#ffffff";

        this.showTableBegin();
        if (applications.size() != 0) {
            Iterator appIt = applications.entrySet().iterator();
            while (appIt.hasNext()) {
                Map.Entry application = (Map.Entry) appIt.next();
                String app_key = application.getKey().toString();
                HashMap app_value = (HashMap) application.getValue();
                this.out.println("<tr>");
                this.out.println("   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                        + app_value.get("title") + "</td>");
                this.out.println("   <td nowrap>" + app_value.get("name") + "</td>");
                this.out.println("   <td nowrap>&nbsp;</td>");
                this.out.println("</tr>");
                if (sections.containsKey(app_key)) {
                    HashMap appSections = (HashMap) sections.get(app_key);
                    Iterator secIt = appSections.entrySet().iterator();
                    while (secIt.hasNext()) {
                        Map.Entry section = (Map.Entry) secIt.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        if (!sec_value.get("name").toString().equals(this.settings.entrySchemaSection)) {
                            this.out.println("<tr>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println(
                                    "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                            + sec_value.get("title") + "</td>");
                            this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println("</tr>");
                            if (entries.containsKey(app_key)) {
                                HashMap secEntrie = (HashMap) entries.get(app_key);
                                if (secEntrie.containsKey(sec_key)) {
                                    HashMap secEntries = (HashMap) secEntrie.get(sec_key);

                                    Iterator entIt = secEntries.entrySet().iterator();
                                    while (entIt.hasNext()) {
                                        Map.Entry entry = (Map.Entry) entIt.next();
                                        String ent_key = entry.getKey().toString();
                                        HashMap ent_value = (HashMap) entry.getValue();

                                        this.out.println("<tr>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                                + ent_value.get("title") + "</td>");
                                        this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                                + ent_value.get("name") + "</td>");
                                        this.out.println("   <td nowrap valign=\"top\">");
                                        if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                            this.out.println("[ "
                                                    + this.rb.getMessage(
                                                            "sos.settings.dialog.dialog_long_value_title")
                                                    + " ]");
                                            if (ent_value.get("display_type").toString().equals("4")) {
                                                this.out.println("&nbsp;" + display_type_entries[4]);
                                            }
                                        } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                            this.out.println("[ " + input_type_entries[6] + " ]");
                                        } else {
                                            if (ent_value.get("display_type").toString().endsWith("3")) {
                                                this.out.println("<pre>" + this.htmlSpecialChars(
                                                        ent_value.get("value").toString()) + "</pre>");
                                            } else {
                                                this.out.println(
                                                        this.htmlSpecialChars(ent_value.get("value").toString())
                                                                + "&nbsp;");
                                            }
                                        }
                                        this.out.println("   </td>");
                                        this.out.println("</tr>");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // if applications
        else if (sections.size() != 0) {
            try {
                HashMap application = this.connection.getSingle("select \"TITLE\",\"NAME\" from "
                        + this.settings.source + " where \"" + this.settings.entryApplication + "\" = "
                        + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection
                        + "\" = " + this.dbQuoted(this.settings.application) + " and \""
                        + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.application));

                Iterator secIt = sections.entrySet().iterator();
                if (sections.containsKey(this.settings.application)) {
                    HashMap appSections = (HashMap) sections.get(this.settings.application);
                    Iterator secI = appSections.entrySet().iterator();
                    while (secI.hasNext()) {
                        Map.Entry section = (Map.Entry) secI.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        this.out.println("<tr>");
                        this.out.println(
                                "   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + application.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + application.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        this.out.println("<tr>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println(
                                "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + sec_value.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        if (entries.containsKey(this.settings.application)) {
                            HashMap secEntrie = (HashMap) entries.get(this.settings.application);
                            if (secEntrie.containsKey(sec_key)) {
                                HashMap secEntries = (HashMap) secEntrie.get(sec_key);
                                Iterator entI = secEntries.entrySet().iterator();
                                while (entI.hasNext()) {
                                    Map.Entry entry = (Map.Entry) entI.next();
                                    String ent_key = entry.getKey().toString();
                                    HashMap ent_value = (HashMap) entry.getValue();

                                    this.out.println("<tr>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                            + ent_value.get("title") + "</td>");
                                    this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                            + ent_value.get("name") + "</td>");
                                    this.out.println("   <td nowrap valign=\"top\">");
                                    if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                        this.out.println("[ " + this.rb.getMessage(
                                                "sos.settings.dialog.dialog_long_value_title") + " ]");
                                        if (ent_value.get("display_type").toString().equals("4")) {
                                            this.out.println("&nbsp;" + display_type_entries[4]);
                                        }
                                    } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                        this.out.println("[ " + input_type_entries[6] + " ]");
                                    } else {
                                        if (ent_value.get("display_type").toString().endsWith("3")) {
                                            this.out.println("<pre>"
                                                    + this.htmlSpecialChars(ent_value.get("value").toString())
                                                    + "</pre>");
                                        } else {
                                            this.out.println(
                                                    this.htmlSpecialChars(ent_value.get("value").toString()));
                                        }
                                    }
                                    this.out.println("   </td>");
                                    this.out.println("</tr>");
                                }
                            }
                        }
                    }
                    //out.print(section);

                }

            } catch (Exception e) {
                this.setError(e.getMessage(), SOSClassUtil.getMethodName());
                return;
            }
        }

        this.showTableEnd();

    } catch (Exception e) {
        this.setError(e.getMessage(), SOSClassUtil.getMethodName());
        return;
    }

}