Example usage for java.util LinkedList get

List of usage examples for java.util LinkedList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:org.apache.sysml.runtime.controlprogram.parfor.opt.PerfTestTool.java

@SuppressWarnings("all")
private static HashMap<Integer, Long> writeResults(String dirname) throws IOException, DMLRuntimeException {
    HashMap<Integer, Long> map = new HashMap<Integer, Long>();
    int count = 1;
    int offset = (MODEL_INTERCEPT ? 1 : 0);
    int cols = MODEL_MAX_ORDER + offset;

    for (Entry<Integer, HashMap<Integer, LinkedList<Double>>> inst : _results.entrySet()) {
        int instID = inst.getKey();
        HashMap<Integer, LinkedList<Double>> instCF = inst.getValue();

        for (Entry<Integer, LinkedList<Double>> cfun : instCF.entrySet()) {
            int tDefID = cfun.getKey();
            long ID = IDHandler.concatIntIDsToLong(instID, tDefID);
            LinkedList<Double> dmeasure = cfun.getValue();

            PerfTestDef def = _regTestDef.get(tDefID);
            LinkedList<Double> dvariable = generateSequence(def.getMin(), def.getMax(), NUM_SAMPLES_PER_TEST);
            int dlen = dvariable.size();
            int plen = def.getInternalVariables().length;

            //write variable data set
            CSVWriter writer1 = new CSVWriter(new FileWriter(dirname + count + "_in1.csv"), ',',
                    CSVWriter.NO_QUOTE_CHARACTER);
            if (plen == 1) //one dimensional function
            {//w w w. j  a v  a2s.  c o m
                //write 1, x, x^2, x^3, ...
                String[] sbuff = new String[cols];
                for (Double val : dvariable) {
                    for (int j = 0; j < cols; j++)
                        sbuff[j] = String.valueOf(Math.pow(val, j + 1 - offset));
                    writer1.writeNext(sbuff);
                }
            } else // multi-dimensional function
            {
                //write 1, x,y,z,x^2,y^2,z^2, xy, xz, yz, xyz

                String[] sbuff = new String[(int) Math.pow(2, plen) - 1 + plen + offset - 1];
                //String[] sbuff = new String[plen+offset];
                if (offset == 1)
                    sbuff[0] = "1";

                //init index stack
                int[] index = new int[plen];
                for (int i = 0; i < plen; i++)
                    index[i] = 0;

                //execute test 
                double[] buff = new double[plen];
                while (index[0] < dlen) {
                    //set buffer values
                    for (int i = 0; i < plen; i++)
                        buff[i] = dvariable.get(index[i]);

                    //core writing
                    for (int i = 1; i <= plen; i++) {
                        if (i == 1) {
                            for (int j = 0; j < plen; j++)
                                sbuff[offset + j] = String.valueOf(buff[j]);
                            for (int j = 0; j < plen; j++)
                                sbuff[offset + plen + j] = String.valueOf(Math.pow(buff[j], 2));
                        } else if (i == 2) {
                            int ix = 0;
                            for (int j = 0; j < plen - 1; j++)
                                for (int k = j + 1; k < plen; k++, ix++)
                                    sbuff[offset + 2 * plen + ix] = String.valueOf(buff[j] * buff[k]);
                        } else if (i == plen) {
                            //double tmp=1;
                            //for( int j=0; j<plen; j++ )
                            //   tmp *= buff[j];
                            //sbuff[offset+2*plen+plen*(plen-1)/2] = String.valueOf(tmp);
                        } else
                            throw new DMLRuntimeException("More than 3 dims currently not supported.");

                    }

                    //for( int i=0; i<plen; i++ )   
                    //   sbuff[offset+i] = String.valueOf( buff[i] );

                    writer1.writeNext(sbuff);

                    //increment indexes
                    for (int i = plen - 1; i >= 0; i--) {
                        if (i == plen - 1)
                            index[i]++;
                        else if (index[i + 1] >= dlen) {
                            index[i]++;
                            index[i + 1] = 0;
                        }
                    }
                }
            }
            writer1.close();

            //write measure data set
            CSVWriter writer2 = new CSVWriter(new FileWriter(dirname + count + "_in2.csv"), ',',
                    CSVWriter.NO_QUOTE_CHARACTER);
            String[] buff2 = new String[1];
            for (Double val : dmeasure) {
                buff2[0] = String.valueOf(val);
                writer2.writeNext(buff2);
            }
            writer2.close();

            map.put(count, ID);
            count++;
        }
    }

    return map;
}

From source file:com.hipu.bdb.util.FileUtils.java

/**
 * Retrieve a number of lines from the file around the given 
 * position, as when paging forward or backward through a file. 
 * /* w w  w  .  ja v  a2 s.  c  o m*/
 * @param file File to retrieve lines
 * @param position offset to anchor lines
 * @param signedDesiredLineCount lines requested; if negative, 
 *        want this number of lines ending with a line containing
 *        the position; if positive, want this number of lines,
 *        all starting at or after position. 
 * @param lines List<String> to insert found lines
 * @param lineEstimate int estimate of line size, 0 means use default
 *        of 128
 * @return LongRange indicating the file offsets corresponding to 
 *         the beginning of the first line returned, and the point
 *         after the end of the last line returned
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public static LongRange pagedLines(File file, long position, int signedDesiredLineCount, List<String> lines,
        int lineEstimate) throws IOException {
    // consider negative positions as from end of file; -1 = last byte
    if (position < 0) {
        position = file.length() + position;
    }

    // calculate a reasonably sized chunk likely to have all desired lines
    if (lineEstimate == 0) {
        lineEstimate = 128;
    }
    int desiredLineCount = Math.abs(signedDesiredLineCount);
    long startPosition;
    long fileEnd = file.length();
    int bufferSize = (desiredLineCount + 5) * lineEstimate;
    if (signedDesiredLineCount > 0) {
        // reading forward; include previous char in case line-end
        startPosition = position - 1;
    } else {
        // reading backward
        startPosition = position - bufferSize + (2 * lineEstimate);
    }
    if (startPosition < 0) {
        startPosition = 0;
    }
    if (startPosition + bufferSize > fileEnd) {
        bufferSize = (int) (fileEnd - startPosition);
    }

    // read that reasonable chunk
    FileInputStream fis = new FileInputStream(file);
    fis.getChannel().position(startPosition);
    byte[] buf = new byte[bufferSize];
    IOUtils.closeQuietly(fis);

    // find all line starts fully in buffer
    // (positions after a line-end, per line-end definition in 
    // BufferedReader.readLine)
    LinkedList<Integer> lineStarts = new LinkedList<Integer>();
    if (startPosition == 0) {
        lineStarts.add(0);
    }
    boolean atLineEnd = false;
    boolean eatLF = false;
    int i;
    for (i = 0; i < bufferSize; i++) {
        if ((char) buf[i] == '\n' && eatLF) {
            eatLF = false;
            continue;
        }
        if (atLineEnd) {
            atLineEnd = false;
            lineStarts.add(i);
            if (signedDesiredLineCount < 0 && startPosition + i > position) {
                // reached next line past position, read no more
                break;
            }
        }
        if ((char) buf[i] == '\r') {
            atLineEnd = true;
            eatLF = true;
            continue;
        }
        if ((char) buf[i] == '\n') {
            atLineEnd = true;
        }
    }
    if (startPosition + i == fileEnd) {
        // add phantom lineStart after end
        lineStarts.add(bufferSize);
    }
    int foundFullLines = lineStarts.size() - 1;

    // if found no lines
    if (foundFullLines < 1) {
        if (signedDesiredLineCount > 0) {
            if (startPosition + bufferSize == fileEnd) {
                // nothing more to read: return nothing
                return new LongRange(fileEnd, fileEnd);
            } else {
                // retry with larger lineEstimate
                return pagedLines(file, position, signedDesiredLineCount, lines,
                        Math.max(bufferSize, lineEstimate));
            }

        } else {
            // try again with much larger line estimate
            // TODO: fail gracefully before growing to multi-MB buffers
            return pagedLines(file, position, signedDesiredLineCount, lines, bufferSize);
        }
    }

    // trim unneeded lines
    while (signedDesiredLineCount > 0 && startPosition + lineStarts.getFirst() < position) {
        // discard lines starting before desired position
        lineStarts.removeFirst();
    }
    while (lineStarts.size() > desiredLineCount + 1) {
        if (signedDesiredLineCount < 0 && (startPosition + lineStarts.get(1) <= position)) {
            // discard from front until reach line containing target position
            lineStarts.removeFirst();
        } else {
            lineStarts.removeLast();
        }
    }
    int firstLine = lineStarts.getFirst();
    int partialLine = lineStarts.getLast();
    LongRange range = new LongRange(startPosition + firstLine, startPosition + partialLine);
    List<String> foundLines = IOUtils
            .readLines(new ByteArrayInputStream(buf, firstLine, partialLine - firstLine));

    if (foundFullLines < desiredLineCount && signedDesiredLineCount < 0 && startPosition > 0) {
        // if needed and reading backward, read more lines from earlier
        range = expandRange(range, pagedLines(file, range.getMinimumLong() - 1,
                signedDesiredLineCount + foundFullLines, lines, bufferSize / foundFullLines));

    }

    lines.addAll(foundLines);

    if (signedDesiredLineCount < 0 && range.getMaximumLong() < position) {
        // did not get line containining start position
        range = expandRange(range, pagedLines(file, partialLine, 1, lines, bufferSize / foundFullLines));
    }

    if (signedDesiredLineCount > 0 && foundFullLines < desiredLineCount && range.getMaximumLong() < fileEnd) {
        // need more forward lines
        range = expandRange(range, pagedLines(file, range.getMaximumLong(), desiredLineCount - foundFullLines,
                lines, bufferSize / foundFullLines));
    }

    return range;
}

