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

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

Introduction

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

Prototype

public static int countMatches(final CharSequence str, final char ch) 

Source Link

Document

Counts how many times the char appears in the given string.

A null or empty ("") String input returns 0 .

 StringUtils.countMatches(null, *)       = 0 StringUtils.countMatches("", *)         = 0 StringUtils.countMatches("abba", 0)  = 0 StringUtils.countMatches("abba", 'a')   = 2 StringUtils.countMatches("abba", 'b')  = 2 StringUtils.countMatches("abba", 'x') = 0 

Usage

From source file:org.manalith.ircbot.plugin.keyseqconv.DubeolAutomataEngine.java

@Override
 public String parseKeySequenceToKorean(String keySequence) throws ParseException, IllegalArgumentException {
     String result = "";

     LetterState stateFlag = LetterState.Null;

     String tICon = "";
     String tIConLookahead = "";
     String tIConLookaheadCombination = "";
     String tVow = "";
     String tVowLookahead = "";
     String tVowLookaheadCombination = "";
     String tFCon = "";
     String tFConLookahead = "";
     String tFConLookaheadCombination = "";

     LetterObject syl = new LetterObject(KeyboardLayout.Dubeol);

     if (isEnableParsingExceptionSyntax() && StringUtils.countMatches(keySequence, "\\") % 2 == 1)

         throw new ParseException("Back slashes do not match", keySequence.lastIndexOf("\\", 0));

     for (int i = 0; i < keySequence.length(); i++) {
         if (stateFlag.equals(LetterState.Null) || stateFlag.equals(LetterState.Finish)) {
             stateFlag = LetterState.IConsonant;
         }//from  w w w  . j a  v  a 2  s.c  o m

         if (!CharUtils.isAsciiAlpha(keySequence.charAt(i))) {
             if (keySequence.charAt(i) == '\\' && isEnableParsingExceptionSyntax()) {
                 if (i < keySequence.length() - 1)
                     if (keySequence.charAt(i + 1) == '\\') {
                         result += "\\";
                         continue;
                     }
                 i++;
                 while (true) {
                     if (i + 1 <= keySequence.length() - 1) {
                         if (keySequence.charAt(i) == '\\') {
                             if (keySequence.charAt(i + 1) == '\\') {
                                 i++;
                                 result += '\\';
                             } else
                                 break;
                         } else {
                             result += keySequence.charAt(i);
                         }
                     } else {
                         if (keySequence.charAt(i) == '\\') {
                             break;
                         } else {
                             result += keySequence.charAt(i);
                         }
                     }
                     i++;
                 }
             } else {
                 result += keySequence.charAt(i);
             }
             continue;
         }
         //  (??, ???)
         if (stateFlag.equals(LetterState.IConsonant)) {
             // ? 
             tIConLookahead = tIConLookaheadCombination = "";

             //  ?? ? ?  ?    ? 
             tICon = hasTwoSymbolinOneKey(keySequence.charAt(i)) ? Character.toString(keySequence.charAt(i))
                     : Character.toString(keySequence.charAt(i)).toLowerCase();
             // ?    ?  
             if (i < keySequence.length() - 1) {
                 //  ?? ? ?  ?    ? 
                 tIConLookahead = hasTwoSymbolinOneKey(keySequence.charAt(i + 1))
                         ? Character.toString(keySequence.charAt(i + 1))
                         : Character.toString(keySequence.charAt(i + 1)).toLowerCase();
                 tIConLookaheadCombination = tICon + tIConLookahead;
             }

             // ??? ??? ?,  ? ?.
             // ( , ?  )
             if (isFConsonant(tIConLookaheadCombination)) {

                 // 2 step - lookahead  try
                 if (i + 2 <= keySequence.length() - 1) {
                     String lookOverTwoStep = hasTwoSymbolinOneKey(keySequence.charAt(i + 2))
                             ? Character.toString(keySequence.charAt(i + 2))
                             : Character.toString(keySequence.charAt(i + 2)).toLowerCase();

                     // ?? ?  , ?? ? ?, , ?
                     if (isISingleConsonant(lookOverTwoStep) || isIDoubleConsonant(lookOverTwoStep)
                             || !CharUtils.isAsciiAlpha(lookOverTwoStep.charAt(0))) {

                         result += getSingleChar(getSingleCharVal(tIConLookaheadCombination));

                         i++;
                     }
                     // ?? ?   ?
                     else if (isVowel(lookOverTwoStep)) {
                         // ???  ?   ? 
                         result += getSingleChar(getSingleCharVal(tICon));
                         continue;
                     }

                 }
                 // ? ? () ?? ?    
                 else {
                     result += getSingleChar(getSingleCharVal(tIConLookaheadCombination));
                     stateFlag = LetterState.Null;
                     break;
                 }
             }
             // ???, ???  ( () ?? )
             else {
                 // ???  ? ?
                 if (isISingleConsonant(tICon) || isIDoubleConsonant(tICon)) {
                     syl.setIConsonant(tICon);
                     // init = DubeolSymbol.DubeolIConsonant.valueOf(tICon);
                 }
                 // ?? ??? ?  ?   
                 else if (isVowel(tICon)) {
                     stateFlag = LetterState.Vowel;
                     i--;
                     continue;
                 }

                 // ? ? ? ?? ?    
                 if (i == keySequence.length() - 1) {

                     result += getSingleChar(getSingleCharVal(tICon));
                     syl.initLetter();
                     stateFlag = LetterState.Null;
                     break;
                 }

                 //  ??? ? ? ?? ?? ?  ? 
                 if (isVowel(tIConLookahead)) {
                     stateFlag = LetterState.Vowel;
                     continue;
                 }
                 //  ??? ?  
                 else {

                     result += getSingleChar(getSingleCharVal(tICon));
                     syl.initLetter();
                 }
             }
         }
         //  (?)
         else if (stateFlag.equals(LetterState.Vowel)) {
             // ? 
             tVowLookahead = tVowLookaheadCombination = "";

             //  ?? ? ?  ?    ? 
             tVow = hasTwoSymbolinOneKey(keySequence.charAt(i)) ? Character.toString(keySequence.charAt(i))
                     : Character.toString(keySequence.charAt(i)).toLowerCase();
             // ?    ?  
             if (i < keySequence.length() - 1) {
                 //  ?? ? ?  ?    ? 
                 tVowLookahead = hasTwoSymbolinOneKey(keySequence.charAt(i + 1))
                         ? Character.toString(keySequence.charAt(i + 1))
                         : Character.toString(keySequence.charAt(i + 1)).toLowerCase();
                 tVowLookaheadCombination = tVow + tVowLookahead;
             }

             // ?? ?
             if (isVowel(tVowLookaheadCombination)) {
                 syl.setVowel(tVowLookaheadCombination);
                 // vow =
                 // DubeolSymbol.DubeolVowel.valueOf(tVowLookaheadCombination);

                 // 2 step - lookahead  try
                 if (i + 2 <= keySequence.length() - 1) {
                     //  ?? ? ?  ?    ? 
                     String lookOverTwoStep = hasTwoSymbolinOneKey(keySequence.charAt(i + 2))
                             ? Character.toString(keySequence.charAt(i + 2))
                             : Character.toString(keySequence.charAt(i + 2)).toLowerCase();

                     i++;

                     // ?? ?? ? ?  ? , ? ?? ??? .
                     // ??  ??? ?   ?  ? ? 
                     if (isVowel(lookOverTwoStep)
                             || ((isISingleConsonant(lookOverTwoStep) || isIDoubleConsonant(lookOverTwoStep))
                                     && !isFConsonant(lookOverTwoStep))) {
                         stateFlag = LetterState.Finish;
                     }
                     // ?? ? ?  ? ? , ex: 
                     else if (isFConsonant(lookOverTwoStep)) {
                         if (!syl.isCompleteSyllable()) {

                             result += getSingleChar(getSingleCharVal(tVowLookaheadCombination));
                             stateFlag = LetterState.Null;
                         } else {
                             stateFlag = LetterState.FConsonant;
                             continue;
                         }
                     }
                     //   ? ?
                     else if (!CharUtils.isAsciiAlpha(lookOverTwoStep.charAt(0))) {
                         if (!syl.isCompleteSyllable()) {
                             result += getSingleChar(getSingleCharVal(tVowLookaheadCombination));
                             syl.initLetter();
                             stateFlag = LetterState.Null;
                         } else
                             stateFlag = LetterState.Finish;
                     }
                 }
                 // ? ? ?   ?  (? )
                 else {
                     // ???  ?  ? ? 
                     if (!syl.isCompleteSyllable()) {
                         result += getSingleChar(getSingleCharVal(tVowLookaheadCombination));
                         syl.initLetter();
                         i++;
                         stateFlag = LetterState.Null;
                     } else {
                         stateFlag = LetterState.Finish;
                     }

                     // ?? ? ?  
                     if (i == keySequence.length() - 1)
                         break;
                 }
             }
             // ??  , ? ?            
             else {
                 //    ??  
                 if (isVowel(tVow)) {
                     // ??  ? .
                     if (!syl.isCompleteSyllable())
                         syl.setVowel(tVow);

                     //  ? ??
                     if (i == keySequence.length() - 1) {
                         // ???   ? ? 
                         if (!syl.isCompleteSyllable()) {

                             result += getSingleChar(getSingleCharVal(tVow));
                             syl.initLetter();
                             stateFlag = LetterState.Null;
                         }
                         // ???  ?   ? 
                         else {
                             stateFlag = LetterState.Finish;
                         }
                         break;
                     }

                     // 2?   ? ???  ?? 
                     // ??  ? ? ? delimiter 
                     // ? , ?, ? ? .
                     if (!CharUtils.isAsciiAlpha(tVowLookahead.charAt(0))) {

                         // ?  ? ? .
                         if (!syl.isCompleteSyllable()) {

                             result += getSingleChar(getSingleCharVal(tVow));
                             syl.initLetter();
                             stateFlag = LetterState.IConsonant;
                             continue;
                         } else
                             stateFlag = LetterState.Finish;
                     }

                     // *// ? ? ?. ?
                     // ??? ? ? 
                     if (!syl.isCompleteSyllable()) {
                         // ? ?
                         result += getSingleChar(getSingleCharVal(tVow));
                         syl.initLetter();

                         // ?? ??? ??
                         if (isISingleConsonant(tVowLookahead) || isIDoubleConsonant(tVowLookahead))
                             stateFlag = LetterState.IConsonant;
                         // ?? ?  
                         else if (isVowel(tVowLookahead))
                             stateFlag = LetterState.Vowel;

                         continue;
                     } else {
                         // ?? + ? +  : good!
                         if (isFConsonant(tVowLookahead))
                             stateFlag = LetterState.FConsonant;
                         // ??? ??  ? ? ?  , : 
                         //   ? ???  ? .
                         else
                             stateFlag = LetterState.Finish;
                     }
                 }
             }
         }
         // 
         else if (stateFlag.equals(LetterState.FConsonant)) {
             // ? 
             tFConLookahead = tFConLookaheadCombination = "";

             //  ?? ? ?  ?    ? 
             tFCon = hasTwoSymbolinOneKey(keySequence.charAt(i)) ? Character.toString(keySequence.charAt(i))
                     : Character.toString(keySequence.charAt(i)).toLowerCase();
             // ?    ?  
             if (i < keySequence.length() - 1) {
                 tFConLookahead = hasTwoSymbolinOneKey(keySequence.charAt(i + 1))
                         ? Character.toString(keySequence.charAt(i + 1))
                         : Character.toString(keySequence.charAt(i + 1)).toLowerCase();
                 tFConLookaheadCombination = tFCon + tFConLookahead;
             }

             stateFlag = LetterState.Finish; // ?   ? ? ??.

             //  ????
             if (isFConsonant(tFConLookaheadCombination)) {

                 // 2 step - lookahead  try
                 if (i + 2 <= keySequence.length() - 1) {
                     String lookOverTwoStep = hasTwoSymbolinOneKey(keySequence.charAt(i))
                             ? Character.toString(keySequence.charAt(i + 2))
                             : Character.toString(keySequence.charAt(i + 2)).toLowerCase();

                     // () ??? ??? ? 
                     if (isISingleConsonant(lookOverTwoStep) || isIDoubleConsonant(lookOverTwoStep)
                             || !CharUtils.isAsciiAlpha(lookOverTwoStep.charAt(0))) {
                         // ?  ? . ???    
                         syl.setFConsonant(tFConLookaheadCombination);
                         i++;
                         // ?? ? ? . , ?? + ?
                     } else if (isVowel(lookOverTwoStep))
                         syl.setFConsonant(tFCon);

                 } else {
                     //  ? ??   ?? ?  ??.
                     if (isFConsonant(tFConLookaheadCombination)) {
                         syl.setFConsonant(tFConLookaheadCombination);
                     }

                     break;
                 }

             } else {
                 // ?? ? ??? ? ? .
                 if (isFConsonant(tFCon))
                     syl.setFConsonant(tFCon);

                 //  ? ???? ??.
                 if (i == keySequence.length() - 1)
                     break;

                 // ? ? ??    backtracking.
                 //  ?  ? 
                 if (isVowel(tFConLookahead)) {
                     syl.setFConsonant("nul");
                     stateFlag = LetterState.Finish;
                     i--;
                 }
             }
         }

         //  ? ?  ? ?   ?? 
         if (stateFlag == LetterState.Finish) {
             result += syl.getLetter();
             syl.initLetter();
         }
     }

     // .
     if (stateFlag == LetterState.Finish)
         result += syl.getLetter();

     return result;
 }

