public static String buildQuery(final HttpMultiMap<?> queryMap, final String encoding) {
		if (queryMap.isEmpty()) {
			return StringPool.EMPTY;
		}

		int queryMapSize = queryMap.size();

		StringBand query = new StringBand(queryMapSize * 4);

		int count = 0;
		for (Map.Entry<String, ?> entry : queryMap) {
			String key = entry.getKey();
			key = URLCoder.encodeQueryParam(key, encoding);

			Object value = entry.getValue();

			if (value == null) {
				if (count != 0) {
					query.append('&');
				}

				query.append(key);
				count++;
			} else {
				if (count != 0) {
					query.append('&');
				}

				query.append(key);
				count++;
				query.append('=');

				String valueString = URLCoder.encodeQueryParam(value.toString(), encoding);
				query.append(valueString);
			}
		}

		return query.toString();
	}

public static String buildQuery ( final HttpMultiMap < ? > queryMap , final String encoding ) { if ( queryMap . isEmpty ( ) ) { return StringPool . EMPTY ; } int queryMapSize = queryMap . size ( ) ; StringBand query = new StringBand ( queryMapSize * 4 ) ; int count = 0 ; for ( Map . Entry < String , ? > entry : queryMap ) { String key = entry . getKey ( ) ; key = URLCoder . encodeQueryParam ( key , encoding ) ; Object value = entry . getValue ( ) ; if ( value == null ) { if ( count != 0 ) { query . append ( ' ' ) ; } query . append ( key ) ; count ++ ; } else { if ( count != 0 ) { query . append ( ' ' ) ; } query . append ( key ) ; count ++ ; query . append ( ' ' ) ; String valueString = URLCoder . encodeQueryParam ( value . toString ( ) , encoding ) ; query . append ( valueString ) ; } } return query . toString ( ) ; }

Builds a query string from given query map.

Builds a query string from given query map .


public static HttpMultiMap<String> parseQuery(final String query, final boolean decode) {

		final HttpMultiMap<String> queryMap = HttpMultiMap.newCaseInsensitiveMap();

		if (StringUtil.isBlank(query)) {
			return queryMap;
		}

		int lastNdx = 0;
		while (lastNdx < query.length()) {
			int ndx = query.indexOf('&', lastNdx);
			if (ndx == -1) {
				ndx = query.length();
			}

			final String paramAndValue = query.substring(lastNdx, ndx);

			ndx = paramAndValue.indexOf('=');

			if (ndx == -1) {
				queryMap.add(paramAndValue, null);
			}
			else {
				String name = paramAndValue.substring(0, ndx);
				if (decode) {
					name = URLDecoder.decodeQuery(name);
				}

				String value = paramAndValue.substring(ndx + 1);

				if (decode) {
					value = URLDecoder.decodeQuery(value);
				}

				queryMap.add(name, value);
			}
			lastNdx += paramAndValue.length() + 1;
		}

		return queryMap;
	}

public static HttpMultiMap < String > parseQuery ( final String query , final boolean decode ) { final HttpMultiMap < String > queryMap = HttpMultiMap . newCaseInsensitiveMap ( ) ; if ( StringUtil . isBlank ( query ) ) { return queryMap ; } int lastNdx = 0 ; while ( lastNdx < query . length ( ) ) { int ndx = query . indexOf ( ' ' , lastNdx ) ; if ( ndx == - 1 ) { ndx = query . length ( ) ; } final String paramAndValue = query . substring ( lastNdx , ndx ) ; ndx = paramAndValue . indexOf ( ' ' ) ; if ( ndx == - 1 ) { queryMap . add ( paramAndValue , null ) ; } else { String name = paramAndValue . substring ( 0 , ndx ) ; if ( decode ) { name = URLDecoder . decodeQuery ( name ) ; } String value = paramAndValue . substring ( ndx + 1 ) ; if ( decode ) { value = URLDecoder . decodeQuery ( value ) ; } queryMap . add ( name , value ) ; } lastNdx += paramAndValue . length ( ) + 1 ; } return queryMap ; }

Parses query from give query string. Values are optionally decoded.

Parses query from give query string . Values are optionally decoded .


public static String prepareHeaderParameterName(final String headerName) {

		// special cases

		if (headerName.equals("etag")) {
			return HttpBase.HEADER_ETAG;
		}

		if (headerName.equals("www-authenticate")) {
			return "WWW-Authenticate";
		}

		char[] name = headerName.toCharArray();

		boolean capitalize = true;

		for (int i = 0; i < name.length; i++) {
			char c = name[i];

			if (c == '-') {
				capitalize = true;
				continue;
			}

			if (capitalize) {
				name[i] = Character.toUpperCase(c);
				capitalize = false;
			} else {
				name[i] = Character.toLowerCase(c);
			}
		}

		return new String(name);
	}

public
static
String
prepareHeaderParameterName
(
final
String
headerName
)
{
// special cases
if
(
headerName
.
equals
(
"etag"
)
)
{
return
HttpBase
.
HEADER_ETAG
;
}
if
(
headerName
.
equals
(
"www-authenticate"
)
)
{
return
"WWW-Authenticate"
;
}
char
[
]
name
=
headerName
.
toCharArray
(
)
;
boolean
capitalize
=
true
;
for
(
int
i
=
0
;
i
<
name
.
length
;
i
++
)
{
char
c
=
name
[
i
]
;
if
(
c
==
'
'
)
{
capitalize
=
true
;
continue
;
}
if
(
capitalize
)
{
name
[
i
]
=
Character
.
toUpperCase
(
c
)
;
capitalize
=
false
;
}
else
{
name
[
i
]
=
Character
.
toLowerCase
(
c
)
;
}
}
return
new
String
(
name
)
;
}


public static String extractMediaType(final String contentType) {
		int index = contentType.indexOf(';');

		if (index == -1) {
			return contentType;
		}

		return contentType.substring(0, index);
	}

public static String extractMediaType ( final String contentType ) { int index = contentType . indexOf ( ' ' ) ; if ( index == - 1 ) { return contentType ; } return contentType . substring ( 0 , index ) ; }

Extracts media-type from value of "Content Type" header.

Extracts media - type from value of Content Type header .


public String toHtml(final Node node, final Appendable appendable) {
		NodeVisitor renderer = createRenderer(appendable);

		node.visit(renderer);

		return appendable.toString();
	}

public String toHtml ( final Node node , final Appendable appendable ) { NodeVisitor renderer = createRenderer ( appendable ) ; node . visit ( renderer ) ; return appendable . toString ( ) ; }


public String toInnerHtml(final Node node, final Appendable appendable) {
		NodeVisitor renderer = createRenderer(appendable);

		node.visitChildren(renderer);

		return appendable.toString();
	}

public String toInnerHtml ( final Node node , final Appendable appendable ) { NodeVisitor renderer = createRenderer ( appendable ) ; node . visitChildren ( renderer ) ; return appendable . toString ( ) ; }


public void configureWith(final ServletContext servletContext) {
		webAppClassName = servletContext.getInitParameter(PARAM_MADVOC_WEBAPP);
		paramsFiles = Converter.get().toStringArray(servletContext.getInitParameter(PARAM_MADVOC_PARAMS));
		madvocConfiguratorClassName = servletContext.getInitParameter(PARAM_MADVOC_CONFIGURATOR);
	}

public void configureWith ( final ServletContext servletContext ) { webAppClassName = servletContext . getInitParameter ( PARAM_MADVOC_WEBAPP ) ; paramsFiles = Converter . get ( ) . toStringArray ( servletContext . getInitParameter ( PARAM_MADVOC_PARAMS ) ) ; madvocConfiguratorClassName = servletContext . getInitParameter ( PARAM_MADVOC_CONFIGURATOR ) ; }

Configures Madvoc by reading context init parameters.

Configures Madvoc by reading context init parameters .


protected void reset() {
		this.ndx = 0;
		this.textLen = 0;
		this.path = new Path();
		this.notFirstObject = false;
		if (useAltPaths) {
			path.altPath = new Path();
		}

		if (classMetadataName != null) {
			mapToBean = createMapToBean(classMetadataName);
		}
	}

protected void reset ( ) { this . ndx = 0 ; this . textLen = 0 ; this . path = new Path ( ) ; this . notFirstObject = false ; if ( useAltPaths ) { path . altPath = new Path ( ) ; } if ( classMetadataName != null ) { mapToBean = createMapToBean ( classMetadataName ) ; } }

Resets JSON parser, so it can be reused.

Resets JSON parser so it can be reused .


public JsonParser lazy(final boolean lazy) {
		this.lazy = lazy;
		this.mapSupplier = lazy ? LAZYMAP_SUPPLIER : HASHMAP_SUPPLIER;
		this.listSupplier = lazy ? LAZYLIST_SUPPLIER : ARRAYLIST_SUPPLIER;
		return this;
	}

public JsonParser lazy ( final boolean lazy ) { this . lazy = lazy ; this . mapSupplier = lazy ? LAZYMAP_SUPPLIER : HASHMAP_SUPPLIER ; this . listSupplier = lazy ? LAZYLIST_SUPPLIER : ARRAYLIST_SUPPLIER ; return this ; }

Defines how JSON parser works. In non-lazy mode, the whole JSON is parsed as it is.
In the lazy mode, not everything is parsed, but some things are left lazy.
This way we gain performance, especially on partial usage of the whole JSON.
However, be aware that parser holds the input memory until the returned
objects are disposed.

Defines how JSON parser works . In non - lazy mode the whole JSON is parsed as it is . In the lazy mode not everything is parsed but some things are left lazy . This way we gain performance especially on partial usage of the whole JSON . However be aware that parser holds the input memory until the returned objects are disposed .


protected Class replaceWithMappedTypeForPath(final Class target) {
		if (mappings == null) {
			return target;
		}

		Class newType;

		// first try alt paths

		Path altPath = path.getAltPath();

		if (altPath != null) {
			if (!altPath.equals(path)) {
				newType = mappings.get(altPath);

				if (newType != null) {
					return newType;
				}
			}
		}

		// now check regular paths

		newType = mappings.get(path);

		if (newType != null) {
			return newType;
		}

		return target;
	}

protected
Class
replaceWithMappedTypeForPath
(
final
Class
target
)
{
if
(
mappings
==
)
{
return
target
;
}
Class
newType
;
// first try alt paths
Path
altPath
=
path
.
getAltPath
(
)
;
if
(
altPath
!=
)
{
if
(
!
altPath
.
equals
(
path
)
)
{
newType
=
mappings
.
get
(
altPath
)
;
if
(
newType
!=
)
{
return
newType
;
}
}
}
// now check regular paths
newType
=
mappings
.
get
(
path
)
;
if
(
newType
!=
)
{
return
newType
;
}
return
target
;
}

Replaces type with mapped type for current path.

Replaces type with mapped type for current path .


public <T> List<T> parseAsList(final String string, final Class<T> componentType) {
		return new JsonParser()
			.map(JsonParser.VALUES, componentType)
			.parse(string);
	}

public < T > List < T > parseAsList ( final String string , final Class < T > componentType ) { return new JsonParser ( ) . map ( JsonParser . VALUES , componentType ) . parse ( string ) ; }

Parses input JSON to a list with specified component type.

Parses input JSON to a list with specified component type .


public <K, V> Map<K, V> parseAsMap(
		final String string, final Class<K> keyType, final Class<V> valueType) {

		return new JsonParser()
			.map(JsonParser.KEYS, keyType)
			.map(JsonParser.VALUES, valueType)
			.parse(string);
	}

public < K , V > Map < K , V > parseAsMap ( final String string , final Class < K > keyType , final Class < V > valueType ) { return new JsonParser ( ) . map ( JsonParser . KEYS , keyType ) . map ( JsonParser . VALUES , valueType ) . parse ( string ) ; }

Parses input JSON to a list with specified key and value types.

Parses input JSON to a list with specified key and value types .


private Object resolveLazyValue(Object value) {
		if (value instanceof Supplier) {
			value = ((Supplier)value).get();
		}
		return value;
	}

private Object resolveLazyValue ( Object value ) { if ( value instanceof Supplier ) { value = ( ( Supplier ) value ) . get ( ) ; } return value ; }

Resolves lazy value during the parsing runtime.

Resolves lazy value during the parsing runtime .


private void skipObject() {
		int bracketCount = 1;
		boolean insideString = false;

		while (ndx < total) {
			final char c = input[ndx];

			if (insideString) {
				if (c == '\"' && notPrecededByEvenNumberOfBackslashes()) {
					insideString = false;
				}
			} else if (c == '\"') {
				insideString = true;
			} else if (c == '{') {
				bracketCount++;
			} else if (c == '}') {
				bracketCount--;
				if (bracketCount == 0) {
					ndx++;
					return;
				}
			}
			ndx++;
		}
	}

