1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 import com
.sun
.star
.uno
.AnyConverter
;
4 /*************************************************************************
6 * The Contents of this file are made available subject to the terms of
9 * Copyright 2000, 2010 Oracle and/or its affiliates.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
31 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
34 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *************************************************************************/
38 public class BooleanValidator
extends ControlValidator
40 private boolean m_preventChecked
;
42 /** Creates a new instance of BooleanValidator */
43 public BooleanValidator( boolean preventChecked
)
45 m_preventChecked
= preventChecked
;
48 public String
explainInvalid( Object Value
)
52 if ( AnyConverter
.isVoid( Value
) )
53 return "'indetermined' is not an allowed state";
54 boolean value
= ((Boolean
)Value
).booleanValue();
55 if ( m_preventChecked
&& ( value
== true ) )
56 return "no no no. Don't check it.";
58 catch( java
.lang
.Exception e
)
60 return "ooops. Unknown error";
65 public boolean isValid( Object Value
)
69 if ( AnyConverter
.isVoid( Value
) )
72 boolean value
= ((Boolean
)Value
).booleanValue();
73 if ( m_preventChecked
&& ( value
== true ) )
77 catch( java
.lang
.Exception e
)
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */