Beispiel #1
1
  private void initIfNeed() {
    if (myInitialized) return;
    myInitialized = true;
    for (Map.Entry<String, Pair<String, List<String>>> entry : myTree.entrySet()) {
      final String group = entry.getKey();
      if (CORE.equals(group)) continue;

      List<IdSet> idSets = new ArrayList<IdSet>();
      StringBuilder description = new StringBuilder();
      for (String idDescription : entry.getValue().getSecond()) {
        IdSet idSet = new IdSet(idDescription);
        String idSetTitle = idSet.getTitle();
        if (idSetTitle == null) continue;
        idSets.add(idSet);
        if (description.length() > 0) {
          description.append(", ");
        }
        description.append(idSetTitle);
      }
      myGroups.put(group, idSets);

      if (description.length() > MAX_DESCR_LENGTH) {
        int lastWord = description.lastIndexOf(",", MAX_DESCR_LENGTH);
        description.delete(lastWord, description.length()).append("...");
      }
      description.insert(0, "<html><body><center><i>");
      myDescriptions.put(group, description.toString());
    }
  }
Beispiel #2
1
  public void clearInput() throws IOException {
    if (in == null) return;

    final StringBuilder dirtyBuffer = new StringBuilder(MAX_LENGTH_DEBUG);
    int i = 0;
    while (in.available() > 0) {
      char c = (char) in.read();
      ++i;

      if (dirtyBuffer.length() < MAX_LENGTH_DEBUG) dirtyBuffer.append(c);
    }
    updateMetricReceivedBytes(i);

    OLogManager.instance()
        .error(
            this,
            "Received unread response from "
                + socket.getRemoteSocketAddress()
                + " probably corrupted data from the network connection. Cleared dirty data in the buffer ("
                + i
                + " bytes): ["
                + dirtyBuffer
                + (i > dirtyBuffer.length() ? "..." : "")
                + "]",
            OIOException.class);
  }
Beispiel #3
1
  @Override
  public Object bind(
      RootParamNode rootParamNode,
      String name,
      Class clazz,
      java.lang.reflect.Type type,
      Annotation[] annotations) {
    // TODO need to be more generic in order to work with JPASupport
    if (clazz.isAnnotationPresent(Entity.class)) {

      ParamNode paramNode = rootParamNode.getChild(name, true);

      String[] keyNames = new JPAModelLoader(clazz).keyNames();
      ParamNode[] ids = new ParamNode[keyNames.length];
      // Collect the matching ids
      int i = 0;
      for (String keyName : keyNames) {
        ids[i++] = paramNode.getChild(keyName, true);
      }
      if (ids != null && ids.length > 0) {
        try {
          EntityManager em = JPABase.getJPAConfig(clazz).getJPAContext().em();
          StringBuilder q =
              new StringBuilder().append("from ").append(clazz.getName()).append(" o where");
          int keyIdx = 1;
          for (String keyName : keyNames) {
            q.append(" o.").append(keyName).append(" = ?").append(keyIdx++).append(" and ");
          }
          if (q.length() > 4) {
            q = q.delete(q.length() - 4, q.length());
          }
          Query query = em.createQuery(q.toString());
          // The primary key can be a composite.
          Class[] pk = new JPAModelLoader(clazz).keyTypes();
          int j = 0;
          for (ParamNode id : ids) {
            if (id.getValues() == null
                || id.getValues().length == 0
                || id.getFirstValue(null) == null
                || id.getFirstValue(null).trim().length() <= 0) {
              // We have no ids, it is a new entity
              return GenericModel.create(rootParamNode, name, clazz, annotations);
            }
            query.setParameter(
                j + 1,
                Binder.directBind(
                    id.getOriginalKey(), annotations, id.getValues()[0], pk[j++], null));
          }
          Object o = query.getSingleResult();
          return GenericModel.edit(rootParamNode, name, o, annotations);
        } catch (NoResultException e) {
          // ok
        } catch (Exception e) {
          throw new UnexpectedException(e);
        }
      }
      return GenericModel.create(rootParamNode, name, clazz, annotations);
    }
    return null;
  }
Beispiel #4
1
  /**
   * Gets the name.
   *
   * @return the name
   */
  public String getName() {
    StringBuilder name = new StringBuilder();

    if (!StringUtil.isNullOrEmpty(title)) {
      name.append(title);
    }

    if (!StringUtil.isNullOrEmpty(firstname)) {
      if (name.length() > 0) {
        name.append(" ");
      }

      name.append(firstname);
    }

    if (!StringUtil.isNullOrEmpty(lastname)) {
      if (name.length() > 0) {
        name.append(" ");
      }

      name.append(lastname);
    }

    return name.toString();
  }
Beispiel #5
1
  public static String[] splitStringToArray(final CharSequence s, final char c) {
    if (s == null || s.length() == 0) {
      return Strings.EMPTY_ARRAY;
    }
    int count = 1;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == c) {
        count++;
      }
    }
    final String[] result = new String[count];
    final StringBuilder builder = new StringBuilder();
    int res = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == c) {
        if (builder.length() > 0) {
          result[res++] = builder.toString();
          builder.setLength(0);
        }

      } else {
        builder.append(s.charAt(i));
      }
    }
    if (builder.length() > 0) {
      result[res++] = builder.toString();
    }
    if (res != count) {
      // we have empty strings, copy over to a new array
      String[] result1 = new String[res];
      System.arraycopy(result, 0, result1, 0, res);
      return result1;
    }
    return result;
  }
  /** 選択されている行をコピーする。 */
  public void copyRow() {

    StringBuilder sb = new StringBuilder();
    int numRows = view.getTable().getSelectedRowCount();
    int[] rowsSelected = view.getTable().getSelectedRows();
    int numColumns = view.getTable().getColumnCount();

    for (int i = 0; i < numRows; i++) {
      if (tableModel.getObject(rowsSelected[i]) != null) {
        StringBuilder s = new StringBuilder();
        for (int col = 0; col < numColumns; col++) {
          Object o = view.getTable().getValueAt(rowsSelected[i], col);
          if (o != null) {
            s.append(o.toString());
          }
          s.append(",");
        }
        if (s.length() > 0) {
          s.setLength(s.length() - 1);
        }
        sb.append(s.toString()).append("\n");
      }
    }
    if (sb.length() > 0) {
      StringSelection stsel = new StringSelection(sb.toString());
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stsel, stsel);
    }
  }
Beispiel #7
1
 /**
  * Removes comments from the specified string and returns the first characters of a query.
  *
  * @param qu query string
  * @param max maximum length of string to return
  * @return result
  */
 public static String removeComments(final String qu, final int max) {
   final StringBuilder sb = new StringBuilder();
   int m = 0;
   boolean s = false;
   final int cl = qu.length();
   for (int c = 0; c < cl && sb.length() < max; ++c) {
     final char ch = qu.charAt(c);
     if (ch == 0x0d) continue;
     if (ch == '(' && c + 1 < cl && qu.charAt(c + 1) == ':') {
       if (m == 0 && !s) {
         sb.append(' ');
         s = true;
       }
       ++m;
       ++c;
     } else if (m != 0 && ch == ':' && c + 1 < cl && qu.charAt(c + 1) == ')') {
       --m;
       ++c;
     } else if (m == 0) {
       if (ch > ' ') sb.append(ch);
       else if (!s) sb.append(' ');
       s = ch <= ' ';
     }
   }
   if (sb.length() >= max) sb.append("...");
   return sb.toString().trim();
 }
