CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
org/jclouds/scriptbuilder/domain/AppendFile.java51
org/jclouds/scriptbuilder/domain/CreateFile.java52
   public CreateFile(String path, Iterable<String> lines, String marker) {
      this.path = checkNotNull(path, "path");
      this.lines = checkNotNull(lines, "lines");
      this.marker = checkNotNull(marker, "marker");
      checkState(Iterables.size(lines) > 0, "you must pass something to execute");
   }

   public static String escapeVarTokens(String toEscape, OsFamily family) {
      Map<String, String> inputToEscape = Maps.newHashMap();
      for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) {
         if (!token.to(family).equals("")) {
            String tokenS = "{" + token.toString().toLowerCase() + "}";
            inputToEscape.put(tokenS, "{escvar}" + tokenS);
         }
      }
      for (Entry<String, String> entry : inputToEscape.entrySet()) {
         toEscape = toEscape.replace(entry.getKey(), entry.getValue());
      }
      return toEscape;
   }

   @Override
   public Iterable<String> functionDependencies(OsFamily family) {
      return Collections.emptyList();
   }

   @Override
   public String render(OsFamily family) {
      List<Statement> statements = Lists.newArrayList();
      if (family == OsFamily.UNIX) {
         StringBuilder builder = new StringBuilder();
         hereFile(path, builder);
         statements.add(interpret(builder.toString()));
      } else {
         for (String line : lines) {
            statements.add(appendToFile(line, path, family));
         }
      }
      return new StatementList(statements).render(family);
   }
FileLine
org/jclouds/scriptbuilder/domain/AppendFile.java56
org/jclouds/scriptbuilder/domain/CreateRunScript.java107
   }

   public static String escapeVarTokens(String toEscape, OsFamily family) {
      Map<String, String> inputToEscape = Maps.newHashMap();
      for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) {
         if (!token.to(family).equals("")) {
            String tokenS = "{" + token.toString().toLowerCase() + "}";
            inputToEscape.put(tokenS, "{escvar}" + tokenS);
         }
      }
      for (Entry<String, String> entry : inputToEscape.entrySet()) {
         toEscape = toEscape.replace(entry.getKey(), entry.getValue());
      }
      return toEscape;
   }

   @Override
   public Iterable<String> functionDependencies(OsFamily family) {
      return Collections.emptyList();
   }