From source file:org.manalith.ircbot.plugin.linuxpkgfinder.ArchPackageFinder.java

public String getResultFromMainPkgDB(String arg) throws IOException {

    String[] arch_keywords = { "any", "i686", "x86_64" };
    int len = arch_keywords.length;
    int pages = 100000000;

    String infostr = "";
    String url = "";

    for (int i = 0; i < len; i++) {
        for (int j = 0; j < pages; j++) {
            url = "http://www.archlinux.org/packages/?page=" + (new Integer(j + 1)).toString() + "&arch="
                    + arch_keywords[i] + "&q=" + arg;

            String pageinfo = "";
            try {
                pageinfo = Jsoup.connect(url).get().select("div#pkglist-results>div.pkglist-stats>p").get(0)
                        .text();/* w  ww .ja v  a2  s. com*/
            } catch (Exception e) {
                pages = 1;
            }

            if (j == 0 && pages == 100000000) {
                if (StringUtils.countMatches(pageinfo, ".") == 1)
                    pages = 1;
                else {
                    if (pageinfo.charAt(pageinfo.length() - 1) == '.')
                        pageinfo = pageinfo.substring(0, pageinfo.length() - 1);
                    String[] piarray = pageinfo.split("\\s");
                    pages = NumberUtils.toInt(piarray[piarray.length - 1]);
                }
            }

            Iterator<Element> e = Jsoup.connect(url).get().select("table.results>tbody>tr").iterator();

            while (e.hasNext()) {
                Elements ee = e.next().select("td");
                if (ee.get(2).select("a").get(0).text().equals(arg)) {
                    if (!infostr.equals(""))
                        infostr += ", ";
                    infostr += "\u0002(main-" + ee.get(0).text() + " " + ee.get(1).text() + ")\u0002 ";

                    if (pkgname.length() == 0)
                        pkgname = ee.get(2).select("a").get(0).text();
                    if (description.length() == 0)
                        description = ee.get(4).text();

                    if (ee.get(3).select("span.flagged").size() > 0)
                        infostr += ee.get(3).select("span.flagged").get(0).text();
                    else
                        infostr += ee.get(3).text();

                    break;
                }
            }
        }
        pages = 100000000;
    }

    return infostr;
}

