コード例 #1
1
ファイル: Macro.java プロジェクト: bramk/bnd
  public String _range(String args[]) {
    verifyCommand(args, _rangeHelp, _rangePattern, 2, 3);
    Version version = null;
    if (args.length >= 3) version = new Version(args[2]);
    else {
      String v = domain.getProperty("@");
      if (v == null) return null;
      version = new Version(v);
    }
    String spec = args[1];

    Matcher m = RANGE_MASK.matcher(spec);
    m.matches();
    String floor = m.group(1);
    String floorMask = m.group(2);
    String ceilingMask = m.group(3);
    String ceiling = m.group(4);

    String left = version(version, floorMask);
    String right = version(version, ceilingMask);
    StringBuilder sb = new StringBuilder();
    sb.append(floor);
    sb.append(left);
    sb.append(",");
    sb.append(right);
    sb.append(ceiling);

    String s = sb.toString();
    VersionRange vr = new VersionRange(s);
    if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) {
      domain.error(
          "${range} macro created an invalid range %s from %s and mask %s", s, version, spec);
    }
    return sb.toString();
  }
コード例 #2
1
ファイル: Macro.java プロジェクト: bramk/bnd
 public static void verifyCommand(
     String args[],
     @SuppressWarnings("unused") String help,
     Pattern[] patterns,
     int low,
     int high) {
   String message = "";
   if (args.length > high) {
     message = "too many arguments";
   } else if (args.length < low) {
     message = "too few arguments";
   } else {
     for (int i = 0; patterns != null && i < patterns.length && i < args.length; i++) {
       if (patterns[i] != null) {
         Matcher m = patterns[i].matcher(args[i]);
         if (!m.matches())
           message +=
               String.format(
                   "Argument %s (%s) does not match %s%n", i, args[i], patterns[i].pattern());
       }
     }
   }
   if (message.length() != 0) {
     StringBuilder sb = new StringBuilder();
     String del = "${";
     for (String arg : args) {
       sb.append(del);
       sb.append(arg);
       del = ";";
     }
     sb.append("}, is not understood. ");
     sb.append(message);
     throw new IllegalArgumentException(sb.toString());
   }
 }
コード例 #3
1
  public String getCoordinates(RevisionRef r) {
    StringBuilder sb = new StringBuilder(r.groupId).append(":").append(r.artifactId).append(":");
    if (r.classifier != null) sb.append(r.classifier).append("@");
    sb.append(r.version);

    return sb.toString();
  }
コード例 #4
1
ファイル: CIManagerImpl.java プロジェクト: manoj-s/framework
 private CIJobStatus deleteCI(CIJob job, List<String> builds) throws PhrescoException {
   S_LOGGER.debug("Entering Method CIManagerImpl.deleteCI(CIJob job)");
   S_LOGGER.debug("Job name " + job.getName());
   cli = getCLI(job);
   String deleteType = null;
   List<String> argList = new ArrayList<String>();
   S_LOGGER.debug("job name " + job.getName());
   S_LOGGER.debug("Builds " + builds);
   if (CollectionUtils.isEmpty(builds)) { // delete job
     S_LOGGER.debug("Job deletion started");
     S_LOGGER.debug("Command " + FrameworkConstants.CI_JOB_DELETE_COMMAND);
     deleteType = DELETE_TYPE_JOB;
     argList.add(FrameworkConstants.CI_JOB_DELETE_COMMAND);
     argList.add(job.getName());
   } else { // delete Build
     S_LOGGER.debug("Build deletion started");
     deleteType = DELETE_TYPE_BUILD;
     argList.add(FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     argList.add(job.getName());
     StringBuilder result = new StringBuilder();
     for (String string : builds) {
       result.append(string);
       result.append(",");
     }
     String buildNos = result.substring(0, result.length() - 1);
     argList.add(buildNos);
     S_LOGGER.debug("Command " + FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     S_LOGGER.debug("Build numbers " + buildNos);
   }
   try {
     int status = cli.execute(argList);
     String message = deleteType + " deletion started in jenkins";
     if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
       deleteType = deleteType.substring(0, 1).toLowerCase() + deleteType.substring(1);
       message = "Error while deleting " + deleteType + " in jenkins";
     }
     S_LOGGER.debug("Delete CI Status " + status);
     S_LOGGER.debug("Delete CI Message " + message);
     return new CIJobStatus(status, message);
   } finally {
     if (cli != null) {
       try {
         cli.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       } catch (InterruptedException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       }
     }
   }
 }
コード例 #5
1
ファイル: CIManagerImpl.java プロジェクト: manoj-s/framework
 private String getCIJobPath(ApplicationInfo appInfo) {
   StringBuilder builder = new StringBuilder(Utility.getProjectHome());
   builder.append(appInfo.getAppDirName());
   builder.append(File.separator);
   builder.append(FOLDER_DOT_PHRESCO);
   builder.append(File.separator);
   builder.append(CI_JOB_INFO_NAME);
   return builder.toString();
 }
コード例 #6
0
 public String toString() {
   StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()).append('{');
   for (TypedValues typed : _values) {
     sb.append(typed);
   }
   return sb.append('}').toString();
 }