Beispiel #8
1
  public static String formatBranches(
      LogInformation.Revision revision, boolean useNumbersIfNamesNotAvailable) {
    String branches = revision.getBranches();
    if (branches == null) return ""; // NOI18N

    boolean branchNamesAvailable = true;
    StringBuilder branchNames = new StringBuilder();
    StringTokenizer st = new StringTokenizer(branches, ";"); // NOI18N
    while (st.hasMoreTokens()) {
      String branchNumber = st.nextToken().trim();
      List<LogInformation.SymName> names =
          revision
              .getLogInfoHeader()
              .getSymNamesForRevision(createBranchRevisionNumber(branchNumber));
      if (names.size() > 0) {
        branchNames.append(names.get(0).getName());
      } else {
        branchNamesAvailable = false;
        if (useNumbersIfNamesNotAvailable) {
          branchNames.append(branchNumber);
        } else {
          break;
        }
      }
      branchNames.append("; "); // NOI18N
    }
    if (branchNamesAvailable || useNumbersIfNamesNotAvailable) {
      branchNames.delete(branchNames.length() - 2, branchNames.length());
    } else {
      branchNames.delete(0, branchNames.length());
    }
    return branchNames.toString();
  }
  /**
   * Break on commas, except those inside quotes, e.g.: size(300, 200, PDF, "output,weirdname.pdf");
   * No special handling implemented for escaped (\") quotes.
   */
  private static StringList breakCommas(String contents) {
    StringList outgoing = new StringList();

    boolean insideQuote = false;
    // The current word being read
    StringBuilder current = new StringBuilder();
    char[] chars = contents.toCharArray();
    for (int i = 0; i < chars.length; i++) {
      char c = chars[i];
      if (insideQuote) {
        current.append(c);
        if (c == '\"') {
          insideQuote = false;
        }
      } else {
        if (c == ',') {
          if (current.length() != 0) {
            outgoing.append(current.toString());
            current.setLength(0);
          }
        } else {
          current.append(c);
          if (c == '\"') {
            insideQuote = true;
          }
        }
      }
    }
    if (current.length() != 0) {
      outgoing.append(current.toString());
    }
    return outgoing;
  }
  /**
   * Returns date in the format: neededDatePattern, in case if year or month isn't entered, current
   * year/month is put.
   *
   * @return correct date.
   */
  private Date getCorrectedDate(String enteredDate) {
    Queue<String> dateParts = new ArrayDeque<>(3);
    StringBuilder number = new StringBuilder();
    for (char symbol : enteredDate.toCharArray()) {
      if (Character.isDigit(symbol)) {
        number.append(symbol);
      } else if (number.length() > 0) {
        dateParts.add(number.toString());
        number = new StringBuilder();
      }
    }
    if (number.length() > 0) {
      dateParts.add(number.toString());
    }

    Calendar currentDate = Calendar.getInstance();
    switch (dateParts.size()) {
      case 1:
        dateParts.add(Integer.toString(currentDate.get(Calendar.MONTH) + 1));
      case 2:
        dateParts.add(Integer.toString(currentDate.get(Calendar.YEAR)));
    }

    try {
      return new SimpleDateFormat("dd.MM.yyyy")
          .parse(dateParts.remove() + '.' + dateParts.remove() + '.' + dateParts.remove());

    } catch (ParseException e) {
      throw new RuntimeException(e); // todo change exception
    }
  }
  @RequestMapping(value = "/order/search/integral")
  public void searchUserIntegralByOrder(String orderNoes, HttpServletResponse response)
      throws IOException {
    String[] orderNoArray = orderNoes.split("\\n");

    Map<Integer, UserIntegralAndCoupon> uicMap =
        new LinkedHashMap<Integer, UserIntegralAndCoupon>();
    StringBuilder sbd = new StringBuilder();
    for (String orderNo : orderNoArray) {
      if (StringUtils.isBlank(orderNo) || NumberUtils.toLong(orderNo) <= 0) continue;

      long no = NumberUtils.toLong(orderNo.trim());
      Order order = tradeCenterBossClient.queryOrderByOrderNo(no);
      if (order == null) continue;

      User user = userService.getUserById(order.getUserId());
      if (user == null || uicMap.get(user.getId()) != null) continue;

      UserIntegralAndCoupon uic = new UserIntegralAndCoupon();
      uic.setUserId(user.getId());
      uic.setUserName(user.getUserName());
      uic.setPhone(StringUtils.isNotBlank(user.getPhone()) ? user.getPhone() : "");
      uic.setEmail(StringUtils.isNotBlank(user.getEmail()) ? user.getEmail() : "");
      uic.setIntegral(user.getCurrency());

      List<Coupon> coupons = couponService.queryCouponByUserId(order.getUserId());
      sbd.delete(0, sbd.length());
      int i = 0;
      String str = "";
      for (Coupon coupon : coupons) {
        sbd.append(coupon.getCode());
        if (coupon.isUsed()) str = "已使用";
        else if (coupon.isExpire()) str = "已过期";
        if (StringUtils.isNotBlank(str)) sbd.append("(").append(str).append(")");

        if (i != coupons.size() - 1) sbd.append(", ");

        i++;
      }
      uic.setCoupon(sbd.toString());

      sbd.delete(0, sbd.length());
      // 从地址中去寻找
      List<Address> addresses = addressService.queryAllAddress(order.getUserId());
      i = 0;
      for (Address address : addresses) {
        sbd.append(address.getName()).append("/").append(address.getMobile()).append("/");
        sbd.append(address.getProvince()).append(address.getLocation());
        if (address.isDefaultAddress()) sbd.append("<span style='color:red;'>(默认地址)</span>");

        if (i != addresses.size() - 1) sbd.append("\n");
      }
      uic.setAddress(sbd.toString());

      uicMap.put(user.getId(), uic);
    }
    new JsonResult(true).addData("orderList", uicMap.values()).toJson(response);
  }