From source file:org.manalith.ircbot.plugin.linuxpkgfinder.ArchPackageFinder.java

private String getResultFromAUR(String arg) throws IOException {
    String infostr = "";
    String pageinfo = "";
    String url = "";

    int pages = 100000000;

    for (int i = 0; i < pages; i++) {

        url = "http://aur.archlinux.org/packages.php?SeB=x&K=" + arg + "&PP=50&O=" + (i * 50);

        try {/*from   w  w w .  jav a 2  s.c o m*/
            pageinfo = Jsoup.connect(url).get().select("div#pkglist-results>div.pkglist-stats>p").get(0).text();
        } catch (IndexOutOfBoundsException e) {
            return "";
        }

        if (i == 0 && pages == 100000000) {
            if (StringUtils.countMatches(pageinfo, ".") == 1)
                pages = 1;
            else {
                if (pageinfo.charAt(pageinfo.length() - 1) == '.')
                    pageinfo = pageinfo.substring(0, pageinfo.length() - 1);
                String[] piarray = pageinfo.split("\\s");
                pages = NumberUtils.toInt(piarray[piarray.length - 1]);
            }
        }

        Iterator<Element> e = Jsoup.connect(url).get().select("table>tbody>tr").iterator();

        while (e.hasNext()) {
            Elements ee = e.next().select("td");
            if (ee.get(1).select("td").get(0).text().equals(arg)) {
                if (!infostr.equals(""))
                    infostr += " | ";
                if (pkgname.length() == 0)
                    pkgname = ee.get(1).select("a").text();
                if (description.length() == 0)
                    description = ee.get(4).text();

                infostr += "\u0002(AUR-" + ee.get(0).text() + ")\u0002 ";
                infostr += ee.get(2).text();
                break;
            }
        }
    }

    return infostr;
}

