Java Code Examples for org.hibernate.internal.util.collections.ArrayHelper#toIntArray()

The following examples show how to use org.hibernate.internal.util.collections.ArrayHelper#toIntArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HqlSqlWalker.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the locations of all occurrences of the named parameter.
 */
public int[] getNamedParameterLocations(String name) throws QueryException {
	Object o = namedParameters.get( name );
	if ( o == null ) {
		throw new QueryException(
				QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name,
				queryTranslatorImpl.getQueryString()
		);
	}
	if ( o instanceof Integer ) {
		return new int[] {(Integer) o};
	}
	else {
		return ArrayHelper.toIntArray( (ArrayList) o );
	}
}
 
Example 2
Source File: ParamLocationRecognizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private NamedParameterDescriptor complete() {
	return new NamedParameterDescriptor(
			name,
			null,
			ArrayHelper.toIntArray( sourcePositions )
	);
}
 
Example 3
Source File: ParamLocationRecognizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private OrdinalParameterDescriptor complete() {
	return new OrdinalParameterDescriptor(
			identifier,
			identifier - 1,
			null,
			ArrayHelper.toIntArray( sourcePositions )
	);
}
 
Example 4
Source File: StringHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static int[] locateUnquoted(String string, char character) {
	if ( '\'' == character ) {
		throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
	}
	if ( string == null ) {
		return new int[0];
	}

	ArrayList locations = new ArrayList( 20 );

	// Impl note: takes advantage of the fact that an escpaed single quote
	// embedded within a quote-block can really be handled as two seperate
	// quote-blocks for the purposes of this method...
	int stringLength = string.length();
	boolean inQuote = false;
	for ( int indx = 0; indx < stringLength; indx++ ) {
		char c = string.charAt( indx );
		if ( inQuote ) {
			if ( '\'' == c ) {
				inQuote = false;
			}
		}
		else if ( '\'' == c ) {
			inQuote = true;
		}
		else if ( c == character ) {
			locations.add( indx );
		}
	}
	return ArrayHelper.toIntArray( locations );
}
 
Example 5
Source File: QueryTranslatorImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int[] getNamedParameterLocs(String name) throws QueryException {
	Object o = namedParameters.get( name );
	if ( o == null ) {
		throw new QueryException( ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name, queryString );
	}
	if ( o instanceof Integer ) {
		return new int[] {(Integer) o};
	}
	else {
		return ArrayHelper.toIntArray( (ArrayList) o );
	}
}
 
Example 6
Source File: NamedParameterInformationImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int[] getSourceLocations() {
	return ArrayHelper.toIntArray( sqlPositions );
}
 
Example 7
Source File: PositionalParameterInformationImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int[] getSourceLocations() {
	return ArrayHelper.toIntArray( sourceLocations );
}
 
Example 8
Source File: AbstractParameterInformation.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int[] getSourceLocations() {
	return ArrayHelper.toIntArray( sqlPositions );
}