Example usage for org.apache.commons.lang StringUtils countMatches

List of usage examples for org.apache.commons.lang StringUtils countMatches

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils countMatches.

Prototype

public static int countMatches(String str, String sub) 

Source Link

Document

Counts how many times the substring appears in the larger String.

Usage

From source file:eu.europa.ec.fisheries.uvms.movement.mapper.SearchMapperListTest.java

@Ignore
@Test/*from   w  w w  .j a  v a  2 s.  c om*/
public void testSingleQueryAllCategory() throws ParseException, SearchMapperException {

    List<SearchValue> list = new ArrayList<>();
    list.add(getSearchValue(GLOBAL_ID, SearchField.MOVEMENT_ID));
    list.add(getSearchValue(GLOBAL_ID, SearchField.SEGMENT_ID));
    list.add(getSearchValue(GLOBAL_ID, SearchField.TRACK_ID));
    list.add(getSearchValue(GLOBAL_ID, SearchField.CONNECT_ID));
    list.add(getSearchValue(MovementTypeType.ENT.name(), SearchField.MOVMENT_TYPE));
    list.add(getSearchValue(MovementActivityTypeType.ANC.name(), SearchField.ACTIVITY_TYPE));
    //TODO
    //list.add(getSearchValue(AREA, SearchField.AREA));
    list.add(getSearchValue(MovementSourceType.INMARSAT_C.name(), SearchField.SOURCE));
    list.add(getSearchValue(SegmentCategoryType.ANCHORED.name(), SearchField.CATEGORY));

    String data = SearchFieldMapper.createSelectSearchSql(list, true);

    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_ID + GLOBAL_ID) == 1);
    //TODO
    //Assert.assertTrue(StringUtils.countMatches(data, SEGMENT_ID + GLOBAL_ID) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, TRACK_ID + GLOBAL_ID) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_CONNECT_ID + "'" + GLOBAL_ID + "'") == 1);
    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_TYPE + MovementTypeType.ENT.ordinal()) == 1);
    Assert.assertTrue(
            StringUtils.countMatches(data, ACTIVITY_TYPE + MovementActivityTypeType.ANC.ordinal()) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, SOURCE + MovementSourceType.INMARSAT_C.ordinal()) == 1);
    //TODO
    //Assert.assertTrue(StringUtils.countMatches(data, CATEGORY + SegmentCategoryType.ANCHORED.ordinal()) == 1);

    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_CONECT_JOIN) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_TRACK_JOIN) == 1);
    //TODO
    //Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_SEGMENT1_JOIN) == 1);
    //Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_SEGMENT2_JOIN) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, METADATA_JOIN) == 1);
    //TODO
    //Assert.assertTrue(StringUtils.countMatches(data, AND) == 11);

}

From source file:com.jgui.ttscrape.htmlunit.GridParser.java

private void parseShowSummary(Show show, String txt) {
    int i1 = txt.indexOf('(');
    if (i1 >= 0) {
        int i2 = txt.indexOf(')', i1);
        if (i2 > 0) {
            String flags = txt.substring(i1 + 1, i2);
            parseShowSummary(show, flags);
            show.setSubtitle(StringUtils.trim(txt.substring(i2 + 1)));
            return;
        }//from   www  .  j  a v a 2  s  .com
    }

    String[] fields = txt.split(",");
    for (String field : fields) {
        field = field.trim();
        if (StringUtils.isNotEmpty(field)) {
            // look for star rating.
            if (StringUtils.containsOnly(field, "*+")) {
                show.setStars((float) (StringUtils.countMatches(field, "*")
                        + 0.5 * StringUtils.countMatches(field, "+")));
            }
            if (StringUtils.containsOnly(field, "0123456789")) {
                try {
                    show.setYear(Integer.parseInt(field));
                } catch (NumberFormatException e) {
                    logger.error("failed to parse year: {}", field);
                }
            }
            if ("New".equals(field)) {
                show.setNewFlag(true);
            }
            if (knownRatings.contains(field)) {
                show.setRating(field);
            }
        }
    }
}