From source file:org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.java

/**
 * @param editor//  www  .j  ava  2s. c o  m
 *          the {@link AstEditor} in context of which we work now.
 * @param key
 *          the {@link ComponentDescriptionKey} of requested {@link ComponentDescription}.
 * @param additionalDescriptionInfos
 *          additional {@link ClassResourceInfo}'s to parse after {@link ClassResourceInfo}'s
 *          collected for component {@link Class}. May be empty, but not <code>null</code>.
 * 
 * @return the {@link ComponentDescription} of component with given {@link Class}.
 * @throws Exception
 *           if no {@link ComponentDescription} can be found.
 */
private static ComponentDescription getDescription0(AstEditor editor, ComponentDescriptionKey key,
        List<ClassResourceInfo> additionalDescriptionInfos) throws Exception {
    EditorState state = EditorState.get(editor);
    ILoadingContext context = EditorStateLoadingContext.get(state);
    Class<?> componentClass = key.getComponentClass();
    //
    try {
        // prepare result description
        ComponentDescription componentDescription = new ComponentDescription(key);
        addConstructors(editor.getJavaProject(), componentDescription);
        componentDescription.setBeanInfo(ReflectionUtils.getBeanInfo(componentClass));
        componentDescription.setBeanDescriptor(new IntrospectionHelper(componentClass).getBeanDescriptor());
        // prepare list of description resources, from generic to specific
        LinkedList<ClassResourceInfo> descriptionInfos;
        {
            descriptionInfos = Lists.newLinkedList();
            DescriptionHelper.addDescriptionResources(descriptionInfos, context, componentClass);
            Assert.isTrueException(!descriptionInfos.isEmpty(),
                    ICoreExceptionConstants.DESCRIPTION_NO_DESCRIPTIONS, componentClass.getName());
            // at last append additional description resource
            descriptionInfos.addAll(additionalDescriptionInfos);
        }
        // prepare Digester
        Digester digester;
        {
            digester = new Digester();
            digester.setLogger(new NoOpLog());
            addRules(digester, editor, componentClass);
        }
        // read descriptions from generic to specific
        for (ClassResourceInfo descriptionInfo : descriptionInfos) {
            ResourceInfo resourceInfo = descriptionInfo.resource;
            // read next description
            {
                componentDescription.setCurrentClass(descriptionInfo.clazz);
                digester.push(componentDescription);
                // do parse
                InputStream is = resourceInfo.getURL().openStream();
                try {
                    digester.parse(is);
                } finally {
                    IOUtils.closeQuietly(is);
                }
            }
            // clear parts that can not be inherited
            if (descriptionInfo.clazz == componentClass) {
                setDescriptionWithInnerTags(componentDescription, resourceInfo);
            } else {
                componentDescription.clearCreations();
                componentDescription.setDescription(null);
            }
        }
        // set toolkit
        if (componentDescription.getToolkit() == null) {
            for (int i = descriptionInfos.size() - 1; i >= 0; i--) {
                ClassResourceInfo descriptionInfo = descriptionInfos.get(i);
                ToolkitDescription toolkit = descriptionInfo.resource.getToolkit();
                if (toolkit != null) {
                    componentDescription.setToolkit(toolkit);
                    break;
                }
            }
            Assert.isTrueException(componentDescription.getToolkit() != null,
                    ICoreExceptionConstants.DESCRIPTION_NO_TOOLKIT, componentClass.getName());
        }
        // icon, default creation
        setIcon(context, componentDescription, componentClass);
        configureDefaultCreation(componentDescription);
        // final operations
        {
            Assert.isNotNull(componentDescription.getModelClass());
            componentDescription.joinProperties();
        }
        // add to caches
        if (key.isPureComponent() && !"true".equals(componentDescription.getParameter("dontCacheDescription"))
                && shouldCacheDescriptions_inPackage(descriptionInfos.getLast(), componentClass)) {
            componentDescription.setCached(true);
        }
        // mark for caching presentation
        if (shouldCachePresentation(descriptionInfos.getLast(), componentClass)) {
            componentDescription.setPresentationCached(true);
        }
        // use processors
        for (IDescriptionProcessor processor : getDescriptionProcessors()) {
            processor.process(editor, componentDescription);
        }
        // well, we have result
        return componentDescription;
    } catch (SAXParseException e) {
        throw new DesignerException(ICoreExceptionConstants.DESCRIPTION_LOAD_ERROR, e.getException(),
                componentClass.getName());
    }
}

From source file:org.archive.util.FileUtils.java

