下面列出了org.hibernate.internal.util.collections.ArrayHelper#toIntArray ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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 );
}
}
private NamedParameterDescriptor complete() {
return new NamedParameterDescriptor(
name,
null,
ArrayHelper.toIntArray( sourcePositions )
);
}
private OrdinalParameterDescriptor complete() {
return new OrdinalParameterDescriptor(
identifier,
identifier - 1,
null,
ArrayHelper.toIntArray( sourcePositions )
);
}
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 );
}
@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 );
}
}
@Override
public int[] getSourceLocations() {
return ArrayHelper.toIntArray( sqlPositions );
}
@Override
public int[] getSourceLocations() {
return ArrayHelper.toIntArray( sourceLocations );
}
@Override
public int[] getSourceLocations() {
return ArrayHelper.toIntArray( sqlPositions );
}