From source file:com.vmware.identity.idm.ValidateUtil.java

public static int getValidIdxAccountNameSeparator(String userPrincipal, char[] validAccountNameSep) {
    // separator scan
    // validate there is no more than one separator is used
    int latestResult = -1; // not found
    int totalSepCount = 0;
    for (char sep : validAccountNameSep) {
        int count = StringUtils.countMatches(userPrincipal, String.valueOf(sep));
        totalSepCount += count;/*from  w  ww . java 2s .  c  o m*/
        if (totalSepCount > 1) {
            logAndThrow(String.format(
                    "Invalid user principal format [%s]: only one separator of '@' or '\' is allowed.",
                    userPrincipal));
        }
        if (count == 1) {
            latestResult = userPrincipal.indexOf(sep);
        }
    }

    return latestResult;
}

From source file:com.hangum.tadpole.manager.core.editor.executedsql.ExecutedSQLEditor.java

/**
 * search//from w w  w.j  av a2  s. c  o  m
 */
private void search() {
    //  ? ?? .
    clearGrid();
    mapSQLHistory.clear();

    // check all db
    String db_seq = "";
    if (!comboDatabase.getText().equals("All")) {
        searchUserDBDAO = (UserDBDAO) comboDatabase.getData(comboDatabase.getText());
        db_seq = "" + searchUserDBDAO.getSeq();
    } else {
        searchUserDBDAO = null;
        for (int i = 0; i < listUserDBDAO.size(); i++) {
            UserDBDAO userDB = listUserDBDAO.get(i);
            if (i == (listUserDBDAO.size() - 1))
                db_seq += ("" + userDB.getSeq());
            else
                db_seq += userDB.getSeq() + ",";
        }
    }

    Calendar cal = Calendar.getInstance();
    cal.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0);
    long startTime = cal.getTimeInMillis();

    cal.set(dateTimeEnd.getYear(), dateTimeEnd.getMonth(), dateTimeEnd.getDay(), 23, 59, 59);
    long endTime = cal.getTimeInMillis();
    int duringExecute = Integer.parseInt(textMillis.getText());

    String strSearchTxt = "%" + StringUtils.trimToEmpty(textSearch.getText()) + "%";

    try {
        List<SQLHistoryDAO> listSQLHistory = TadpoleSystem_ExecutedSQL.getExecuteQueryHistoryDetail(
                comboTypes.getText(), db_seq, startTime, endTime, duringExecute, strSearchTxt);
        for (SQLHistoryDAO sqlHistoryDAO : listSQLHistory) {
            mapSQLHistory.put("" + gridHistory.getRootItemCount(), sqlHistoryDAO);

            GridItem item = new GridItem(gridHistory, SWT.V_SCROLL | SWT.H_SCROLL);

            String strSQL = StringUtils.strip(sqlHistoryDAO.getStrSQLText());
            int intLine = StringUtils.countMatches(strSQL, "\n");
            if (intLine >= 1) {
                int height = (intLine + 1) * 24;
                if (height > 100)
                    item.setHeight(100);
                else
                    item.setHeight(height);
            }

            item.setText(0, "" + gridHistory.getRootItemCount());
            item.setText(1, sqlHistoryDAO.getDbName());
            item.setText(2, Utils.dateToStr(sqlHistoryDAO.getStartDateExecute()));
            logger.debug(Utils.convLineToHtml(strSQL));
            item.setText(3, Utils.convLineToHtml(strSQL));
            item.setToolTipText(3, strSQL);

            item.setText(4, "" + ((sqlHistoryDAO.getEndDateExecute().getTime()
                    - sqlHistoryDAO.getStartDateExecute().getTime()) / 1000f));
            item.setText(5, "" + sqlHistoryDAO.getRows());
            item.setText(6, sqlHistoryDAO.getResult());

            item.setText(7, Utils.convLineToHtml(sqlHistoryDAO.getMesssage()));
            item.setToolTipText(7, sqlHistoryDAO.getMesssage());

            item.setText(8, sqlHistoryDAO.getUserName());
            item.setText(9, sqlHistoryDAO.getIpAddress());

            if ("F".equals(sqlHistoryDAO.getResult())) {
                item.setBackground(SWTResourceManager.getColor(240, 180, 167));
            } else {
                item.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
            }
        }
    } catch (Exception ee) {
        logger.error("Executed SQL History call", ee); //$NON-NLS-1$
    }
}

