Пример #1
0
 /**
  * @param groupName allow groupName is null
  * @param charsetName
  * @param cmd
  * @param errorNo
  * @return
  * @throws FdfsException
  */
 public static byte[] createRequest(String groupName, String charsetName, byte cmd, byte errorNo)
     throws FdfsException {
   byte[] groupNameByteArr = null;
   int headerLength = 10;
   int bodyLength = 0;
   if (Strings.isNotBlank(groupName)) { //
     bodyLength = FDFS_GROUP_NAME_MAX_LEN;
     groupNameByteArr = Strings.getBytes(groupName, charsetName);
   }
   int totalLength = headerLength + bodyLength;
   WriteByteArrayFragment request = new WriteByteArrayFragment(totalLength);
   // writeHeader
   {
     request.writeLong(bodyLength);
     request.writeByte(cmd);
     request.writeByte(errorNo);
   }
   // writeBody
   {
     if (Strings.isNotBlank(groupName)) { //
       request.writeLimitedBytes(groupNameByteArr, FDFS_GROUP_NAME_MAX_LEN);
     }
   }
   return request.getData();
 }
Пример #2
0
 /**
  * Assert that the given text does not contain the given substring.
  *
  * <pre class="code">
  * Assert.notContains(name, &quot;rod&quot;, &quot;Name must not contain 'rod'&quot;);
  * </pre>
  *
  * @param textToSearch the text to search
  * @param substring the substring to find within the text
  * @param message the exception message to use if the assertion fails
  */
 public static void notContains(String textToSearch, String substring, String message) {
   if (Strings.isNotBlank(textToSearch)
       && Strings.isNotBlank(substring)
       && textToSearch.indexOf(substring) != -1) {
     throw new IllegalArgumentException(message);
   }
 }