static boolean checkSchemaNamespace(XmlTag context) {
   final String namespace = context.getNamespace();
   if (namespace.length() > 0) {
     return checkSchemaNamespace(namespace);
   }
   return StringUtil.startsWithConcatenationOf(context.getName(), XSD_PREFIX, ":");
 }
  @NotNull
  public static String convertFromUrl(@NotNull URL url) {
    String protocol = url.getProtocol();
    String path = url.getPath();
    if (protocol.equals(JAR)) {
      if (StringUtil.startsWithConcatenationOf(path, FILE, PROTOCOL_DELIMITER)) {
        try {
          URL subURL = new URL(path);
          path = subURL.getPath();
        } catch (MalformedURLException e) {
          throw new RuntimeException(VfsBundle.message("url.parse.unhandled.exception"), e);
        }
      } else {
        throw new RuntimeException(
            new IOException(VfsBundle.message("url.parse.error", url.toExternalForm())));
      }
    }
    if (SystemInfo.isWindows || SystemInfo.isOS2) {
      while (path.length() > 0 && path.charAt(0) == '/') {
        path = path.substring(1, path.length());
      }
    }

    path = URLUtil.unescapePercentSequences(path);
    return protocol + "://" + path;
  }
 public void testStartsWithConcatenation() {
   assertTrue(StringUtil.startsWithConcatenationOf("something.withdot", "something", "."));
   assertTrue(StringUtil.startsWithConcatenationOf("something.withdot", "", "something."));
   assertTrue(StringUtil.startsWithConcatenationOf("something.", "something", "."));
   assertTrue(StringUtil.startsWithConcatenationOf("something", "something", ""));
   assertFalse(StringUtil.startsWithConcatenationOf("something", "something", "."));
   assertFalse(StringUtil.startsWithConcatenationOf("some", "something", ""));
 }
  private Collection<String> getBranchList(final boolean includeRevisionNumbers) {
    final ArrayList<String> result = new ArrayList<String>();
    final Set<SymbolicName> processedSymbolicNames = new HashSet<SymbolicName>();

    final String branches = myCvsRevision.getBranches();
    if (branches != null && branches.length() != 0) {
      final String[] branchNames = branches.split(";");
      for (String branchName : branchNames) {
        final CvsRevisionNumber revisionNumber = new CvsRevisionNumber(branchName.trim());
        final List<SymbolicName> symNames = getSymbolicNames(revisionNumber);
        if (!symNames.isEmpty()) {
          for (final SymbolicName symName : symNames) {
            processedSymbolicNames.add(symName);
            if (includeRevisionNumbers) {
              result.add(symName.getName() + " (" + revisionNumber.asString() + ")");
            } else {
              result.add(symName.getName());
            }
          }
        }
      }
    }
    // IDEADEV-15186 - show branch name for just created branch with no revisions yet
    //noinspection unchecked
    final List<SymbolicName> symNames = myLogInformation.getAllSymbolicNames();
    for (final SymbolicName symName : symNames) {
      if (StringUtil.startsWithConcatenationOf(
              symName.getRevision(), myCvsRevision.getNumber(), ".")
          && !processedSymbolicNames.contains(symName)) {
        CvsRevisionNumber number = new CvsRevisionNumber(symName.getRevision().trim());
        final int[] subRevisions = number.getSubRevisions();
        if (subRevisions.length == 4) {
          int lastSubRevision = subRevisions[subRevisions.length - 1];
          number = number.removeTailVersions(2);
          number = number.addTailVersions(lastSubRevision);
        }
        if (includeRevisionNumbers) {
          result.add(symName.getName() + " (" + number.asString() + ")");
        } else {
          result.add(symName.getName());
        }
      }
    }
    return result;
  }
 public static boolean isEqualOrAncestor(String ancestor, String child) {
   return ancestor.equals(child) || StringUtil.startsWithConcatenationOf(child, ancestor, "/");
 }
  public void processCompletion(final CompletionResult result) {
    result.myToComplete = new ArrayList<LookupFile>();
    result.mySiblings = new ArrayList<LookupFile>();
    result.myKidsAfterSeparator = new ArrayList<LookupFile>();
    String typed = result.myCompletionBase;

    if (typed == null || typed.length() == 0) return;

    addMacroPaths(result, typed);

    final String typedText = myFinder.normalize(typed);

    result.current = getClosestParent(typed);
    result.myClosestParent = result.current;

    if (result.current != null) {
      result.currentParentMatch =
          SystemInfo.isFileSystemCaseSensitive
              ? typedText.equals(result.current.getAbsolutePath())
              : typedText.equalsIgnoreCase(result.current.getAbsolutePath());

      result.closedPath =
          typed.endsWith(myFinder.getSeparator())
              && typedText.length() > myFinder.getSeparator().length();
      final String currentParentText = result.current.getAbsolutePath();

      if (!typedText.toUpperCase().startsWith(currentParentText.toUpperCase())) return;

      String prefix = typedText.substring(currentParentText.length());
      if (prefix.startsWith(myFinder.getSeparator())) {
        prefix = prefix.substring(myFinder.getSeparator().length());
      } else if (typed.endsWith(myFinder.getSeparator())) {
        prefix = "";
      }

      result.effectivePrefix = prefix.toUpperCase();

      result.currentGrandparent = result.current.getParent();
      if (result.currentGrandparent != null && result.currentParentMatch && !result.closedPath) {
        final String currentGrandparentText = result.currentGrandparent.getAbsolutePath();
        if (StringUtil.startsWithConcatenationOf(
            typedText, currentGrandparentText, myFinder.getSeparator())) {
          result.grandparentPrefix =
              currentParentText
                  .substring(currentGrandparentText.length() + myFinder.getSeparator().length())
                  .toUpperCase();
        }
      }
    } else {
      result.effectivePrefix = typedText.toUpperCase();
    }

    ApplicationManager.getApplication()
        .runReadAction(
            new Runnable() {
              public void run() {
                if (result.current != null) {
                  result.myToComplete.addAll(
                      result.current.getChildren(
                          new LookupFilter() {
                            public boolean isAccepted(final LookupFile file) {
                              return myFilter.isAccepted(file)
                                  && file.getName()
                                      .toUpperCase()
                                      .startsWith(result.effectivePrefix);
                            }
                          }));

                  if (result.currentParentMatch && !result.closedPath) {
                    result.myKidsAfterSeparator.addAll(result.myToComplete);
                  }

                  if (result.grandparentPrefix != null) {
                    final List<LookupFile> siblings =
                        result.currentGrandparent.getChildren(
                            new LookupFilter() {
                              public boolean isAccepted(final LookupFile file) {
                                return !file.equals(result.current)
                                    && myFilter.isAccepted(file)
                                    && file.getName()
                                        .toUpperCase()
                                        .startsWith(result.grandparentPrefix);
                              }
                            });
                    result.myToComplete.addAll(0, siblings);
                    result.mySiblings.addAll(siblings);
                  }
                }

                int currentDiff = Integer.MIN_VALUE;
                LookupFile toPreselect = result.myPreselected;

                if (toPreselect == null || !result.myToComplete.contains(toPreselect)) {
                  boolean toPreselectFixed = false;
                  if (result.effectivePrefix.length() > 0) {
                    for (LookupFile each : result.myToComplete) {
                      String eachName = each.getName().toUpperCase();
                      if (!eachName.startsWith(result.effectivePrefix)) continue;
                      int diff = result.effectivePrefix.compareTo(eachName);
                      currentDiff = Math.max(diff, currentDiff);
                      if (currentDiff == diff) {
                        toPreselect = each;
                        toPreselectFixed = true;
                        break;
                      }
                    }

                    if (!toPreselectFixed) {
                      toPreselect = null;
                    }
                  } else {
                    toPreselect = null;
                  }

                  if (toPreselect == null) {
                    if (result.myToComplete.size() == 1) {
                      toPreselect = result.myToComplete.get(0);
                    } else if (result.effectivePrefix.length() == 0) {
                      if (result.mySiblings.size() > 0) {
                        toPreselect = result.mySiblings.get(0);
                      }
                    }

                    if (toPreselect == null
                        && !result.myToComplete.contains(toPreselect)
                        && result.myToComplete.size() > 0) {
                      toPreselect = result.myToComplete.get(0);
                    }
                  }
                }

                if (result.currentParentMatch && result.mySiblings.size() > 0) {
                  toPreselect = null;
                }

                result.myPreselected = toPreselect;
              }
            });
  }
 public boolean hasProperty(@NonNls final String name) {
   for (@NonNls String parameter : myParameters) {
     if (StringUtil.startsWithConcatenationOf(parameter, "-D" + name, "=")) return true;
   }
   return false;
 }