Пример #1
1
  /**
   * Returns the nl expression of a property name
   *
   * @param s property name
   * @return String NL-representation
   */
  public static String getNLExpression(String s) {
    StringBuffer result = new StringBuffer(s);
    if (s.length() < 3)
      return s; // LET'S ASSUME FOR NOW THAT ONLY HAPPENS WITH ABBREVIATIONS, WHICH SHOULD BE
    // CAPITALISED ANYWAY
    String sub = result.substring(result.length() - 2); // get the last two characters
    if (sub.equals("Of") || (result.indexOf("For") == (result.length() - 3))) {
      if (!result.substring(0, 2).toLowerCase().equals("is")) result.insert(0, "Is ");
    } else if ((sub.equals("By") || sub.equals("As"))
        && !result.substring(0, 2).toLowerCase().equals("is")) result.insert(0, "Is ");

    for (int i = 1;
        i < result.length();
        i++) { // replace all capitals with lowercase letters, and add spaces if needed
      char c = result.charAt(i);
      if (Character.isUpperCase(c)) {
        result.setCharAt(i, Character.toLowerCase(c));
        if (!(result.charAt(i - 1) == ' ') && !(result.charAt(i - 1) == '_'))
          result.insert(i, ' '); // insert a space		
      }
    }
    result.setCharAt(
        0, Character.toUpperCase(result.charAt(0))); // set first character to upper case
    return result.toString().replaceAll("_", " "); // replace all underscores with spaces
  }
Пример #2
0
 /**
  * suffix stripping (stemming) on the current term. The stripping is reduced to the seven "base"
  * suffixes "e", "s", "n", "t", "em", "er" and * "nd", from which all regular suffixes are build
  * of. The simplification causes some overstemming, and way more irregular stems, but still
  * provides unique. discriminators in the most of those cases. The algorithm is context free,
  * except of the length restrictions.
  */
 private void strip(StringBuffer buffer) {
   boolean doMore = true;
   while (doMore && buffer.length() > 3) {
     if ((buffer.length() + substCount > 5)
         && buffer.substring(buffer.length() - 2, buffer.length()).equals("nd")) {
       buffer.delete(buffer.length() - 2, buffer.length());
     } else if ((buffer.length() + substCount > 4)
         && buffer.substring(buffer.length() - 2, buffer.length()).equals("em")) {
       buffer.delete(buffer.length() - 2, buffer.length());
     } else if ((buffer.length() + substCount > 4)
         && buffer.substring(buffer.length() - 2, buffer.length()).equals("er")) {
       buffer.delete(buffer.length() - 2, buffer.length());
     } else if (buffer.charAt(buffer.length() - 1) == 'e') {
       buffer.deleteCharAt(buffer.length() - 1);
     } else if (buffer.charAt(buffer.length() - 1) == 's') {
       buffer.deleteCharAt(buffer.length() - 1);
     } else if (buffer.charAt(buffer.length() - 1) == 'n') {
       buffer.deleteCharAt(buffer.length() - 1);
     }
     // "t" occurs only as suffix of verbs.
     else if (buffer.charAt(buffer.length() - 1) == 't') {
       buffer.deleteCharAt(buffer.length() - 1);
     } else {
       doMore = false;
     }
   }
 }