private void skipObject ( ) { int bracketCount = 1 ; boolean insideString = false ; while ( ndx < total ) { final char c = input [ ndx ] ; if ( insideString ) { if ( c == ' ' && notPrecededByEvenNumberOfBackslashes ( ) ) { insideString = false ; } } else if ( c == ' ' ) { insideString = true ; } else if ( c == ' ' ) { bracketCount ++ ; } else if ( c == ' ' ) { bracketCount -- ; if ( bracketCount == 0 ) { ndx ++ ; return ; } } ndx ++ ; } }

Skips over complete object. It is not parsed, just skipped. It will be
parsed later, but only if required.

Skips over complete object . It is not parsed just skipped . It will be parsed later but only if required .


protected String parseString() {
		char quote = '\"';
		if (looseMode) {
			quote = consumeOneOf('\"', '\'');
			if (quote == 0) {
				return parseUnquotedStringContent();
			}
		} else {
			consume(quote);
		}

		return parseStringContent(quote);
	}

protected String parseString ( ) { char quote = ' ' ; if ( looseMode ) { quote = consumeOneOf ( ' ' , ' ' ) ; if ( quote == 0 ) { return parseUnquotedStringContent ( ) ; } } else { consume ( quote ) ; } return parseStringContent ( quote ) ; }


protected String parseStringContent(final char quote) {
		final int startNdx = ndx;

		// roll-out until the end of the string or the escape char
		while (true) {
			final char c = input[ndx];

			if (c == quote) {
				// no escapes found, just use existing string
				ndx++;
				return new String(input, startNdx, ndx - 1 - startNdx);
			}

			if (c == '\\') {
				break;
			}

			ndx++;
		}

		// escapes found, proceed differently

		textLen = ndx - startNdx;

		growEmpty();

//		for (int i = startNdx, j = 0; j < textLen; i++, j++) {
//			text[j] = input[i];
//		}
		System.arraycopy(input, startNdx, text, 0, textLen);

		// escape char, process everything until the end
		while (true) {
			char c = input[ndx];

			if (c == quote) {
				// done
				ndx++;
				final String str = new String(text, 0, textLen);
				textLen = 0;
				return str;
			}

			if (c == '\\') {
				// escape char found
				ndx++;

				c = input[ndx];

				switch (c) {
					case '\"' : c = '\"'; break;
					case '\\' : c = '\\'; break;
					case '/' : c = '/'; break;
					case 'b' : c = '\b'; break;
					case 'f' : c = '\f'; break;
					case 'n' : c = '\n'; break;
					case 'r' : c = '\r'; break;
					case 't' : c = '\t'; break;
					case 'u' :
						ndx++;
						c = parseUnicode();
						break;
					default:
						if (looseMode) {
							if (c != '\'') {
								c = '\\';
								ndx--;
							}
						}
						else {
							syntaxError("Invalid escape char: " + c);
						}
				}
			}

			text[textLen] = c;

			textLen++;

			growAndCopy();

			ndx++;
		}
	}

Parses string content, once when starting quote has been consumed.

Parses string content once when starting quote has been consumed .


protected char parseUnicode() {
		int i0 = CharUtil.hex2int(input[ndx++]);
		int i1 = CharUtil.hex2int(input[ndx++]);
		int i2 = CharUtil.hex2int(input[ndx++]);
		int i3 = CharUtil.hex2int(input[ndx]);

		return (char) ((i0 << 12) + (i1 << 8) + (i2 << 4) + i3);
	}

protected char parseUnicode ( ) { int i0 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i1 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i2 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i3 = CharUtil . hex2int ( input [ ndx ] ) ; return ( char ) ( ( i0 << 12 ) + ( i1 << 8 ) + ( i2 << 4 ) + i3 ) ; }

Parses 4 characters and returns unicode character.

Parses 4 characters and returns unicode character .


protected String parseUnquotedStringContent() {
		final int startNdx = ndx;

		while (true) {
			final char c = input[ndx];

			if (c <= ' ' || CharUtil.equalsOne(c, UNQUOTED_DELIMETERS)) {
				final int currentNdx = ndx;

				// done
				skipWhiteSpaces();

				return new String(input, startNdx, currentNdx - startNdx);
			}

			ndx++;
		}
	}

protected
String
parseUnquotedStringContent
(
)
{
final
int
startNdx
=
ndx
;
while
(
true
)
{
final
char
c
=
input
[
ndx
]
;
if
(
c
<=
'
'
||
CharUtil
.
equalsOne
(
c
,
UNQUOTED_DELIMETERS
)
)
{
final
int
currentNdx
=
ndx
;
// done
skipWhiteSpaces
(
)
;
return
new
String
(
input
,
startNdx
,
currentNdx
startNdx
)
;
}
ndx
++
;
}
}


protected Number parseNumber() {
		final int startIndex = ndx;

		char c = input[ndx];

		boolean isDouble = false;
		boolean isExp = false;

		if (c == '-') {
			ndx++;
		}

		while (true) {
			if (isEOF()) {
				break;
			}

			c = input[ndx];

			if (c >= '0' && c <= '9') {
				ndx++;
				continue;
			}
			if (c <= 32) {		// white space
				break;
			}
			if (c == ',' || c == '}' || c == ']') {	// delimiter
				break;
			}

			if (c == '.') {
				isDouble = true;
			}
			else if (c == 'e' || c == 'E') {
				isExp = true;
			}
			ndx++;
		}

		final String value = new String(input, startIndex, ndx - startIndex);

		if (isDouble) {
			return Double.valueOf(value);
		}

		long longNumber;

		if (isExp) {
			longNumber = Double.valueOf(value).longValue();
		}
		else {
			if (value.length() >= 19) {
				// if string is 19 chars and longer, it can be over the limit
				BigInteger bigInteger = new BigInteger(value);

				if (isGreaterThanLong(bigInteger)) {
					return bigInteger;
				}
				longNumber = bigInteger.longValue();
			}
			else {
				longNumber = Long.parseLong(value);
			}
		}

		if ((longNumber >= Integer.MIN_VALUE) && (longNumber <= Integer.MAX_VALUE)) {
			return (int) longNumber;
		}
		return longNumber;
	}


protected Object parseArrayContent(Class targetType, Class componentType) {
		// detect special case

		if (targetType == Object.class) {
			targetType = List.class;
		}

		// continue

		targetType = replaceWithMappedTypeForPath(targetType);

		if (componentType == null && targetType != null && targetType.isArray()) {
			componentType = targetType.getComponentType();
		}

		path.push(VALUES);

		componentType = replaceWithMappedTypeForPath(componentType);

		Collection<Object> target = newArrayInstance(targetType);

		boolean koma = false;

		mainloop:
		while (true) {
			skipWhiteSpaces();

			char c = input[ndx];

			if (c == ']') {
				if (koma) {
					syntaxError("Trailing comma");
				}

				ndx++;
				path.pop();
				return target;
			}

			Object value = parseValue(componentType, null, null);

			target.add(value);

			skipWhiteSpaces();

			c = input[ndx];

			switch (c) {
				case ']': ndx++; break mainloop;
				case ',': ndx++; koma = true; break;
				default: syntaxError("Invalid char: expected ] or ,");
			}

		}

		path.pop();

		if (targetType != null) {
			return convertType(target, targetType);
		}

		return target;
	}

protected
Object
parseArrayContent
(
Class
targetType
,
Class
componentType
)
{
// detect special case
if
(
targetType
==
Object
.
class
)
{
targetType
=
List
.
class
;
}
// continue
targetType
=
replaceWithMappedTypeForPath
(
targetType
)
;
if
(
componentType
==
&&
targetType
!=
&&
targetType
.
isArray
(
)
)
{
componentType
=
targetType
.
getComponentType
(
)
;
}
path
.
push
(
VALUES
)
;
componentType
=
replaceWithMappedTypeForPath
(
componentType
)
;
Collection
<
Object
>
target
=
newArrayInstance
(
targetType
)
;
boolean
koma
=
false
;
mainloop
:
while
(
true
)
{
skipWhiteSpaces
(
)
;
char
c
=
input
[
ndx
]
;
if
(
c
==
'
'
)
{
if
(
koma
)
{
syntaxError
(
"Trailing comma"
)
;
}
ndx
++
;
path
.
pop
(
)
;
return
target
;
}
Object
value
=
parseValue
(
componentType
,
,
)
;
target
.
add
(
value
)
;
skipWhiteSpaces
(
)
;
c
=
input
[
ndx
]
;
switch
(
c
)
{
case
'
'
:
ndx
++
;
break
mainloop
;
case
'
'
:
ndx
++
;
koma
=
true
;
break
;
default
:
syntaxError
(
"Invalid char: expected ] or ,"
)
;
}
}
path
.
pop
(
)
;
if
(
targetType
!=
)
{
return
convertType
(
target
,
targetType
)
;
}
return
target
;
}

Parses arrays, once when open bracket has been consumed.

Parses arrays once when open bracket has been consumed .


protected void createEmptyCtor() {
		final MethodVisitor mv = wd.dest.visitMethod(AsmUtil.ACC_PUBLIC, INIT, "()V", null, null);
		mv.visitCode();
		mv.visitVarInsn(Opcodes.ALOAD, 0);
		mv.visitMethodInsn(
			Opcodes.INVOKESPECIAL,
			AsmUtil.SIGNATURE_JAVA_LANG_OBJECT,
			INIT, "()V",
			false);
		mv.visitInsn(Opcodes.RETURN);
		mv.visitMaxs(1, 1);
		mv.visitEnd();
	}

protected void createEmptyCtor ( ) { final MethodVisitor mv = wd . dest . visitMethod ( AsmUtil . ACC_PUBLIC , INIT , "()V" , null , null ) ; mv . visitCode ( ) ; mv . visitVarInsn ( Opcodes . ALOAD , 0 ) ; mv . visitMethodInsn ( Opcodes . INVOKESPECIAL , AsmUtil . SIGNATURE_JAVA_LANG_OBJECT , INIT , "()V" , false ) ; mv . visitInsn ( Opcodes . RETURN ) ; mv . visitMaxs ( 1 , 1 ) ; mv . visitEnd ( ) ; }


protected void createSimpleMethodWrapper(final MethodSignatureVisitor msign) {

		int access = msign.getAccessFlags();

		access &= ~ACC_ABSTRACT;
		access &= ~ACC_NATIVE;

		MethodVisitor mv = wd.dest.visitMethod(
				access, msign.getMethodName(), msign.getDescription(), msign.getAsmMethodSignature(), msign.getExceptions());
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitFieldInsn(GETFIELD, wd.thisReference, wd.wrapperRef, wd.wrapperType);
		loadVirtualMethodArguments(mv, msign);

		if (wd.wrapInterface) {
			mv.visitMethodInsn(
				INVOKEINTERFACE,
				wd.wrapperType.substring(1, wd.wrapperType.length() - 1),
				msign.getMethodName(),
				msign.getDescription(),
				true);
		} else {
			mv.visitMethodInsn(
				INVOKEVIRTUAL,
				wd.wrapperType.substring(1, wd.wrapperType.length() - 1),
				msign.getMethodName(),
				msign.getDescription(),
				false);
		}

		ProxettaAsmUtil.prepareReturnValue(mv, msign, 0);
		visitReturn(mv, msign, true);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}

