in plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java [241:585]
private static boolean parseLimit( SizeLimitWrapper slw, String limitStr )
{
int pos = 0;
// The sizelimit always starts with a "size"
if ( limitStr.startsWith( "size" ) )
{
pos += 4;
// A global or hard/soft/pr/prtotal ?
if ( limitStr.startsWith( "=", pos ) )
{
// Global : get the limit
pos++;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.globalLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.globalLimit = UNLIMITED;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
pos += integer.length();
try
{
Integer value = Integer.valueOf( integer );
if ( value > UNLIMITED )
{
slw.globalLimit = value;
}
else
{
return false;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else if ( limitStr.startsWith( ".hard=", pos ) )
{
// Hard limit : get the hard limit
pos += 6;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.hardLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.hardLimit = UNLIMITED;
}
else if ( limitStr.startsWith( SOFT_STR, pos ) )
{
pos += 4;
slw.globalLimit = HARD_SOFT;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
pos += integer.length();
try
{
Integer value = Integer.valueOf( integer );
if ( value >= UNLIMITED )
{
slw.hardLimit = value;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else if ( limitStr.startsWith( ".soft=", pos ) )
{
// Soft limit : get the limit
pos += 6;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.softLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.softLimit = UNLIMITED;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
try
{
pos += integer.length();
Integer value = Integer.valueOf( integer );
if ( value > UNLIMITED )
{
slw.softLimit = value;
}
else
{
return false;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else if ( limitStr.startsWith( ".unchecked=", pos ) )
{
// Unchecked limit : get the limit
pos += 11;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.uncheckedLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.uncheckedLimit = UNLIMITED;
}
else if ( limitStr.startsWith( DISABLED_STR, pos ) )
{
pos += 8;
slw.uncheckedLimit = UC_DISABLED;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
try
{
pos += integer.length();
Integer value = Integer.valueOf( integer );
if ( value > UNLIMITED )
{
slw.uncheckedLimit = value;
}
else
{
return false;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else if ( limitStr.startsWith( ".pr=", pos ) )
{
// pr limit : get the limit
pos += 4;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.prLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.prLimit = UNLIMITED;
}
else if ( limitStr.startsWith( "noestimate", pos ) )
{
pos += 10;
slw.noEstimate = true;
}
else if ( limitStr.startsWith( DISABLED_STR, pos ) )
{
pos += 8;
slw.prLimit = PR_DISABLED;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
try
{
pos += integer.length();
Integer value = Integer.valueOf( integer );
if ( value > UNLIMITED )
{
slw.prLimit = value;
}
else
{
return false;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else if ( limitStr.startsWith( ".prtotal=", pos ) )
{
// prTotal limit : get the limit
pos += 9;
if ( limitStr.startsWith( UNLIMITED_STR, pos ) )
{
pos += 9;
slw.prTotalLimit = UNLIMITED;
}
else if ( limitStr.startsWith( NONE_STR, pos ) )
{
pos += 4;
slw.prTotalLimit = UNLIMITED;
}
else if ( limitStr.startsWith( DISABLED_STR, pos ) )
{
pos += 8;
slw.prTotalLimit = PR_DISABLED;
}
else if ( limitStr.startsWith( HARD_STR, pos ) )
{
pos += 4;
slw.prTotalLimit = PR_HARD;
}
else
{
String integer = getInteger( limitStr, pos );
if ( integer != null )
{
try
{
pos += integer.length();
Integer value = Integer.valueOf( integer );
if ( value > UNLIMITED )
{
slw.prTotalLimit = value;
}
else
{
return false;
}
}
catch ( NumberFormatException nfe )
{
return false;
}
}
else
{
return false;
}
}
}
else
{
// This is wrong
return false;
}
}
else
{
// This is wrong
return false;
}
// last check : the pos should be equal to the limitStr length
return ( pos == limitStr.length() );
}