Пример #3
0
 /** Time a string written to a file and turn it into a searchable array of ints */
 private int[] stringLineToArray(String line) {
   // int[] with correct amount of entries
   ArrayList<Integer> times = new ArrayList<Integer>();
   StringBuffer stringBuffer = new StringBuffer(line);
   // I start variables at 1 instead of 0 to avoid the inevitable '['
   int singleTimeStartIndex = 1;
   int singleTimeEndIndex = 1;
   for (int i = 1; i < stringBuffer.length(); i++) {
     if (stringBuffer.charAt(i) == ' ') {
       System.out.println("FOUND A SPACE");
       times.add(
           Integer.parseInt(stringBuffer.substring(singleTimeStartIndex, singleTimeEndIndex - 1)));
       System.out.println(times);
       // subtract two to avoid the ", "
       singleTimeStartIndex = i + 1;
       singleTimeEndIndex++;
     } else {
       System.out.println("NO SPACE");
       singleTimeEndIndex++;
     }
   }
   // Solve Fencepost Problem, for loop cannot add the very last integer
   // Instead of taking the last 4 digits, take all digits until a ' ' to be flexible.
   // O(1) basically since the only options are three or four iterations
   int index = stringBuffer.length() - 2; // -2 to avoid inevitable ']'
   while (stringBuffer.charAt(index) != ' ') {
     index--;
   }
   times.add(Integer.parseInt(stringBuffer.substring(index + 1, stringBuffer.length() - 1)));
   return intArrayListToArray(times);
 }
  public String normalizePath(String path) {
    int column = path.indexOf(':');
    if (column > 0) {
      char driveLetter = path.charAt(column - 1);
      if (Character.isLowerCase(driveLetter)) {
        StringBuffer sb = new StringBuffer();
        if (column - 1 > 0) {
          sb.append(path.substring(0, column - 1));
        }
        sb.append(Character.toUpperCase(driveLetter));
        sb.append(path.substring(column));
        path = sb.toString();
      }
    }
    if (path.indexOf('.') == -1 || path.equals(".")) { // $NON-NLS-1$
      return (new Path(path)).toString(); // convert separators to '/'
    }
    // lose "./" segments since they confuse the Path normalization
    StringBuffer buf = new StringBuffer(path);
    int len = buf.length();
    StringBuffer newBuf = new StringBuffer(buf.length());
    int scp = 0; // starting copy point
    int ssp = 0; // starting search point
    int sdot;
    boolean validPrefix;
    while (ssp < len && (sdot = buf.indexOf(".", ssp)) != -1) { // $NON-NLS-1$
      validPrefix = false;
      int ddot = buf.indexOf("..", ssp); // $NON-NLS-1$
      if (sdot < ddot || ddot == -1) {
        newBuf.append(buf.substring(scp, sdot));
        scp = sdot;
        ssp = sdot + 1;
        if (ssp < len) {
          if (sdot == 0 || buf.charAt(sdot - 1) == '/' || buf.charAt(sdot - 1) == '\\') {
            validPrefix = true;
          }
          char nextChar = buf.charAt(ssp);
          if (validPrefix && nextChar == '/') {
            ++ssp;
            scp = ssp;
          } else if (validPrefix && nextChar == '\\') {
            ++ssp;
            if (ssp < len - 1 && buf.charAt(ssp) == '\\') {
              ++ssp;
            }
            scp = ssp;
          } else {
            // no path delimiter, must be '.' inside the path
            scp = ssp - 1;
          }
        }
      } else if (sdot == ddot) {
        ssp = sdot + 2;
      }
    }
    newBuf.append(buf.substring(scp, len));

    IPath orgPath = new Path(newBuf.toString());
    return orgPath.toString();
  }
  public void formatted(Format.Field attr, Object value, int start, int end, StringBuffer buffer) {
    if (start != end) {
      if (start < size) {
        // Adjust attributes of existing runs
        int index = size;
        int asIndex = attributedStrings.size() - 1;

        while (start < index) {
          AttributedString as = (AttributedString) attributedStrings.get(asIndex--);
          int newIndex = index - as.length();
          int aStart = Math.max(0, start - newIndex);

          as.addAttribute(
              attr, value, aStart, Math.min(end - start, as.length() - aStart) + aStart);
          index = newIndex;
        }
      }
      if (size < start) {
        // Pad attributes
        attributedStrings.add(new AttributedString(buffer.substring(size, start)));
        size = start;
      }
      if (size < end) {
        // Add new string
        int aStart = Math.max(start, size);
        AttributedString string = new AttributedString(buffer.substring(aStart, end));

        string.addAttribute(attr, value);
        attributedStrings.add(string);
        size = end;
      }
    }
  }