protected void createSimpleMethodWrapper ( final MethodSignatureVisitor msign ) { int access = msign . getAccessFlags ( ) ; access &= ~ ACC_ABSTRACT ; access &= ~ ACC_NATIVE ; MethodVisitor mv = wd . dest . visitMethod ( access , msign . getMethodName ( ) , msign . getDescription ( ) , msign . getAsmMethodSignature ( ) , msign . getExceptions ( ) ) ; mv . visitCode ( ) ; mv . visitVarInsn ( ALOAD , 0 ) ; mv . visitFieldInsn ( GETFIELD , wd . thisReference , wd . wrapperRef , wd . wrapperType ) ; loadVirtualMethodArguments ( mv , msign ) ; if ( wd . wrapInterface ) { mv . visitMethodInsn ( INVOKEINTERFACE , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , true ) ; } else { mv . visitMethodInsn ( INVOKEVIRTUAL , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , false ) ; } ProxettaAsmUtil . prepareReturnValue ( mv , msign , 0 ) ; visitReturn ( mv , msign , true ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; }

Creates simple method wrapper without proxy.

Creates simple method wrapper without proxy .


private String resolveRawTypeName(String typeName) {
		if (typeName == null) {
			return null;
		}

		boolean isArray = typeName.startsWith(StringPool.LEFT_SQ_BRACKET);
		if (isArray) {
			typeName = typeName.substring(1);
		}

		String rawTypeName;

		if (generics.containsKey(typeName)) {
			rawTypeName = generics.get(typeName);
		}
		else {
			rawTypeName = declaredTypeGeneric.getOrDefault(typeName, typeName);
		}

		if (isArray) {
			rawTypeName = '[' + rawTypeName;
		}

		return rawTypeName;
	}

private String resolveRawTypeName ( String typeName ) { if ( typeName == null ) { return null ; } boolean isArray = typeName . startsWith ( StringPool . LEFT_SQ_BRACKET ) ; if ( isArray ) { typeName = typeName . substring ( 1 ) ; } String rawTypeName ; if ( generics . containsKey ( typeName ) ) { rawTypeName = generics . get ( typeName ) ; } else { rawTypeName = declaredTypeGeneric . getOrDefault ( typeName , typeName ) ; } if ( isArray ) { rawTypeName = ' ' + rawTypeName ; } return rawTypeName ; }

Resolves raw type name using the generics information from the class
or method information.

Resolves raw type name using the generics information from the class or method information .


public BeanReferences resolveReferenceFromValue(final PropertyDescriptor propertyDescriptor, final String refName) {
		BeanReferences references;

		if (refName == null || refName.isEmpty()) {
			references = buildDefaultReference(propertyDescriptor);
		}
		else {
			references = BeanReferences.of(refName);
		}

		references = references.removeDuplicateNames();

		return references;
	}

public BeanReferences resolveReferenceFromValue ( final PropertyDescriptor propertyDescriptor , final String refName ) { BeanReferences references ; if ( refName == null || refName . isEmpty ( ) ) { references = buildDefaultReference ( propertyDescriptor ) ; } else { references = BeanReferences . of ( refName ) ; } references = references . removeDuplicateNames ( ) ; return references ; }

Resolves reference from given values. Returns bean reference of given value or defaults
if given name is blank.

Resolves reference from given values . Returns bean reference of given value or defaults if given name is blank .


public BeanReferences[] resolveReferenceFromValues(final Executable methodOrCtor, final String... parameterReferences) {
		BeanReferences[] references = convertRefToReferences(parameterReferences);

		if (references == null || references.length == 0) {
			references = buildDefaultReferences(methodOrCtor);
		}

		if (methodOrCtor.getParameterTypes().length != references.length) {
			throw new PetiteException("Different number of method parameters and references for: " +
				methodOrCtor.getDeclaringClass().getName() + '#' + methodOrCtor.getName());
		}

		removeAllDuplicateNames(references);

		return references;
	}

Takes given parameters references and returns reference set for given method or constructor.

Takes given parameters references and returns reference set for given method or constructor .


public BeanReferences[] readAllReferencesFromAnnotation(final Executable methodOrCtor) {
		PetiteInject petiteInject = methodOrCtor.getAnnotation(PetiteInject.class);

		final Parameter[] parameters = methodOrCtor.getParameters();

		BeanReferences[] references;

		final boolean hasAnnotationOnMethodOrCtor;

		if (petiteInject != null) {
			references = convertAnnValueToReferences(petiteInject.value());

			hasAnnotationOnMethodOrCtor = true;
		}
		else {
			references = new BeanReferences[parameters.length];

			hasAnnotationOnMethodOrCtor = false;
		}

		int parametersWithAnnotationCount = 0;

		for (int i = 0; i < parameters.length; i++) {
			Parameter parameter = parameters[i];

			petiteInject = parameter.getAnnotation(PetiteInject.class);

			if (petiteInject == null) {
				// no annotation on argument
				continue;
			}

			// there is annotation on argument, override values
			String annotationValue = readAnnotationValue(petiteInject);

			if (annotationValue != null) {
				references[i] = BeanReferences.of(annotationValue);
			}

			parametersWithAnnotationCount++;
		}

		if (!hasAnnotationOnMethodOrCtor) {
			if (parametersWithAnnotationCount == 0) {
				return null;
			}
			if (parametersWithAnnotationCount != parameters.length) {
				throw new PetiteException("All arguments must be annotated with PetiteInject");
			}
		}

		references = updateReferencesWithDefaultsIfNeeded(methodOrCtor, references);

		removeAllDuplicateNames(references);

		return references;
	}

Extracts references from method or constructor annotation.

Extracts references from method or constructor annotation .


private BeanReferences[] buildDefaultReferences(final Executable methodOrCtor) {
		final boolean useParamo = petiteConfig.getUseParamo();
		final PetiteReferenceType[] lookupReferences = petiteConfig.getLookupReferences();
		MethodParameter[] methodParameters = null;

		if (useParamo) {
			methodParameters = Paramo.resolveParameters(methodOrCtor);
		}

		final Class[] paramTypes = methodOrCtor.getParameterTypes();
		final BeanReferences[] references = new BeanReferences[paramTypes.length];

		for (int j = 0; j < paramTypes.length; j++) {
			String[] ref = new String[lookupReferences.length];
			references[j] = BeanReferences.of(ref);

			for (int i = 0; i < ref.length; i++) {
				switch (lookupReferences[i]) {
					case NAME:
						ref[i] = methodParameters != null ? methodParameters[j].getName() : null;
						break;
					case TYPE_SHORT_NAME:
						ref[i] = StringUtil.uncapitalize(paramTypes[j].getSimpleName());
						break;
					case TYPE_FULL_NAME:
						ref[i] = paramTypes[j].getName();
						break;
				}
			}
		}

		return references;
	}

private BeanReferences [ ] buildDefaultReferences ( final Executable methodOrCtor ) { final boolean useParamo = petiteConfig . getUseParamo ( ) ; final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; MethodParameter [ ] methodParameters = null ; if ( useParamo ) { methodParameters = Paramo . resolveParameters ( methodOrCtor ) ; } final Class [ ] paramTypes = methodOrCtor . getParameterTypes ( ) ; final BeanReferences [ ] references = new BeanReferences [ paramTypes . length ] ; for ( int j = 0 ; j < paramTypes . length ; j ++ ) { String [ ] ref = new String [ lookupReferences . length ] ; references [ j ] = BeanReferences . of ( ref ) ; for ( int i = 0 ; i < ref . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : ref [ i ] = methodParameters != null ? methodParameters [ j ] . getName ( ) : null ; break ; case TYPE_SHORT_NAME : ref [ i ] = StringUtil . uncapitalize ( paramTypes [ j ] . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : ref [ i ] = paramTypes [ j ] . getName ( ) ; break ; } } } return references ; }


public BeanReferences buildDefaultReference(final PropertyDescriptor propertyDescriptor) {
		final PetiteReferenceType[] lookupReferences = petiteConfig.getLookupReferences();

		final String[] references = new String[lookupReferences.length];

		for (int i = 0; i < references.length; i++) {
			switch (lookupReferences[i]) {
				case NAME:
					references[i] = propertyDescriptor.getName();
					break;
				case TYPE_SHORT_NAME:
					references[i] = StringUtil.uncapitalize(propertyDescriptor.getType().getSimpleName());
					break;
				case TYPE_FULL_NAME:
					references[i] = propertyDescriptor.getType().getName();
					break;
			}
		}

		return BeanReferences.of(references);
	}

public BeanReferences buildDefaultReference ( final PropertyDescriptor propertyDescriptor ) { final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; final String [ ] references = new String [ lookupReferences . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : references [ i ] = propertyDescriptor . getName ( ) ; break ; case TYPE_SHORT_NAME : references [ i ] = StringUtil . uncapitalize ( propertyDescriptor . getType ( ) . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : references [ i ] = propertyDescriptor . getType ( ) . getName ( ) ; break ; } } return BeanReferences . of ( references ) ; }


private void removeAllDuplicateNames(final BeanReferences[] allBeanReferences) {
		for (int i = 0; i < allBeanReferences.length; i++) {
			BeanReferences references = allBeanReferences[i];
			allBeanReferences[i] = references.removeDuplicateNames();
		}
	}

private void removeAllDuplicateNames ( final BeanReferences [ ] allBeanReferences ) { for ( int i = 0 ; i < allBeanReferences . length ; i ++ ) { BeanReferences references = allBeanReferences [ i ] ; allBeanReferences [ i ] = references . removeDuplicateNames ( ) ; } }

Removes duplicate names from bean references.

Removes duplicate names from bean references .


private BeanReferences[] convertRefToReferences(final String[] references) {
		if (references == null) {
			return null;
		}
		BeanReferences[] ref = new BeanReferences[references.length];

		for (int i = 0; i < references.length; i++) {
			ref[i] = BeanReferences.of(references[i]);
		}
		return ref;
	}

private BeanReferences [ ] convertRefToReferences ( final String [ ] references ) { if ( references == null ) { return null ; } BeanReferences [ ] ref = new BeanReferences [ references . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { ref [ i ] = BeanReferences . of ( references [ i ] ) ; } return ref ; }

Converts single string array to an array of bean references.

Converts single string array to an array of bean references .


private BeanReferences[] convertAnnValueToReferences(String value) {
		if (value == null) {
			return null;
		}

		value = value.trim();
		if (value.length() == 0) {
			return null;
		}

		String[] refNames = Converter.get().toStringArray(value);

		BeanReferences[] references = new BeanReferences[refNames.length];
		for (int i = 0; i < refNames.length; i++) {
			references[i] = BeanReferences.of(refNames[i].trim());
		}
		return references;
	}

private BeanReferences [ ] convertAnnValueToReferences ( String value ) { if ( value == null ) { return null ; } value = value . trim ( ) ; if ( value . length ( ) == 0 ) { return null ; } String [ ] refNames = Converter . get ( ) . toStringArray ( value ) ; BeanReferences [ ] references = new BeanReferences [ refNames . length ] ; for ( int i = 0 ; i < refNames . length ; i ++ ) { references [ i ] = BeanReferences . of ( refNames [ i ] . trim ( ) ) ; } return references ; }

Converts comma-separated string into array of Bean references.

Converts comma - separated string into array of Bean references .


public void runJoy(final Consumer<JoddJoyRuntime> consumer) {
		final JoddJoy joddJoy = new JoddJoy();

		final JoddJoyRuntime joyRuntime = joddJoy.startOnlyBackend();

		joddJoy.withDb(joyDb -> setJtxManager(joyRuntime.getJtxManager()));

		final JtxTransaction tx = startRwTx();
		final Print print = new Print();
		try {
			print.line("START", 80);
			print.newLine();

			consumer.accept(joyRuntime);

			print.newLine();
			print.line("END", 80);

			if (tx != null) {
				tx.commit();
			}
		} catch (Throwable throwable) {
			throwable.printStackTrace();
			if (tx != null) {
				tx.rollback();
			}
		}

		joddJoy.stop();
	}

public void runJoy ( final Consumer < JoddJoyRuntime > consumer ) { final JoddJoy joddJoy = new JoddJoy ( ) ; final JoddJoyRuntime joyRuntime = joddJoy . startOnlyBackend ( ) ; joddJoy . withDb ( joyDb -> setJtxManager ( joyRuntime . getJtxManager ( ) ) ) ; final JtxTransaction tx = startRwTx ( ) ; final Print print = new Print ( ) ; try { print . line ( "START" , 80 ) ; print . newLine ( ) ; consumer . accept ( joyRuntime ) ; print . newLine ( ) ; print . line ( "END" , 80 ) ; if ( tx != null ) { tx . commit ( ) ; } } catch ( Throwable throwable ) { throwable . printStackTrace ( ) ; if ( tx != null ) { tx . rollback ( ) ; } } joddJoy . stop ( ) ; }

Runs JOY in standalone mode, with only backend.

Runs JOY in standalone mode with only backend .


public static Method findMethod(final Class c, final String methodName) {
		return findDeclaredMethod(c, methodName, true);
	}

public static Method findMethod ( final Class c , final String methodName ) { return findDeclaredMethod ( c , methodName , true ) ; }

Returns method from an object, matched by name. This may be considered as
a slow operation, since methods are matched one by one.
Returns only accessible methods.
Only first method is matched.

@param c          class to examine
@param methodName Full name of the method.
@return null if method not found

Returns method from an object matched by name . This may be considered as a slow operation since methods are matched one by one . Returns only accessible methods . Only first method is matched .


public static <T> Constructor<T> findConstructor(final Class<T> clazz, final Class<?>... parameterTypes) {
		final Constructor<?>[] constructors = clazz.getConstructors();

		Class<?>[] pts;

		for (Constructor<?> constructor : constructors) {
			pts = constructor.getParameterTypes();

			if (isAllAssignableFrom(pts, parameterTypes)) {
				return (Constructor<T>) constructor;
			}
		}
		return null;
	}

public static < T > Constructor < T > findConstructor ( final Class < T > clazz , final Class < ? > ... parameterTypes ) { final Constructor < ? > [ ] constructors = clazz . getConstructors ( ) ; Class < ? > [ ] pts ; for ( Constructor < ? > constructor : constructors ) { pts = constructor . getParameterTypes ( ) ; if ( isAllAssignableFrom ( pts , parameterTypes ) ) { return ( Constructor < T > ) constructor ; } } return null ; }

Finds constructor with given parameter types. First matched ctor is returned.

Finds constructor with given parameter types . First matched ctor is returned .


public static Class[] resolveAllInterfaces(final Class type) {
		Set<Class> bag = new LinkedHashSet<>();
		_resolveAllInterfaces(type, bag);

		return bag.toArray(new Class[0]);
	}

public static Class [ ] resolveAllInterfaces ( final Class type ) { Set < Class > bag = new LinkedHashSet <> ( ) ; _resolveAllInterfaces ( type , bag ) ; return bag . toArray ( new Class [ 0 ] ) ; }

Resolves all interfaces of a type. No duplicates are returned.
Direct interfaces are prior the interfaces of subclasses in
the returned array.

Resolves all interfaces of a type . No duplicates are returned . Direct interfaces are prior the interfaces of subclasses in the returned array .


public static boolean compareParameters(final Class[] first, final Class[] second) {
		if (first.length != second.length) {
			return false;
		}
		for (int i = 0; i < first.length; i++) {
			if (first[i] != second[i]) {
				return false;
			}
		}
		return true;
	}

public static boolean compareParameters ( final Class [ ] first , final Class [ ] second ) { if ( first . length != second . length ) { return false ; } for ( int i = 0 ; i < first . length ; i ++ ) { if ( first [ i ] != second [ i ] ) { return false ; } } return true ; }

Compares classes, usually method or ctor parameters.

Compares classes usually method or ctor parameters .


public static void forceAccess(final AccessibleObject accObject) {
		try {
			if (System.getSecurityManager() == null)
				accObject.setAccessible(true);
			else {
				AccessController.doPrivileged((PrivilegedAction) () -> {
					accObject.setAccessible(true);
					return null;
				});
			}
		} catch (SecurityException sex) {
			// ignore
		}
	}

public
static
void
forceAccess
(
final
AccessibleObject
accObject
)
{
try
{
if
(
System
.
getSecurityManager
(
)
==
)
accObject
.
setAccessible
(
true
)
;
else
{
AccessController
.
doPrivileged
(
(
PrivilegedAction
)
(
)
->
{
accObject
.
setAccessible
(
true
)
;
return
;
}
)
;
}
}
catch
(
SecurityException
sex
)
{
// ignore
}
}

Suppress access check against a reflection object. SecurityException is silently ignored.
Checks first if the object is already accessible.

Suppress access check against a reflection object . SecurityException is silently ignored . Checks first if the object is already accessible .


@SuppressWarnings("unchecked")
	public static <T> T newInstance(final Class<T> clazz, final Object... params) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		if (params.length == 0) {
			return newInstance(clazz);
		}

		final Class<?>[] paramTypes = getClasses(params);

		final Constructor<?> constructor = findConstructor(clazz, paramTypes);

		if (constructor == null) {
			throw new InstantiationException("No constructor matched parameter types.");
		}

		return (T) constructor.newInstance(params);
	}

Creates new instance of given class with given optional arguments.

Creates new instance of given class with given optional arguments .


public static Class[] getSuperclasses(final Class type) {
		int i = 0;
		for (Class x = type.getSuperclass(); x != null; x = x.getSuperclass()) {
			i++;
		}
		Class[] result = new Class[i];
		i = 0;
		for (Class x = type.getSuperclass(); x != null; x = x.getSuperclass()) {
			result[i] = x;
			i++;
		}
		return result;
	}

public static Class [ ] getSuperclasses ( final Class type ) { int i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { i ++ ; } Class [ ] result = new Class [ i ] ; i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { result [ i ] = x ; i ++ ; } return result ; }


public static Class<?> childClassOf(final Class<?> parentClass, final Object instance) {

		if (instance == null || instance == Object.class) {
			return null;
		}

		if (parentClass != null) {
			if (parentClass.isInterface()) {
				return null;
			}
		}

		Class<?> childClass = instance.getClass();
		while (true) {
			Class<?> parent = childClass.getSuperclass();
			if (parent == parentClass) {
				return childClass;
			}
			if (parent == null) {
				return null;
			}
			childClass = parent;
		}
	}

public static Class < ? > childClassOf ( final Class < ? > parentClass , final Object instance ) { if ( instance == null || instance == Object . class ) { return null ; } if ( parentClass != null ) { if ( parentClass . isInterface ( ) ) { return null ; } } Class < ? > childClass = instance . getClass ( ) ; while ( true ) { Class < ? > parent = childClass . getSuperclass ( ) ; if ( parent == parentClass ) { return childClass ; } if ( parent == null ) { return null ; } childClass = parent ; } }

Returns the class of the immediate subclass of the given parent class for
the given object instance; or null if such immediate subclass cannot be
uniquely identified for the given object instance.

Returns the class of the immediate subclass of the given parent class for the given object instance ; or null if such immediate subclass cannot be uniquely identified for the given object instance .


public static JarFile jarFileOf(final Class<?> klass) {
		URL url = klass.getResource(
			"/" + klass.getName().replace('.', '/') + ".class");

		if (url == null) {
			return null;
		}

		String s = url.getFile();
		int beginIndex = s.indexOf("file:") + "file:".length();
		int endIndex = s.indexOf(".jar!");
		if (endIndex == -1) {
			return null;
		}

		endIndex += ".jar".length();
		String f = s.substring(beginIndex, endIndex);
		// decode URL string - it may contain encoded chars (e.g. whitespaces) which are not supported for file-instances
		f = URLDecoder.decode(f, "UTF-8");
		File file = new File(f);

		try {
			return file.exists() ? new JarFile(file) : null;
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
	}

Returns the jar file from which the given class is loaded; or null
if no such jar file can be located.

Returns the jar file from which the given class is loaded ; or null if no such jar file can be located .


public static void sleep(final long ms) {
		try {
			Thread.sleep(ms);
		} catch (InterruptedException iex) {
			Thread.currentThread().interrupt();
		}
	}

public static void sleep ( final long ms ) { try { Thread . sleep ( ms ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; } }

Puts a thread to sleep, without throwing an InterruptedException.

@param ms     the length of time to sleep in milliseconds

Puts a thread to sleep without throwing an InterruptedException .


public static void sleep() {
		try {
			Thread.sleep(Long.MAX_VALUE);
		} catch (InterruptedException iex) {
			Thread.currentThread().interrupt();
		}
	}

public static void sleep ( ) { try { Thread . sleep ( Long . MAX_VALUE ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; } }


public static void wait(final Object obj) {
		synchronized (obj) {
			try {
				obj.wait();
			} catch (InterruptedException inex) {
				Thread.currentThread().interrupt();
			}
		}
	}

public static void wait ( final Object obj ) { synchronized ( obj ) { try { obj . wait ( ) ; } catch ( InterruptedException inex ) { Thread . currentThread ( ) . interrupt ( ) ; } } }

Waits for a object for synchronization purposes.

Waits for a object for synchronization purposes .


public static ThreadFactory daemonThreadFactory(final String name, final int priority) {
		return new ThreadFactory() {
			private AtomicInteger count = new AtomicInteger();

			@Override
			public Thread newThread(final Runnable r) {
				Thread thread = new Thread(r);
				thread.setName(name + '-' + count.incrementAndGet());
				thread.setDaemon(true);
				thread.setPriority(priority);
				return thread;
			}
		};
	}

public static ThreadFactory daemonThreadFactory ( final String name , final int priority ) { return new ThreadFactory ( ) { private AtomicInteger count = new AtomicInteger ( ) ; @ Override public Thread newThread ( final Runnable r ) { Thread thread = new Thread ( r ) ; thread . setName ( name + ' ' + count . incrementAndGet ( ) ) ; thread . setDaemon ( true ) ; thread . setPriority ( priority ) ; return thread ; } } ; }


@Override
	public T get() {
		if (!initialized) {
			synchronized (this) {
				if (!initialized) {
					final T t = supplier.get();
					value = t;
					initialized = true;
					supplier = null;
					return t;
				}
			}
		}
		return value;
	}

@ Override public T get ( ) { if ( ! initialized ) { synchronized ( this ) { if ( ! initialized ) { final T t = supplier . get ( ) ; value = t ; initialized = true ; supplier = null ; return t ; } } } return value ; }

Returns the value. Value will be computed on first call.

Returns the value . Value will be computed on first call .


public void visitParameter(final String name, final int access) {
    if (api < Opcodes.ASM5) {
      throw new UnsupportedOperationException(REQUIRES_ASM5);
    }
    if (mv != null) {
      mv.visitParameter(name, access);
    }
  }

public void visitParameter ( final String name , final int access ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitParameter ( name , access ) ; } }

Visits a parameter of this method.

@param name parameter name or null if none is provided.
@param access the parameter's access flags, only {@code ACC_FINAL}, {@code ACC_SYNTHETIC}
or/and {@code ACC_MANDATED} are allowed (see {@link Opcodes}).


public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
    if (mv != null) {
      return mv.visitAnnotation(descriptor, visible);
    }
    return null;
  }

public AnnotationVisitor visitAnnotation ( final String descriptor , final boolean visible ) { if ( mv != null ) { return mv . visitAnnotation ( descriptor , visible ) ; } return null ; }

Visits an annotation of this method.

@param descriptor the class descriptor of the annotation class.
@param visible {@literal true} if the annotation is visible at runtime.
@return a visitor to visit the annotation values, or {@literal null} if this visitor is not
interested in visiting this annotation.


public AnnotationVisitor visitTypeAnnotation(
      final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
    if (api < Opcodes.ASM5) {
      throw new UnsupportedOperationException(REQUIRES_ASM5);
    }
    if (mv != null) {
      return mv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
    }
    return null;
  }

public AnnotationVisitor visitTypeAnnotation ( final int typeRef , final TypePath typePath , final String descriptor , final boolean visible ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitTypeAnnotation ( typeRef , typePath , descriptor , visible ) ; } return null ; }

Visits an annotation on a type in the method signature.

@param typeRef a reference to the annotated type. The sort of this type reference must be
{@link TypeReference#METHOD_TYPE_PARAMETER}, {@link
TypeReference#METHOD_TYPE_PARAMETER_BOUND}, {@link TypeReference#METHOD_RETURN}, {@link
TypeReference#METHOD_RECEIVER}, {@link TypeReference#METHOD_FORMAL_PARAMETER} or {@link
TypeReference#THROWS}. 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 {@literal null} if the annotation targets
'typeRef' as a whole.
@param descriptor the class descriptor of the annotation class.
@param visible {@literal true} if the annotation is visible at runtime.
@return a visitor to visit the annotation values, or {@literal null} if this visitor is not
interested in visiting this annotation.

Visits an annotation on a type in the method signature .


public AnnotationVisitor visitParameterAnnotation(
      final int parameter, final String descriptor, final boolean visible) {
    if (mv != null) {
      return mv.visitParameterAnnotation(parameter, descriptor, visible);
    }
    return null;
  }

public AnnotationVisitor visitParameterAnnotation ( final int parameter , final String descriptor , final boolean visible ) { if ( mv != null ) { return mv . visitParameterAnnotation ( parameter , descriptor , visible ) ; } return null ; }

Visits an annotation of a parameter this method.

@param parameter the parameter index. This index must be strictly smaller than the number of
parameters in the method descriptor, and strictly smaller than the parameter count
specified in {@link #visitAnnotableParameterCount}. Important note: <i>a parameter index i
is not required to correspond to the i'th parameter descriptor in the method
descriptor</i>, in particular in case of synthetic parameters (see
https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18).
@param descriptor the class descriptor of the annotation class.
@param visible {@literal true} if the annotation is visible at runtime.
@return a visitor to visit the annotation values, or {@literal null} if this visitor is not
interested in visiting this annotation.

Visits an annotation of a parameter this method .


public void visitFieldInsn(
      final int opcode, final String owner, final String name, final String descriptor) {
    if (mv != null) {
      mv.visitFieldInsn(opcode, owner, name, descriptor);
    }
  }

public void visitFieldInsn ( final int opcode , final String owner , final String name , final String descriptor ) { if ( mv != null ) { mv . visitFieldInsn ( opcode , owner , name , descriptor ) ; } }

Visits a field instruction. A field instruction is an instruction that loads or stores the
value of a field of an object.

@param opcode the opcode of the type instruction to be visited. This opcode is either
GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
@param owner the internal name of the field's owner class (see {@link Type#getInternalName()}).
@param name the field's name.
@param descriptor the field's descriptor (see {@link Type}).

Visits a field instruction . A field instruction is an instruction that loads or stores the value of a field of an object .


public void visitMethodInsn(
      final int opcode,
      final String owner,
      final String name,
      final String descriptor,
      final boolean isInterface) {
    if (api < Opcodes.ASM5) {
      if (isInterface != (opcode == Opcodes.INVOKEINTERFACE)) {
        throw new IllegalArgumentException("INVOKESPECIAL/STATIC on interfaces requires ASM5");
      }
      visitMethodInsn(opcode, owner, name, descriptor);
      return;
    }
    if (mv != null) {
      mv.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
    }
  }

Visits a method instruction. A method instruction is an instruction that invokes a method.

@param opcode the opcode of the type instruction to be visited. This opcode is either
INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
@param owner the internal name of the method's owner class (see {@link
Type#getInternalName()}).
@param name the method's name.
@param descriptor the method's descriptor (see {@link Type}).
@param isInterface if the method's owner class is an interface.

Visits a method instruction . A method instruction is an instruction that invokes a method .


public void visitInvokeDynamicInsn(
      final String name,
      final String descriptor,
      final Handle bootstrapMethodHandle,
      final Object... bootstrapMethodArguments) {
    if (api < Opcodes.ASM5) {
      throw new UnsupportedOperationException(REQUIRES_ASM5);
    }
    if (mv != null) {
      mv.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);
    }
  }

public void visitInvokeDynamicInsn ( final String name , final String descriptor , final Handle bootstrapMethodHandle , final Object ... bootstrapMethodArguments ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitInvokeDynamicInsn ( name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments ) ; } }

Visits an invokedynamic instruction.

@param name the method's name.
@param descriptor the method's descriptor (see {@link Type}).
@param bootstrapMethodHandle the bootstrap method.
@param bootstrapMethodArguments the bootstrap method constant arguments. Each argument must be
an {@link Integer}, {@link Float}, {@link Long}, {@link Double}, {@link String}, {@link
Type}, {@link Handle} or {@link ConstantDynamic} value. This method is allowed to modify
the content of the array so a caller should expect that this array may change.


public void visitJumpInsn(final int opcode, final Label label) {
    if (mv != null) {
      mv.visitJumpInsn(opcode, label);
    }
  }

public void visitJumpInsn ( final int opcode , final Label label ) { if ( mv != null ) { mv . visitJumpInsn ( opcode , label ) ; } }

Visits a jump instruction. A jump instruction is an instruction that may jump to another
instruction.

@param opcode the opcode of the type instruction to be visited. This opcode is either IFEQ,
IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT,
IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
@param label the operand of the instruction to be visited. This operand is a label that
designates the instruction to which the jump instruction may jump.

Visits a jump instruction . A jump instruction is an instruction that may jump to another instruction .


public void visitMultiANewArrayInsn(final String descriptor, final int numDimensions) {
    if (mv != null) {
      mv.visitMultiANewArrayInsn(descriptor, numDimensions);
    }
  }

public void visitMultiANewArrayInsn ( final String descriptor , final int numDimensions ) { if ( mv != null ) { mv . visitMultiANewArrayInsn ( descriptor , numDimensions ) ; } }

Visits a MULTIANEWARRAY instruction.

@param descriptor an array type descriptor (see {@link Type}).
@param numDimensions the number of dimensions of the array to allocate.


public void visitTryCatchBlock(
      final Label start, final Label end, final Label handler, final String type) {
    if (mv != null) {
      mv.visitTryCatchBlock(start, end, handler, type);
    }
  }

public void visitTryCatchBlock ( final Label start , final Label end , final Label handler , final String type ) { if ( mv != null ) { mv . visitTryCatchBlock ( start , end , handler , type ) ; } }

Visits a try catch block.

@param start the beginning of the exception handler's scope (inclusive).
@param end the end of the exception handler's scope (exclusive).
@param handler the beginning of the exception handler's code.
@param type the internal name of the type of exceptions handled by the handler, or {@literal
null} to catch any exceptions (for "finally" blocks).
@throws IllegalArgumentException if one of the labels has already been visited by this visitor
(by the {@link #visitLabel} method).


public AnnotationVisitor visitLocalVariableAnnotation(
      final int typeRef,
      final TypePath typePath,
      final Label[] start,
      final Label[] end,
      final int[] index,
      final String descriptor,
      final boolean visible) {
    if (api < Opcodes.ASM5) {
      throw new UnsupportedOperationException(REQUIRES_ASM5);
    }
    if (mv != null) {
      return mv.visitLocalVariableAnnotation(
          typeRef, typePath, start, end, index, descriptor, visible);
    }
    return null;
  }

public AnnotationVisitor visitLocalVariableAnnotation ( final int typeRef , final TypePath typePath , final Label [ ] start , final Label [ ] end , final int [ ] index , final String descriptor , final boolean visible ) { if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , descriptor , visible ) ; } return null ; }

Visits an annotation on a local variable type.

@param typeRef a reference to the annotated type. The sort of this type reference must be
{@link TypeReference#LOCAL_VARIABLE} or {@link TypeReference#RESOURCE_VARIABLE}. 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 {@literal null} if the annotation targets
'typeRef' as a whole.
@param start the fist instructions corresponding to the continuous ranges that make the scope
of this local variable (inclusive).
@param end the last instructions corresponding to the continuous ranges that make the scope of
this local variable (exclusive). This array must have the same size as the 'start' array.
@param index the local variable's index in each range. This array must have the same size as
the 'start' array.
@param descriptor the class descriptor of the annotation class.
@param visible {@literal true} if the annotation is visible at runtime.
@return a visitor to visit the annotation values, or {@literal null} if this visitor is not
interested in visiting this annotation.

Visits an annotation on a local variable type .


void convertToWriter(final Writer writer, final Properties properties, final Map<String, Properties> profiles)
			throws IOException {
		final BufferedWriter bw = getBufferedWriter(writer);
		writeBaseAndProfileProperties(bw, properties, profiles);
		writeProfilePropertiesThatAreNotInTheBase(bw, properties, profiles);
		bw.flush();
	}

Convert Java Properties to Jodd Props format

@param writer     Writer to write Props formatted file content to
@param properties Properties to convert to Props format
@param profiles   Properties per profile to convert and add to the Props format
@throws IOException On any I/O error when writing to the writer


@Override
	public void processStream() throws IOException {
		FastByteArrayOutputStream out = new FastByteArrayOutputStream();
		size = 0;
		if (maxFileSize == -1) {
			size += input.copyAll(out);
		} else {
			size += input.copyMax(out, maxFileSize + 1);		// one more byte to detect larger files
			if (size > maxFileSize) {
				fileTooBig = true;
				valid = false;
				input.skipToBoundary();
				return;
			}
		}
		data = out.toByteArray();
		size = data.length;
		valid = true;
	}

@
Override
public
void
processStream
(
)
throws
IOException
{
FastByteArrayOutputStream
out
=
new
FastByteArrayOutputStream
(
)
;
size
=
0
;
if
(
maxFileSize
==
1
)
{
size
+=
input
.
copyAll
(
out
)
;
}
else
{
size
+=
input
.
copyMax
(
out
,
maxFileSize
+
1
)
;
// one more byte to detect larger files
if
(
size
>
maxFileSize
)
{
fileTooBig
=
true
;
valid
=
false
;
input
.
skipToBoundary
(
)
;
return
;
}
}
data
=
out
.
toByteArray
(
)
;
size
=
data
.
length
;
valid
=
true
;
}

Reads data from input stream into byte array and stores file size.

Reads data from input stream into byte array and stores file size .


@Override
	public T next() {
		if (hasNext == null) {
			hasNext = Boolean.valueOf(moveToNext());
		}
		if (hasNext == false) {
			throw new NoSuchElementException();
		}

		if (!entityAwareMode) {
			hasNext = null;
			return newElement;
		}

		count++;

		T result = previousElement;

		previousElement = newElement;

		hasNext = null;
		return result;
	}

@ Override public T next ( ) { if ( hasNext == null ) { hasNext = Boolean . valueOf ( moveToNext ( ) ) ; } if ( hasNext == false ) { throw new NoSuchElementException ( ) ; } if ( ! entityAwareMode ) { hasNext = null ; return newElement ; } count ++ ; T result = previousElement ; previousElement = newElement ; hasNext = null ; return result ; }


private boolean moveToNext() {
		if (last) {
			// last has been set to true, so no more rows to iterate - close everything

			if (closeOnEnd) {
				query.close();
			} else {
				query.closeResultSet(resultSetMapper.getResultSet());
			}

			return false;
		}

		while (true) {

			if (!resultSetMapper.next()) {
				// no more rows, no more parsing, previousElement is the last one to iterate
				last = true;
				return entityAwareMode;
			}

			// parse row

			Object[] objects = resultSetMapper.parseObjects(types);

			Object row = query.resolveRowResults(objects);

			newElement = (T) row;

			if (entityAwareMode) {

				if (count == 0 && previousElement == null) {
					previousElement = newElement;

					continue;
				}

				if (previousElement != null && newElement != null) {
					boolean equals;

					if (newElement.getClass().isArray()) {
						equals = Arrays.equals((Object[]) previousElement, (Object[]) newElement);
					} else {
						equals = previousElement.equals(newElement);
					}

					if (equals) {
						continue;
					}
				}
			}

			break;
		}

		return true;
	}


@SuppressWarnings({"unchecked"})
	public static <T> T[] join(T[]... arrays) {
		Class<T> componentType = (Class<T>) arrays.getClass().getComponentType().getComponentType();
		return join(componentType, arrays);
	}

@ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] join ( T [ ] ... arrays ) { Class < T > componentType = ( Class < T > ) arrays . getClass ( ) . getComponentType ( ) . getComponentType ( ) ; return join ( componentType , arrays ) ; }

Joins arrays. Component type is resolved from the array argument.

Joins arrays . Component type is resolved from the array argument .


@SuppressWarnings({"unchecked"})
	public static <T> T[] join(Class<T> componentType, T[][] arrays) {
		if (arrays.length == 1) {
			return arrays[0];
		}
		int length = 0;
		for (T[] array : arrays) {
			length += array.length;
		}
		T[] result = (T[]) Array.newInstance(componentType, length);

		length = 0;
		for (T[] array : arrays) {
			System.arraycopy(array, 0, result, length, array.length);
			length += array.length;
		}
		return result;
	}

@ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] join ( Class < T > componentType , T [ ] [ ] arrays ) { if ( arrays . length == 1 ) { return arrays [ 0 ] ; } int length = 0 ; for ( T [ ] array : arrays ) { length += array . length ; } T [ ] result = ( T [ ] ) Array . newInstance ( componentType , length ) ; length = 0 ; for ( T [ ] array : arrays ) { System . arraycopy ( array , 0 , result , length , array . length ) ; length += array . length ; } return result ; }

