Java String Length Get lengthExpression(final String operand, final long length)

Here you can find the source of lengthExpression(final String operand, final long length)

Description

Build expression to check the 'length' restriction, depending on the data type of the member variable.

License

Open Source License

Parameter

Parameter Description
operand Name of member variable or other operand (e.g. a string literal) for comparison in expression
length Value of 'length' restriction

Return

Expression for restriction check

Declaration

public static String lengthExpression(final String operand, final long length) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* ww w  .j  a v  a 2  s  .  c  o  m*/
     * Build expression to check the 'length' restriction, depending
     * on the data type of the member variable.
     *
     * @param operand Name of member variable or other operand (e.g.
     * a string literal) for comparison in expression
     * @param length Value of 'length' restriction
     *
     * @return Expression for restriction check
     */
    public static String lengthExpression(final String operand, final long length) {
        return String.format("%s.length() != %d", operand, length);
    }
}

Related

  1. lengthByteInPrepared(String s)
  2. lengthCheck(final String str, final int minLength, final int maxLength)
  3. lengthConstToString(int val, int len)
  4. LengthConversionFactor(String OldUnits)
  5. lengthExpandedTabs(String string, int toIdx, int tabWidth)
  6. lengthField(String propertyName)
  7. lengthFormat(String str, int maxLength)
  8. lengthIfAllAlpha(String str)
  9. lengthIntegers(String str)