Beispiel #12
1
 public static OMElement serializeHandlerConfiguration(HandlerConfigurationBean bean) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement handler = factory.createOMElement("handler", null);
   handler.addAttribute(factory.createOMAttribute("class", null, bean.getHandlerClass()));
   if (bean.getTenant() != null) {
     handler.addAttribute(factory.createOMAttribute("tenant", null, bean.getTenant()));
   }
   StringBuilder sb = new StringBuilder();
   for (String method : bean.getMethods()) {
     if (method != null && method.length() > 0) {
       sb.append(method).append(",");
     }
   }
   // Remove last ","
   if (sb.length() > 0) {
     sb.deleteCharAt(sb.length() - 1);
     handler.addAttribute(factory.createOMAttribute("methods", null, sb.toString()));
   }
   for (String property : bean.getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getXmlProperties().get(property);
     if (xmlProperty != null) {
       //                The serialization happens by adding the whole XML property value to the
       // bean.
       //                Therefore if it is a XML property, we take that whole element.
       handler.addChild(xmlProperty);
     } else {
       String nonXMLProperty = bean.getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         handler.addChild(temp);
       }
     }
   }
   OMElement filter = factory.createOMElement("filter", null);
   filter.addAttribute(
       factory.createOMAttribute("class", null, bean.getFilter().getFilterClass()));
   for (String property : bean.getFilter().getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getFilter().getXmlProperties().get(property);
     if (xmlProperty != null) {
       temp.addAttribute(factory.createOMAttribute("type", null, "xml"));
       temp.addChild(xmlProperty);
       filter.addChild(temp);
     } else {
       String nonXMLProperty = bean.getFilter().getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         filter.addChild(temp);
       }
     }
   }
   handler.addChild(filter);
   return handler;
 }
Beispiel #13
1
 private StringBuilder appendNewLine(StringBuilder buffer) {
   if (buffer.length() != 0 && buffer.charAt(buffer.length() - 1) != '\n') {
     while (buffer.charAt(buffer.length() - 1) == ' ') {
       buffer.setLength(buffer.length() - 1);
     }
     buffer.append("\n");
   }
   return buffer;
 }
Beispiel #14
1
 /**
  * Trim all occurrences of the supplied trailing character from the given String.
  *
  * @param str the String to check
  * @param trailingCharacter the trailing character to be trimmed
  * @return the trimmed String
  */
 public static String trimTrailingCharacter(String str, char trailingCharacter) {
   if (!hasLength(str)) {
     return str;
   }
   StringBuilder sb = new StringBuilder(str);
   while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) {
     sb.deleteCharAt(sb.length() - 1);
   }
   return sb.toString();
 }
 @NotNull
 private static String stripPath(@NotNull String path) {
   String[] endingsToStrip = {"/", "!", ".jar"};
   StringBuilder buffer = new StringBuilder(path);
   for (String ending : endingsToStrip) {
     if (buffer.lastIndexOf(ending) == buffer.length() - ending.length()) {
       buffer.setLength(buffer.length() - ending.length());
     }
   }
   return buffer.toString();
 }