Joins arrays using provided component type.

Joins arrays using provided component type .


public static <T> T[] resize(T[] buffer, int newSize) {
		Class<T> componentType = (Class<T>) buffer.getClass().getComponentType();
		T[] temp = (T[]) Array.newInstance(componentType, newSize);
		System.arraycopy(buffer, 0, temp, 0, buffer.length >= newSize ? newSize : buffer.length);
		return temp;
	}

public static < T > T [ ] resize ( T [ ] buffer , int newSize ) { Class < T > componentType = ( Class < T > ) buffer . getClass ( ) . getComponentType ( ) ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , newSize ) ; System . arraycopy ( buffer , 0 , temp , 0 , buffer . length >= newSize ? newSize : buffer . length ) ; return temp ; }


public static <T> T[] append(T[] buffer, T newElement) {
		T[] t = resize(buffer, buffer.length + 1);
		t[buffer.length] = newElement;
		return t;
	}

public static < T > T [ ] append ( T [ ] buffer , T newElement ) { T [ ] t = resize ( buffer , buffer . length + 1 ) ; t [ buffer . length ] = newElement ; return t ; }


@SuppressWarnings({"unchecked"})
	public static <T> T[] remove(T[] buffer, int offset, int length, Class<T> componentType) {
		int len2 = buffer.length - length;
		T[] temp = (T[]) Array.newInstance(componentType, len2);
		System.arraycopy(buffer, 0, temp, 0, offset);
		System.arraycopy(buffer, offset + length, temp, offset, len2 - offset);
		return temp;
	}