From source file:jenkins.security.apitoken.LegacyApiTokenAdministrativeMonitorTest.java

private void checkUserWithLegacyTokenListHasSizeOf(Page page, int countOfToken, int countOfFreshToken,
        int countOfRecentToken) throws Exception {
    String pageContent = page.getWebResponse().getContentAsString();

    int actualCountOfToken = StringUtils.countMatches(pageContent, "token-to-revoke");
    assertEquals(countOfToken, actualCountOfToken);

    int actualCountOfFreshToken = StringUtils.countMatches(pageContent, "fresh-token");
    assertEquals(countOfFreshToken, actualCountOfFreshToken);

    int actualCountOfRecentToken = StringUtils.countMatches(pageContent, "recent-token");
    assertEquals(countOfRecentToken, actualCountOfRecentToken);
}

From source file:eu.europa.ec.fisheries.uvms.movement.mapper.SearchMapperListTest.java

/**
 * If there are several keys of the same type the query should build IN
 * statements//  ww  w . j  a v a 2 s. c o  m
 *
 * @throws ParseException
 * @throws SearchMapperException
 */
@Ignore
@Test
public void testQueryAllCategoryTwoTimes() throws ParseException, SearchMapperException {

    String ID = "1";
    String ID2 = "2";

    List<SearchValue> list = new ArrayList<>();

    //FIRST ROUND
    list.add(getSearchValue(ID, SearchField.MOVEMENT_ID));
    list.add(getSearchValue(ID, SearchField.SEGMENT_ID));
    list.add(getSearchValue(ID, SearchField.TRACK_ID));
    list.add(getSearchValue(ID, SearchField.CONNECT_ID));
    list.add(getSearchValue(MovementTypeType.ENT.name(), SearchField.MOVMENT_TYPE));
    list.add(getSearchValue(MovementActivityTypeType.ANC.name(), SearchField.ACTIVITY_TYPE));
    //TODO
    //list.add(getSearchValue(AREA, SearchField.AREA));
    //list.add(getSearchValue(SPEED_TYPE, SearchField.SPEED_TYPE));
    list.add(getSearchValue(MovementSourceType.INMARSAT_C.name(), SearchField.SOURCE));
    list.add(getSearchValue(SegmentCategoryType.ANCHORED.name(), SearchField.CATEGORY));

    //SECOND ROUND ( DATE_TO, DATE_FROM MAX_SPEED, MIN_SPEED are not added because they can only occur once )
    list.add(getSearchValue(ID2, SearchField.MOVEMENT_ID));
    list.add(getSearchValue(ID2, SearchField.SEGMENT_ID));
    list.add(getSearchValue(ID2, SearchField.TRACK_ID));
    list.add(getSearchValue(ID2, SearchField.CONNECT_ID));
    list.add(getSearchValue(MovementTypeType.EXI.name(), SearchField.MOVMENT_TYPE));
    list.add(getSearchValue(MovementActivityTypeType.CAN.name(), SearchField.ACTIVITY_TYPE));
    //TODO
    //list.add(getSearchValue(AREA, SearchField.AREA));
    //list.add(getSearchValue(SPEED_TYPE, SearchField.SPEED_TYPE));
    list.add(getSearchValue(MovementSourceType.INMARSAT_C.name(), SearchField.SOURCE));
    list.add(getSearchValue(SegmentCategoryType.EXIT_PORT.name(), SearchField.CATEGORY));

    //GET THE LIST
    String data = SearchFieldMapper.createSelectSearchSql(list, true);

    //ASSERT THE DATA
    String movement = revertToInStatement(MOVEMENT_ID, ID + ", " + ID2);
    Assert.assertTrue(StringUtils.countMatches(data, movement) == 1);

    String segment = revertToInStatement(SEGMENT_ID, ID + ", " + ID2);
    /*//System.out.println(data);
     //System.out.println(segment);*/
    //TODO FIX!
    //Assert.assertTrue(StringUtils.countMatches(data, segment) == 1);

    String track = revertToInStatement(TRACK_ID, ID + ", " + ID2);
    Assert.assertTrue(StringUtils.countMatches(data, track) == 1);

    //String connect = revertToInStatement(MOVEMENT_CONNECT_ID, ID + ", " + ID2);
    //Assert.assertTrue(StringUtils.countMatches(data, connect) == 1);
    String movementType = revertToInStatement(MOVEMENT_TYPE,
            MovementTypeType.ENT.ordinal() + ", " + MovementTypeType.EXI.ordinal());
    Assert.assertTrue(StringUtils.countMatches(data, movementType) == 1);

    String activityType = revertToInStatement(ACTIVITY_TYPE,
            MovementActivityTypeType.ANC.ordinal() + ", " + MovementActivityTypeType.CAN.ordinal());
    Assert.assertTrue(StringUtils.countMatches(data, activityType) == 1);

    String movementSource = revertToInStatement(SOURCE,
            MovementSourceType.INMARSAT_C.ordinal() + ", " + MovementSourceType.INMARSAT_C.ordinal());
    Assert.assertTrue(StringUtils.countMatches(data, movementSource) == 1);

    String segmentCategory = revertToInStatement(CATEGORY,
            SegmentCategoryType.ANCHORED.ordinal() + ", " + SegmentCategoryType.EXIT_PORT.ordinal());
    //TODO FIX!
    //Assert.assertTrue(StringUtils.countMatches(data, movementSource) == 1);

    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_CONECT_JOIN) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_TRACK_JOIN) == 1);
    //TODO        
    //Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_SEGMENT1_JOIN) == 1);
    //Assert.assertTrue(StringUtils.countMatches(data, MOVEMENT_SEGMENT2_JOIN) == 1);
    Assert.assertTrue(StringUtils.countMatches(data, METADATA_JOIN) == 1);
    //Assert.assertTrue(StringUtils.countMatches(data, AND) == 11);
}