Beispiel #16
1
 public void searchTags() {
   StringBuilder strTags = new StringBuilder();
   for (int i = 0; i < tempStrBuilder.length() - 1; i++) {
     i = tempStrBuilder.indexOf("<");
     if (i == -1) {
       break;
     }
     strTags.append(tempStrBuilder.substring(i, tempStrBuilder.indexOf(">") + 1));
     tempStrBuilder.delete(i, tempStrBuilder.indexOf(">") + 1);
     tags.add(strTags.toString());
     strTags.delete(0, strTags.length());
   }
 }
  /** Convert the HTML document back to a string. */
  @Override
  public String toString() {
    try {
      StringBuilder result = new StringBuilder();

      int ch = 0;
      StringBuilder text = new StringBuilder();
      do {
        ch = read();
        if (ch == 0) {
          if (text.length() > 0) {
            System.out.println("Text:" + text.toString());
            text.setLength(0);
          }
          System.out.println("Tag:" + getTag());
        } else if (ch != -1) {
          text.append((char) ch);
        }
      } while (ch != -1);
      if (text.length() > 0) {
        System.out.println("Text:" + text.toString().trim());
      }
      return result.toString();
    } catch (IOException e) {
      return "[IO Error]";
    }
  }
Beispiel #18
0
  public static Result start() {
    java.util.Map<String, String[]> map = request().body().asFormUrlEncoded();

    List<String> terms = new ArrayList<>(map.size());
    for (int i = 0; i < map.size(); i++) {
      String key = "terms[" + i + "]";
      if (map.containsKey(key)) {
        String[] values = map.get(key);
        if ((values != null) && (values.length >= 1)) {
          terms.add(values[0]);
        }
      }
    }

    StreamConfig config = getConfig();
    config.putTerms(terms);
    config.update();

    StringBuilder sb = new StringBuilder();
    for (String t : terms) {
      sb.append(t);
      sb.append(", ");
    }
    sb.delete(sb.length() - 2, sb.length());

    try {
      startStream(terms);
      flash("success", "Twitter stream started (" + sb.toString() + ")");
    } catch (TwitterException e) {
      Logger.info("Error starting twitter stream", e);
      flash("error", "Error starting Twitter stream" + e.getMessage());
    }
    return redirect(routes.Streams.listAll());
  }
Beispiel #19
0
 public static String[] formatCollection(Collection<String> c) {
   if (c.isEmpty()) return new String[] {""};
   else {
     List<String> lines = new ArrayList<String>();
     StringBuilder sb = new StringBuilder();
     String s;
     for (Iterator<String> iter = c.iterator(); iter.hasNext(); ) {
       s = iter.next();
       if (sb.length() + s.length() > CHARS_PER_LINE && sb.length() != 0) {
         lines.add(sb.toString());
         sb = new StringBuilder();
       }
       sb.append(s);
       if (iter.hasNext()) {
         if (sb.length() + 2 > CHARS_PER_LINE && sb.length() != 0) {
           lines.add(sb.toString());
           sb = new StringBuilder();
         } else {
           sb.append(", ");
         }
       } else {
         lines.add(sb.toString());
       }
     }
     return lines.toArray(new String[lines.size()]);
   }
 }
Beispiel #20
0
 private static void equalizeLengths(StringBuilder sb1, StringBuilder sb2, StringBuilder sb3) {
   int maxLength = sb1.length();
   maxLength = Math.max(maxLength, sb2.length());
   maxLength = Math.max(maxLength, sb3.length());
   ensureLength(sb1, maxLength);
   ensureLength(sb2, maxLength);
   ensureLength(sb3, maxLength);
 }