コード例 #7
0
    public static void printViewPatterns() {
      processedViewsForPatterns = new HashSet<ViewTrace>();
      HashMap<String, Integer> viewPatterns = new HashMap<String, Integer>();

      ps.println("ViewPatterns ------------------- \n");
      for (ViewTrace trace : viewsRegistry) {
        if (processedViewsForPatterns.contains(trace)) {
          continue;
        }
        ViewTrace v = trace.getRootView();
        StringBuilder p = new StringBuilder();
        p.append("PATTERN ");
        extractViewPattern(0, v, p);
        p.append("\n");
        String pattern = p.toString();
        Integer count = viewPatterns.get(pattern);
        if (count == null) {
          viewPatterns.put(pattern, 1);
        } else {
          viewPatterns.put(pattern, count + 1);
        }
      }
      processedViewsForPatterns = null;
      for (Map.Entry<String, Integer> e : viewPatterns.entrySet()) {
        ps.print("(" + e.getValue() + ") ");
        ps.println(e.getKey());
      }
    }
コード例 #8
0
    public StringBuilder getQualifiedName(StringBuilder b, boolean generic) {
      if (getEnclosingType() instanceof ClassRef) {
        getEnclosingType().getQualifiedName(b, generic).append('$');
      } else if (getEnclosingType() instanceof NamespaceRef) {
        getEnclosingType().getQualifiedName(b, generic).append('.');
      }
      b.append(ident.simpleName);
      if (generic && ident.templateArguments != null) {
        int args = 0;
        for (int i = 0, n = ident.templateArguments.length; i < n; i++) {
          TemplateArg arg = ident.templateArguments[i];
          if (!(arg instanceof TypeRef)) {
            continue;
          }

          if (args == 0) {
            b.append('<');
          } else {
            b.append(", ");
          }
          ((TypeRef) arg).getQualifiedName(b, generic);
          args++;
        }
        if (args > 0) {
          b.append('>');
        }
      }
      return b;
    }
コード例 #9
0
 @Override
 public String toString() {
   final StringBuilder sb = new StringBuilder();
   sb.append("{firstBound=").append(firstBound());
   sb.append(", interfaceBounds=[]}");
   return sb.toString();
 }
コード例 #10
0
    public static void printSite(Site s, StringBuilder out) {
      if (s == null) {
        out.append("(null)");
        return;
      }
      StackTraceElement[] st = s.site();

      int interestingSitesPrinted = 0;
      for (int i = s.offset; i < st.length; i++) {
        StackTraceElement e = st[i];
        String fileName = e.getFileName();
        if (THIS_FILE_NAME.equals(fileName)) {
          continue;
        }
        out.append(" " + e.getMethodName() + "(" + e.getFileName() + ":" + e.getLineNumber() + ")");
        interestingSitesPrinted++;
        if (interestingSitesPrinted <= SITES_TO_PRINT) {
          continue;
        }
        if (fileName == null || "View.java".equals(fileName)) {
          continue;
        }
        String methodName = e.getMethodName();
        if (skipMethods.contains(methodName)) {
          continue;
        }
        break;
      }
    }
コード例 #11
0
 @Override
 public String toString() {
   final StringBuilder sb = new StringBuilder();
   sb.append("{firstBound=").append(firstBound());
   sb.append(", interfaceBounds=").append(Arrays.deepToString(interfaceBounds()));
   sb.append('}');
   return sb.toString();
 }