@ SuppressWarnings ( { "unchecked" } ) public static < T > T [ ] remove ( T [ ] buffer , int offset , int length , Class < T > componentType ) { int len2 = buffer . length - length ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , len2 ) ; System . arraycopy ( buffer , 0 , temp , 0 , offset ) ; System . arraycopy ( buffer , offset + length , temp , offset , len2 - offset ) ; return temp ; }


public static int indexOf(char[] array, char value) {
		for (int i = 0; i < array.length; i++) {
			if (array[i] == value) {
				return i;
			}
		}
		return -1;
	}

public static int indexOf ( char [ ] array , char value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == value ) { return i ; } } return - 1 ; }

Finds the first occurrence of an element in an array.

Finds the first occurrence of an element in an array .


public static int indexOf(Object[] array, Object value) {
		for (int i = 0; i < array.length; i++) {
			if (array[i].equals(value)) {
				return i;
			}
		}
		return -1;
	}

public static int indexOf ( Object [ ] array , Object value ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] . equals ( value ) ) { return i ; } } return - 1 ; }

Finds the first occurrence in an array .


public static int indexOf(byte[] array, byte[] sub, int startIndex) {
		return indexOf(array, sub, startIndex, array.length);
	}

public static int indexOf ( byte [ ] array , byte [ ] sub , int startIndex ) { return indexOf ( array , sub , startIndex , array . length ) ; }