Пример #6
0
  private boolean doReq(List<TlogBean> normalDfs) {
    StringBuffer normalMsg = new StringBuffer();
    StringBuffer exceptionMsg = new StringBuffer();
    String resp = "手工审核成功\n";
    try {
      // MMs重发代付、 因订单重新生产
      if (normalDfs.size() != 0) {
        for (TlogBean tlog : normalDfs) {
          String respFlag = "suc";
          if (!"suc".equals(respFlag)) {
            tlog.setTstat(PayState.FAILURE);
            tlog.setError_msg("请求银行失败");
            tlog.setAgainPay_status(Constant.SgDfTstat.TSTAT_SHFAIL);
            new SgDfShDao().updateTstat(tlog);
            exceptionMsg.append(tlog.getOid()).append(",");
          } else {
            normalMsg.append(tlog.getOid()).append(",");
          }
        }
      }
    } catch (Exception e) {
      LogUtil.printErrorLog("SgDfShService", "reqPayDf", "reqPayDf_exception", e);
    }

    if (!Ryt.empty(normalMsg.toString())) {
      resp += "提交成功:" + normalMsg.substring(0, normalMsg.length() - 1) + "\n";
    }
    if (!Ryt.empty(exceptionMsg.toString())) {
      resp += "请求银行失败:" + exceptionMsg.substring(0, exceptionMsg.length() - 1) + "\n";
    }
    LogUtil.printInfoLog("SgDfShServiceTest", "doReq", "resp:" + resp);

    return true;
  }
  protected Empresa getData(HtmlPage page) {

    StringBuffer sb = new StringBuffer();
    sb.append(page.asText());

    int posInit = 0;
    int posEnd = 0;

    Empresa empresa = new Empresa();

    posInit = sb.indexOf(EMPRESA[0]);
    posEnd = (posInit > -1) ? sb.indexOf(EMPRESA[1], posInit) : -1;
    // NOME EMPRESA
    if (posInit > -1 && posEnd > -1) {
      empresa.setNome(sb.substring(posInit + EMPRESA[0].length(), posEnd).trim());
    }

    posInit = sb.indexOf(CONTATO[0]);
    posEnd = (posInit > -1) ? sb.indexOf(CONTATO[1], posInit) : -1;
    if (posInit > -1 && posEnd > -1) {
      empresa.setContato(sb.substring(posInit + CONTATO[0].length(), posEnd).trim());
    }

    empresa.setSite(null);
    empresa.setEmail(null);
    empresa.setLocal("MX");

    System.out.println("\n### EMPRESA:" + empresa.getNome());
    System.out.println("### CONTATO:" + empresa.getContato() + "\n");

    return empresa;
  }
Пример #8
0
 private String[] formatTimeStr(String str) {
   String[] gp = new String[2];
   StringBuffer sb = new StringBuffer(str);
   sb.insert(2, ':');
   sb.insert(8, ':');
   gp[0] = sb.substring(0, 5);
   gp[1] = sb.substring(6);
   return gp;
 }
Пример #9
0
 public void sendServiceSignal(final Word serviceSignal) {
   StringBuffer service = new StringBuffer(serviceSignal.getWord());
   StringBuffer signal =
       new StringBuffer(service.substring(4))
           .append(nodeId)
           .append(service.substring(4, service.length()));
   serviceSignal.setWord(signal.toString());
   driver.send(serviceSignal);
 }
    public VirtualNasServerInfo(VirtualNASRestRep vNasRestRep, boolean isProjectAccessible) {

      StringBuffer projectListWithIds = new StringBuffer();
      this.nasName = vNasRestRep.getNasName();
      this.storageDeviceURI =
          (vNasRestRep.getStorageDeviceURI() != null)
              ? vNasRestRep.getStorageDeviceURI().toString()
              : "";
      if (isProjectAccessible) {
        Set<String> associatedProjects = vNasRestRep.getAssociatedProjects();
        if (associatedProjects != null && !associatedProjects.isEmpty()) {
          StringBuffer projectList = new StringBuffer();

          for (Iterator<String> iterator = associatedProjects.iterator(); iterator.hasNext(); ) {
            String projectId = iterator.next();
            ProjectRestRep projectRestRep = getViprClient().projects().get(URI.create(projectId));
            projectList.append(projectRestRep.getName()).append(", ");
            projectListWithIds
                .append(projectRestRep.getName())
                .append("+")
                .append(projectRestRep.getId())
                .append(",");
          }
          this.project = projectList.substring(0, projectList.length() - 2);
        }
      }

      this.protocols = vNasRestRep.getProtocols();
      this.baseDirPath = vNasRestRep.getBaseDirPath();
      this.nasTag = vNasRestRep.getTags();
      this.nasState = vNasRestRep.getNasState();
      this.cifsServers = vNasRestRep.getCifsServers();
      this.storagePorts =
          (vNasRestRep.getStoragePorts() != null) ? vNasRestRep.getStoragePorts().toString() : "";
      this.storageDomain =
          (vNasRestRep.getStorageDomain() != null) ? vNasRestRep.getStorageDomain().toString() : "";
      NamedRelatedResourceRep resourceRep = vNasRestRep.getParentNASURI();
      if (resourceRep != null) {
        this.parentNASURI = resourceRep.getName();
      }
      this.registrationStatus = vNasRestRep.getRegistrationStatus();
      this.compatibilityStatus = vNasRestRep.getCompatibilityStatus();
      this.discoveryStatus = vNasRestRep.getDiscoveryStatus();
      this.storageObjects = vNasRestRep.getStorageObjects();
      this.storageCapacity = vNasRestRep.getUsedStorageCapacity();
      this.avgPercentagebusy = vNasRestRep.getAvgPercentagebusy();
      this.percentLoad = vNasRestRep.getPercentLoad();

      if (projectListWithIds.length() > 0) {
        this.id =
            vNasRestRep.getId().toString()
                + "~~~"
                + projectListWithIds.substring(0, projectListWithIds.length() - 1);
      } else {
        this.id = vNasRestRep.getId().toString() + "~~~";
      }
    }