コード例 #12
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
 private static String or(String... tokens) {
   StringBuilder buf = new StringBuilder();
   for (String t : tokens) {
     if (buf.length() > 0) buf.append('|');
     buf.append(t);
   }
   return buf.toString();
 }
コード例 #13
0
ファイル: JavaMapping.java プロジェクト: phspaelti/basex
 /**
  * Returns a string representation of all found arguments.
  *
  * @param args array with arguments
  * @return string representation
  */
 static String foundArgs(final Value[] args) {
   // compose found arguments
   final StringBuilder sb = new StringBuilder();
   for (final Value v : args) {
     if (sb.length() != 0) sb.append(", ");
     sb.append(v instanceof Jav ? Util.className(((Jav) v).toJava()) : v.seqType());
   }
   return sb.toString();
 }
コード例 #14
0
 @Override
 public String toString() {
   StringBuilder b = new StringBuilder();
   for (Class<?> ann : annotations) {
     b.append(ann.getSimpleName()).append(' ');
   }
   b.append((type instanceof Class<?>) ? ((Class<?>) type).getSimpleName() : type.toString());
   return b.toString();
 }
コード例 #15
0
 /**
  * Builds the key that uniquely identifies the MBeanServerConnection that would be created by
  * this builder
  *
  * @return the unique MBeanServerConnection key
  */
 private String buildKey() {
   StringBuilder b = new StringBuilder();
   b.append(channel.getId());
   b.append(domain);
   if (remoteAddress != null) {
     b.append(remoteAddress.toString());
   }
   return b.toString();
 }
コード例 #16
0
ファイル: ReturnStatement.java プロジェクト: wokaka/cedp
  public String toString() {
    StringBuilder str = new StringBuilder(80);

    str.append("return ");

    if (getExpression() != null) str.append(getExpression().toString());

    str.append(";");

    return str.toString();
  }
コード例 #17
0
  public String toString() {
    StringBuilder str = new StringBuilder(80);

    Iterator iter = children.iterator();

    str.append(iter.next().toString());

    while (iter.hasNext()) str.append("[" + iter.next().toString() + "]");

    return str.toString();
  }
コード例 #18
0
 private static String functionSig(Method method, Object[] args) {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < args.length; i++) {
     if (i > 0) sb.append(",");
     sb.append(TypeUtil.toCodeStringLimited(args[i]));
   }
   return FunctionRegistry.functionName(method.getDeclaringClass().getName(), method.getName())
       + "("
       + sb.toString()
       + ")";
 }
コード例 #19
0
    @Override
    public String toString() {
      StringBuilder b = new StringBuilder();

      if (enclosingType != null) {
        b.append(enclosingType).append('.');
      }

      b.append(ident);
      return b.toString();
    }
コード例 #20
0
  public String toString() {
    StringBuilder str = new StringBuilder(80);

    str.append("extern \"");
    str.append(calling_convention);
    str.append("\"\n{\n");
    str.append(Tools.listToString(children, "\n") + "\n");
    str.append("}");

    return str.toString();
  }
コード例 #21
0
ファイル: Rope.java プロジェクト: NormanShapiro/Naomi
  private void end(StringBuilder ans, Pretty pretty, String indent) {
    if (endEncloser == null) return;
    if (!pretty.pretty) ans.append(endEncloser);
    else {
      Utilities.assureEndsWithNewLine(ans);
      ans.append(indent + endEncloser);
      if (pretty.comments && endComment.length() > 0) ans.append("#" + endComment);

      Utilities.assureEndsWithNewLine(ans);
    }
  }
コード例 #22
0
ファイル: Rope.java プロジェクト: NormanShapiro/Naomi
 private void start(StringBuilder ans, Pretty pretty, String indent) {
   if (startEncloser == null) return;
   if (!pretty.pretty) {
     ans.append(startEncloser);
   } else {
     String comment;
     if (pretty.comments && startComment.length() > 0) comment = " #" + startComment;
     else comment = "";
     ans.append(indent + startEncloser + comment);
     Utilities.assureEndsWithNewLine(ans);
   }
 }
