public void testGetFirstWord() {
   final String firstWord = "one";
   String tmpStr = TextUtils.getFirstWord(firstWord + " two three");
   assertTrue("Failed to get first word 1 " + tmpStr, tmpStr.equals(firstWord));
   tmpStr = TextUtils.getFirstWord(firstWord);
   assertTrue("Failed to get first word 2 " + tmpStr, tmpStr.equals(firstWord));
 }
示例#2
0
 public static void viewTagInfo(String inurl, String tag) throws Exception {
   // pr = new PrintStream(new FileOutputStream("/semplest/lluis/keywordExp/urldata.txt"));
   pr = System.out;
   long start = System.currentTimeMillis();
   pr.println(inurl + "****************************************************************");
   printList(cleanUrlText(TextUtils.HTMLText(inurl, tag)));
   String urls = TextUtils.HTMLLinkString(inurl, inurl);
   String[] url = urls.split("\\s+");
   Set<String> urlMap = new HashSet<String>(url.length);
   urlMap.add(inurl);
   for (String ur : url) {
     if (!urlMap.contains(ur)) {
       pr.println(ur + "***************************************************************");
       try {
         printList(cleanUrlText(TextUtils.HTMLText(ur, tag)));
       } catch (Exception e) {
         System.out.println("Error with url :" + ur);
         e.printStackTrace();
         logger.error("Problem", e);
       }
       urlMap.add(ur);
     }
   }
   pr.println("Time elapsed" + (start - System.currentTimeMillis()));
 }
示例#3
0
 @Test
 public void testRemoveLastComma() {
   assertEquals(null, TextUtils.removeLastComma(null));
   assertEquals("", TextUtils.removeLastComma(""));
   assertEquals("tom,john", TextUtils.removeLastComma("tom,john,"));
   assertEquals("tom, john", TextUtils.removeLastComma("tom, john, "));
   assertEquals("tom, john", TextUtils.removeLastComma("tom, john,  "));
 }
示例#4
0
 @Test
 public void testGetTokens() {
   assertEquals(
       new ArrayList<>(Arrays.asList("John", "Doe", "Main", "Road", "25")),
       TextUtils.getTokens("John Doe Main Road 25"));
   assertEquals(
       new ArrayList<>(Arrays.asList("Ted,Johnson", "Upper-Road", "45")),
       TextUtils.getTokens("Ted,Johnson Upper-Road 45"));
 }