Finds the first occurrence in an array from specified given position.

Finds the first occurrence in an array from specified given position .


public LagartoDOMBuilder enableXhtmlMode() {
		config.ignoreWhitespacesBetweenTags = false;			// collect all whitespaces
		config.setCaseSensitive(true);							// XHTML is case sensitive
		config.setEnableRawTextModes(false);					// all tags are parsed in the same way
		config.enabledVoidTags = true;							// list of void tags
		config.selfCloseVoidTags = true;						// self close void tags
		config.impliedEndTags = false;							// no implied tag ends
		config.setEnableConditionalComments(false);				// don't enable IE conditional comments
		config.setParseXmlTags(false);							// enable XML mode in parsing
		return this;
	}

public
LagartoDOMBuilder
enableXhtmlMode
(
)
{
config
.
ignoreWhitespacesBetweenTags
=
false
;
// collect all whitespaces
config
.
setCaseSensitive
(
true
)
;
// XHTML is case sensitive
config
.
setEnableRawTextModes
(
false
)
;
// all tags are parsed in the same way
config
.
enabledVoidTags
=
true
;
// list of void tags
config
.
selfCloseVoidTags
=
true
;
// self close void tags
config
.
impliedEndTags
=
false
;
// no implied tag ends
config
.
setEnableConditionalComments
(
false
)
;
// don't enable IE conditional comments
config
.
setParseXmlTags
(
false
)
;
// enable XML mode in parsing
return
this
;
}


@Override
	public Document parse(final char[] content) {
		LagartoParser lagartoParser = new LagartoParser(content);
		return doParse(lagartoParser);
	}

@ Override public Document parse ( final char [ ] content ) { LagartoParser lagartoParser = new LagartoParser ( content ) ; return doParse ( lagartoParser ) ; }

Creates DOM tree from provided content .


protected Document doParse(final LagartoParser lagartoParser) {
		lagartoParser.setConfig(config);

		LagartoDOMBuilderTagVisitor domBuilderTagVisitor =
				new LagartoDOMBuilderTagVisitor(this);

		lagartoParser.parse(domBuilderTagVisitor);

		return domBuilderTagVisitor.getDocument();
	}

protected Document doParse ( final LagartoParser lagartoParser ) { lagartoParser . setConfig ( config ) ; LagartoDOMBuilderTagVisitor domBuilderTagVisitor = new LagartoDOMBuilderTagVisitor ( this ) ; lagartoParser . parse ( domBuilderTagVisitor ) ; return domBuilderTagVisitor . getDocument ( ) ; }

Parses the content using provided lagarto parser.

Parses the content using provided lagarto parser .


private void computeMaxStackAndLocal() {
    // Complete the control flow graph with exception handler blocks.
    Handler handler = firstHandler;
    while (handler != null) {
      Label handlerBlock = handler.handlerPc;
      Label handlerRangeBlock = handler.startPc;
      Label handlerRangeEnd = handler.endPc;
      // Add handlerBlock as a successor of all the basic blocks in the exception handler range.
      while (handlerRangeBlock != handlerRangeEnd) {
        if ((handlerRangeBlock.flags & Label.FLAG_SUBROUTINE_CALLER) == 0) {
          handlerRangeBlock.outgoingEdges =
              new Edge(Edge.EXCEPTION, handlerBlock, handlerRangeBlock.outgoingEdges);
        } else {
          // If handlerRangeBlock is a JSR block, add handlerBlock after the first two outgoing
          // edges to preserve the hypothesis about JSR block successors order (see
          // {@link #visitJumpInsn}).
          handlerRangeBlock.outgoingEdges.nextEdge.nextEdge =
              new Edge(
                  Edge.EXCEPTION, handlerBlock, handlerRangeBlock.outgoingEdges.nextEdge.nextEdge);
        }
        handlerRangeBlock = handlerRangeBlock.nextBasicBlock;
      }
      handler = handler.nextHandler;
    }

    // Complete the control flow graph with the successor blocks of subroutines, if needed.
    if (hasSubroutines) {
      // First step: find the subroutines. This step determines, for each basic block, to which
      // subroutine(s) it belongs. Start with the main "subroutine":
      short numSubroutines = 1;
      firstBasicBlock.markSubroutine(numSubroutines);
      // Then, mark the subroutines called by the main subroutine, then the subroutines called by
      // those called by the main subroutine, etc.
      for (short currentSubroutine = 1; currentSubroutine <= numSubroutines; ++currentSubroutine) {
        Label basicBlock = firstBasicBlock;
        while (basicBlock != null) {
          if ((basicBlock.flags & Label.FLAG_SUBROUTINE_CALLER) != 0
              && basicBlock.subroutineId == currentSubroutine) {
            Label jsrTarget = basicBlock.outgoingEdges.nextEdge.successor;
            if (jsrTarget.subroutineId == 0) {
              // If this subroutine has not been marked yet, find its basic blocks.
              jsrTarget.markSubroutine(++numSubroutines);
            }
          }
          basicBlock = basicBlock.nextBasicBlock;
        }
      }
      // Second step: find the successors in the control flow graph of each subroutine basic block
      // 'r' ending with a RET instruction. These successors are the virtual successors of the basic
      // blocks ending with JSR instructions (see {@link #visitJumpInsn)} that can reach 'r'.
      Label basicBlock = firstBasicBlock;
      while (basicBlock != null) {
        if ((basicBlock.flags & Label.FLAG_SUBROUTINE_CALLER) != 0) {
          // By construction, jsr targets are stored in the second outgoing edge of basic blocks
          // that ends with a jsr instruction (see {@link #FLAG_SUBROUTINE_CALLER}).
          Label subroutine = basicBlock.outgoingEdges.nextEdge.successor;
          subroutine.addSubroutineRetSuccessors(basicBlock);
        }
        basicBlock = basicBlock.nextBasicBlock;
      }
    }

    // Data flow algorithm: put the first basic block in a list of blocks to process (i.e. blocks
    // whose input stack size has changed) and, while there are blocks to process, remove one
    // from the list, update the input stack size of its successor blocks in the control flow
    // graph, and add these blocks to the list of blocks to process (if not already done).
    Label listOfBlocksToProcess = firstBasicBlock;
    listOfBlocksToProcess.nextListElement = Label.EMPTY_LIST;
    int maxStackSize = maxStack;
    while (listOfBlocksToProcess != Label.EMPTY_LIST) {
      // Remove a basic block from the list of blocks to process. Note that we don't reset
      // basicBlock.nextListElement to null on purpose, to make sure we don't reprocess already
      // processed basic blocks.
      Label basicBlock = listOfBlocksToProcess;
      listOfBlocksToProcess = listOfBlocksToProcess.nextListElement;
      // Compute the (absolute) input stack size and maximum stack size of this block.
      int inputStackTop = basicBlock.inputStackSize;
      int maxBlockStackSize = inputStackTop + basicBlock.outputStackMax;
      // Update the absolute maximum stack size of the method.
      if (maxBlockStackSize > maxStackSize) {
        maxStackSize = maxBlockStackSize;
      }
      // Update the input stack size of the successor blocks of basicBlock in the control flow
      // graph, and add these blocks to the list of blocks to process, if not already done.
      Edge outgoingEdge = basicBlock.outgoingEdges;
      if ((basicBlock.flags & Label.FLAG_SUBROUTINE_CALLER) != 0) {
        // Ignore the first outgoing edge of the basic blocks ending with a jsr: these are virtual
        // edges which lead to the instruction just after the jsr, and do not correspond to a
        // possible execution path (see {@link #visitJumpInsn} and
        // {@link Label#FLAG_SUBROUTINE_CALLER}).
        outgoingEdge = outgoingEdge.nextEdge;
      }
      while (outgoingEdge != null) {
        Label successorBlock = outgoingEdge.successor;
        if (successorBlock.nextListElement == null) {
          successorBlock.inputStackSize =
              (short) (outgoingEdge.info == Edge.EXCEPTION ? 1 : inputStackTop + outgoingEdge.info);
          successorBlock.nextListElement = listOfBlocksToProcess;
          listOfBlocksToProcess = successorBlock;
        }
        outgoingEdge = outgoingEdge.nextEdge;
      }
    }
    this.maxStack = maxStackSize;
  }

Computes the maximum stack size of the method.

Computes the maximum stack size of the method .


private void endCurrentBasicBlockWithNoSuccessor() {
    if (compute == COMPUTE_ALL_FRAMES) {
      Label nextBasicBlock = new Label();
      nextBasicBlock.frame = new Frame(nextBasicBlock);
      nextBasicBlock.resolve(code.data, code.length);
      lastBasicBlock.nextBasicBlock = nextBasicBlock;
      lastBasicBlock = nextBasicBlock;
      currentBasicBlock = null;
    } else if (compute == COMPUTE_MAX_STACK_AND_LOCAL) {
      currentBasicBlock.outputStackMax = (short) maxRelativeStackSize;
      currentBasicBlock = null;
    }
  }

private void endCurrentBasicBlockWithNoSuccessor ( ) { if ( compute == COMPUTE_ALL_FRAMES ) { Label nextBasicBlock = new Label ( ) ; nextBasicBlock . frame = new Frame ( nextBasicBlock ) ; nextBasicBlock . resolve ( code . data , code . length ) ; lastBasicBlock . nextBasicBlock = nextBasicBlock ; lastBasicBlock = nextBasicBlock ; currentBasicBlock = null ; } else if ( compute == COMPUTE_MAX_STACK_AND_LOCAL ) { currentBasicBlock . outputStackMax = ( short ) maxRelativeStackSize ; currentBasicBlock = null ; } }

Ends the current basic block. This method must be used in the case where the current basic
block does not have any successor.

<p>WARNING: this method must be called after the currently visited instruction has been put in
{@link #code} (if frames are computed, this method inserts a new Label to start a new basic
block after the current instruction).

Ends the current basic block . This method must be used in the case where the current basic block does not have any successor .


final void collectAttributePrototypes(final Attribute.Set attributePrototypes) {
    attributePrototypes.addAttributes(firstAttribute);
    attributePrototypes.addAttributes(firstCodeAttribute);
  }

final void collectAttributePrototypes ( final Attribute . Set attributePrototypes ) { attributePrototypes . addAttributes ( firstAttribute ) ; attributePrototypes . addAttributes ( firstCodeAttribute ) ; }

Collects the attributes of this method into the given set of attribute prototypes.

@param attributePrototypes a set of attribute prototypes.

Collects the attributes of this method into the given set of attribute prototypes .


public void injectContext(final Object targetObject) {
		final Class targetType = targetObject.getClass();

		final ScopeData scopeData = scopeDataInspector.inspectClassScopesWithCache(targetType);

		final Targets targets = new Targets(targetObject, scopeData);

		// inject no context
		scopeResolver.forEachScope(madvocScope -> madvocScope.inject(targets));

		// inject special case
		scopeResolver.forScope(ParamsScope.class, scope -> scope.inject(targets));

		// inject servlet context
		final ServletContext servletContext = madvocController.getApplicationContext();
		if (servletContext != null) {
			scopeResolver.forEachScope(madvocScope -> madvocScope.inject(servletContext, targets));
		}
	}