Пример #11
0
  /**
   * 分割CSV文件数值,并返回List
   *
   * @param line
   * @return
   */
  private ArrayList<String> getCSVItems(String line) {
    ArrayList<String> v = new ArrayList<String>();
    int startIdx = 0;
    int searchIdx = -1;
    StringBuffer sbLine = new StringBuffer(line);
    while ((searchIdx = sbLine.toString().indexOf(delimiter, startIdx)) != -1) {
      String buf = null;

      if (sbLine.charAt(startIdx) != escape) {
        buf = sbLine.substring(startIdx, searchIdx);
        startIdx = searchIdx + 1;
      } else {

        int escapeIdx = -1;
        searchIdx = startIdx;
        boolean findDelimiter = false;

        while ((escapeIdx = sbLine.toString().indexOf(escape, searchIdx + 1)) != -1
            && sbLine.length() > escapeIdx + 1) {
          char nextChar = sbLine.charAt(escapeIdx + 1);
          if (delimiter.indexOf(nextChar) != -1) {
            buf = sbLine.substring(startIdx + 1, escapeIdx);
            startIdx = escapeIdx + 2;
            findDelimiter = true;
            break;
          }
          if (nextChar == escape) {
            sbLine.deleteCharAt(escapeIdx);
            escapeIdx--;
          }
          searchIdx = escapeIdx + 1;
        }

        if (!findDelimiter) {
          break;
        }
      }

      v.add(buf.trim());
    }

    if (startIdx < sbLine.length()) {
      int lastIdx = sbLine.length() - 1;
      if (sbLine.charAt(startIdx) == escape && sbLine.charAt(lastIdx) == escape) {
        sbLine.deleteCharAt(lastIdx);
        sbLine.deleteCharAt(startIdx);
      }
      v.add(sbLine.substring(startIdx, sbLine.length()).trim());
    } else if (startIdx == sbLine.length()) {
      v.add("");
    }

    return v;
  }
Пример #12
0
  protected void addPlugins() {
    ContainerBase container = new ContainerBase("Plugins");
    container.initProperties();
    addChild(container);

    ComponentDescription[] desc = ComponentConnector.parseFile(filename);
    if (desc == null) {
      if (log.isWarnEnabled()) {
        log.warn("No data found in file " + filename);
      }
      return;
    }
    for (int i = 0; i < desc.length; i++) {
      StringBuffer name = new StringBuffer(desc[i].getName());
      StringBuffer className = new StringBuffer(desc[i].getClassname());
      String insertionPoint = desc[i].getInsertionPoint();
      String priority = desc[i].priorityToString(desc[i].getPriority());
      //       if(log.isDebugEnabled()) {
      //         log.debug("Insertion Point: " + insertionPoint);
      //       }

      if (insertionPoint.endsWith("Plugin")) {
        int start = 0;
        if ((start = name.indexOf("OrgRTData")) != -1) {
          name.delete(start, start + 2);
          start = className.indexOf("RT");
          className.delete(start, start + 2);
        }

        // HACK!
        // When dumping INIs we add an extra parameter to the GLSInitServlet,
        // so strip it off here
        boolean isGLS = false;
        if (className.indexOf("GLSInitServlet") != -1) {
          isGLS = true;
        }

        int index = name.lastIndexOf(".");
        if (index != -1) name.delete(0, index + 1);
        PluginBase plugin = new PluginBase(name.substring(0), className.substring(0), priority);
        plugin.initProperties();
        Iterator iter = ComponentConnector.getPluginProps(desc[i]);
        while (iter.hasNext()) {
          if (isGLS) {
            String param = (String) iter.next();
            if (param.startsWith("exptid=")) continue;
            else plugin.addParameter(param);
          } else plugin.addParameter((String) iter.next());
        }
        container.addChild(plugin);
      }
    }
  }
