You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2017/03/12 05:03:37 UTC
svn commit: r1786559 -
/directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java
Author: elecharny
Date: Sun Mar 12 05:03:37 2017
New Revision: 1786559
URL: http://svn.apache.org/viewvc?rev=1786559&view=rev
Log:
o Improved the getRawValue() to accept a null value
o Added a doSetValue() method to store a valid value when we have anull value
o Improved the doGetValue() method
Modified:
directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java
Modified: directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java?rev=1786559&r1=1786558&r2=1786559&view=diff
==============================================================================
--- directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java (original)
+++ directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/bool/InPlaceBooleanValueEditor.java Sun Mar 12 05:03:37 2017
@@ -44,29 +44,32 @@ public class InPlaceBooleanValueEditor e
/**
* {@inheritDoc}
*/
+ @Override
protected Object doGetValue()
{
Object value = super.doGetValue();
if ( value instanceof String )
{
- String stringValue = ( String ) value;
-
- if ( EMPTY.equals( stringValue ) )
- {
- return null;
- }
- else if ( "TRUE".equalsIgnoreCase( stringValue ) || "T".equalsIgnoreCase( stringValue )
- || "YES".equalsIgnoreCase( stringValue ) || "Y".equalsIgnoreCase( stringValue )
- || "1".equalsIgnoreCase( stringValue ) )
- {
- return TRUE;
- }
- else if ( "FALSE".equalsIgnoreCase( stringValue ) || "F".equalsIgnoreCase( stringValue )
- || "NO".equalsIgnoreCase( stringValue ) || "N".equalsIgnoreCase( stringValue )
- || "0".equalsIgnoreCase( stringValue ) )
+ String stringValue = ( ( String ) value ).toUpperCase();
+
+ switch ( stringValue )
{
- return FALSE;
+ case "T" :
+ case "TRUE" :
+ case "Y" :
+ case "YES" :
+ case "1" :
+ case "" : // Special case : default to TRUE
+ default :
+ return TRUE;
+
+ case "F" :
+ case "FALSE" :
+ case "N" :
+ case "NO" :
+ case "0" :
+ return FALSE;
}
}
@@ -74,19 +77,53 @@ public class InPlaceBooleanValueEditor e
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void doSetValue( Object value )
+ {
+ Object v = value;
+
+ if ( value instanceof IValue.EmptyValue )
+ {
+ v = ( ( IValue.EmptyValue ) value ).getStringValue();
+ }
+
+ if ( value == null )
+ {
+ v = "TRUE";
+ }
+
+ super.doSetValue( v );
+ }
+
+
@Override
public Object getRawValue( IValue value )
{
Object rawValue = super.getRawValue( value );
- if ( rawValue instanceof String && new BooleanSyntaxChecker().isValidSyntax( rawValue ) )
+ if ( rawValue instanceof String )
+ {
+ String stringValue = ( String ) rawValue;
+
+ if ( ( stringValue.length() == 0 ) || ( BooleanSyntaxChecker.INSTANCE.isValidSyntax( stringValue ) ) )
+ {
+ return TRUE;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if ( rawValue == null )
{
- return rawValue;
+ return TRUE;
}
else
{
return null;
}
}
-
}