public
void
injectContext
(
final
Object
targetObject
)
{
final
Class
targetType
=
targetObject
.
getClass
(
)
;
final
ScopeData
scopeData
=
scopeDataInspector
.
inspectClassScopesWithCache
(
targetType
)
;
final
Targets
targets
=
new
Targets
(
targetObject
,
scopeData
)
;
// inject no context
scopeResolver
.
forEachScope
(
madvocScope
->
madvocScope
.
inject
(
targets
)
)
;
// inject special case
scopeResolver
.
forScope
(
ParamsScope
.
class
,
scope
->
scope
.
inject
(
targets
)
)
;
// inject servlet context
final
ServletContext
servletContext
=
madvocController
.
getApplicationContext
(
)
;
if
(
servletContext
!=
)
{
scopeResolver
.
forEachScope
(
madvocScope
->
madvocScope
.
inject
(
servletContext
,
targets
)
)
;
}
}


public static void registerPseudoClass(final Class<? extends PseudoClass> pseudoClassType) {
		PseudoClass pseudoClass;
		try {
			pseudoClass = ClassUtil.newInstance(pseudoClassType);
		} catch (Exception ex) {
			throw new CSSellyException(ex);
		}
		PSEUDO_CLASS_MAP.put(pseudoClass.getPseudoClassName(), pseudoClass);
	}

public static void registerPseudoClass ( final Class < ? extends PseudoClass > pseudoClassType ) { PseudoClass pseudoClass ; try { pseudoClass = ClassUtil . newInstance ( pseudoClassType ) ; } catch ( Exception ex ) { throw new CSSellyException ( ex ) ; } PSEUDO_CLASS_MAP . put ( pseudoClass . getPseudoClassName ( ) , pseudoClass ) ; }


public static PseudoClass lookupPseudoClass(final String pseudoClassName) {
		PseudoClass pseudoClass = PSEUDO_CLASS_MAP.get(pseudoClassName);
		if (pseudoClass == null) {
			throw new CSSellyException("Unsupported pseudo class: " + pseudoClassName);
		}
		return pseudoClass;
	}

public
static
PseudoClass
lookupPseudoClass
(
final
String
pseudoClassName
)
{
PseudoClass
pseudoClass
=
PSEUDO_CLASS_MAP
.
get
(
pseudoClassName
)
;
if
(
pseudoClass
==
)
{
throw
new
CSSellyException
(
"Unsupported pseudo class: "
+
pseudoClassName
)
;
}
return
pseudoClass
;
}

Lookups pseudo class for given pseudo class name.

Lookups pseudo class for given pseudo class name .


public void invoke(final ActionRequest actionRequest) {
		if (executorService == null) {
			throw new MadvocException("No action is marked as async!");
		}

		final HttpServletRequest servletRequest = actionRequest.getHttpServletRequest();

		log.debug(() -> "Async call to: " + actionRequest);

		final AsyncContext asyncContext = servletRequest.startAsync();

		executorService.submit(() -> {
			try {
				actionRequest.invoke();
			} catch (Exception ex) {
				log.error("Invoking async action path failed: " , ExceptionUtil.unwrapThrowable(ex));
			} finally {
				asyncContext.complete();
			}
		});
	}

public
void
invoke
(
final
ActionRequest
actionRequest
)
{
if
(
executorService
==
)
{
throw
new
MadvocException
(
"No action is marked as async!"
)
;
}
final
HttpServletRequest
servletRequest
=
actionRequest
.
getHttpServletRequest
(
)
;
log
.
debug
(
(
)
->
"Async call to: "
+
actionRequest
)
;
final
AsyncContext
asyncContext
=
servletRequest
.
startAsync
(
)
;
executorService
.
submit
(
(
)
->
{
try
{
actionRequest
.
invoke
(
)
;
}
catch
(
Exception
ex
)
{
log
.
error
(
"Invoking async action path failed: "
,
ExceptionUtil
.
unwrapThrowable
(
ex
)
)
;
}
finally
{
asyncContext
.
complete
(
)
;
}
}
)
;
}

Invokes an action asynchronously by submitting it to the thread pool.

Invokes an action asynchronously by submitting it to the thread pool .


protected String[] getAllBeanPropertyNames(final Class type, final boolean declared) {
		ClassDescriptor classDescriptor = ClassIntrospector.get().lookup(type);

		PropertyDescriptor[] propertyDescriptors = classDescriptor.getAllPropertyDescriptors();

		ArrayList<String> names = new ArrayList<>(propertyDescriptors.length);

		for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
			MethodDescriptor getter = propertyDescriptor.getReadMethodDescriptor();
			if (getter != null) {
				if (getter.matchDeclared(declared)) {
					names.add(propertyDescriptor.getName());
				}
			}
			else if (includeFields) {
				FieldDescriptor field = propertyDescriptor.getFieldDescriptor();
				if (field != null) {
					if (field.matchDeclared(declared)) {
						names.add(field.getName());
					}
				}
			}
		}

		return names.toArray(new String[0]);
	}

protected String [ ] getAllBeanPropertyNames ( final Class type , final boolean declared ) { ClassDescriptor classDescriptor = ClassIntrospector . get ( ) . lookup ( type ) ; PropertyDescriptor [ ] propertyDescriptors = classDescriptor . getAllPropertyDescriptors ( ) ; ArrayList < String > names = new ArrayList <> ( propertyDescriptors . length ) ; for ( PropertyDescriptor propertyDescriptor : propertyDescriptors ) { MethodDescriptor getter = propertyDescriptor . getReadMethodDescriptor ( ) ; if ( getter != null ) { if ( getter . matchDeclared ( declared ) ) { names . add ( propertyDescriptor . getName ( ) ) ; } } else if ( includeFields ) { FieldDescriptor field = propertyDescriptor . getFieldDescriptor ( ) ; if ( field != null ) { if ( field . matchDeclared ( declared ) ) { names . add ( field . getName ( ) ) ; } } } } return names . toArray ( new String [ 0 ] ) ; }


public void visit() {
		String[] properties = resolveProperties(source, declared);

		for (String name : properties) {
			if (name == null) {
				continue;
			}

			if (!rules.match(name, blacklist)) {
				continue;
			}

			Object value;

			String propertyName = name;

			if (isSourceMap) {
				propertyName = LEFT_SQ_BRACKET + name + RIGHT_SQ_BRACKET;
			}

			if (declared) {
				value = BeanUtil.declared.getProperty(source, propertyName);
			} else {
				value = BeanUtil.pojo.getProperty(source, propertyName);
			}

			if (value == null && ignoreNullValues) {
				continue;
			}

			if (value instanceof String && StringUtil.isEmpty((String) value)) {
				continue;
			}

			visitProperty(name, value);
		}
	}

public void visit ( ) { String [ ] properties = resolveProperties ( source , declared ) ; for ( String name : properties ) { if ( name == null ) { continue ; } if ( ! rules . match ( name , blacklist ) ) { continue ; } Object value ; String propertyName = name ; if ( isSourceMap ) { propertyName = LEFT_SQ_BRACKET + name + RIGHT_SQ_BRACKET ; } if ( declared ) { value = BeanUtil . declared . getProperty ( source , propertyName ) ; } else { value = BeanUtil . pojo . getProperty ( source , propertyName ) ; } if ( value == null && ignoreNullValues ) { continue ; } if ( value instanceof String && StringUtil . isEmpty ( ( String ) value ) ) { continue ; } visitProperty ( name , value ) ; } }


@Override
	public boolean accept(final String propertyName, final String rule, final boolean include) {
		return propertyName.equals(rule);
	}

@ Override public boolean accept ( final String propertyName , final String rule , final boolean include ) { return propertyName . equals ( rule ) ; }


public MethodInjectionPoint[] resolve(final Class type) {
		// lookup methods
		ClassDescriptor cd = ClassIntrospector.get().lookup(type);
		List<MethodInjectionPoint> list = new ArrayList<>();
		MethodDescriptor[] allMethods = cd.getAllMethodDescriptors();

		for (MethodDescriptor methodDescriptor : allMethods) {
			Method method = methodDescriptor.getMethod();

			if (ClassUtil.isBeanPropertySetter(method)) {
				// ignore setters
				continue;
			}

			if (method.getParameterTypes().length == 0) {
				// ignore methods with no argument
				continue;
			}

			BeanReferences[] references = referencesResolver.readAllReferencesFromAnnotation(method);

			if (references != null) {
				MethodInjectionPoint methodInjectionPoint = new MethodInjectionPoint(method, references);

				list.add(methodInjectionPoint);
			}
		}

		final MethodInjectionPoint[] methodInjectionPoints;

		if (list.isEmpty()) {
			methodInjectionPoints = MethodInjectionPoint.EMPTY;
		} else {
			methodInjectionPoints = list.toArray(new MethodInjectionPoint[0]);
		}

		return methodInjectionPoints;
	}

public
MethodInjectionPoint
[
]
resolve
(
final
Class
type
)
{
// lookup methods
ClassDescriptor
cd
=
ClassIntrospector
.
get
(
)
.
lookup
(
type
)
;
List
<
MethodInjectionPoint
>
list
=
new
ArrayList
<>
(
)
;
MethodDescriptor
[
]
allMethods
=
cd
.
getAllMethodDescriptors
(
)
;
for
(
MethodDescriptor
methodDescriptor
:
allMethods
)
{
Method
method
=
methodDescriptor
.
getMethod
(
)
;
if
(
ClassUtil
.
isBeanPropertySetter
(
method
)
)
{
// ignore setters
continue
;
}
if
(
method
.
getParameterTypes
(
)
.
length
==
0
)
{
// ignore methods with no argument
continue
;
}
BeanReferences
[
]
references
=
referencesResolver
.
readAllReferencesFromAnnotation
(
method
)
;
if
(
references
!=
)
{
MethodInjectionPoint
methodInjectionPoint
=
new
MethodInjectionPoint
(
method
,
references
)
;
list
.
add
(
methodInjectionPoint
)
;
}
}
final
MethodInjectionPoint
[
]
methodInjectionPoints
;
if
(
list
.
isEmpty
(
)
)
{
methodInjectionPoints
=
MethodInjectionPoint
.
EMPTY
;
}
else
{
methodInjectionPoints
=
list
.
toArray
(
new
MethodInjectionPoint
[
0
]
)
;
}
return
methodInjectionPoints
;
}

Resolve method injection points in given class.

Resolve method injection points in given class .


protected void readFilterConfigParameters(final FilterConfig filterConfig, final Object target, final String... parameters) {
		for (String parameter : parameters) {
			String value = filterConfig.getInitParameter(parameter);

			if (value != null) {
				BeanUtil.declared.setProperty(target, parameter, value);
			}
		}
	}

protected void readFilterConfigParameters ( final FilterConfig filterConfig , final Object target , final String ... parameters ) { for ( String parameter : parameters ) { String value = filterConfig . getInitParameter ( parameter ) ; if ( value != null ) { BeanUtil . declared . setProperty ( target , parameter , value ) ; } } }

Reads filter config parameters and set into destination target.

Reads filter config parameters and set into destination target .


protected void sendBundleFile(final HttpServletResponse resp, final File bundleFile) throws IOException {
		OutputStream out = resp.getOutputStream();
		FileInputStream fileInputStream = new FileInputStream(bundleFile);
		try {
			StreamUtil.copy(fileInputStream, out);
		}
		finally {
			StreamUtil.close(fileInputStream);
		}
	}

protected void sendBundleFile ( final HttpServletResponse resp , final File bundleFile ) throws IOException { OutputStream out = resp . getOutputStream ( ) ; FileInputStream fileInputStream = new FileInputStream ( bundleFile ) ; try { StreamUtil . copy ( fileInputStream , out ) ; } finally { StreamUtil . close ( fileInputStream ) ; } }


public File lookupBundleFile(String bundleId) {
		if ((mirrors != null) && (!mirrors.isEmpty())) {
			String realBundleId = mirrors.remove(bundleId);

			if (realBundleId != null) {
				bundleId = realBundleId;
			}
		}
		return createBundleFile(bundleId);
	}

public File lookupBundleFile ( String bundleId ) { if ( ( mirrors != null ) && ( ! mirrors . isEmpty ( ) ) ) { String realBundleId = mirrors . remove ( bundleId ) ; if ( realBundleId != null ) { bundleId = realBundleId ; } } return createBundleFile ( bundleId ) ; }


public File lookupGzipBundleFile(final File file) throws IOException {
		String path = file.getPath() + ZipUtil.GZIP_EXT;
		File gzipFile = new File(path);

		if (!gzipFile.exists()) {
			if (log.isDebugEnabled()) {
				log.debug("gzip bundle to " + path);
			}
			ZipUtil.gzip(file);
		}

		return gzipFile;
	}