Пример #13
0
  private void _checkAccountCRC(String frontendname, String blz, String number) {
    // pruefsummenberechnung nur wenn blz/kontonummer angegeben sind
    if (blz == null || number == null) {
      return;
    }
    if (blz.length() == 0 || number.length() == 0) {
      return;
    }

    // daten merken, die im urspruenglich verwendet wurden (um spaeter
    // zu wissen, ob sie korrigiert wurden)
    String orig_blz = blz;
    String orig_number = number;

    while (true) {
      // daten validieren
      boolean crcok = HBCIUtils.checkAccountCRC(blz, number);

      // aktuelle daten merken
      String old_blz = blz;
      String old_number = number;

      if (!crcok) {
        // wenn beim validieren ein fehler auftrat, nach neuen daten fragen
        StringBuffer sb = new StringBuffer(blz).append("|").append(number);
        HBCIUtilsInternal.getCallback()
            .callback(
                getMainPassport(),
                HBCICallback.HAVE_CRC_ERROR,
                HBCIUtilsInternal.getLocMsg("CALLB_HAVE_CRC_ERROR"),
                HBCICallback.TYPE_TEXT,
                sb);

        int idx = sb.indexOf("|");
        blz = sb.substring(0, idx);
        number = sb.substring(idx + 1);
      }

      if (blz.equals(old_blz) && number.equals(old_number)) {
        // blz und kontonummer auch nach rueckfrage unveraendert,
        // also tatsaechlich mit diesen daten weiterarbeiten
        break;
      }
    }

    if (!blz.equals(orig_blz)) {
      setParam(frontendname + ".KIK.blz", blz);
    }
    if (!number.equals(orig_number)) {
      setParam(frontendname + ".number", number);
    }
  }
  /**
   * Returns a comparison result from the given buffer. Removes the terminating line delimiter.
   *
   * @param buf the comparison result
   * @return the result or <code>null</code> if empty
   * @since 3.7
   */
  private static String nullifyEmpty(StringBuffer buf) {
    int length = buf.length();
    if (length == 0) return null;

    char last = buf.charAt(length - 1);
    if (last == '\n') {
      if (length > 1 && buf.charAt(length - 2) == '\r') return buf.substring(0, length - 2);
      else return buf.substring(0, length - 1);
    } else if (last == '\r') {
      return buf.substring(0, length - 1);
    }
    return buf.toString();
  }
Пример #15
0
 /** Writing to the output */
 public void write(Writer w) throws IOException {
   StringBuffer buf = ibuf().getbuf();
   int beg = this.beg_charno0;
   int pos = beg;
   Iterator<Node> i = iterator();
   while (i.hasNext()) {
     YYNode n = (YYNode) i.next();
     w.write(buf.substring(pos, n.beg_charno0));
     n.write(w);
     pos = n.end_charno0;
   }
   w.write(buf.substring(pos, this.end_charno0));
 }
Пример #16
0
 /*
  * Returns the next element from a string with
  * the following format: next:restOfString
  */
 public static String nextElement(StringBuffer str) {
   String result = "";
   int i = str.indexOf(":", 0);
   if (i == -1) {
     result = str.toString();
     str.setLength(0);
   } else {
     result = str.substring(0, i).toString();
     String a = str.substring(i + 1);
     str.setLength(0);
     str.append(a);
   }
   return result;
 }
Пример #17
0
  /**
   * Formats a hash 256 input.
   *
   * @param hash256 the hash input
   * @return the formatted hash
   */
  private String format(String hash256) {
    StringBuffer buffer;
    String formatted;

    buffer = new StringBuffer();
    for (int i = 0; i < hash256.length(); i += 2) {
      buffer.append(hash256.charAt(i));
      buffer.append(hash256.charAt(i + 1));
      buffer.append(' ');
    }

    formatted = buffer.substring(0, 48) + LINE_SEPARATOR + buffer.substring(48) + LINE_SEPARATOR;
    return formatted;
  }
Пример #18
0
  /**
   * To find a string in the buffer.
   *
   * @param buffer is the buffer
   * @param tag is the string to search
   * @param posBegin is the beginning index
   * @param posEnd is the ending index
   * @return the index of the string, or -1 if it doesn't exist
   */
  private int indexOf(StringBuffer buffer, String tag, int posBegin, int posEnd) {
    int index = buffer.substring(posBegin, posEnd).indexOf(tag);
    if ((index + posBegin) > 1
        && IAcceleoConstants.LITERAL_ESCAPE.equals(tag)
        && "\\".equals(buffer.substring(posBegin + index - 1, posBegin + index))) { // $NON-NLS-1$
      // Ensure that "\'" does not count
      index = -1;
    }

    if (index >= 0) {
      return index + posBegin;
    }
    return index;
  }