コード例 #23
0
ファイル: Macro.java プロジェクト: bramk/bnd
 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   String del = "[";
   for (Link r = this; r != null; r = r.previous) {
     sb.append(del);
     sb.append(r.key);
     del = ",";
   }
   sb.append("]");
   return sb.toString();
 }
コード例 #24
0
 public static StringBuilder implode(StringBuilder b, Iterable<?> items, String sep) {
   boolean first = true;
   for (Object item : items) {
     if (first) {
       first = false;
     } else {
       b.append(sep);
     }
     b.append(item);
   }
   return b;
 }
コード例 #25
0
 static void appendArgs(StringBuilder b, char pre, char post, Object[] params) {
   b.append(pre);
   if (params != null) {
     for (int i = 0; i < params.length; i++) {
       if (i != 0) {
         b.append(", ");
       }
       b.append(params[i]);
     }
   }
   b.append(post);
 }
コード例 #26
0
ファイル: Macro.java プロジェクト: bramk/bnd
  protected String replace(String key, Link link) {
    if (link != null && link.contains(key)) return "${infinite:" + link.toString() + "}";

    if (key != null) {
      key = key.trim();
      if (key.length() > 0) {
        Processor source = domain;
        String value = null;

        if (key.indexOf(';') < 0) {
          Instruction ins = new Instruction(key);
          if (!ins.isLiteral()) {
            SortedList<String> sortedList = SortedList.fromIterator(domain.iterator());
            StringBuilder sb = new StringBuilder();
            String del = "";
            for (String k : sortedList) {
              if (ins.matches(k)) {
                String v = replace(k, new Link(source, link, key));
                if (v != null) {
                  sb.append(del);
                  del = ",";
                  sb.append(v);
                }
              }
            }
            return sb.toString();
          }
        }
        while (value == null && source != null) {
          value = source.getProperties().getProperty(key);
          source = source.getParent();
        }

        if (value != null) return process(value, new Link(source, link, key));

        value = doCommands(key, link);
        if (value != null) return process(value, new Link(source, link, key));

        if (key != null && key.trim().length() > 0) {
          value = System.getProperty(key);
          if (value != null) return value;
        }
        if (!flattening && !key.equals("@"))
          domain.warning("No translation found for macro: " + key);
      } else {
        domain.warning("Found empty macro key");
      }
    } else {
      domain.warning("Found null macro key");
    }
    return "${" + key + "}";
  }
コード例 #27
0
 private void visitNested(java.lang.reflect.Type type, StringBuilder builder) {
   if (type instanceof Class) {
     Class<?> cl = (Class<?>) type;
     if (cl.isPrimitive()) {
       builder.append(Type.getType(cl).getDescriptor());
     } else {
       builder.append('L');
       builder.append(cl.getName().replace('.', '/'));
     }
   } else {
     visitType(type, builder);
   }
 }
コード例 #28
0
 @Override
 public void assertNoPlugins() {
   for (ExtractedRuleDetails details : rules) {
     if (!details.rule.getRuleDependencies().isEmpty()) {
       StringBuilder message = new StringBuilder();
       details.method.getDescriptor().describeTo(message);
       message.append(" has dependencies on plugins: ");
       message.append(details.rule.getRuleDependencies());
       message.append(". Plugin dependencies are not supported in this context.");
       throw new UnsupportedOperationException(message.toString());
     }
   }
 }
コード例 #29
0
 private static String decamelizeClassName(String className) {
   Matcher match = CAPS.matcher(className);
   StringBuilder deCameled = new StringBuilder();
   while (match.find()) {
     if (deCameled.length() == 0) {
       deCameled.append(match.group());
     } else {
       deCameled.append(" ");
       deCameled.append(match.group().toLowerCase());
     }
   }
   return deCameled.toString();
 }
コード例 #30
0
 public String getClasspath() {
   final StringBuilder sb = new StringBuilder();
   boolean firstPass = true;
   final Enumeration<File> componentEnum = this.pathComponents.elements();
   while (componentEnum.hasMoreElements()) {
     if (!firstPass) {
       sb.append(System.getProperty("path.separator"));
     } else {
       firstPass = false;
     }
     sb.append(componentEnum.nextElement().getAbsolutePath());
   }
   return sb.toString();
 }