public
File
lookupGzipBundleFile
(
final
File
file
)
throws
IOException
{
String
path
=
file
.
getPath
(
)
+
ZipUtil
.
GZIP_EXT
;
File
gzipFile
=
new
File
(
path
)
;
if
(
!
gzipFile
.
exists
(
)
)
{
if
(
log
.
isDebugEnabled
(
)
)
{
log
.
debug
(
"gzip bundle to "
+
path
)
;
}
ZipUtil
.
gzip
(
file
)
;
}
return
gzipFile
;
}

Locates gzipped version of bundle file. If gzip file
does not exist, it will be created.

Locates gzipped version of bundle file . If gzip file does not exist it will be created .


public synchronized String registerBundle(final String contextPath, final String actionPath, final String tempBundleId, final String bundleContentType, final List<String> sources) {

		if (tempBundleId == null || sources.isEmpty()) {
			if (strategy == Strategy.ACTION_MANAGED) {
				// page does not include any resource source file
				actionBundles.put(actionPath, StringPool.EMPTY);
			}
			return null;
		}

		// create unique digest from the collected sources
		String[] sourcesArray = sources.toArray(new String[0]);
		for (int i = 0, sourcesArrayLength = sourcesArray.length; i < sourcesArrayLength; i++) {
			sourcesArray[i] = sourcesArray[i].trim().toLowerCase();
		}
		if (sortResources) {
			Arrays.sort(sourcesArray);
		}

		StringBand sb = new StringBand(sourcesArray.length);
		for (String src : sourcesArray) {
			sb.append(src);
		}
		String sourcesString = sb.toString();

		String bundleId = createDigest(sourcesString);
		bundleId += '.' + bundleContentType;

		// bundle appears for the first time, create the bundle
		if (strategy == Strategy.ACTION_MANAGED) {
			actionBundles.put(actionPath, bundleId);
			mirrors.put(tempBundleId, bundleId);
		}
		try {
			createBundle(contextPath, actionPath, bundleId, sources);
		} catch (IOException ioex) {
			throw new HtmlStaplerException("Can't create bundle", ioex);
		}
		return bundleId;
	}

Registers new bundle that consist of provided list of source paths.
Returns the real bundle id, as provided one is just a temporary bundle id.

Registers new bundle that consist of provided list of source paths . Returns the real bundle id as provided one is just a temporary bundle id .


protected String createDigest(final String source) {
		final DigestEngine digestEngine = DigestEngine.sha256();

		final byte[] bytes = digestEngine.digest(CharUtil.toSimpleByteArray(source));

		String digest = Base32.encode(bytes);

		if (uniqueDigestKey != null) {
			digest += uniqueDigestKey;
		}

		return digest;
	}

protected String createDigest ( final String source ) { final DigestEngine digestEngine = DigestEngine . sha256 ( ) ; final byte [ ] bytes = digestEngine . digest ( CharUtil . toSimpleByteArray ( source ) ) ; String digest = Base32 . encode ( bytes ) ; if ( uniqueDigestKey != null ) { digest += uniqueDigestKey ; } return digest ; }

Creates digest i.e. bundle id from given string.
Returned digest must be filename safe, for all platforms.

Creates digest i . e . bundle id from given string . Returned digest must be filename safe for all platforms .


protected void createBundle(final String contextPath, final String actionPath, final String bundleId, final List<String>sources) throws IOException {
		final File bundleFile = createBundleFile(bundleId);
		if (bundleFile.exists()) {
			return;
		}

		StringBand sb = new StringBand(sources.size() * 2);
		for (String src : sources) {
			if (sb.length() != 0) {
				sb.append(StringPool.NEWLINE);
			}
			String content;
			if (isExternalResource(src)) {
				content = downloadString(src);
			} else {
				if (!downloadLocal) {
					// load local resource from file system
					String localFile = webRoot;

					if (src.startsWith(contextPath + '/')) {
						src = src.substring(contextPath.length());
					}

					if (src.startsWith(StringPool.SLASH)) {
						// absolute path
						localFile += src;
					} else {
						// relative path
						localFile += '/' + FileNameUtil.getPathNoEndSeparator(actionPath) + '/' + src;
					}

					// trim link parameters, if any
					int qmndx = localFile.indexOf('?');
					if (qmndx != -1) {
						localFile = localFile.substring(0, qmndx);
					}

					try {
						content = FileUtil.readString(localFile);
					} catch (IOException ioex) {
						if (notFoundExceptionEnabled) {
							throw ioex;
						}
						if (log.isWarnEnabled()) {
							log.warn(ioex.getMessage());
						}
						content = null;
					}
				} else {
					// download local resource
					String localUrl = localAddressAndPort;

					if (src.startsWith(StringPool.SLASH)) {
						localUrl += contextPath + src;
					} else {
						localUrl += contextPath + FileNameUtil.getPath(actionPath) + '/' + src;
					}

					content = downloadString(localUrl);
				}

				if (content != null) {
					if (isCssResource(src)) {
						content = fixCssRelativeUrls(content, src);
					}
				}
			}

			if (content != null) {
				content = onResourceContent(content);
				sb.append(content);
			}
		}

		FileUtil.writeString(bundleFile, sb.toString());

		if (log.isInfoEnabled()) {
			log.info("Bundle created: " + bundleId);
		}
	}

protected
void
createBundle
(
final
String
contextPath
,
final
String
actionPath
,
final
String
bundleId
,
final
List
<
String
>
sources
)
throws
IOException
{
final
File
bundleFile
=
createBundleFile
(
bundleId
)
;
if
(
bundleFile
.
exists
(
)
)
{
return
;
}
StringBand
sb
=
new
StringBand
(
sources
.
size
(
)
*
2
)
;
for
(
String
src
:
sources
)
{
if
(
sb
.
length
(
)
!=
0
)
{
sb
.
append
(
StringPool
.
NEWLINE
)
;
}
String
content
;
if
(
isExternalResource
(
src
)
)
{
content
=
downloadString
(
src
)
;
}
else
{
if
(
!
downloadLocal
)
{
// load local resource from file system
String
localFile
=
webRoot
;
if
(
src
.
startsWith
(
contextPath
+
'
'
)
)
{
src
=
src
.
substring
(
contextPath
.
length
(
)
)
;
}
if
(
src
.
startsWith
(
StringPool
.
SLASH
)
)
{
// absolute path
localFile
+=
src
;
}
else
{
// relative path
localFile
+=
'
'
+
FileNameUtil
.
getPathNoEndSeparator
(
actionPath
)
+
'
'
+
src
;
}
// trim link parameters, if any
int
qmndx
=
localFile
.
indexOf
(
'
'
)
;
if
(
qmndx
!=
1
)
{
localFile
=
localFile
.
substring
(
0
,
qmndx
)
;
}
try
{
content
=
FileUtil
.
readString
(
localFile
)
;
}
catch
(
IOException
ioex
)
{
if
(
notFoundExceptionEnabled
)
{
throw
ioex
;
}
if
(
log
.
isWarnEnabled
(
)
)
{
log
.
warn
(
ioex
.
getMessage
(
)
)
;
}
content
=
;
}
}
else
{
// download local resource
String
localUrl
=
localAddressAndPort
;
if
(
src
.
startsWith
(
StringPool
.
SLASH
)
)
{
localUrl
+=
contextPath
+
src
;
}
else
{
localUrl
+=
contextPath
+
FileNameUtil
.
getPath
(
actionPath
)
+
'
'
+
src
;
}
content
=
downloadString
(
localUrl
)
;
}
if
(
content
!=
)
{
if
(
isCssResource
(
src
)
)
{
content
=
fixCssRelativeUrls
(
content
,
src
)
;
}
}
}
if
(
content
!=
)
{
content
=
onResourceContent
(
content
)
;
sb
.
append
(
content
)
;
}
}
FileUtil
.
writeString
(
bundleFile
,
sb
.
toString
(
)
)
;
if
(
log
.
isInfoEnabled
(
)
)
{
log
.
info
(
"Bundle created: "
+
bundleId
)
;
}
}

Creates bundle file by loading resource files content. If bundle file already
exist it will not be recreated!

Creates bundle file by loading resource files content . If bundle file already exist it will not be recreated!


public synchronized void reset() {
		if (strategy == Strategy.ACTION_MANAGED) {
			actionBundles.clear();
			mirrors.clear();
		}

		final FindFile ff = new FindFile();
		ff.includeDirs(false);
		ff.searchPath(new File(bundleFolder, staplerPath));

		File f;
		int count = 0;
		while ((f = ff.nextFile()) != null) {
			f.delete();
			count++;
		}
		if (log.isInfoEnabled()) {
			log.info("reset: " + count + " bundle files deleted.");
		}
	}

public
synchronized
void
reset
(
)
{
if
(
strategy
==
Strategy
.
ACTION_MANAGED
)
{
actionBundles
.
clear
(
)
;
mirrors
.
clear
(
)
;
}
final
FindFile
ff
=
new
FindFile
(
)
;
ff
.
includeDirs
(
false
)
;
ff
.
searchPath
(
new
File
(
bundleFolder
,
staplerPath
)
)
;
File
f
;
int
count
=
0
;
while
(
(
f
=
ff
.
nextFile
(
)
)
!=
)
{
f
.
delete
(
)
;
count
++
;
}
if
(
log
.
isInfoEnabled
(
)
)
{
log
.
info
(
"reset: "
+
count
+
" bundle files deleted."
)
;
}
}

Clears all settings and removes all created bundle files from file system.

Clears all settings and removes all created bundle files from file system .


protected String fixCssRelativeUrls(final String content, final String src) {
		final String path = FileNameUtil.getPath(src);

		final Matcher matcher = CSS_URL_PATTERN.matcher(content);

		final StringBuilder sb = new StringBuilder(content.length());

		int start = 0;

		while (matcher.find()) {
			sb.append(content, start, matcher.start());

			final String matchedUrl = StringUtil.removeChars(matcher.group(1), "'\"");

			final String url;
			if (matchedUrl.startsWith("https://") || matchedUrl.startsWith("http://") || matchedUrl.startsWith("data:")) {
				url = "url('" + matchedUrl + "')";
			}
			else {
				url = fixRelativeUrl(matchedUrl, path);
			}

			sb.append(url);

			start = matcher.end();
		}

		sb.append(content.substring(start));

		return sb.toString();
	}

protected String fixCssRelativeUrls ( final String content , final String src ) { final String path = FileNameUtil . getPath ( src ) ; final Matcher matcher = CSS_URL_PATTERN . matcher ( content ) ; final StringBuilder sb = new StringBuilder ( content . length ( ) ) ; int start = 0 ; while ( matcher . find ( ) ) { sb . append ( content , start , matcher . start ( ) ) ; final String matchedUrl = StringUtil . removeChars ( matcher . group ( 1 ) , "'\"" ) ; final String url ; if ( matchedUrl . startsWith ( "https://" ) || matchedUrl . startsWith ( "http://" ) || matchedUrl . startsWith ( "data:" ) ) { url = "url('" + matchedUrl + "')" ; } else { url = fixRelativeUrl ( matchedUrl , path ) ; } sb . append ( url ) ; start = matcher . end ( ) ; } sb . append ( content . substring ( start ) ) ; return sb . toString ( ) ; }

Returns the content with all relative URLs fixed.

Returns the content with all relative URLs fixed .


public DbSqlBuilder updateColumn(final Object entity, final String columnRef) {
		final Object value = BeanUtil.pojo.getProperty(entity, columnRef);
		return updateColumn(entity, columnRef, value);
	}

public DbSqlBuilder updateColumn ( final Object entity , final String columnRef ) { final Object value = BeanUtil . pojo . getProperty ( entity , columnRef ) ; return updateColumn ( entity , columnRef , value ) ; }

Reads property value and updates the DB.

Reads property value and updates the DB .


protected static String createTableRefName(final Object entity) {
		Class type = entity.getClass();
		type = (type == Class.class ? (Class) entity : type);
		return (type.getSimpleName() + '_');
	}

protected static String createTableRefName ( final Object entity ) { Class type = entity . getClass ( ) ; type = ( type == Class . class ? ( Class ) entity : type ) ; return ( type . getSimpleName ( ) + ' ' ) ; }

Creates table reference name from entity type.
Always appends an underscore to reference name in order
to circumvent SQL compatibility issues when entity class name
equals to a reserved word.

Creates table reference name from entity type . Always appends an underscore to reference name in order to circumvent SQL compatibility issues when entity class name equals to a reserved word .