Пример #19
0
  public Font toFont() {
    StringBuffer stringBuffer = new StringBuffer(getFont());
    String fontName = stringBuffer.substring(0, stringBuffer.indexOf("-"));
    stringBuffer = stringBuffer.delete(0, stringBuffer.indexOf("-") + 1);
    String dataStyle = stringBuffer.substring(0, stringBuffer.indexOf("-"));
    if (dataStyle.equalsIgnoreCase("PLAIN")) fontStyle = Font.PLAIN;
    else if (dataStyle.equalsIgnoreCase("BOLD")) fontStyle = Font.BOLD;
    else if (dataStyle.equalsIgnoreCase("")) fontStyle = Font.ITALIC;

    stringBuffer = stringBuffer.delete(0, stringBuffer.indexOf("-") + 1);
    int fontSize = Integer.parseInt(stringBuffer.toString());

    Font font = new Font(fontName, fontStyle, fontSize);
    return font;
  }
Пример #20
0
  public Alignment getPairAlignment(int x, int y) {

    SimpleAlignment pairAlignment = new SimpleAlignment();

    StringBuffer sequence0 = new StringBuffer();
    StringBuffer sequence1 = new StringBuffer();

    DataType dataType = alignment.getDataType();
    int stateCount = dataType.getStateCount();

    for (int i = 0; i < alignment.getSiteCount(); i++) {

      int s0 = alignment.getState(x, i);
      int s1 = alignment.getState(y, i);

      char c0 = dataType.getChar(s0);
      char c1 = dataType.getChar(s1);

      if (s0 < stateCount || s1 < stateCount) {
        sequence0.append(c0);
        sequence1.append(c1);
      }
    }

    // trim hanging ends on left
    int left = 0;
    while ((dataType.getState(sequence0.charAt(left)) >= stateCount)
        || (dataType.getState(sequence1.charAt(left)) >= stateCount)) {
      left += 1;
    }

    // trim hanging ends on right
    int right = sequence0.length() - 1;
    while ((dataType.getState(sequence0.charAt(right)) >= stateCount)
        || (dataType.getState(sequence1.charAt(right)) >= stateCount)) {
      right -= 1;
    }

    if (right < left) return null;

    String sequenceString0 = sequence0.substring(left, right + 1);
    String sequenceString1 = sequence1.substring(left, right + 1);

    pairAlignment.addSequence(new Sequence(alignment.getTaxon(x), sequenceString0));
    pairAlignment.addSequence(new Sequence(alignment.getTaxon(y), sequenceString1));

    return pairAlignment;
  }
Пример #21
0
 /**
  * 将数组中重复的字符串 去除
  *
  * @param destmsisdns
  * @return
  */
 public static String removeSameDestmsisdn(String destmsisdns) {
   String tmp = null;
   StringBuffer sb_destmsisdn = new StringBuffer();
   String[] destmsisdnArray = destmsisdns.split(",");
   if (destmsisdnArray == null || destmsisdnArray.length == 0) {
     return null;
   }
   ArrayList<String> resultList = new ArrayList<String>();
   for (int i = 0; i < destmsisdnArray.length; i++) {
     if (resultList.contains(destmsisdnArray[i])) {
       continue;
     } else {
       resultList.add(destmsisdnArray[i]);
     }
   }
   for (int i = 0; i < resultList.size(); i++) {
     sb_destmsisdn.append(resultList.get(i));
     sb_destmsisdn.append(",");
   }
   if (sb_destmsisdn.length() > 0) {
     tmp = sb_destmsisdn.substring(0, sb_destmsisdn.length() - 1);
   } else {
     tmp = sb_destmsisdn.toString();
   }
   return tmp;
 }
Пример #22
0
 private String a()
 {
   boolean bool = DialogToastListActivity.f;
   StringBuffer localStringBuffer = new StringBuffer();
   TreeSet localTreeSet = new TreeSet();
   Iterator localIterator1 = this.p.iterator();
   do
   {
     if (!localIterator1.hasNext())
       break;
     zq localzq = (zq)localIterator1.next();
     if (localzq.l)
       localTreeSet.add(localzq.b);
   }
   while (!bool);
   Iterator localIterator2 = localTreeSet.iterator();
   do
   {
     if (!localIterator2.hasNext())
       break;
     localStringBuffer.append((String)localIterator2.next()).append(",");
   }
   while (!bool);
   if (localStringBuffer.length() > 0);
   for (String str = localStringBuffer.substring(0, -1 + localStringBuffer.length()); ; str = null)
   {
     return str;
     localTreeSet.clear();
   }
 }