From source file:com.amalto.core.storage.SystemStorageWrapper.java

@Override
public String getDocumentAsString(String clusterName, String uniqueID, String encoding)
        throws XmlServerException {
    if (encoding == null) {
        encoding = "UTF-8"; //$NON-NLS-1$
    }/*  www.  ja va 2s . c o  m*/
    Storage storage = getStorage(clusterName);
    ComplexTypeMetadata type = getType(clusterName, storage, uniqueID);
    if (type == null) {
        return null; // TODO
    }
    UserQueryBuilder qb;
    boolean isUserFormat = false;
    String documentUniqueID;
    if (DROPPED_ITEM_TYPE.equals(type.getName())) {
        // head.Product.Product.0- (but DM1.Bird.bid3)
        if (uniqueID.endsWith("-")) { //$NON-NLS-1$
            uniqueID = uniqueID.substring(0, uniqueID.length() - 1);
        }
        // TODO Code may not correctly handle composite id (but no system objects use this)
        documentUniqueID = uniqueID;
        if (StringUtils.countMatches(uniqueID, ".") >= 3) { //$NON-NLS-1$
            documentUniqueID = StringUtils.substringAfter(uniqueID, "."); //$NON-NLS-1$
        }
    } else if (COMPLETED_ROUTING_ORDER.equals(type.getName()) || FAILED_ROUTING_ORDER.equals(type.getName())) {
        documentUniqueID = uniqueID;
    } else {
        // TMDM-5513 custom form layout pk contains double dot .. to split, but it's a system definition object
        // like this Product..Product..product_layout
        isUserFormat = !uniqueID.contains("..") && uniqueID.indexOf('.') > 0; //$NON-NLS-1$
        documentUniqueID = uniqueID;
        if (uniqueID.startsWith(PROVISIONING_PREFIX_INFO)) {
            documentUniqueID = StringUtils.substringAfter(uniqueID, PROVISIONING_PREFIX_INFO);
        } else if (uniqueID.startsWith(BROWSEITEM_PREFIX_INFO)) {
            documentUniqueID = StringUtils.substringAfter(uniqueID, BROWSEITEM_PREFIX_INFO); //$NON-NLS-1$
        } else if (isUserFormat) {
            documentUniqueID = StringUtils.substringAfterLast(uniqueID, "."); //$NON-NLS-1$
        }
    }
    qb = from(type).where(eq(type.getKeyFields().iterator().next(), documentUniqueID));
    StorageResults results = null;
    try {
        storage.begin();
        results = storage.fetch(qb.getSelect());
        String xmlString = getXmlString(clusterName, type, results.iterator(), uniqueID, encoding,
                isUserFormat);
        storage.commit();
        return xmlString;
    } catch (IOException e) {
        storage.rollback();
        throw new XmlServerException(e);
    } finally {
        if (results != null) {
            results.close();
        }
    }
}

