/*
returns true if name value pair was added to the string buffer
559393
static boolean addListToJSON(StringBuilder sb, String name, Object[] list, boolean jsonEscapeValues, boolean isFirstField) {
        if (name == null || list == null)
            return false;

        // add comma if isFirstField == false
        if (!isFirstField)
            sb.append(",");

        sb.append("\"" + name + "\":[");
        boolean firstParm = true;
        for (Object element : list) {
            if (firstParm)
                sb.append("\"");
            else
                sb.append(",\"");
            if (element != null) {
                if (jsonEscapeValues)
                    sb.append(jsonEscape2(element.toString()));
                else
                    sb.append(element.toString());
            }
            sb.append("\"");
            firstParm = false;
        }
        sb.append("]");
        return true;
    }
1256352
private static String checkName(String name) {
        if (name == null)
            return "null";

        int len = name.length();
        if (len == 0)
            return "\"\"";

        int cc = '/';
        int cp;
        for (int k = 0; k < len; k += Character.charCount(cp)) {
            cp = name.codePointAt(k);
            if ((cc == '/' && !Character.isJavaIdentifierStart(cp))
                    || (cp != '/' && !Character.isJavaIdentifierPart(cp))) {
                return "\"" + addEscapes(name) + "\"";
            }
            cc = cp;
        }

        return name;
    }
175143
public static boolean isValidNcName( String name ) {
        if (name == null || name.length() == 0) return false;
        CharacterIterator iter = new StringCharacterIterator(name);
        char c = iter.first();
        if (!isValidNcNameStart(c)) return false;
        while (c != CharacterIterator.DONE) {
            if (!isValidNcName(c)) return false;
            c = iter.next();
        }
        return true;
    }
820194
private static final void auditNamedValues(String m, Map<String, ?> namedValues) {
        if (logger.isDebugEnabled()) {
            assert namedValues != null;
            for (Iterator<String> outer = namedValues.keySet().iterator(); outer
                    .hasNext();) {
                Object name = outer.next();
                assert name instanceof String : "not a string, name==" + name;
                StringBuffer sb = new StringBuffer(m + name + "==");
                Object temp = namedValues.get(name);
                assert temp instanceof String || temp instanceof Set : "neither string nor set, temp=="
                        + temp;
                if (temp instanceof String) {
                    sb.append(temp.toString());
                } else if (temp instanceof Set) {
                    @SuppressWarnings("unchecked")
                    Set<String> values = (Set<String>) temp;
                    sb.append("(" + values.size() + ") {");
                    String punct = "";
                    for (Iterator<String> it = values.iterator(); it.hasNext();) {
                        String value = it.next();
                        sb.append(punct + value);
                        punct = ",";
                    }
                    sb.append("}");
                }
                logger.debug(sb.toString());
            }
        }
    }
526957
function strToBool(input, defaultValue = false) {
  const value = String(input)
    .trim()
    .toLowerCase()
  if (['1', 'true', 'on', 'yes'].includes(value)) return true
  if (['0', 'false', 'off', 'no'].includes(value)) return false
  return defaultValue
}
997982
@Override
    public boolean hasValue(String paramName) {
        return criterias.containsKey(paramName) || LIMIT_NAME.equals(paramName)
                || OFFSET_NAME.equals(paramName);
    }
709201
public boolean isDuplicateName(String name) {
        if (name == null || name.trim().isEmpty()) {
            return false;
        }
        List<AssignmentRow> as = view.getAssignmentRows();
        if (as != null && !as.isEmpty()) {
            int nameCount = 0;
            for (AssignmentRow row : as) {
                if (name.trim().compareTo(row.getName()) == 0) {
                    nameCount++;
                    if (nameCount > 1) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
474697
private static boolean isDefaultStringAttributeValue(String value)
    {
        if (value == null)
        {
            return true;
        }
        else if (value.length() == 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
463837
function(name) {
    name = name || '';

    // TODO optimize with RegExp

    var nameChain = name.split('.');
    for(var i=0; i<nameChain.length; i++) {
      if(!nameChain[i].match(/[a-zA-Z0-9_]+/)) {
        return false;
      }
    }

    return true;
  }
1284096
@Override
    public void visit(final String name, final Object value) {
        ++size;
        if (named) {
            bv.putShort(cw.newUTF8(name));
        }
        if (value instanceof String) {
            bv.put12('s', cw.newUTF8((String) value));
        } else if (value instanceof Byte) {
            bv.put12('B', cw.newInteger(((Byte) value).byteValue()).index);
        } else if (value instanceof Boolean) {
            int v = ((Boolean) value).booleanValue() ? 1 : 0;
            bv.put12('Z', cw.newInteger(v).index);
        } else if (value instanceof Character) {
            bv.put12('C', cw.newInteger(((Character) value).charValue()).index);
        } else if (value instanceof Short) {
            bv.put12('S', cw.newInteger(((Short) value).shortValue()).index);
        } else if (value instanceof Type) {
            bv.put12('c', cw.newUTF8(((Type) value).getDescriptor()));
        } else if (value instanceof byte[]) {
            byte[] v = (byte[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('B', cw.newInteger(v[i]).index);
            }
        } else if (value instanceof boolean[]) {
            boolean[] v = (boolean[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('Z', cw.newInteger(v[i] ? 1 : 0).index);
            }
        } else if (value instanceof short[]) {
            short[] v = (short[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('S', cw.newInteger(v[i]).index);
            }
        } else if (value instanceof char[]) {
            char[] v = (char[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('C', cw.newInteger(v[i]).index);
            }
        } else if (value instanceof int[]) {
            int[] v = (int[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('I', cw.newInteger(v[i]).index);
            }
        } else if (value instanceof long[]) {
            long[] v = (long[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('J', cw.newLong(v[i]).index);
            }
        } else if (value instanceof float[]) {
            float[] v = (float[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('F', cw.newFloat(v[i]).index);
            }
        } else if (value instanceof double[]) {
            double[] v = (double[]) value;
            bv.put12('[', v.length);
            for (int i = 0; i < v.length; i++) {
                bv.put12('D', cw.newDouble(v[i]).index);
            }
        } else {
            Item i = cw.newConstItem(value);
            bv.put12(".s.IFJDCS".charAt(i.type), i.index);
        }
    }

    @Override
    public void visitEnum(final String name, final String desc,
            final String value) {
        ++size;
        if (named) {
            bv.putShort(cw.newUTF8(name));
        }
        bv.put12('e', cw.newUTF8(desc)).putShort(cw.newUTF8(value));
    }

    @Override
    public AnnotationVisitor visitAnnotation(final String name,
            final String desc) {
        ++size;
        if (named) {
            bv.putShort(cw.newUTF8(name));
        }
        // write tag and type, and reserve space for values count
        bv.put12('@', cw.newUTF8(desc)).putShort(0);
        return new AnnotationWriter(cw, true, bv, bv, bv.length - 2);
    }

    @Override
    public AnnotationVisitor visitArray(final String name) {
        ++size;
        if (named) {
            bv.putShort(cw.newUTF8(name));
        }
        // write tag, and reserve space for array size
        bv.put12('[', 0);
        return new AnnotationWriter(cw, false, bv, bv, bv.length - 2);
    }

    @Override
    public void visitEnd() {
        if (parent != null) {
            byte[] data = parent.data;
            data[offset] = (byte) (size >>> 8);
            data[offset + 1] = (byte) size;
        }
    }

    // 
    // Utility methods
    // 

    /**
     * Returns the size of this annotation writer list.
     * 
     * @return the size of this annotation writer list.
     */
    int getSize() {
        int size = 0;
        AnnotationWriter aw = this;
        while (aw != null) {
            size += aw.bv.length;
            aw = aw.next;
        }
        return size;
    }

    /**
     * Puts the annotations of this annotation writer list into the given byte
     * vector.
     * 
     * @param out
     *            where the annotations must be put.
     */
    void put(final ByteVector out) {
        int n = 0;
        int size = 2;
        AnnotationWriter aw = this;
        AnnotationWriter last = null;
        while (aw != null) {
            ++n;
            size += aw.bv.length;
            aw.visitEnd(); // in case user forgot to call visitEnd
            aw.prev = last;
            last = aw;
            aw = aw.next;
        }
        out.putInt(size);
        out.putShort(n);
        aw = last;
        while (aw != null) {
            out.putByteArray(aw.bv.data, 0, aw.bv.length);
            aw = aw.prev;
        }
    }

    /**
     * Puts the given annotation lists into the given byte vector.
     * 
     * @param panns
     *            an array of annotation writer lists.
     * @param off
     *            index of the first annotation to be written.
     * @param out
     *            where the annotations must be put.
     */
    static void put(final AnnotationWriter[] panns, final int off,
            final ByteVector out) {
        int size = 1 + 2 * (panns.length - off);
        for (int i = off; i < panns.length; ++i) {
            size += panns[i] == null ? 0 : panns[i].getSize();
        }
        out.putInt(size).putByte(panns.length - off);
        for (int i = off; i < panns.length; ++i) {
            AnnotationWriter aw = panns[i];
            AnnotationWriter last = null;
            int n = 0;
            while (aw != null) {
                ++n;
                aw.visitEnd(); // in case user forgot to call visitEnd
                aw.prev = last;
                last = aw;
                aw = aw.next;
            }
            out.putShort(n);
            aw = last;
            while (aw != null) {
                out.putByteArray(aw.bv.data, 0, aw.bv.length);
                aw = aw.prev;
            }
        }
    }

    /**
     * Puts the given type reference and type path into the given bytevector.
     * LOCAL_VARIABLE and RESOURCE_VARIABLE target types are not supported.
     * 
     * @param typeRef
     *            a reference to the annotated type. See {@link TypeReference}.
     * @param typePath
     *            the path to the annotated type argument, wildcard bound, array
     *            element type, or static inner type within 'typeRef'. May be
     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
     * @param out
     *            where the type reference and type path must be put.
     */
    static void putTarget(int typeRef, TypePath typePath, ByteVector out) {
        switch (typeRef >>> 24) {
        case 0x00: // CLASS_TYPE_PARAMETER
        case 0x01: // METHOD_TYPE_PARAMETER
        case 0x16: // METHOD_FORMAL_PARAMETER
            out.putShort(typeRef >>> 16);
            break;
        case 0x13: // FIELD
        case 0x14: // METHOD_RETURN
        case 0x15: // METHOD_RECEIVER
            out.putByte(typeRef >>> 24);
            break;
        case 0x47: // CAST
        case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
        case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
        case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
        case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
            out.putInt(typeRef);
            break;
        // case 0x10: // CLASS_EXTENDS
        // case 0x11: // CLASS_TYPE_PARAMETER_BOUND
        // case 0x12: // METHOD_TYPE_PARAMETER_BOUND
        // case 0x17: // THROWS
        // case 0x42: // EXCEPTION_PARAMETER
        // case 0x43: // INSTANCEOF
        // case 0x44: // NEW
        // case 0x45: // CONSTRUCTOR_REFERENCE
        // case 0x46: // METHOD_REFERENCE
        default:
            out.put12(typeRef >>> 24, (typeRef & 0xFFFF00) >> 8);
            break;
        }
        if (typePath == null) {
            out.putByte(0);
        } else {
            int length = typePath.b[typePath.offset] * 2 + 1;
            out.putByteArray(typePath.b, typePath.offset, length);
        }
    }
}
111992
boolean addToBuffer(char c) throws IOException {
	int len = sb.length();
	if (len == 0 && c != CHAR_LT) return false; // buffer must starts with '<'

	sb.append(c); // if we reached this point then we will return true
	if (++len >= minTagLen) { // increment len as it was sampled before we appended c
	    boolean isClosingTag = (len >= 2 && sb.charAt(1) == CHAR_SL);
	    String substr;
	    if (isClosingTag) substr = sb.substring(2); // we know that the 1st two chars are "</"
	    else substr = sb.substring(1); // we know that the 1st char is "<"
	    for (int i = 0; i < EXCLUDE_TAGS.length; i++) { // loop thru list of WS-preserving tags
		if (substr.equalsIgnoreCase(EXCLUDE_TAGS[i])) { // we have a match
		    if (isClosingTag) {
			depthDec(i); // decrement the depth at i and calc depthSum
			printBuffer();
			lastChar = 0; // needed to allow WS after buffer was printed
		    }
		    else {
			depthInc(i); // increment the depth at i and calc depthSum
		    }
		}
	    }
	}
	return true;
    }