From source file:org.moe.gradle.natj.IBActionAndOutletComposer.java

public String compose(UIActionsAndOutletsOptions options) {
    final List<String> classIncludeFilters = new ArrayList<>(options.getIncludes());
    if (classIncludeFilters.size() == 0) {
        classIncludeFilters.add(".*");
    }//from  ww w  . ja va 2  s.c om

    final StringBuilder builder = new StringBuilder();
    final StringBuilder headBuilder = new StringBuilder();

    final Set<String> allLibraries = new HashSet<>();
    allLibraries.add("UIKit");

    headBuilder.append("/** THIS FILE IS GENERATED BY MULTI-OS ENGINE AND MAY BE OVERWRITTEN! **/\n\n");
    headBuilder.append("#if TARGET_INTERFACE_BUILDER\n\n");
    resolver.resolve((k, resolvedClass) -> {
        final ClassVisitor v = resolvedClass.getClazz();
        if (!v.hasObjcClassName() || !resolvedClass.isValidObjCType() || v.hasObjcClassBinding()) {
            return;
        }
        final String prettyName = resolvedClass.getPrettyName();
        if (classIncludeFilters.stream().noneMatch(prettyName::matches)) {
            LOG.info("Skipping " + prettyName + ": not found in include list");
            return;
        }

        // Get class
        final String objcClassName = v.getObjcClassName();
        LOG.debug("Generating interface for " + objcClassName + "\n");

        // Get super class
        if (v.getSuperName() == null) {
            LOG.warn("Superclass is null for " + objcClassName);
            return;
        }
        final String objcSuperClassName = resolvedClass.getSuperObjCName();
        if (objcSuperClassName == null) {
            LOG.warn("Failed to locate superclass for " + objcClassName);
            return;
        }
        LOG.debug("    Found superclass " + objcSuperClassName + "\n");

        // Get interfaces
        final Set<String> interfaces = TaskUtils.compute(() -> {
            final Set<String> itfs = new HashSet<>();

            // Add libraries from interface hierarchy
            for (String superItf : v.getSuperInterfaces()) {
                final ResolvedClass superItfRc = resolver.get(superItf);
                if (superItfRc == null) {
                    continue;
                }
                NatJClass _v = superItfRc.getClazz();
                if (_v != null && _v.hasObjcProtocolName()) {
                    if (_v.hasObjcProtocolSourceName()) {
                        itfs.add(_v.getObjcProtocolSourceName());
                    } else {
                        itfs.add(_v.getObjcProtocolName());
                    }
                }
            }

            return itfs;
        });
        LOG.debug("    Found interfaces " + interfaces + "\n");

        // Get libraries
        final Set<String> libraries = TaskUtils.compute(() -> {
            final Set<String> libs = new HashSet<>();

            // Add first library in class hierarchy
            ResolvedClass _r = resolvedClass;
            do {
                NatJClass _v = _r.getClazz();
                if (_v.hasLibrary()) {
                    libs.add(_v.getLibrary());
                    break;
                }
                _r = _r.getSuper();
            } while (_r != null);

            // Add libraries from interface hierarchy
            for (String superItf : v.getSuperInterfaces()) {
                _r = resolver.get(superItf);
                NatJClass _v = _r.getClazz();
                if (_v.hasLibrary()) {
                    libs.add(_v.getLibrary());
                    break;
                }
            }

            return libs;
        });
        LOG.debug("    Found libraries " + libraries + "\n");
        allLibraries.addAll(libraries);

        // Generate interface
        headBuilder.append("@class ").append(objcClassName).append(";\n");
        builder.append("@interface ").append(objcClassName).append(" : ").append(objcSuperClassName);
        if (interfaces.size() > 0) {
            builder.append(" <").append(interfaces.stream().collect(Collectors.joining(", "))).append(">");
        }
        builder.append("\n");
        v.methods.forEach(m -> {
            final Type methodType = Type.getMethodType(m.getDesc());
            final String sel = m.getSel();

            // Generate properties
            if (m.isProperty()) {
                LOG.debug("    Generating property for " + m.getName() + m.getDesc() + "\n");
                if (methodType.getArgumentTypes().length > 0) {
                    logSkip(resolvedClass, m,
                            "cannot have the @Property annotation and have arguments at the same time");
                    return;
                }
                final Type returnType = methodType.getReturnType();
                if (returnType.getSort() != Type.OBJECT) {
                    logSkip(resolvedClass, m,
                            "cannot have the @Property annotation and have a non-object return type");
                    return;
                }
                final ResolvedClass internalType = resolver.get(returnType.getInternalName());
                if (internalType == null || internalType.getBindingType() == null) {
                    logSkip(resolvedClass, m, "unsupported return type");
                    return;
                }
                if (internalType.getClazz().hasLibrary()) {
                    allLibraries.add(internalType.getClazz().getLibrary());
                }
                builder.append("@property (strong) ");
                if (m.isIBOutlet()) {
                    builder.append("IBOutlet ");
                }
                final int begin = builder.length();
                builder.append(internalType.getBindingType());
                builder.append(" ").append(sel).append(";\n");
                return;
            }

            // Generate actions
            if (m.isIBAction()) {
                LOG.debug("    Generating action for " + m.getName() + m.getDesc() + "\n");
                final Type returnType = methodType.getReturnType();
                if (returnType.getSort() != Type.VOID) {
                    logSkip(resolvedClass, m,
                            "cannot have the @IBAction annotation and have a non-void return type");
                    return;
                }

                final int numArgs = methodType.getArgumentTypes().length;
                if (numArgs == 0) {
                    builder.append("- (IBAction)").append(sel).append(";\n");
                    return;
                }

                final Type arg0 = methodType.getArgumentTypes()[0];
                if (arg0.getSort() != Type.OBJECT) {
                    logSkip(resolvedClass, m,
                            "cannot have the @IBAction annotation, have 1 one or more arguments and have a "
                                    + "non-object first argument type");
                    return;
                }
                final ResolvedClass arg0InternalType = resolver.get(arg0.getInternalName());
                if (arg0InternalType == null || arg0InternalType.getBindingType() == null) {
                    logSkip(resolvedClass, m, "unsupported first argument type");
                    return;
                }

                if (numArgs == 1) {
                    if (StringUtils.countMatches(sel, ":") != 1) {
                        logSkip(resolvedClass, m, "bad selector, expected one argument in selector");
                        return;
                    }
                    if (!sel.endsWith(":")) {
                        logSkip(resolvedClass, m, "malformed selector, selector must end in ':'");
                        return;
                    }
                    final int begin = builder.length();
                    builder.append("- (IBAction)").append(sel).append("(");
                    builder.append(arg0InternalType.getBindingType());
                    builder.append(")sender;\n");
                    return;
                }

                final Type arg1 = methodType.getArgumentTypes()[1];
                if (arg1.getSort() != Type.OBJECT) {
                    logSkip(resolvedClass, m,
                            "cannot have the @IBAction annotation, have 2 one or more arguments and have a "
                                    + "non UIEvent second argument type");
                    return;
                }
                final String arg1InternalName = arg1.getInternalName();
                final ResolvedClass arg1InternalType = resolver.get(arg1InternalName);
                if (arg1InternalType == null
                        || !"UIEvent".equals(arg1InternalType.getClazz().getObjcClassBinding())) {
                    logSkip(resolvedClass, m,
                            "cannot have the @IBAction annotation, have 2 one or more arguments and have a "
                                    + "non UIEvent second argument type");
                    return;
                }

                if (numArgs == 2) {
                    if (StringUtils.countMatches(sel, ":") != 2) {
                        logSkip(resolvedClass, m, "bad selector, expected two arguments in selector");
                        return;
                    }
                    if (!sel.endsWith(":")) {
                        logSkip(resolvedClass, m, "malformed selector, selector must end in ':'");
                        return;
                    }
                    final int begin = builder.length();
                    builder.append("- (IBAction)").append(sel.substring(0, sel.indexOf(':') + 1)).append("(");
                    builder.append(arg0InternalType.getBindingType());
                    final String selSuffix = sel.substring(sel.indexOf(':') + 1);
                    builder.append(")sender ").append(selSuffix).append("(UIEvent *)event;\n");
                    return;
                }

                logSkip(resolvedClass, m,
                        "malformed selector, expected zero, one or two arguments in selector");
                return;
            }

            LOG.debug("    Skipping " + m.getName() + m.getDesc() + "\n");
        });

        // Generate close interface
        builder.append("@end\n\n");
    });

    // Generate footer
    builder.append("#endif\n");

    // Combine head and body
    headBuilder.append("\n");

    // Generate imports
    allLibraries.removeAll(options.getExcludeLibraries());
    allLibraries.forEach(x -> headBuilder.append("@import ").append(x).append(";\n"));
    headBuilder.append("\n");
    options.getAdditionalCodes().forEach(x -> headBuilder.append(x).append("\n"));
    headBuilder.append("\n");

    headBuilder.append(builder);
    return headBuilder.toString();
}