Пример #23
0
 /**
  * ************************************************************************ Write to file
  *
  * @param sb string buffer
  * @param fileName file name
  */
 private void writeToFile(StringBuffer sb, String fileName) {
   try {
     File out = new File(fileName);
     FileWriter fw = new FileWriter(out);
     for (int i = 0; i < sb.length(); i++) {
       char c = sb.charAt(i);
       //	after
       if (c == ';' || c == '}') {
         fw.write(c);
         if (sb.substring(i + 1).startsWith("//")) fw.write('\t');
         else fw.write(Env.NL);
       }
       //	before & after
       else if (c == '{') {
         fw.write(Env.NL);
         fw.write(c);
         fw.write(Env.NL);
       } else fw.write(c);
     }
     fw.flush();
     fw.close();
     float size = out.length();
     size /= 1024;
     log.info(out.getAbsolutePath() + " - " + size + " kB");
   } catch (Exception ex) {
     log.log(Level.SEVERE, fileName, ex);
   }
 } //	writeToFile
Пример #24
0
 /**
  * 参数替换
  *
  * @param strVal
  * @param props
  * @param visitedPlaceholders
  * @return
  * @throws Exception
  */
 public static String parseStringValue(String strVal, Properties props) throws Exception {
   StringBuffer buf = new StringBuffer(strVal);
   int startIndex = strVal.indexOf(placeholderPrefix);
   while (startIndex != -1) {
     int endIndex = findPlaceholderEndIndex(buf, startIndex);
     if (endIndex != -1) {
       String placeholder = buf.substring(startIndex + placeholderPrefix.length(), endIndex);
       placeholder = parseStringValue(placeholder, props);
       String propVal = resolvePlaceholder(placeholder, props);
       if (propVal != null) {
         propVal = parseStringValue(propVal, props);
         buf.replace(startIndex, endIndex + placeholderSuffix.length(), propVal);
         if (log.isTraceEnabled()) {
           log.trace("已经替换占位符 '" + placeholder + "'");
         }
         startIndex = buf.indexOf(placeholderPrefix, startIndex + propVal.length());
       } else if (ignoreUnresolvablePlaceholders) {
         startIndex = buf.indexOf(placeholderPrefix, endIndex + placeholderSuffix.length());
       } else {
         throw new Exception("无法替换占位符 '" + placeholder + "'");
       }
     } else {
       startIndex = -1;
     }
   }
   return buf.toString();
 }