1021981
public boolean canDeposit(String name) {
        if (getParent().ignoreACL()) {
            return true;
        }
        String newName = name.toLowerCase();
        boolean result = false;
        if (aclList.containsKey(newName)) {
            result = aclList.get(newName).canDeposit();
        }
        return result;
    }
1256661
private static boolean isSafeFilenameCharacter(char c)
	{
		if (Character.isLetterOrDigit(c))
		{
			return true;
		}
		else if (c == '-' || c == '_' || c == '.')
		{
			return true;
		}
		else
		{
			return false;
		}
	}
62354
public static boolean isValidQName(String str) {
       
       final int colon = str.indexOf(':');
       
       if (colon == 0 || colon == str.length() - 1) {
           return false;
       }       
       
       if (colon > 0) {
           final String prefix = str.substring(0,colon);
           final String localPart = str.substring(colon+1);
           return isValidNCName(prefix) && isValidNCName(localPart);
       }
       else {
           return isValidNCName(str);
       }       
    }
608726
function _addStringToBuffer(buffer, val) {
  buffer.putInt32(val.length);
  buffer.putString(val);
}
73304
private static boolean isDateHeader(final Buffer name) {
        try {
            return name.getByte(0) == 'D' && name.getByte(1) == 'a' &&
                    name.getByte(2) == 't' && name.getByte(3) == 'e';
        } catch (final IOException e) {
            return false;
        }
    }
816178
boolean valuesAreTheSameAsDefault()
    {
        if (getDefaultValues() == null || getDefaultValues().size() == 0)
            return false;
        if (getValues() == null || getValues().size() == 0)
            return false;
        if (getDefaultValues().size() != getValues().size())
            return false;
        for (int v = 0; v < getDefaultValues().size(); v++)
            if (!getDefaultValues().get(v).equals(getValues().get(v)))
                return false;
        return true;
    }