From source file:org.ms123.common.importing.BaseImportingServiceImpl.java

private String[] getFieldsFromMapping(List<Map> mappings) {
    List<String> fields = new ArrayList<String>();
    for (Map<String, String> mapping : mappings) {
        String source = mapping.get("source");
        String target = mapping.get("target");
        String targetType = mapping.get("targetType");
        if (!("list".equals(targetType) || "object".equals(targetType))) {
            if (StringUtils.countMatches(target, ".") == 1) {
                fields.add(getLastElement(target, "."));
            }/*from w w w. ja  v  a  2s.c om*/
        }
    }
    System.out.println("getFieldsFromMapping2:" + fields);
    String sa[] = new String[fields.size()];
    return fields.toArray(sa);
}

From source file:org.ms123.common.importing.XmlImporter.java

private int countDotSegments(String toCheck) {
    return StringUtils.countMatches(toCheck, ".");
}

From source file:org.ms123.common.importing.XmlImporter.java

private int countSegments(String toCheck) {
    return StringUtils.countMatches(toCheck, "/");
}

From source file:org.multibit.utils.CSMiscUtils.java

public static void updateForegroundColorOfAmountChangesLabel(MultiBitLabel label) {
    String s = label.getText();/*w w  w .  jav  a  2s .  co  m*/
    if (s == null)
        return;
    String[] a = StringUtils.split(s, ",");
    for (String entry : a) {
        entry = entry.trim();
        if (StringUtils.countMatches(entry, ":") == 1) {
            if (entry.startsWith("BTC: -")) {
                label.setForeground(ColorAndFontConstants.DEBIT_FOREGROUND_COLOR);
                return;
            } else if (entry.startsWith("BTC:")) {
                label.setForeground(ColorAndFontConstants.CREDIT_FOREGROUND_COLOR);
                return;
            }
        }
    }
}