Beispiel #21
0
 /**
  * Trim trailing whitespace from the given String.
  *
  * @param str the String to check
  * @return the trimmed String
  * @see Character#isWhitespace
  */
 public static String trimTrailingWhitespace(String str) {
   if (!hasLength(str)) {
     return str;
   }
   StringBuilder sb = new StringBuilder(str);
   while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) {
     sb.deleteCharAt(sb.length() - 1);
   }
   return sb.toString();
 }
 StringBuilder addSignedHeaders(
     SortedMap<String, String> sortedFormattedHeaders, StringBuilder builder) {
   int startingLength = builder.length();
   for (String headerName : sortedFormattedHeaders.keySet()) {
     if (builder.length() > startingLength) {
       builder.append(';');
     }
     builder.append(headerName);
   }
   return builder;
 }
Beispiel #23
0
 /**
  * Returns a string representation of the given collection of objects.
  *
  * @param objects The {@link Iterable} that will be used to iterate over the objects.
  * @return A string of the format "[a, b, ...]".
  */
 public static String toString(Iterable<?> objects) {
   StringBuilder str = new StringBuilder();
   str.append("[");
   for (Object o : objects) {
     str.append(o).append(", ");
   }
   if (str.length() > 1) {
     str.setLength(str.length() - 2);
   }
   str.append("]");
   return str.toString();
 }
  private static String getCommaseparatedStringFromList(List controllIdList) {
    StringBuilder result = new StringBuilder();

    for (int i = 0; i < controllIdList.size(); i++) {
      Map map = (Map) controllIdList.get(i);
      if (map.get("control_ids") != null) {
        result.append(map.get("control_ids"));
        result.append(",");
      }
    }
    return result.length() > 0 ? result.substring(0, result.length() - 1) : "";
  }
Beispiel #25
0
 protected StringBuilder getAbilities(
     MOB viewerM, MOB ableM, Vector ofTypes, int mask, boolean addQualLine, int maxLevel) {
   final int COL_LEN1 = ListingLibrary.ColFixer.fixColWidth(3.0, viewerM);
   final int COL_LEN2 = ListingLibrary.ColFixer.fixColWidth(18.0, viewerM);
   final int COL_LEN3 = ListingLibrary.ColFixer.fixColWidth(19.0, viewerM);
   int highestLevel = 0;
   final int lowestLevel = ableM.phyStats().level() + 1;
   final StringBuilder msg = new StringBuilder("");
   for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
     final Ability A = a.nextElement();
     int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
     if (level < 0) level = 0;
     if ((A != null)
         && (level > highestLevel)
         && (level < lowestLevel)
         && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask))))
       highestLevel = level;
   }
   if ((maxLevel >= 0) && (maxLevel < highestLevel)) highestLevel = maxLevel;
   for (int l = 0; l <= highestLevel; l++) {
     final StringBuilder thisLine = new StringBuilder("");
     int col = 0;
     for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
       if (level < 0) level = 0;
       if ((A != null)
           && (level == l)
           && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask)))) {
         if (thisLine.length() == 0) thisLine.append("\n\rLevel ^!" + l + "^?:\n\r");
         if ((++col) > 3) {
           thisLine.append("\n\r");
           col = 1;
         }
         thisLine.append(
             "^N[^H"
                 + CMStrings.padRight(Integer.toString(A.proficiency()), COL_LEN1)
                 + "%^?]^N"
                 + " " // +(A.isAutoInvoked()?"^H.^N":" ")
                 + CMStrings.padRight(
                     "^<HELP^>" + A.name() + "^</HELP^>", (col == 3) ? COL_LEN2 : COL_LEN3));
       }
     }
     if (thisLine.length() > 0) msg.append(thisLine);
   }
   if (msg.length() == 0) msg.append(L("^!None!^?"));
   else if (addQualLine)
     msg.append(
         L(
             "\n\r\n\rUse QUALIFY to see additional skills you can GAIN.")); // ^H.^N =
                                                                             // passive/auto-invoked."));
   return msg;
 }