From source file:com.ing.connector.util.WStringUtil.java

public static String formatAgentName(String agentName) {

    int commaCount = StringUtils.countMatches(agentName, ",");
    String formattedAgentName = null;
    if (commaCount == 2) {
        String lastName = agentName.substring(0, agentName.indexOf(",")).trim();
        String firstName = (agentName.substring(agentName.indexOf(",") + 1, agentName.lastIndexOf(","))).trim();
        String middleName = (agentName.substring(agentName.lastIndexOf(",") + 1)).trim();

        formattedAgentName = lastName;//from w ww  .  j  av a 2s. com
        if (firstName.length() > 0) {
            if (formattedAgentName.length() > 0) {
                formattedAgentName = formattedAgentName + ", " + firstName;
            } else {
                formattedAgentName = firstName;
            }
        }

        if (middleName.length() > 0) {
            if (formattedAgentName.length() == 0) {
                formattedAgentName = middleName;
            } else if (firstName.length() > 0) {
                formattedAgentName = formattedAgentName + " " + middleName;
            } else {
                formattedAgentName = formattedAgentName + ", " + middleName;
            }
        }
        return formattedAgentName;

    } else {
        return agentName;
    }

}

From source file:com.cubusmail.mail.imap.IMAPMailbox.java

/**
 * @throws MessagingException/*from   w w w .jav  a  2  s.  c  o  m*/
 */
private void loadMailFolder() throws MessagingException {

    logger.debug("loading folder tree...");
    long millis = System.currentTimeMillis();
    this.mailFolderMap.clear();
    this.mailFolderList.clear();
    Folder defaultFolder = this.store.getDefaultFolder();
    this.folderSeparator = defaultFolder.getSeparator();

    // read all folders to a map
    List<String> topFolderNames = new ArrayList<String>();
    Folder[] allFolders = defaultFolder.list("*");
    if (allFolders != null && allFolders.length > 0) {
        for (Folder folder : allFolders) {
            this.mailFolderMap.put(folder.getFullName(), createMailFolder(folder));
            if (SessionManager.get().getPreferences().getInboxFolderName().equals(folder.getFullName())) {
                topFolderNames.add(0, SessionManager.get().getPreferences().getInboxFolderName());
            } else {
                String folderName = folder.getFullName();
                if (!StringUtils.isEmpty(this.personalNameSpace)
                        && folderName.startsWith(this.personalNameSpace)) {
                    folderName = StringUtils.substringAfter(folderName, this.personalNameSpace);
                }
                if (StringUtils.countMatches(folderName, String.valueOf(getFolderSeparator())) == 0) {
                    topFolderNames.add(folder.getFullName());
                }
            }
        }
    }

    // build the tree structure
    for (String folderName : topFolderNames) {
        IMailFolder mailFolder = this.mailFolderMap.get(folderName);
        this.mailFolderList.add(mailFolder);
        if (!SessionManager.get().getPreferences().getInboxFolderName().equals(folderName)
                && mailFolder.hasChildren()) {
            mailFolder.setSubfolders(getSubfolders(mailFolder));
        }
    }

    logger.debug("...finish: " + (System.currentTimeMillis() - millis) + "ms");
}