From source file:org.mxupdate.test.test.update.util.UpdateException_ErrorKeyTest.java

/**
 * Positive test to check error keys.//from   ww w .  j  a  v  a 2 s.co  m
 *
 * @param _errorKey     error key to test
 */
@Test(description = "positive test to check error keys", dataProvider = "data")
public void positiveTest(final ErrorKey _errorKey) {
    final List<String> args = new ArrayList<String>();
    for (int num = 0; num < StringUtils.countMatches(_errorKey.getText(), '{'); num++) {
        args.add("a");
    }
    final String msg = MessageFormat.format(_errorKey.getText(), args.toArray());
    Assert.assertEquals(StringUtils.countMatches(msg, '{'), 0,
            "check that all indexes are evaluated for [" + msg + "]");
}

From source file:org.n52.movingcode.feed.FeedConfig.java

/**
 * Parse line, return array of strings (key,value)
 * /*from w ww.java2s . com*/
 * @param line
 * @return
 */
private static final String[] processLine(String line) {

    // strip leading and trailing spaces
    line = StringUtils.trim(line);
    line = StringUtils.strip(line);

    // ignore comments starting with "#"
    if (line.startsWith(comment)) {
        // skip line
        return null;
    }

    // check no of occurences of "="
    if (StringUtils.countMatches(line, separator) < 1) {
        // skip line
        return null;
    }

    // extract key / value and strip leading and trailing spaces
    int sepIndex = line.indexOf(separator);

    String key = line.substring(0, sepIndex - 1);
    key = StringUtils.trim(key);
    //key = StringUtils.strip(key);

    String value = line.substring(sepIndex + 1);
    value = StringUtils.trim(value);

    return new String[] { key, value };
}