Пример #25
0
 public static void main(String[] args) {
   System.err.println("Checking FSL path in " + args[0]);
   StringBuffer bf = new StringBuffer();
   try {
     FileReader fr = new FileReader(args[0]);
     int c;
     do {
       c = fr.read();
       bf.append((char) c);
     } while (c != -1);
     FSLNSResolver nsr = new FSLNSResolver();
     nsr.addPrefixBinding("a", "http://a#");
     nsr.addPrefixBinding("b", "http://b#");
     nsr.addPrefixBinding("c", "http://c#");
     nsr.addPrefixBinding("d", "http://d#");
     nsr.addPrefixBinding("e", "http://e#");
     nsr.addPrefixBinding("f", "http://f#");
     nsr.addPrefixBinding("n", "http://n#");
     nsr.addPrefixBinding("dc", "http://dc#");
     nsr.addPrefixBinding("xsd", "http://xsd#");
     nsr.addPrefixBinding("rdf", "http://rdf#");
     nsr.addPrefixBinding("foaf", "http://foaf#");
     nsr.addPrefixBinding("r", "http://r#");
     nsr.addPrefixBinding("", "http://DD#"); // default NS
     System.out.println(
         "serialization:  "
             + FSLPath.pathFactory(bf.substring(0, bf.length() - 1), nsr, FSLPath.NODE_STEP)
                 .serialize()
             + "\n");
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Пример #26
0
  /**
   * ajaxGetName(动态获取名称)
   *
   * @param name
   * @param @return 设定文件
   * @return String DOM对象 @Exception 异常对象
   * @since CodingExample Ver(编码范例查看) 1.1
   */
  public String ajaxGetName() {
    StringBuffer sb = new StringBuffer(200);
    try {
      Map<String, String> map = new HashMap<String, String>();
      map.put("MA006", b00401PO.getMA006());
      map.put("MA004", b00401PO.getMA004());
      List<B00401PO> poList = b00401Service.retrieveB00401ByPinyin(map);
      B00401PO po = null;
      sb.append("[");
      if (poList != null && poList.size() > 0) {
        for (int i = 0, n = poList.size(); i < n; i++) {
          po = poList.get(i);
          sb.append("{'id':'" + i + "','name':'" + po.getMA004() + "'},");
        }
        sb = new StringBuffer(sb.substring(0, sb.length() - 1));
      }
      sb.append("]");

      this.getResponse().setCharacterEncoding("utf-8");
      PrintWriter out = this.getResponse().getWriter();
      out.write(sb.toString());

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
Пример #27
0
 /**
  * bean转化成字符串
  *
  * @param bean
  * @param beanName
  * @return beanStr
  */
 public static String convertBean2Str(Object bean, String beanName) {
   StringBuffer str = new StringBuffer();
   Class<? extends Object> type = bean.getClass();
   try {
     BeanInfo beanInfo = Introspector.getBeanInfo(type);
     PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
     for (int i = 0; i < propertyDescriptors.length; i++) {
       PropertyDescriptor descriptor = propertyDescriptors[i];
       String propertyName = descriptor.getName();
       if (!propertyName.equals("class")) {
         Method readMethod = descriptor.getReadMethod();
         Object result = readMethod.invoke(bean, new Object[0]);
         if (result != null && StringUtils.trim(result.toString()).length() != 0) {
           str.append("&")
               .append(beanName)
               .append(".")
               .append(propertyName)
               .append("=")
               .append(result);
         }
       }
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   }
   return str.indexOf("&") != -1 ? str.substring(1) : str.toString();
 }
Пример #28
0
 private static String internalReplaceDynamicParameters(
     String address, Map parameters, int index) {
   StringBuffer sb = new StringBuffer(address);
   int startPos = sb.indexOf("{");
   while (startPos >= 0) {
     int endPos = sb.indexOf("}", startPos + 1);
     if (endPos >= 0) {
       String attribute = sb.substring(startPos + 1, endPos);
       Object value = parameters.get(attribute);
       if (value != null) {
         if (value instanceof Object[]) {
           value = ((Object[]) value)[index];
         }
         sb.replace(startPos, endPos + 1, value.toString());
         endPos = startPos + value.toString().length();
       } else {
         sb.replace(startPos, endPos + 1, "");
         endPos = startPos;
       }
       startPos = sb.indexOf("{", endPos);
     } else {
       startPos = -1;
     }
   }
   return sb.toString();
 }
Пример #29
0
  /**
   * 解析url{@link StringBuffer}返回一个新的实例
   *
   * @param url
   * @return UrlRole
   */
  public static UrlRole parse(StringBuffer url) {

    UrlRole def = new UrlRole();

    int point = url.lastIndexOf(".");
    if (point != -1) url.delete(point, url.length());

    int a = url.indexOf("!");

    if (a == url.length() - 1) {
      def.className = url.deleteCharAt(url.length() - 1);
      def.methodName = "execute";
    } else if (a != -1) {
      def.methodName = url.substring(a + 1);
      def.className = url.delete(a, url.length());
    } else {
      def.className = url;
      def.methodName = "execute";
    }

    int b = def.className.lastIndexOf("/");

    char c = def.className.charAt(b + 1);

    if (c >= 'a' && c <= 'z') def.className.setCharAt(b + 1, (char) (c - 32));
    def.className.replace(b, b + 1, ".action.").append("Action");

    while ((b = def.className.indexOf("/")) != -1) {
      def.className.setCharAt(b, '.');
    }

    def.className.insert(0, P3Filter.ACTION_PACKAGE);
    if (logger.isDebugEnabled()) logger.debug("action define : " + def);
    return def;
  }
 private String createTableQuery(SingleTable t) {
   StringBuffer query = new StringBuffer("CREATE TABLE " + t.getName() + "(");
   StringBuffer primaryKeys = new StringBuffer(",PRIMARY KEY(");
   List<DBColumn> columns = t.getColumns();
   int i = 1;
   boolean PKFound = false;
   for (DBColumn column : columns) {
     query.append(column.getName() + " " + column.getType());
     if (column.isNotNull()) {
       query.append(" NOT NULL");
     }
     if (column.isPrimaryKey()) {
       PKFound = true;
       primaryKeys.append(column.getName() + ",");
     }
     if (i != columns.size()) {
       query.append(",");
     }
     i++;
   }
   if (PKFound) {
     String pks = primaryKeys.substring(0, primaryKeys.length() - 1);
     query.append(pks + ")");
   }
   query.append(");");
   return query.toString();
 }