/**
 * Retrieve a number of lines from the file around the given 
 * position, as when paging forward or backward through a file. 
 * //  w  ww  . ja v a  2  s  . c  o  m
 * @param file File to retrieve lines
 * @param position offset to anchor lines
 * @param signedDesiredLineCount lines requested; if negative, 
 *        want this number of lines ending with a line containing
 *        the position; if positive, want this number of lines,
 *        all starting at or after position. 
 * @param lines List<String> to insert found lines
 * @param lineEstimate int estimate of line size, 0 means use default
 *        of 128
 * @return LongRange indicating the file offsets corresponding to 
 *         the beginning of the first line returned, and the point
 *         after the end of the last line returned
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public static LongRange pagedLines(File file, long position, int signedDesiredLineCount, List<String> lines,
        int lineEstimate) throws IOException {
    // consider negative positions as from end of file; -1 = last byte
    if (position < 0) {
        position = file.length() + position;
    }

    // calculate a reasonably sized chunk likely to have all desired lines
    if (lineEstimate == 0) {
        lineEstimate = 128;
    }
    int desiredLineCount = Math.abs(signedDesiredLineCount);
    long startPosition;
    long fileEnd = file.length();
    int bufferSize = (desiredLineCount + 5) * lineEstimate;
    if (signedDesiredLineCount > 0) {
        // reading forward; include previous char in case line-end
        startPosition = position - 1;
    } else {
        // reading backward
        startPosition = position - bufferSize + (2 * lineEstimate);
    }
    if (startPosition < 0) {
        startPosition = 0;
    }
    if (startPosition + bufferSize > fileEnd) {
        bufferSize = (int) (fileEnd - startPosition);
    }

    // read that reasonable chunk
    FileInputStream fis = new FileInputStream(file);
    fis.getChannel().position(startPosition);
    byte[] buf = new byte[bufferSize];
    ArchiveUtils.readFully(fis, buf);
    IOUtils.closeQuietly(fis);

    // find all line starts fully in buffer
    // (positions after a line-end, per line-end definition in 
    // BufferedReader.readLine)
    LinkedList<Integer> lineStarts = new LinkedList<Integer>();
    if (startPosition == 0) {
        lineStarts.add(0);
    }
    boolean atLineEnd = false;
    boolean eatLF = false;
    int i;
    for (i = 0; i < bufferSize; i++) {
        if ((char) buf[i] == '\n' && eatLF) {
            eatLF = false;
            continue;
        }
        if (atLineEnd) {
            atLineEnd = false;
            lineStarts.add(i);
            if (signedDesiredLineCount < 0 && startPosition + i > position) {
                // reached next line past position, read no more
                break;
            }
        }
        if ((char) buf[i] == '\r') {
            atLineEnd = true;
            eatLF = true;
            continue;
        }
        if ((char) buf[i] == '\n') {
            atLineEnd = true;
        }
    }
    if (startPosition + i == fileEnd) {
        // add phantom lineStart after end
        lineStarts.add(bufferSize);
    }
    int foundFullLines = lineStarts.size() - 1;

    // if found no lines
    if (foundFullLines < 1) {
        if (signedDesiredLineCount > 0) {
            if (startPosition + bufferSize == fileEnd) {
                // nothing more to read: return nothing
                return new LongRange(fileEnd, fileEnd);
            } else {
                // retry with larger lineEstimate
                return pagedLines(file, position, signedDesiredLineCount, lines,
                        Math.max(bufferSize, lineEstimate));
            }

        } else {
            // try again with much larger line estimate
            // TODO: fail gracefully before growing to multi-MB buffers
            return pagedLines(file, position, signedDesiredLineCount, lines, bufferSize);
        }
    }

    // trim unneeded lines
    while (signedDesiredLineCount > 0 && startPosition + lineStarts.getFirst() < position) {
        // discard lines starting before desired position
        lineStarts.removeFirst();
    }
    while (lineStarts.size() > desiredLineCount + 1) {
        if (signedDesiredLineCount < 0 && (startPosition + lineStarts.get(1) <= position)) {
            // discard from front until reach line containing target position
            lineStarts.removeFirst();
        } else {
            lineStarts.removeLast();
        }
    }
    int firstLine = lineStarts.getFirst();
    int partialLine = lineStarts.getLast();
    LongRange range = new LongRange(startPosition + firstLine, startPosition + partialLine);
    List<String> foundLines = IOUtils
            .readLines(new ByteArrayInputStream(buf, firstLine, partialLine - firstLine));

    if (foundFullLines < desiredLineCount && signedDesiredLineCount < 0 && startPosition > 0) {
        // if needed and reading backward, read more lines from earlier
        range = expandRange(range, pagedLines(file, range.getMinimumLong() - 1,
                signedDesiredLineCount + foundFullLines, lines, bufferSize / foundFullLines));

    }

    lines.addAll(foundLines);

    if (signedDesiredLineCount < 0 && range.getMaximumLong() < position) {
        // did not get line containining start position
        range = expandRange(range, pagedLines(file, partialLine, 1, lines, bufferSize / foundFullLines));
    }

    if (signedDesiredLineCount > 0 && foundFullLines < desiredLineCount && range.getMaximumLong() < fileEnd) {
        // need more forward lines
        range = expandRange(range, pagedLines(file, range.getMaximumLong(), desiredLineCount - foundFullLines,
                lines, bufferSize / foundFullLines));
    }

    return range;
}

From source file:org.mind.prebot.robot.PreBot.java

@Override
public void onMessage(String channel, String sender, String login, String hostname, String message) {
    if (!this.getIgnoredList().contains(sender)) {
        String years_str = "", months_str = "", days_str = "", hours_str = "", minutes_str = "",
                seconds_str = "";
        String[] tab = this.decryptData(message, true).trim().split(" ");
        if (tab.length > 0) {
            if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!pre") || tab[0].equalsIgnoreCase("!p"))) {
                if (tab.length > 1) {
                    String names = "";
                    for (Integer i = 1; i < tab.length; i++)
                        names += tab[i] + " ";
                    Release release = this.getMySQLManager().pre(names.trim());
                    if (release.getResults().equals(0))
                        this.sendMessage(channel,
                                this.encryptData("Nothing found for your search: " + names.trim()));
                    else {
                        if (release.getResults() > 1)
                            this.sendMessage(channel, this.encryptData(Colors.TEAL + "[ " + Colors.RED
                                    + release.getResults() + " results found! " + Colors.TEAL + "]"));
                        else
                            this.sendMessage(channel, this.encryptData(Colors.TEAL + "[ " + Colors.RED
                                    + release.getResults() + " result found! " + Colors.TEAL + "]"));
                        Integer years = release.getDiffDate() / 31536000;
                        Integer yearsMod = release.getDiffDate() % 31536000;
                        if (years == 1)
                            years_str = years + " year ";
                        else if (years > 1)
                            years_str = years + " years ";
                        Integer months = yearsMod / 2592000;
                        Integer monthsMod = yearsMod % 2592000;
                        if (months == 1)
                            months_str = months + " month ";
                        else if (months > 1)
                            months_str = months + " months ";
                        Integer days = monthsMod / 86400;
                        Integer daysMod = monthsMod % 86400;
                        if (days == 1)
                            days_str = days + " day ";
                        else if (days > 1)
                            days_str = days + " days ";
                        Integer hours = daysMod / 3600;
                        Integer hoursMod = daysMod % 3600;
                        if (hours == 1)
                            hours_str = hours + " hour ";
                        else if (hours > 1)
                            hours_str = hours + " hours ";
                        Integer minutes = hoursMod / 60;
                        if (minutes == 1)
                            minutes_str = minutes + " minute ";
                        else if (minutes > 1)
                            minutes_str = minutes + " minutes ";
                        Integer seconds = hoursMod % 60;
                        if (seconds == 1)
                            seconds_str = seconds + " second ";
                        else
                            seconds_str = seconds + " seconds ";
                        if (release.getChecked().equals("1") || release.getNuked().equals("0"))
                            this.sendMessage(channel,
                                    this.encryptData(Colors.TEAL + "[" + Colors.YELLOW + " PRED " + Colors.TEAL
                                            + "][ " + Utils.getCategoryCode(release.getCategory())
                                            + release.getCategory() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + release.getName() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + years_str + months_str + days_str + hours_str + minutes_str
                                            + seconds_str + "ago (" + release.getDate() + ") " + Colors.TEAL
                                            + "][ " + Colors.OLIVE + release.getSize() + Colors.TEAL + " ]"
                                            + (release.getChecked().equals("1") ? ""
                                                    : "[ " + Colors.RED + "UNCHECKED" + Colors.TEAL + " ]")));
                        else
                            this.sendMessage(channel,
                                    this.encryptData(Colors.TEAL + "[" + Colors.RED + " NUKED " + Colors.TEAL
                                            + "][ " + Utils.getCategoryCode(release.getCategory())
                                            + release.getCategory() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + release.getName() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + years_str + months_str + days_str + hours_str + minutes_str
                                            + seconds_str + "ago (" + release.getDate() + ") " + Colors.TEAL
                                            + "][ " + Colors.RED + release.getReason() + Colors.TEAL + " ][ "
                                            + Colors.OLIVE + release.getSize() + Colors.TEAL + " ]"));
                    }/*from  ww  w . j  a  v a  2s  .co m*/
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!dupenuke") || tab[0].equalsIgnoreCase("!dnu"))) {
                String names = "";
                String limit = "10";
                for (Integer i = 1; i < tab.length; i++) {
                    if (tab[i].contains("limit"))
                        limit = tab[i].substring(tab[i].indexOf("limit:") + 6, tab[i].length());
                    else
                        names += tab[i] + " ";
                }
                LinkedList<Release> releases = null;
                if (tab.length > 1)
                    releases = this.getMySQLManager().dupenuke(names.trim(), limit);
                else
                    releases = this.getMySQLManager().dupenuke("", limit);
                if (releases.isEmpty())
                    this.sendMessage(channel, this.encryptData(
                            "Nothing found for your search: " + (tab.length > 1 ? names.trim() : "")));
                else {
                    if (releases.get(0).getResults() > 1)
                        this.sendMessage(channel,
                                this.encryptData("Sending " + Colors.OLIVE + sender + Colors.LIGHT_GRAY
                                        + " last " + Colors.OLIVE + releases.get(0).getResults() + Colors.RED
                                        + " nuked " + Colors.LIGHT_GRAY + "results."));
                    else
                        this.sendMessage(channel,
                                this.encryptData("Sending " + Colors.OLIVE + sender + Colors.LIGHT_GRAY
                                        + " last " + Colors.OLIVE + releases.get(0).getResults() + Colors.RED
                                        + " nuked " + Colors.LIGHT_GRAY + "results"));
                    for (Release release : releases) {
                        Integer years = release.getDiffDate() / 31536000;
                        Integer yearsMod = release.getDiffDate() % 31536000;
                        if (years == 1)
                            years_str = years + " year ";
                        else if (years > 1)
                            years_str = years + " years ";
                        Integer months = yearsMod / 2592000;
                        Integer monthsMod = yearsMod % 2592000;
                        if (months == 1)
                            months_str = months + " month ";
                        else if (months > 1)
                            months_str = months + " months ";
                        Integer days = monthsMod / 86400;
                        Integer daysMod = monthsMod % 86400;
                        if (days == 1)
                            days_str = days + " day ";
                        else if (days > 1)
                            days_str = days + " days ";
                        Integer hours = daysMod / 3600;
                        Integer hoursMod = daysMod % 3600;
                        if (hours == 1)
                            hours_str = hours + " hour ";
                        else if (hours > 1)
                            hours_str = hours + " hours ";
                        Integer minutes = hoursMod / 60;
                        if (minutes == 1)
                            minutes_str = minutes + " minute ";
                        else if (minutes > 1)
                            minutes_str = minutes + " minutes ";
                        Integer seconds = hoursMod % 60;
                        if (seconds == 1)
                            seconds_str = seconds + " second ";
                        else
                            seconds_str = seconds + " seconds ";
                        this.sendMessage(sender,
                                this.encryptData(Colors.TEAL + "[" + Colors.RED + " NUKED " + Colors.TEAL
                                        + "][ " + Utils.getCategoryCode(release.getCategory())
                                        + release.getCategory() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                        + release.getName() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                        + years_str + months_str + days_str + hours_str + minutes_str
                                        + seconds_str + "ago (" + release.getDate() + ") " + Colors.TEAL + "][ "
                                        + Colors.RED + release.getReason() + Colors.TEAL + " ][ " + Colors.OLIVE
                                        + release.getSize() + Colors.TEAL + " ]"));
                    }
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!dupe") || tab[0].equalsIgnoreCase("!d"))) {
                String names = "";
                String limit = "10";
                for (Integer i = 1; i < tab.length; i++) {
                    if (tab[i].contains("limit"))
                        limit = tab[i].substring(tab[i].indexOf("limit:") + 6, tab[i].length());
                    else
                        names += tab[i] + " ";
                }
                LinkedList<Release> releases = null;
                if (tab.length > 1)
                    releases = this.getMySQLManager().dupe(names.trim(), limit);
                else
                    releases = this.getMySQLManager().dupe("", limit);
                if (releases.isEmpty())
                    this.sendMessage(channel, this.encryptData(
                            "Nothing found for your search: " + (tab.length > 1 ? names.trim() : "")));
                else {
                    if (releases.get(0).getResults() > 1)
                        this.sendMessage(channel,
                                this.encryptData("Sending " + Colors.OLIVE + sender + Colors.LIGHT_GRAY
                                        + " last " + Colors.OLIVE + releases.get(0).getResults()
                                        + Colors.LIGHT_GRAY + " results."));
                    else
                        this.sendMessage(channel,
                                this.encryptData("Sending " + Colors.OLIVE + sender + Colors.LIGHT_GRAY
                                        + " last " + Colors.OLIVE + releases.get(0).getResults()
                                        + Colors.LIGHT_GRAY + " result."));
                    for (Release release : releases) {
                        Integer years = release.getDiffDate() / 31536000;
                        Integer yearsMod = release.getDiffDate() % 31536000;
                        if (years == 1)
                            years_str = years + " year ";
                        else if (years > 1)
                            years_str = years + " years ";
                        Integer months = yearsMod / 2592000;
                        Integer monthsMod = yearsMod % 2592000;
                        if (months == 1)
                            months_str = months + " month ";
                        else if (months > 1)
                            months_str = months + " months ";
                        Integer days = monthsMod / 86400;
                        Integer daysMod = monthsMod % 86400;
                        if (days == 1)
                            days_str = days + " day ";
                        else if (days > 1)
                            days_str = days + " days ";
                        Integer hours = daysMod / 3600;
                        Integer hoursMod = daysMod % 3600;
                        if (hours == 1)
                            hours_str = hours + " hour ";
                        else if (hours > 1)
                            hours_str = hours + " hours ";
                        Integer minutes = hoursMod / 60;
                        if (minutes == 1)
                            minutes_str = minutes + " minute ";
                        else if (minutes > 1)
                            minutes_str = minutes + " minutes ";
                        Integer seconds = hoursMod % 60;
                        if (seconds == 1)
                            seconds_str = seconds + " second ";
                        else
                            seconds_str = seconds + " seconds ";
                        if (release.getChecked().equals("1") || release.getNuked().equals("0"))
                            this.sendMessage(sender,
                                    this.encryptData(Colors.TEAL + "[" + Colors.YELLOW + " PRED " + Colors.TEAL
                                            + "][ " + Utils.getCategoryCode(release.getCategory())
                                            + release.getCategory() + Colors.TEAL + "][ " + Colors.LIGHT_GRAY
                                            + release.getName() + Colors.TEAL + "][ " + Colors.LIGHT_GRAY
                                            + years_str + months_str + days_str + hours_str + minutes_str
                                            + seconds_str + "ago (" + release.getDate() + ") " + Colors.TEAL
                                            + "][ " + Colors.OLIVE + release.getSize() + Colors.TEAL + " ]"
                                            + (release.getChecked().equals("1") ? ""
                                                    : "[ " + Colors.RED + "UNCHECKED" + Colors.TEAL + " ]")));
                        else
                            this.sendMessage(sender,
                                    this.encryptData(Colors.TEAL + "[" + Colors.RED + " NUKED " + Colors.TEAL
                                            + "][ " + Utils.getCategoryCode(release.getCategory())
                                            + release.getCategory() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + release.getName() + Colors.TEAL + " ][ " + Colors.LIGHT_GRAY
                                            + years_str + months_str + days_str + hours_str + minutes_str
                                            + seconds_str + "ago (" + release.getDate() + ") " + Colors.TEAL
                                            + "][ " + Colors.RED + release.getReason() + Colors.TEAL + " ][ "
                                            + Colors.OLIVE + release.getSize() + Colors.TEAL + " ]"));
                    }
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!nuke") || tab[0].equalsIgnoreCase("!nk"))) {
                if (this.getNukerList().contains(sender)) {
                    String names = "";
                    for (Integer i = 2; i < tab.length; i++)
                        names += tab[i] + " ";
                    if (tab.length > 2) {
                        Integer ret = this.getMySQLManager().nuke(tab[1], names.trim());
                        if (ret > 0)
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has been successfully " + Colors.RED + "nuked"
                                            + Colors.LIGHT_GRAY + "!"));
                        else
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has not been successfully " + Colors.RED + "nuked"
                                            + Colors.LIGHT_GRAY + "!"));
                    }
                } else
                    this.sendMessage(channel, this.encryptData(sender + ": You've to be a nuker to do this."));
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!unnuke") || tab[0].equalsIgnoreCase("!un"))) {
                if (this.getNukerList().contains(sender)) {
                    String names = "";
                    for (Integer i = 2; i < tab.length; i++)
                        names += tab[i] + " ";
                    if (tab.length > 2) {
                        Integer ret = this.getMySQLManager().unnuke(tab[1], names.trim());
                        if (ret > 0)
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has been successfully " + Colors.DARK_GREEN + "unnuked"
                                            + Colors.LIGHT_GRAY + "!"));
                        else
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has not been successfully " + Colors.DARK_GREEN + "unnuked"
                                            + Colors.LIGHT_GRAY + "!"));
                    }
                } else
                    this.sendMessage(channel, this.encryptData(sender + ": You've to be a nuker to do this."));
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!addpre") || tab[0].equalsIgnoreCase("!ap"))) {
                if (this.getNukerList().contains(sender)) {
                    String names = "";
                    for (Integer i = 3; i < tab.length; i++)
                        names += tab[i] + " ";
                    if (tab.length > 3) {
                        Integer ret = this.getMySQLManager().addpre(tab[1], tab[2], names.trim());
                        if (ret > 0)
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has been successfully " + Colors.DARK_GREEN + "addpred"
                                            + Colors.LIGHT_GRAY + "!"));
                        else
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has not been successfully " + Colors.DARK_GREEN + "addpred"
                                            + Colors.LIGHT_GRAY + "!"));
                    }
                } else
                    this.sendMessage(channel, this.encryptData(sender + ": You've to be a nuker to do this."));
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!delpre") || tab[0].equalsIgnoreCase("!dp"))) {
                if (this.getNukerList().contains(sender)) {
                    if (tab.length > 1) {
                        Integer ret = this.getMySQLManager().delpre(tab[1]);
                        if (ret > 0)
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has been successfully " + Colors.DARK_GREEN + "delpred"
                                            + Colors.LIGHT_GRAY + "!"));
                        else
                            this.sendMessage(channel,
                                    this.encryptData(Colors.OLIVE + tab[1] + Colors.LIGHT_GRAY
                                            + " has not been successfully " + Colors.DARK_GREEN + "delpred"
                                            + Colors.LIGHT_GRAY + "!"));
                    }
                } else
                    this.sendMessage(channel, this.encryptData(sender + ": You've to be a nuker to do this."));
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindChannel())
                    && tab[0].equalsIgnoreCase("!vdm")) {
                List<String> vdms = Utils.getMatcher(Utils.VDMRegex, Utils.getCode(Utils.VDMFeed),
                        Pattern.MULTILINE);
                if (!vdms.isEmpty()) {
                    String vdm = vdms.get(new Random().nextInt(vdms.size()));
                    vdm = StringEscapeUtils.unescapeHtml4(vdm);
                    vdm = vdm.substring(30).replaceAll("[\r\n]+", "").replaceAll(" {2,}", " ").trim();
                    this.sendMessage(channel, this.encryptData(Colors.TEAL + "[" + Colors.BROWN + " VDM "
                            + Colors.TEAL + "] :: [ " + Colors.DARK_GREEN + vdm + Colors.TEAL + " ]"));
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindChannel())
                    && tab[0].equalsIgnoreCase("!cnf")) {
                List<String> cnfs = Utils.getMatcher(Utils.CNFRegex, Utils.getCode(Utils.CNFPage),
                        Pattern.MULTILINE);
                if (!cnfs.isEmpty()) {
                    String cnf = cnfs.get(new Random().nextInt(cnfs.size()));
                    cnf = StringEscapeUtils.unescapeHtml4(cnf);
                    cnf = cnf.substring(cnf.indexOf(">") + 1, cnf.indexOf("</div>")).replaceAll("[\r\n]+", "")
                            .replaceAll(" {2,}", " ").trim();
                    this.sendMessage(channel, this.encryptData(Colors.TEAL + "[" + Colors.RED + " CNF "
                            + Colors.TEAL + "] :: [ " + Colors.DARK_GREEN + cnf + Colors.TEAL + " ]"));
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindChannel())
                    && (tab[0].equalsIgnoreCase("!slap") || tab[0].equalsIgnoreCase("!s"))) {
                if (this.getSlaps() < this.getSlapsRandom())
                    this.setSlaps(this.getSlaps() + 1);
                else {
                    this.kick(channel, sender, this.encryptData("Sorry, you loose this time ^^"));
                    this.setSlaps(0);
                    this.setSlapsRandom(new Random().nextInt(26));
                }
            } else if (tab[0].equalsIgnoreCase("!kick") || tab[0].equalsIgnoreCase("!k")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 2) {
                        String names = "";
                        for (Integer i = 2; i < tab.length; i++)
                            names += tab[i] + " ";
                        this.kick(channel, tab[1], this.encryptData(names.trim()));
                    } else
                        this.kick(channel, tab[1]);
                }
            } else if (tab[0].equalsIgnoreCase("!ban") || tab[0].equalsIgnoreCase("!b")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 1)
                        this.ban(channel, tab[1]);
                }
            } else if (tab[0].equalsIgnoreCase("!mode") || tab[0].equalsIgnoreCase("!m")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 2)
                        this.setMode(channel, tab[1] + " " + tab[2]);
                }
            } else if (tab[0].equalsIgnoreCase("!message") || tab[0].equalsIgnoreCase("!msg")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 2) {
                        String names = "";
                        for (Integer i = 2; i < tab.length; i++)
                            names += tab[i] + " ";
                        this.sendMessage(tab[1], this.encryptData(names.trim()));
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!action") || tab[0].equalsIgnoreCase("!a")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 2) {
                        String names = "";
                        for (Integer i = 2; i < tab.length; i++)
                            names += tab[i] + " ";
                        this.sendAction(tab[1], this.encryptData(names.trim()));
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!notice") || tab[0].equalsIgnoreCase("!n")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 2) {
                        String names = "";
                        for (Integer i = 2; i < tab.length; i++)
                            names += tab[i] + " ";
                        this.sendNotice(tab[1], this.encryptData(names.trim()));
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!ignore") || tab[0].equalsIgnoreCase("!i")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 1) {
                        if (!this.getIgnoredList().contains(tab[1]))
                            this.getIgnoredList().add(tab[1]);
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!unignore") || tab[0].equalsIgnoreCase("!ui")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 1) {
                        if (this.getIgnoredList().contains(tab[1]))
                            this.getIgnoredList().remove(tab[1]);
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!addnuker") || tab[0].equalsIgnoreCase("!an")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 1) {
                        if (!this.getNukerList().contains(tab[1]))
                            this.getNukerList().add(tab[1]);
                    }
                }
            } else if (tab[0].equalsIgnoreCase("!delnuker") || tab[0].equalsIgnoreCase("!dn")) {
                if (sender.equals("BaYbEE")) {
                    if (tab.length > 1) {
                        if (this.getNukerList().contains(tab[1]))
                            this.getNukerList().remove(tab[1]);
                    }
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!showrequest") || tab[0].equalsIgnoreCase("!sr"))) {
                if (tab.length > 1) {
                    String names = "";
                    for (Integer i = 1; i < tab.length; i++)
                        names += tab[i] + " ";
                    Request request = this.getMySQLManager().showrequest(names.trim());
                    if (request.getResults().equals(0))
                        this.sendMessage(channel,
                                this.encryptData("Nothing found for your search: " + names.trim()));
                    else {
                        if (request.getResults() > 1)
                            this.sendMessage(channel, this.encryptData(
                                    "\00310[\00304 " + request.getResults() + " results found! \00310]"));
                        else
                            this.sendMessage(channel, this.encryptData(
                                    "\00310[\00304 " + request.getResults() + " result found! \00310]"));
                        Integer years = request.getDiffDate() / 31536000;
                        Integer yearsMod = request.getDiffDate() % 31536000;
                        if (years == 1)
                            years_str = years + " year ";
                        else if (years > 1)
                            years_str = years + " years ";
                        Integer months = yearsMod / 2592000;
                        Integer monthsMod = yearsMod % 2592000;
                        if (months == 1)
                            months_str = months + " month ";
                        else if (months > 1)
                            months_str = months + " months ";
                        Integer days = monthsMod / 86400;
                        Integer daysMod = monthsMod % 86400;
                        if (days == 1)
                            days_str = days + " day ";
                        else if (days > 1)
                            days_str = days + " days ";
                        Integer hours = daysMod / 3600;
                        Integer hoursMod = daysMod % 3600;
                        if (hours == 1)
                            hours_str = hours + " hour ";
                        else if (hours > 1)
                            hours_str = hours + " hours ";
                        Integer minutes = hoursMod / 60;
                        if (minutes == 1)
                            minutes_str = minutes + " minute ";
                        else if (minutes > 1)
                            minutes_str = minutes + " minutes ";
                        Integer seconds = hoursMod % 60;
                        if (seconds == 1)
                            seconds_str = seconds + " second ";
                        else
                            seconds_str = seconds + " seconds ";
                        if (request.getFilled())
                            this.sendMessage(channel, this.encryptData("\00310[\00308 REQ \00310] [\00315 "
                                    + request.getRequest() + " \00310] [\00315 " + years_str + months_str
                                    + days_str + hours_str + minutes_str + seconds_str + "ago ("
                                    + (request.getRequestDate()) + ") \00310] [ \00307Requested by: \00315"
                                    + request.getRequestBy() + " \00310] [ \00307Filled by: \00315"
                                    + request.getFilledBy() + " \00310]"));
                        else
                            this.sendMessage(channel, this.encryptData("\00310[\00308 REQ \00310] [\00315 "
                                    + request.getRequest() + " \00310] [\00315 " + years_str + months_str
                                    + days_str + hours_str + minutes_str + seconds_str + "ago ("
                                    + request.getRequestDate() + ") \00310] [ \00307Requested by: \00315"
                                    + request.getRequestBy() + " \00310]"));
                    }
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!addrequest") || tab[0].equalsIgnoreCase("!ar"))) {
                String names = "";
                for (Integer i = 1; i < tab.length; i++)
                    names += tab[i] + " ";
                if (tab.length > 1) {
                    Request request = new Request();
                    request.setRequest(names.trim());
                    request.setRequestBy(sender);
                    request.setRequestDate(null);
                    request.setFilled(false);
                    request.setFilledBy("");
                    Integer ret = this.getMySQLManager().addrequest(request);
                    if (ret > 0)
                        this.sendMessage(channel, this.encryptData("\00307" + names.trim()
                                + "\00315 has been successfully \00304requested\00315!"));
                    else
                        this.sendMessage(channel, this.encryptData("\00307" + names.trim()
                                + "\00315 has not been successfully \00304requested\00315!"));
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!fillrequest") || tab[0].equalsIgnoreCase("!fr"))) {
                String names = "";
                for (Integer i = 1; i < tab.length; i++)
                    names += tab[i] + " ";
                if (tab.length > 1) {
                    Integer ret = this.getMySQLManager().fillrequest(names.trim(), sender);
                    if (ret > 0)
                        this.sendMessage(channel, this.encryptData(
                                "\00307" + names.trim() + "\00315 has been successfully \00304filled\00315!"));
                    else
                        this.sendMessage(channel, this.encryptData("\00307" + names.trim()
                                + "\00315 has not been successfully \0030filled\00315!"));
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!duperequest") || tab[0].equalsIgnoreCase("!dr"))) {
                String names = "";
                String limit = "10";
                for (Integer i = 1; i < tab.length; i++) {
                    if (tab[i].contains("limit"))
                        limit = tab[i].substring(tab[i].indexOf("limit:") + 6, tab[i].length());
                    else
                        names += tab[i] + " ";
                }
                LinkedList<Request> requests = null;
                if (tab.length > 1)
                    requests = this.getMySQLManager().duperequest(names.trim(), limit);
                else
                    requests = this.getMySQLManager().duperequest("", limit);
                if (requests.isEmpty())
                    this.sendMessage(channel, this.encryptData(
                            "Nothing found for your search: " + (tab.length > 1 ? names.trim() : "")));
                else {
                    if (requests.get(0).getResults() > 1)
                        this.sendMessage(channel, this.encryptData("Sending \00307" + sender
                                + "\00315 last \00307" + requests.get(0).getResults() + "\00315 results."));
                    else
                        this.sendMessage(channel, this.encryptData("Sending \00307" + sender
                                + "\00315 last \00307" + requests.get(0).getResults() + "\00315 result."));
                    for (Request request : requests) {
                        Integer years = request.getDiffDate() / 31536000;
                        Integer yearsMod = request.getDiffDate() % 31536000;
                        if (years == 1)
                            years_str = years + " year ";
                        else if (years > 1)
                            years_str = years + " years ";
                        Integer months = yearsMod / 2592000;
                        Integer monthsMod = yearsMod % 2592000;
                        if (months == 1)
                            months_str = months + " month ";
                        else if (months > 1)
                            months_str = months + " months ";
                        Integer days = monthsMod / 86400;
                        Integer daysMod = monthsMod % 86400;
                        if (days == 1)
                            days_str = days + " day ";
                        else if (days > 1)
                            days_str = days + " days ";
                        Integer hours = daysMod / 3600;
                        Integer hoursMod = daysMod % 3600;
                        if (hours == 1)
                            hours_str = hours + " hour ";
                        else if (hours > 1)
                            hours_str = hours + " hours ";
                        Integer minutes = hoursMod / 60;
                        if (minutes == 1)
                            minutes_str = minutes + " minute ";
                        else if (minutes > 1)
                            minutes_str = minutes + " minutes ";
                        Integer seconds = hoursMod % 60;
                        if (seconds == 1)
                            seconds_str = seconds + " second ";
                        else
                            seconds_str = seconds + " seconds ";
                        if (request.getFilled())
                            this.sendMessage(sender, this.encryptData("\00310[\00308 REQ \00310] [\00315 "
                                    + request.getRequest() + " \00310] [\00315 " + years_str + months_str
                                    + days_str + hours_str + minutes_str + seconds_str + "ago ("
                                    + request.getRequestDate() + ") \00310] [ \00307Requested by: \00315"
                                    + request.getRequestBy() + " \00310] [ \00307Filled by: \00315"
                                    + request.getFilledBy() + " \00310]"));
                        else
                            this.sendMessage(sender, this.encryptData("\00310[\00308 REQ \00310] [\00315 "
                                    + request.getRequest() + " \00310] [\00315 " + years_str + months_str
                                    + days_str + hours_str + minutes_str + seconds_str + "ago ("
                                    + request.getRequestDate() + ") \00310] [ \00307Requested by: \00315"
                                    + request.getRequestBy() + " \00310]"));
                    }
                }
            } else if (channel.equalsIgnoreCase(this.getParent().getIRCMindPreSearchChannel())
                    && (tab[0].equalsIgnoreCase("!group") || tab[0].equalsIgnoreCase("!g"))) {
                Group group = this.getMySQLManager().group();
                this.sendMessage(channel,
                        this.encryptData(Colors.DARK_GRAY + "Total Releases: " + Colors.GREEN
                                + group.getTotalReleases() + Colors.DARK_GRAY + " Total Nuked: " + Colors.RED
                                + group.getTotalNukes() + Colors.DARK_GRAY + " Total Unuked: " + Colors.OLIVE
                                + group.getTotalUnnukes()));
                this.sendMessage(channel,
                        this.encryptData(Colors.DARK_GRAY + "First Pre: " + Colors.LIGHT_GRAY + "["
                                + Utils.getCategoryCode(group.getCategoryFirstPre())
                                + group.getCategoryFirstPre() + Colors.LIGHT_GRAY + "] " + group.getFirstPre()
                                + " [" + group.getDateFirstPre() + "]"));
                this.sendMessage(channel, this.encryptData(Colors.DARK_GRAY + "Last Pre: " + Colors.LIGHT_GRAY
                        + "[" + Utils.getCategoryCode(group.getCategoryLastPre()) + group.getCategoryLastPre()
                        + Colors.LIGHT_GRAY + "] " + group.getLastPre() + " [" + group.getDateLastPre() + "]"));
            } else {
                for (String t : tab) {
                    if (!Utils.getMatcher(Utils.URLRegex, t, Pattern.DOTALL).isEmpty()) {
                        String title = Utils.getTitleMatcher(Utils.getCode(t));
                        if (title != null) {
                            title = StringEscapeUtils.unescapeHtml4(title);
                            title = title.substring(7, title.length() - 8).replaceAll("[\r\n]+", "")
                                    .replaceAll(" {2,}", " ").trim();
                            this.sendMessage(channel,
                                    this.encryptData("\00310[\00303 Title:\00307 " + title + " \00310]"));
                        }
                    }
                }
            }
        }
    }
}

From source file:UI.MainStageController.java

/**
 * shows the correlation table in the analysis view
 *///from  w  w  w.  j  av  a 2 s .co  m
@FXML
private void displayCorrelationTable() {
    //Delete whatever's been in the table before
    TableView<String[]> analysisTable = new TableView<>();

    //We want to display correlations and p-Values of every node combination
    double[][] correlationMatrix = AnalysisData.getCorrelationMatrix().getData();
    double[][] pValueMatrix = AnalysisData.getPValueMatrix().getData();
    LinkedList<TaxonNode> taxonList = SampleComparison.getUnifiedTaxonList(LoadedData.getSamplesToAnalyze(),
            AnalysisData.getLevelOfAnalysis());

    //Table will consist of strings
    String[][] tableValues = new String[correlationMatrix.length][correlationMatrix[0].length + 1];

    //Add the values as formatted strings
    for (int i = 0; i < tableValues.length; i++) {
        tableValues[i][0] = taxonList.get(i).getName();
        for (int j = 1; j < tableValues[0].length; j++) {
            tableValues[i][j] = String.format("%.3f", correlationMatrix[i][j - 1]).replace(",", ".") + "\n("
                    + String.format("%.2f", pValueMatrix[i][j - 1]).replace(",", ".") + ")";
        }
    }

    for (int i = 0; i < tableValues[0].length; i++) {
        String columnTitle;
        if (i > 0) {
            columnTitle = taxonList.get(i - 1).getName();
        } else {
            columnTitle = "";
        }
        TableColumn<String[], String> column = new TableColumn<>(columnTitle);
        final int columnIndex = i;
        column.setCellValueFactory(cellData -> {
            String[] row = cellData.getValue();
            return new SimpleStringProperty(row[columnIndex]);
        });
        analysisTable.getColumns().add(column);

        //First column contains taxon names and should be italic
        if (i == 0)
            column.setStyle("-fx-font-style:italic;");
    }

    for (int i = 0; i < tableValues.length; i++) {
        analysisTable.getItems().add(tableValues[i]);
    }

    //Display table on a new stage
    Stage tableStage = new Stage();
    tableStage.setTitle("Correlation Table");
    BorderPane tablePane = new BorderPane();
    Button exportCorrelationsButton = new Button("Save correlation table to CSV");
    Button exportPValuesButton = new Button("Save p-value table to CSV");
    exportCorrelationsButton.setOnAction(e -> exportTableToCSV(tableValues, false));
    exportPValuesButton.setOnAction(e -> exportTableToCSV(tableValues, true));
    HBox exportBox = new HBox(exportCorrelationsButton, exportPValuesButton);
    exportBox.setPadding(new Insets(10));
    exportBox.setSpacing(10);
    tablePane.setTop(exportBox);
    tablePane.setCenter(analysisTable);
    Scene tableScene = new Scene(tablePane);
    tableStage.setScene(tableScene);
    tableStage.show();
}

From source file:net.sf.jvifm.ui.FileLister.java

private String getLastLongestPath(String path) {

    if (path.indexOf(File.separator) < 0)
        return path;
    LinkedList<String> list = historyManager.getFullHistory();
    if (list.size() < 0)
        return path;

    if (!path.endsWith(File.separator))
        path = path + File.separator;
    String longestPath = path;/*  w  ww.  j a  va 2s .c  o  m*/

    int lastMatchIndex = -1;
    for (int i = list.size() - 1; i > 0; i--) {
        String his = (String) list.get(i);
        if (his.startsWith(path)) {
            lastMatchIndex = i;
            longestPath = his;
            break;
        }
    }
    while (true) {
        if (lastMatchIndex < 1)
            break;
        String tmp = (String) list.get(lastMatchIndex--);

        if (!tmp.startsWith(longestPath))
            break;
        longestPath = tmp;
    }
    if (longestPath.endsWith(File.separator))
        longestPath = longestPath.substring(0, longestPath.length() - 1);
    return longestPath;

}

From source file:com.github.vanroy.springdata.jest.JestElasticsearchTemplateTests.java

@Test
public void shouldReturnObjectsForGivenIdsUsingMultiGet() {
    // given//w  ww  .  ja  v a 2  s. co m
    List<IndexQuery> indexQueries;
    // first document
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
            .version(System.currentTimeMillis()).build();

    // second document
    String documentId2 = randomNumeric(5);
    SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some message")
            .version(System.currentTimeMillis()).build();

    indexQueries = getIndexQueries(Arrays.asList(sampleEntity1, sampleEntity2));

    elasticsearchTemplate.bulkIndex(indexQueries);
    elasticsearchTemplate.refresh(SampleEntity.class);

    // when
    SearchQuery query = new NativeSearchQueryBuilder().withIds(Arrays.asList(documentId, documentId2)).build();
    LinkedList<SampleEntity> sampleEntities = elasticsearchTemplate.multiGet(query, SampleEntity.class);
    // then
    assertThat(sampleEntities.size(), is(equalTo(2)));
    assertEquals(sampleEntities.get(0), sampleEntity1);
    assertEquals(sampleEntities.get(1), sampleEntity2);
}

From source file:uk.ac.diamond.scisoft.analysis.rcp.inspector.InspectionTab.java

@Override
protected void repopulateCombos(String oldName, String newName) {
    if (combos == null)
        return;/*from w  w  w.j  a va 2s  . c om*/

    if (daxes != null && daxes.size() != 1) {
        super.repopulateCombos(oldName, newName);
        return;
    }

    // cascade through plot axes strings and indices
    // reduce choice each time
    int cSize = combos.size() - comboOffset;
    LinkedList<String> sAxes = getAllAxisNames();

    int jmax = daxes.size();
    if (jmax == 0)
        return;

    boolean fromAxisSelection = oldName != null && newName != null;
    String a = null;
    for (int i = 0; i < cSize; i++) {
        Combo c = combos.get(i + comboOffset);
        a = (fromAxisSelection && i < jmax) ? daxes.get(i).getSelectedName() : c.getItem(c.getSelectionIndex());
        c.removeAll();

        if (!sAxes.contains(a)) {
            a = sAxes.get(0);
        }
        if (!fromAxisSelection) {
            if (i < jmax)
                daxes.get(i).selectAxis(a, false);
        }
        for (String p : sAxes)
            c.add(p);

        c.setText(a);
        sAxes.remove(a);
        if (paxes != null) {
            PlotAxisProperty p = paxes.get(i + comboOffset);
            if (p.isInSet()) {
                p.setName(a, false);
            }
        }

    }
    if (a != null && paxes != null) {
        if (paxes.get(cSize - 1 + comboOffset).isInSet()) {
            paxes.get(cSize - 1 + comboOffset).setName(a);
        }
    }

}

From source file:util.method.java

public static LinkedList<VM> readClientFileAndGenerateVMList(String fileName)
        throws IOException, ParseException {
    JSONParser parser = new JSONParser();
    LinkedList<VM> VMList = new LinkedList<VM>();

    /*Read file and store in file related format*/
    Object obj = parser.parse(new FileReader(fileName));

    JSONObject jsonObject = (JSONObject) obj;

    HashMap serviceRequirement = (HashMap) jsonObject.get("serviceRequirement");

    HashMap serviceDescription = (HashMap) jsonObject.get("serviceDescription");

    //method.printHashMap(serviceDescription);

    HashMap gauranteeTerm = (HashMap) jsonObject.get("gauranteeTerm");

    // method.printHashMap(gauranteeTerm);

    //ArrayList creationConstraint=(ArrayList) jsonObject.get("creationConstraint");

    //method.printArrayList(creationConstraint);

    /*Extract information and put it into VMlist*/

    /*0. Servcie Requirement*/

    Iterator iter0 = serviceRequirement.entrySet().iterator();

    while (iter0.hasNext()) {

        HashMap.Entry entry = (HashMap.Entry) iter0.next();
        Object key = entry.getKey();

        String value = (String) entry.getValue();
        String[] keys = getSplitResult((String) key);
        String ID = keys[0];//from   w  ww.  ja  v a  2  s . c o  m
        String term = keys[1];

        if (VMList.size() == 0) {

            VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
            newVM.addServiceRequirement(term, value);
            VMList.add(newVM);

        }

        boolean find = false;
        for (int i = 0; i < VMList.size(); i++) {
            VM currentVM = VMList.get(i);

            if (currentVM.getID().equals(ID))

            {
                currentVM.addServiceRequirement(term, value);

                find = true;

            }

        }

        if (find == false) {

            VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
            newVM.addServiceRequirement(term, value);
            VMList.add(newVM);
        }

    }

    /*1. Servcie Description*/

    Iterator iter1 = serviceDescription.entrySet().iterator();
    while (iter1.hasNext()) {

        HashMap.Entry entry = (HashMap.Entry) iter1.next();
        Object key = entry.getKey();

        try {
            float value = Float.parseFloat((String) entry.getValue());

            String[] keys = getSplitResult((String) key);
            String ID = keys[0];
            String term = keys[1];

            if (VMList.size() == 0) {

                VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
                newVM.addServiceDescription(term, value);
                VMList.add(newVM);

            }

            boolean find = false;
            for (int i = 0; i < VMList.size(); i++) {
                VM currentVM = VMList.get(i);

                if (currentVM.getID().equals(ID))

                {
                    currentVM.addServiceDescription(term, value);

                    find = true;

                }

            }

            if (find == false) {

                VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
                newVM.addServiceDescription(term, value);
                VMList.add(newVM);
            }

        }

        catch (NumberFormatException e) {

            String value = (String) entry.getValue();
            String[] keys = getSplitResult((String) key);
            String ID = keys[0];
            String term = keys[1];

            if (VMList.size() == 0) {

                VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
                newVM.addServiceDescription(term, value);
                VMList.add(newVM);

            }

            boolean find = false;
            for (int i = 0; i < VMList.size(); i++) {
                VM currentVM = VMList.get(i);

                if (currentVM.getID().equals(ID))

                {
                    currentVM.addServiceDescription(term, value);

                    find = true;

                }

            }

            if (find == false) {

                VM newVM = new VM(ID, new HashMap(), new HashMap(), new HashMap());
                newVM.addServiceDescription(term, value);
                VMList.add(newVM);
            }

        }
    }

    /*2 Gaurantee term*/

    Iterator iter2 = gauranteeTerm.entrySet().iterator();

    while (iter2.hasNext()) {
        HashMap.Entry entry2 = (HashMap.Entry) iter2.next();
        Object key2 = entry2.getKey();
        Object value2 = entry2.getValue();

        String[] keys2 = getSplitResult((String) key2);
        String ID2 = keys2[0];
        String term2 = keys2[1];

        if (VMList.size() == 0) {
            VM newVM = new VM(ID2, new HashMap(), new HashMap(), new HashMap());
            newVM.addGauranteeTerm(term2, (String) value2);

        }

        boolean find2 = false;
        for (int i = 0; i < VMList.size(); i++) {
            VM currentVM = VMList.get(i);

            if (currentVM.getID().equals(ID2))

                currentVM.addGauranteeTerm(term2, (String) value2);

            find2 = true;

        }

        if (find2 == false) {
            VM newVM = new VM(ID2, new HashMap(), new HashMap(), new HashMap());
            newVM.addGauranteeTerm(term2, (String) value2);

        }
    }

    return VMList;
}