From source file:it.ventuland.ytd.YTDownloadThread.java

boolean savetextdata(BufferedReader textreader, int iRecursionCount, VideoElement pVideo) throws IOException {
    boolean rc = false;
    // read html lines one by one and search for java script array of video URLs
    String sline = "";
    while (sline != null) {
        sline = textreader.readLine();/*from w w  w  .java2s  .  c  o  m*/
        try {
            if (iRecursionCount == 0 && sline.matches("(.*)\"url_encoded_fmt_stream_map\":(.*)")) {
                rc = true;
                HashMap<String, String> ssourcecodevideourls = new HashMap<String, String>();

                sline = sline.replaceFirst(".*\"url_encoded_fmt_stream_map\": \"", "");
                sline = sline.replaceFirst("\".*", "");
                sline = sline.replace("%25", "%");
                sline = sline.replace("\\u0026", "&");
                sline = sline.replace("\\", "");

                // by anonymous
                String[] ssourcecodeyturls = sline.split(",");
                debugoutput("ssourcecodeuturls.length: ".concat(Integer.toString(ssourcecodeyturls.length)));
                String sResolutions = "found video URL for resolution: ";

                for (String urlString : ssourcecodeyturls) {

                    // assuming rtmpe is used for all resolutions, if found once - end download
                    if (urlString.matches(".*conn=rtmpe.*")) {
                        debugoutput("RTMPE found. cannot download this one!");
                        output("Unable to download video due to unsupported protocol (RTMPE). sry!");
                        break;
                    }
                    String[] fmtUrlPair = urlString.split("url=http", 2);
                    fmtUrlPair[1] = "url=http" + fmtUrlPair[1] + "&" + fmtUrlPair[0];
                    // grep itag=xz out and use xy as hash key
                    // 2013-02 itag now has up to 3 digits
                    fmtUrlPair[0] = fmtUrlPair[1].substring(fmtUrlPair[1].indexOf("itag=") + 5,
                            fmtUrlPair[1].indexOf("itag=") + 5 + 1
                                    + (fmtUrlPair[1].matches(".*itag=[0-9]{2}.*") ? 1 : 0)
                                    + (fmtUrlPair[1].matches(".*itag=[0-9]{3}.*") ? 1 : 0));
                    fmtUrlPair[1] = fmtUrlPair[1].replaceFirst("url=http%3A%2F%2F", "http://");
                    fmtUrlPair[1] = fmtUrlPair[1].replaceAll("%3F", "?").replaceAll("%2F", "/")
                            .replaceAll("%3B", ";").replaceAll("%2C", ",").replaceAll("%3D", "=")
                            .replaceAll("%26", "&").replaceAll("%252C", "%2C").replaceAll("sig=", "signature=")
                            .replaceAll("&s=", "&signature=").replaceAll("\\?s=", "?signature=");

                    // remove duplicated &itag=xy
                    if (StringUtils.countMatches(fmtUrlPair[1], "itag=") == 2) {
                        fmtUrlPair[1] = fmtUrlPair[1].replaceFirst("itag=[0-9]{1,3}", "");
                    }

                    try {
                        ssourcecodevideourls.put(fmtUrlPair[0], fmtUrlPair[1]); // save that URL
                        // debugoutput(String.format( "video url saved with key %s: %s",fmtUrlPair[0],ssourcecodevideourls.get(fmtUrlPair[0]) ));
                        sResolutions = sResolutions.concat(fmtUrlPair[0].equals("37") ? "1080p mpeg, " : // HD type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"
                                fmtUrlPair[0].equals("22") ? "720p mpeg, " : // HD type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"
                                        fmtUrlPair[0].equals("84") ? "1080p 3d mpeg, " : // HD 3D type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"
                                                fmtUrlPair[0].equals("35") ? "480p flv, " : // SD type=video/x-flv
                                                        fmtUrlPair[0].equals("18") ? "360p mpeg, " : // SD type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"
                                                                fmtUrlPair[0].equals("34") ? "360p flv, " : // SD type=video/x-flv
                                                                        fmtUrlPair[0].equals("82")
                                                                                ? "360p 3d mpeg, "
                                                                                : // SD 3D type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"
                                                                                fmtUrlPair[0].equals("36")
                                                                                        ? "240p mpeg 3gpp, "
                                                                                        : // LD type=video/3gpp;+codecs="mp4v.20.3,+mp4a.40.2"
                                                                                        fmtUrlPair[0].equals(
                                                                                                "17") ? "114p mpeg 3gpp, "
                                                                                                        : // LD type=video/3gpp;+codecs="mp4v.20.3,+mp4a.40.2"

                                                                                                        fmtUrlPair[0]
                                                                                                                .equals("46")
                                                                                                                        ? "1080p webm, "
                                                                                                                        : // HD type=video/webm;+codecs="vp8.0,+vorbis"&
                                                                                                                        fmtUrlPair[0]
                                                                                                                                .equals("45")
                                                                                                                                        ? "720p webm, "
                                                                                                                                        : // HD type=video/webm;+codecs="vp8.0,+vorbis"
                                                                                                                                        fmtUrlPair[0]
                                                                                                                                                .equals("100")
                                                                                                                                                        ? "1080p 3d webm, "
                                                                                                                                                        : // HD 3D type=video/webm;+codecs="vp8.0,+vorbis"&
                                                                                                                                                        fmtUrlPair[0]
                                                                                                                                                                .equals("44")
                                                                                                                                                                        ? "480p webm, "
                                                                                                                                                                        : // SD type=video/webm;+codecs="vp8.0,+vorbis"
                                                                                                                                                                        fmtUrlPair[0]
                                                                                                                                                                                .equals("43")
                                                                                                                                                                                        ? "360p webm, "
                                                                                                                                                                                        : // SD type=video/webm;+codecs="vp8.0,+vorbis"
                                                                                                                                                                                        fmtUrlPair[0]
                                                                                                                                                                                                .equals("102")
                                                                                                                                                                                                        ? "360p 3d webm, "
                                                                                                                                                                                                        : // SD 3D type=video/webm;+codecs="vp8.0,+vorbis"&
                                                                                                                                                                                                        fmtUrlPair[0]
                                                                                                                                                                                                                .equals("5")
                                                                                                                                                                                                                        ? "240p flv, "
                                                                                                                                                                                                                        : // LD type=video/x-flv
                                                                                                                                                                                                                        "unknown resolution! ("
                                                                                                                                                                                                                                .concat(fmtUrlPair[0])
                                                                                                                                                                                                                                .concat(")"));
                    } catch (java.lang.ArrayIndexOutOfBoundsException aioobe) {
                    }
                } // for

                output(sResolutions);
                debugoutput(sResolutions);

                int iindex;
                iindex = 0;
                this.vNextVideoURL.removeAllElements();

                debugoutput(
                        "ssourcecodevideourls.length: ".concat(Integer.toString(ssourcecodevideourls.size())));
                // figure out what resolution-button is pressed now and fill list with possible URLs

                switch (pVideo.videoQuality) {
                case "HD": // HD
                    // try 1080p/720p in selected format first. if it's not available than the other format will be used
                    if ("MPEG".equals(pVideo.videoFormat)) {
                        iindex = addMPEG_HD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    if ("WEBM".equals(pVideo.videoFormat)) {
                        iindex = addWBEM_HD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    // there are no FLV HD URLs for now, so at least try mpg,wbem HD then
                    iindex = addMPEG_HD_Urls(iindex, ssourcecodevideourls, pVideo);
                    iindex = addWBEM_HD_Urls(iindex, ssourcecodevideourls, pVideo);

                case "Std": // SD
                    // try to download desired format first, if it's not available we take the other of same res
                    if ("MPEG".equals(pVideo.videoFormat)) {
                        iindex = addMPEG_SD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    if ("WEBM".equals(pVideo.videoFormat)) {
                        iindex = addWBEM_SD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    if ("FLV".equals(pVideo.videoFormat)) {
                        iindex = addFLV_SD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    iindex = addMPEG_SD_Urls(iindex, ssourcecodevideourls, pVideo);
                    iindex = addWBEM_SD_Urls(iindex, ssourcecodevideourls, pVideo);
                    iindex = addFLV_SD_Urls(iindex, ssourcecodevideourls, pVideo);

                case "LD": // LD

                    // TODO this.sFilenameResPart = "(LD)"; // adding LD to filename because HD-Videos are almost already named HD (?)
                    if ("MPEG".equals(pVideo.videoFormat)) {
                        iindex = addMPEG_LD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    if ("WEBM".equals(pVideo.videoFormat)) {
                        // there are no wbem LD URLs for now
                    }

                    if ("FLV".equals(pVideo.videoFormat)) {
                        iindex = addFLV_LD_Urls(iindex, ssourcecodevideourls, pVideo);
                    }

                    // we must ensure all (16) possible URLs get added to the list so that the list of URLs is never empty
                    iindex = addMPEG_LD_Urls(iindex, ssourcecodevideourls, pVideo);
                    iindex = addFLV_LD_Urls(iindex, ssourcecodevideourls, pVideo);

                    break;
                default:
                    // this.vNextVideoURL = null;
                    this.sVideoURL = null;
                    break;
                }

                // if the first 2 entries are null than there are no URLs for the selected resolution
                // strictly speaking this is only true for HD as there are only two URLs in contrast to three of SD - in this case the output will not be shown but downloading should work anyway
                if (this.vNextVideoURL.get(0).getsURL() == null
                        && this.vNextVideoURL.get(1).getsURL() == null) {
                    String smsg = "could not find video url for selected resolution! trying lower res...";
                    output(smsg);
                    debugoutput(smsg);
                }

                // remove null entries in list - we later try to download the first (index 0) and if it fails the next one (at index 1) and so on
                for (int x = this.vNextVideoURL.size() - 1; x >= 0; x--) {
                    if (this.vNextVideoURL.get(x).getsURL() == null) {
                        this.vNextVideoURL.remove(x);
                    }
                }

                try {
                    this.sVideoURL = this.vNextVideoURL.get(0).getsURL();
                    debugoutput(String.format("trying this one: %s %s %s", this.vNextVideoURL.get(0).getsITAG(),
                            this.vNextVideoURL.get(0).getsQUALITY(), this.vNextVideoURL.get(0).getsTYPE()));
                } catch (ArrayIndexOutOfBoundsException aioobe) {
                }

                this.setTitle(this.getTitle()
                        .concat(!this.vNextVideoURL.get(0).getsRESPART().equals("")
                                ? "." + this.vNextVideoURL.get(0).getsRESPART()
                                : ""));

            }

            if (iRecursionCount == 0 && sline.matches("(.*)<meta name=\"title\" content=(.*)")) {
                String stmp = sline.replaceFirst("(.*)<meta name=\"title\" content=", "").trim();
                // change html characters to their UTF8 counterpart
                stmp = UTF8Utils.changeHTMLtoUTF8(stmp);
                stmp = stmp.replaceFirst("^\"", "").replaceFirst("\">$", "");

                // http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
                //
                stmp = stmp.replaceAll("<", "");
                stmp = stmp.replaceAll(">", "");
                stmp = stmp.replaceAll(":", "");
                stmp = stmp.replaceAll("/", " ");
                stmp = stmp.replaceAll("\\\\", " ");
                stmp = stmp.replaceAll("|", "");
                stmp = stmp.replaceAll("\\?", "");
                stmp = stmp.replaceAll("\\*", "");
                stmp = stmp.replaceAll("/", " ");
                stmp = stmp.replaceAll("\"", " ");
                stmp = stmp.replaceAll("%", "");

                this.setTitle(stmp); // complete file name without path
            }

        } catch (NullPointerException npe) {
        }
    } // while
    return rc;
}