Beispiel #26
0
 @Override
 public String toString() {
   StringBuilder b = new StringBuilder();
   b.append(setAtom).append("=").append("{");
   for (Atom atom : referencedAtoms) {
     b.append(atom).append(" , ");
   }
   b.delete(b.length() - 3, b.length());
   b.append("}");
   b.append(" defined by ").append(definitionType.getAggregator());
   return b.toString();
 }
Beispiel #27
0
 public String toString() {
   StringBuilder result = new StringBuilder("{");
   for (Map.Entry<Class<? extends Pet>, Integer> pair : entrySet()) {
     result.append(pair.getKey().getSimpleName());
     result.append("=");
     result.append(pair.getValue());
     result.append(", ");
   }
   result.delete(result.length() - 2, result.length());
   result.append("}");
   return result.toString();
 }
 public static String unwebMessageTextPoint(String text) {
   text = Utils.replace(text, "<br/>", "\n");
   text = Utils.replace(text, "<br />", "\n");
   text = Utils.replace(text, "<b>", "*");
   text = Utils.replace(text, "</b>", "*");
   text = Utils.replace(text, "<p>", "");
   text = Utils.replace(text, "</p>", "\n");
   text = Utils.replace(text, "<x>", "");
   text = Utils.replace(text, "</x>", "");
   text = Utils.replace(text, "&gt;", ">");
   text = Utils.replace(text, "&lt;", "<");
   text = Utils.replace(text, "&laquo;", "«");
   text = Utils.replace(text, "&quot;", "\"");
   text = Utils.replace(text, "&copy;", "©");
   text = Utils.replace(text, "&raquo;", "»");
   text = Utils.replace(text, "&mdash;", "-");
   text = Utils.replace(text, "&nbsp;", " ");
   text = Utils.replace(text, "<div class=\"text-content\">", "");
   text = Utils.replace(text, "<div class=\"text\">", "");
   text = Utils.replace(text, "</div>", "");
   text = Utils.replace(text, " \n", "\n");
   while (text.startsWith("\n") || text.startsWith(" ")) {
     text = text.substring(1);
   }
   String[] texts = StringSplitter.split(text, "\n");
   StringBuilder sb = new StringBuilder();
   for (String s : texts) {
     sb.append(s.trim()); // trim all
     sb.append("\n");
   }
   while (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\n')
     sb.setLength(sb.length() - 1); // remove last \n
   String beforeYoutube = sb.toString();
   int ix = 0;
   while (ix != -1) {
     ix = beforeYoutube.indexOf(HTTPS_IMG_YOUTUBE_COM_VI, ix);
     if (ix >= 0) {
       ix += HTTPS_IMG_YOUTUBE_COM_VI.length();
       int ix2 = beforeYoutube.indexOf("/", ix);
       String key = beforeYoutube.substring(ix, ix2);
       ix2 = beforeYoutube.indexOf(" ", ix);
       if (ix2 == -1) ix2 = beforeYoutube.length();
       beforeYoutube =
           beforeYoutube.substring(0, ix2)
               + " https://www.youtube.com/watch?v="
               + key
               + beforeYoutube.substring(ix2);
       ix = ix2;
     }
   }
   return beforeYoutube;
 }
 private String debugHiddenTokens(antlr.CommonHiddenStreamToken t) {
   final StringBuilder sb = new StringBuilder();
   for (; t != null; t = filter.getHiddenAfter(t)) {
     if (sb.length() == 0) {
       sb.append("[");
     }
     sb.append(t.getText().replace("\n", "\\n"));
   }
   if (sb.length() > 0) {
     sb.append("]");
   }
   return sb.toString();
 }
  /**
   * This will convert the Map to a string representation.
   *
   * @param pmapData <code>Map</code> PI data to convert
   * @return a string representation of the Map as appropriate for a PI
   */
  private static final String toString(Map<String, String> pmapData) {
    StringBuilder stringData = new StringBuilder();

    for (Map.Entry<String, String> me : pmapData.entrySet()) {
      stringData.append(me.getKey()).append("=\"").append(me.getValue()).append("\" ");
    }
    // Remove last space, if we did any appending
    if (stringData.length() > 0) {
      stringData.setLength(stringData.length() - 1);
    }

    return stringData.toString();
  }