示例#5
0
 public static void testControlCharactersCleanup() {
   final Pattern patternAll = Pattern.compile("(.*)", Pattern.DOTALL);
   assertEquals(
       "some control characters removed",
       TextUtils.getMatch(
           "some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, ""));
   assertEquals(
       "newline also removed", TextUtils.getMatch("newline\nalso\nremoved", patternAll, ""));
 }
示例#6
0
 public static void testRegEx() {
   final String page = MockedCache.readCachePage("GC2CJPF");
   assertEquals(
       GCConstantsTest.MOCK_LOGIN_NAME,
       TextUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???"));
   assertThat(
           page.contains("id=\"ctl00_hlRenew\"")
               || GCConstants.MEMBER_STATUS_PM.equals(
                   TextUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")))
       .isTrue();
 }
示例#7
0
  public static String getActionTitle(final AFreeplaneAction action) {
    String title = (String) action.getValue(Action.NAME);

    if (title == null || title.isEmpty()) {
      title = TextUtils.getText(action.getTextKey());
    }
    if (title == null || title.isEmpty()) {
      title = action.getTextKey();
    }
    return TextUtils.removeTranslateComment(title);
  }
示例#8
0
 @Test
 public void testJoinReplaceNull() {
   assertEquals(
       "green-red-blue", TextUtils.join(Arrays.asList("green", "red", "blue"), "-", "[n/a]"));
   assertEquals(
       "green-[n/a]-blue", TextUtils.join(Arrays.asList("green", null, "blue"), "-", "[n/a]"));
   assertEquals(
       "green-red-[n/a]", TextUtils.join(Arrays.asList("green", "red", null), "-", "[n/a]"));
   assertEquals(
       "greenred[n/a]", TextUtils.join(Arrays.asList("green", "red", null), null, "[n/a]"));
   assertEquals("greenred", TextUtils.join(Arrays.asList("green", "red", null), null, null));
 }
示例#9
0
  /**
   * Returns null if not boring; the width, ascent, and descent in the provided Metrics object (or a
   * new one if the provided one was null) if boring.
   */
  public static Metrics isBoring(CharSequence text, TextPaint paint, Metrics metrics) {
    char[] temp = TextUtils.obtain(500);
    int len = text.length();
    boolean boring = true;

    outer:
    for (int i = 0; i < len; i += 500) {
      int j = i + 500;

      if (j > len) j = len;

      TextUtils.getChars(text, i, j, temp, 0);

      int n = j - i;

      for (int a = 0; a < n; a++) {
        char c = temp[a];

        if (c == '\n' || c == '\t' || c >= FIRST_RIGHT_TO_LEFT) {
          boring = false;
          break outer;
        }
      }
    }

    TextUtils.recycle(temp);

    if (boring && text instanceof Spanned) {
      Spanned sp = (Spanned) text;
      Object[] styles = sp.getSpans(0, text.length(), ParagraphStyle.class);
      if (styles.length > 0) {
        boring = false;
      }
    }

    if (boring) {
      Metrics fm = metrics;
      if (fm == null) {
        fm = new Metrics();
      }

      int wid;

      synchronized (sTemp) {
        wid = (int) (FloatMath.ceil(Styled.measureText(paint, sTemp, text, 0, text.length(), fm)));
      }
      fm.width = wid;
      return fm;
    } else {
      return null;
    }
  }
示例#10
0
 @Test
 public void testRemoveLastOr() {
   assertEquals(null, TextUtils.removeLastOr(null));
   assertEquals("", TextUtils.removeLastOr(""));
   assertEquals(
       "or name='tom' or name='john' ", TextUtils.removeLastOr("or name='tom' or name='john' or"));
   assertEquals(
       "or name='tom' or name='john' ",
       TextUtils.removeLastOr("or name='tom' or name='john' or "));
   assertEquals(
       "or name='tom' or name='john' ",
       TextUtils.removeLastOr("or name='tom' or name='john' or  "));
 }
  /**
   * 自动格式化 会尝试判断格式 python等语言不支持
   *
   * @param source
   * @return
   */
  public static String formatEscapeCode(String source) {

    source = StringUtils.trim(source);
    // 需要先还原,因为提交过来页面显示的代码都是转义后的
    source = TextUtils.reverseSpecialChars(source);
    if (StringUtils.startsWith(source, "<")) {
      source = formatXML(source);
    } else {
      source = formatCode(source);
    }
    // 还原成转义后
    return TextUtils.convertSpecialChars(source);
  }
示例#12
0
    /**
     * Verifies that the data was signed with the given signature, and returns
     * the verified purchase. The data is in JSON format and signed
     * with a private key. The data also contains the {@link PurchaseState}
     * and product ID of the purchase.
     * @param base64PublicKey the base64-encoded public key to use for verifying.
     * @param signedData the signed JSON string (signed, not encrypted)
     * @param signature the signature for the data, signed with the private key
     */
    public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
        if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
                TextUtils.isEmpty(signature)) {
            Log.e(TAG, "Purchase verification failed: missing data.");
            // if (BuildConfig.DEBUG) {
            //     return true;
            // }
            return false;
        }

        PublicKey key = Security.generatePublicKey(base64PublicKey);
        return Security.verify(key, signedData, signature);
    }
 public void testMatcherRecycling() {
   String pattern = "f.*";
   Matcher m1 = TextUtils.getMatcher(pattern, "foo");
   assertTrue("matcher against 'foo' problem", m1.matches());
   TextUtils.recycleMatcher(m1);
   Matcher m2 = TextUtils.getMatcher(pattern, "");
   assertFalse("matcher against '' problem", m2.matches());
   assertTrue("matcher not recycled", m1 == m2);
   // now verify proper behavior without recycling
   Matcher m3 = TextUtils.getMatcher(pattern, "fuggedaboutit");
   assertTrue("matcher against 'fuggedaboutit' problem", m3.matches());
   assertFalse("matcher was recycled", m3 == m2);
 }
示例#14
0
 @Test
 public void testRemoveLastAnd() {
   assertEquals(null, TextUtils.removeLastAnd(null));
   assertEquals("", TextUtils.removeLastAnd(""));
   assertEquals(
       "and name='tom' and name='john' ",
       TextUtils.removeLastAnd("and name='tom' and name='john' and"));
   assertEquals(
       "and name='tom' and name='john' ",
       TextUtils.removeLastAnd("and name='tom' and name='john' and "));
   assertEquals(
       "and name='tom' and name='john' ",
       TextUtils.removeLastAnd("and name='tom' and name='john' and  "));
 }
示例#15
0
 private String cleanWords(List<String> words, int count) {
   List<String> result = newArrayList();
   for (String part : readRawWords(words, count, 0)) {
     result.add(uncapitalize(replaceChars(part, "., ", "")));
   }
   return TextUtils.joinWithSpace(result);
 }
示例#16
0
  /**
   * built market browse url
   *
   * @param itemSearch
   * @param name
   * @return
   */
  public static String browseUrl(ItemSearch itemSearch, String name) {
    String url;
    boolean check = false;
    if (itemSearch.getCategoryIds() == null || itemSearch.getCategoryIds().isEmpty()) {
      check = true;
      url = "/tim-kiem.html";
    } else {
      url =
          "/mua-ban/"
              + itemSearch.getCategoryIds().get(0)
              + "/"
              + TextUtils.createAlias(name)
              + ".html";
    }

    String search = "";
    String keyword = itemSearch.getKeyword();
    int pageIndex = itemSearch.getPageIndex();
    if ((itemSearch.getModelIds() != null && !itemSearch.getModelIds().isEmpty())
        || (itemSearch.getManufacturerIds() != null && !itemSearch.getManufacturerIds().isEmpty())
        || (itemSearch.getCityIds() != null && !itemSearch.getCityIds().isEmpty())
        || itemSearch.getOrderBy() > 0
        || (itemSearch.getProperties() != null && !itemSearch.getProperties().isEmpty())
        || (itemSearch.getCondition() == Condition.NEW
            || itemSearch.getCondition() == Condition.OLD)
        || (itemSearch.getListingType() == ListingType.AUCTION
            || itemSearch.getListingType() == ListingType.BUYNOW)
        || (itemSearch.getPriceFrom() > 0 || itemSearch.getPriceTo() > 0)
        || itemSearch.isCod()
        || itemSearch.isFreeShip()
        || itemSearch.isOnlinePayment()
        || itemSearch.isPromotion()
        || (itemSearch.getSellerId() != null && !itemSearch.getSellerId().equals(""))
        || (itemSearch.getPromotionId() != null && !itemSearch.getPromotionId().equals(""))) {
      itemSearch.setKeyword(null);
      itemSearch.setPageIndex(0);
      search =
          "filter="
              + Base64.encodeBase64String(StringUtils.getBytesUtf8(new Gson().toJson(itemSearch)));
    }

    if (keyword != null && !keyword.equals("")) {
      if (check && search.equals("")) {
        return "/s/"
            + keyword.replaceAll("\\s+", "\\+").trim()
            + ".html"
            + (pageIndex <= 1 ? "" : "?page=" + pageIndex);
      } else {
        url += "?keyword=" + keyword.replaceAll("\\s+", "\\+").trim();
        url = pageIndex <= 1 ? url : url + "&page=" + pageIndex;
        return search.equals("") ? url : url + (search.equals("") ? "" : ("&" + search));
      }
    } else {
      return search.equals("")
          ? (pageIndex <= 1 ? url : url + "?page=" + pageIndex)
          : ((pageIndex <= 1 ? (url + "?") : (url + "?page=" + pageIndex + "&")) + search);
    }
  }
示例#17
0
 public static <T extends CharSequence> T notEmpty(T t, String str) {
   if (t == null) {
     throw new IllegalArgumentException(str + " may not be null");
   } else if (!TextUtils.isEmpty(t)) {
     return t;
   } else {
     throw new IllegalArgumentException(str + " may not be empty");
   }
 }
示例#18
0
 public static List<String> getURLArray(Context context) {
   List<String> urlList = new ArrayList<String>();
   for (int i = 0; i < URL_COUNT; i++) {
     if (!TextUtils.isEmpty(getURL(context, i))) {
       urlList.add(getString(context, KEY_URL + i));
     }
   }
   return urlList;
 }
示例#19
0
 public static void recordData(String inurl) throws Exception {
   // pr = new PrintStream(new FileOutputStream("http://en.wikipedia.org/wiki/HAProxy"));
   pr = System.out;
   long start = System.currentTimeMillis();
   pr.println(inurl + "****************************************************************");
   printList(cleanUrlText(TextUtils.HTMLText(inurl)));
   String urls = TextUtils.HTMLLinkString(inurl, inurl);
   String[] url = urls.split("\\s+");
   HashSet<String> urlMap = new HashSet<String>(url.length);
   urlMap.add(inurl);
   for (String ur : url) {
     /*
      * if(!urlMap.contains(ur)){ pr.println(ur+"***************************************************************"); try{
      * printList(cleanUrlText(TextUtils.HTMLText(ur))); }catch(Exception e){ System.out.println("Error with url :"+ ur); e.printStackTrace(); }
      * urlMap.add(ur); }
      */
   }
   pr.println("Time elapsed" + (start - System.currentTimeMillis()));
   pr.close();
 }
示例#20
0
  /**
   * 解析附近群组Json数据
   *
   * @param application
   * @return
   */
  public static boolean resolveNearbyGroup(BaseApplication application) {
    if (application.mNearByGroups != null && application.mNearByGroups.isEmpty()) {
      String json = TextUtils.getJson(application.getApplicationContext(), NEARBY_GROUP);
      if (json != null) {
        try {
          JSONArray array = new JSONArray(json);

          NearByGroup group = null;
          JSONObject object = null;
          JSONArray groupsArray = null;
          List<NearByGroups> groupsList = null;
          NearByGroups groups = null;
          int mLength = array.length();
          for (int i = 0; i < mLength; i++) {
            object = array.getJSONObject(i);
            String address = object.getString(NearByGroup.ADDRESS);
            String distance = object.getString(NearByGroup.DISTANCE);
            int groupCount = object.getInt(NearByGroup.GROUP_COUNT);

            groupsArray = object.getJSONArray(NearByGroup.GROUPS);
            groupsList = new ArrayList<NearByGroups>();
            int mGroupLength = groupsArray.length();
            for (int j = 0; j < mGroupLength; j++) {
              JSONObject o = groupsArray.getJSONObject(j);
              String avatar = o.getString(NearByGroups.AVATAR);
              String name = o.getString(NearByGroups.NAME);
              int isNew = o.getInt(NearByGroups.IS_NEW);
              int isParty = o.getInt(NearByGroups.IS_PARTY);
              int memberCount = o.getInt(NearByGroups.MEMBER_COUNT);
              int memberTotal = o.getInt(NearByGroups.MEMBER_TOTAL);
              int isVip = o.getInt(NearByGroups.IS_VIP);
              int level = o.getInt(NearByGroups.LEVEL);
              String sign = o.getString(NearByGroups.SIGN);
              groups =
                  new NearByGroups(
                      avatar, name, isNew, isParty, memberCount, memberTotal, isVip, level, sign);
              groupsList.add(groups);
            }
            group = new NearByGroup(address, distance, groupCount, groupsList);
            application.mNearByGroups.add(group);
          }
        } catch (JSONException e) {
          application.mNearByGroups.clear();
        }
      }
    }
    if (application.mNearByGroups.isEmpty()) {
      return false;
    } else {
      return true;
    }
  }
  /**
   * 按照任务配置读取数据,并按照任务配置里的时间粒度,对数据进行聚合
   *
   * @param doAggregate 是否聚合
   * @param doDiscretize 是否离散化
   * @return
   */
  public DataItems readInput(boolean doAggregate, boolean doDiscretize) {
    if (UtilsSimulation.instance.isUseSimulatedData()) // 使用
    {
      TextUtils txt = new TextUtils();
      txt.setTextPath(task.getSourcePath());
      DataItems dataItems = txt.readInput();
      boolean isNonDouble = !dataItems.isAllDataIsDouble(); // 离散的或非double型的
      if (doAggregate)
        dataItems =
            DataPretreatment.aggregateData(
                dataItems, task.getGranularity(), task.getAggregateMethod(), isNonDouble);
      if (doDiscretize)
        dataItems =
            DataPretreatment.toDiscreteNumbers(
                dataItems,
                task.getDiscreteMethod(),
                task.getDiscreteDimension(),
                task.getDiscreteEndNodes());
      String endNodes = dataItems.discreteNodes();
      task.setDiscreteEndNodes(endNodes);
      return dataItems;
    } else {
      Calendar cal = Calendar.getInstance();
      cal.set(1, 0, 1, 0, 0, 0);
      cal.set(Calendar.MILLISECOND, 0);
      Date dStart;
      Date dEnd;
      if (task.getDateStart() == null || task.getDateStart().equals(cal.getTime()))
        dStart = UtilsSimulation.instance.getStartTime();
      else dStart = task.getDateStart();

      if (task.getDateEnd() == null || task.getDateEnd().equals(cal.getTime()))
        dEnd = UtilsSimulation.instance.getCurTime();
      else dEnd = task.getDateEnd();
      if (dEnd.after(UtilsSimulation.instance.getCurTime()))
        dEnd = UtilsSimulation.instance.getCurTime();
      return readInputBetween(dStart, dEnd);
    }
  }
 /**
  * Creates a reader that pipes the input file through a XSLT-Script that updates the version to
  * the current.
  *
  * @throws IOException
  */
 public Reader getUpdateReader(final File file, final String xsltScript)
     throws FileNotFoundException, IOException {
   try {
     String updatedXml = transform(file, xsltScript);
     return new StringReader(updatedXml);
   } catch (final Exception ex) {
     final String message = ex.getMessage();
     UITools.errorMessage(TextUtils.format("update_failed", String.valueOf(message)));
     LogUtils.warn(ex);
     final InputStream input = new BufferedInputStream(new FileInputStream(file));
     return getActualReader(input);
   }
 }
示例#23
0
 @Test
 public void should_escape() {
   assertThat(TextUtils.escape('\r')).isEqualTo("\\r");
   assertThat(TextUtils.escape('\n')).isEqualTo("\\n");
   assertThat(TextUtils.escape('\f')).isEqualTo("\\f");
   assertThat(TextUtils.escape('\t')).isEqualTo("\\t");
   assertThat(TextUtils.escape('"')).isEqualTo("\\\"");
   assertThat(TextUtils.escape('\\')).isEqualTo("\\");
 }
示例#24
0
 public Connection connect(java.lang.String dburl, java.util.Properties info) throws SQLException {
   if (acceptsURL(dburl)) {
     String dbname = dburl.substring(URL_PREFIX_LEN);
     try {
       java.util.Vector param = TextUtils.getWords(dbname, "/");
       if (param.size() > 1)
         return DBLogicalManager.getPoolConnection(
             param.elementAt(0).toString(), getIntValue(param.elementAt(1).toString(), 0));
       else return DBLogicalManager.getPoolConnection(dbname);
     } catch (ConnectTimeoutException cte) {
       throw new SQLException(cte.getMessage(), "TIMEOUT");
     } catch (DatabaseMarkdownException dme) {
       throw new SQLException(dme.getMessage(), "MARKDOWN");
     }
   }
   throw new SQLException("invalid url string error.");
 }
示例#25
0
 public static void executeMenuItems(final List<String> menuItemKeys) {
   LogUtils.info("menu items to execute: " + menuItemKeys);
   final MenuBuilder menuBuilder = getMenuBuilder();
   for (String menuItemKey : menuItemKeys) {
     final DefaultMutableTreeNode treeNode = menuBuilder.get(menuItemKey);
     if (treeNode == null
         || !treeNode.isLeaf()
         || !(treeNode.getUserObject() instanceof JMenuItem)) {
       UITools.errorMessage(TextUtils.format("MenuUtils.invalid_menuitem", menuItemKey));
       return;
     }
     final JMenuItem menuItem = (JMenuItem) treeNode.getUserObject();
     final Action action = menuItem.getAction();
     LogUtils.info("executing " + menuItem.getText() + "(" + menuItemKey + ")");
     ActionEvent e = new ActionEvent(menuItem, 0, null);
     action.actionPerformed(e);
   }
 }
示例#26
0
 public void addRoot(String s, File file)
 {
     if (TextUtils.isEmpty(s))
     {
         throw new IllegalArgumentException("Name must not be empty");
     }
     File file1;
     try
     {
         file1 = file.getCanonicalFile();
     }
     // Misplaced declaration of an exception variable
     catch (String s)
     {
         throw new IllegalArgumentException((new StringBuilder()).append("Failed to resolve canonical path for ").append(file).toString(), s);
     }
     mRoots.put(s, file1);
 }
示例#27
0
  public BoringLayout(
      CharSequence source,
      TextPaint paint,
      int outerwidth,
      Alignment align,
      float spacingmult,
      float spacingadd,
      BoringLayout.Metrics metrics,
      boolean includepad,
      TextUtils.TruncateAt ellipsize,
      int ellipsizedWidth) {
    /*
     * It is silly to have to call super() and then replaceWith(),
     * but we can't use "this" for the callback until the call to
     * super() finishes.
     */
    super(source, paint, outerwidth, align, spacingmult, spacingadd);

    boolean trust;

    if (ellipsize == null || ellipsize == TextUtils.TruncateAt.MARQUEE) {
      mEllipsizedWidth = outerwidth;
      mEllipsizedStart = 0;
      mEllipsizedCount = 0;
      trust = true;
    } else {
      replaceWith(
          TextUtils.ellipsize(source, paint, ellipsizedWidth, ellipsize, true, this),
          paint,
          outerwidth,
          align,
          spacingmult,
          spacingadd);

      mEllipsizedWidth = ellipsizedWidth;
      trust = false;
    }

    init(getText(), paint, outerwidth, align, spacingmult, spacingadd, metrics, includepad, trust);
  }
示例#28
0
  /**
   * Returns a BoringLayout for the specified text, potentially reusing this one if it is already
   * suitable. The caller must make sure that no one is still using this Layout.
   */
  public BoringLayout replaceOrMake(
      CharSequence source,
      TextPaint paint,
      int outerwidth,
      Alignment align,
      float spacingmult,
      float spacingadd,
      BoringLayout.Metrics metrics,
      boolean includepad,
      TextUtils.TruncateAt ellipsize,
      int ellipsizedWidth) {
    boolean trust;

    if (ellipsize == null || ellipsize == TextUtils.TruncateAt.MARQUEE) {
      replaceWith(source, paint, outerwidth, align, spacingmult, spacingadd);

      mEllipsizedWidth = outerwidth;
      mEllipsizedStart = 0;
      mEllipsizedCount = 0;
      trust = true;
    } else {
      replaceWith(
          TextUtils.ellipsize(source, paint, ellipsizedWidth, ellipsize, true, this),
          paint,
          outerwidth,
          align,
          spacingmult,
          spacingadd);

      mEllipsizedWidth = ellipsizedWidth;
      trust = false;
    }

    init(getText(), paint, outerwidth, align, spacingmult, spacingadd, metrics, includepad, trust);
    return this;
  }
示例#29
0
  /**
   * built market model browse url
   *
   * @param modelSearch
   * @param name
   * @return
   */
  public static String modelBrowseUrl(ModelSearch modelSearch, String name) {
    String url;

    if (modelSearch.getCategoryId() == null) {
      url = "/tim-kiem-model.html";
    } else {
      url =
          "/mua-ban/model/"
              + modelSearch.getCategoryId()
              + "/"
              + TextUtils.createAlias(name)
              + ".html";
    }
    String search = "";
    String keyword = modelSearch.getKeyword();
    int pageIndex = modelSearch.getPageIndex();
    if ((modelSearch.getManufacturerIds() != null && !modelSearch.getManufacturerIds().isEmpty())
        || modelSearch.getOrderBy() > 0
        || (modelSearch.getProperties() != null && !modelSearch.getProperties().isEmpty())) {
      modelSearch.setKeyword(null);
      modelSearch.setPageIndex(0);
      search =
          "filter="
              + Base64.encodeBase64String(StringUtils.getBytesUtf8(new Gson().toJson(modelSearch)));
    }

    if (keyword != null && !keyword.equals("")) {
      url += "?keyword=" + keyword.replaceAll("\\s+", "\\+");
      url = pageIndex <= 1 ? url : url + "&page=" + pageIndex;
      return search.equals("") ? url : url + "&" + search;
    } else {
      return search.equals("")
          ? (pageIndex <= 1 ? url : url + "?page=" + pageIndex)
          : ((pageIndex <= 1 ? (url + "?") : (url + "?page=" + pageIndex + "&")) + search);
    }
  }
 public void testUnescapeHtml() {
   final String abc = "abc";
   CharSequence cs = TextUtils.unescapeHtml("abc");
   assertEquals(cs, abc);
   final String backwards = "aaa;lt&aaa";
   cs = TextUtils.unescapeHtml(backwards);
   assertEquals(cs, backwards);
   final String ampersand = "aaa&aaa";
   cs = TextUtils.unescapeHtml(ampersand);
   assertEquals(cs, ampersand);
   final String encodedAmpersand = "aaa&amp;aaa";
   cs = TextUtils.unescapeHtml(encodedAmpersand);
   assertEquals(cs, ampersand);
   final String encodedQuote = "aaa&#39;aaa";
   cs = TextUtils.unescapeHtml(encodedQuote);
   assertEquals(cs, "aaa'aaa");
   final String entityQuote = "aaa&quot;aaa";
   cs = TextUtils.unescapeHtml(entityQuote);
   assertEquals(cs, "aaa\"aaa");
 }