4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4740 |
05 Feb 09 |
nicklas |
21 |
*/ |
4740 |
05 Feb 09 |
nicklas |
22 |
package net.sf.basedb.util.overview.validator; |
4740 |
05 Feb 09 |
nicklas |
23 |
|
4740 |
05 Feb 09 |
nicklas |
24 |
import net.sf.basedb.core.DbControl; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.util.overview.OverviewContext; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
27 |
|
4740 |
05 Feb 09 |
nicklas |
28 |
/** |
4740 |
05 Feb 09 |
nicklas |
A node validator implementation that accepts all nodes, |
5500 |
18 Nov 10 |
nicklas |
except missing items and denied access items (depending on configuration). |
5500 |
18 Nov 10 |
nicklas |
No validation failures are reported. |
4740 |
05 Feb 09 |
nicklas |
32 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
36 |
*/ |
4740 |
05 Feb 09 |
nicklas |
37 |
public class NullNodeValidator<I> |
4740 |
05 Feb 09 |
nicklas |
38 |
implements NodeValidator<I> |
4740 |
05 Feb 09 |
nicklas |
39 |
{ |
4740 |
05 Feb 09 |
nicklas |
40 |
|
5500 |
18 Nov 10 |
nicklas |
41 |
private boolean acceptDenied; |
5500 |
18 Nov 10 |
nicklas |
42 |
private boolean acceptMissing; |
5500 |
18 Nov 10 |
nicklas |
43 |
|
5500 |
18 Nov 10 |
nicklas |
44 |
/** |
5500 |
18 Nov 10 |
nicklas |
Create a new validator with default settings. |
5500 |
18 Nov 10 |
nicklas |
46 |
*/ |
4740 |
05 Feb 09 |
nicklas |
47 |
public NullNodeValidator() |
4740 |
05 Feb 09 |
nicklas |
48 |
{} |
4740 |
05 Feb 09 |
nicklas |
49 |
|
5500 |
18 Nov 10 |
nicklas |
50 |
/** |
5500 |
18 Nov 10 |
nicklas |
Created a new validator that accepts denied and/or missing nodes. |
5500 |
18 Nov 10 |
nicklas |
@param acceptDenied TRUE to accept denied nodes, FALSE to reject |
5500 |
18 Nov 10 |
nicklas |
@param acceptMissing TRUE to accept missing nodes, FALSE to reject |
5500 |
18 Nov 10 |
nicklas |
@since 2.17 |
5500 |
18 Nov 10 |
nicklas |
55 |
*/ |
5500 |
18 Nov 10 |
nicklas |
56 |
public NullNodeValidator(boolean acceptDenied, boolean acceptMissing) |
5500 |
18 Nov 10 |
nicklas |
57 |
{ |
5500 |
18 Nov 10 |
nicklas |
58 |
this.acceptDenied = acceptDenied; |
5500 |
18 Nov 10 |
nicklas |
59 |
this.acceptMissing = acceptMissing; |
5500 |
18 Nov 10 |
nicklas |
60 |
} |
5500 |
18 Nov 10 |
nicklas |
61 |
|
4740 |
05 Feb 09 |
nicklas |
62 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the NodeValidator interface |
4740 |
05 Feb 09 |
nicklas |
64 |
-------------------------------- |
4740 |
05 Feb 09 |
nicklas |
65 |
*/ |
4740 |
05 Feb 09 |
nicklas |
66 |
/** |
5500 |
18 Nov 10 |
nicklas |
@return TRUE / FALSE depening on the acceptDenied setting (default = false). |
4740 |
05 Feb 09 |
nicklas |
68 |
*/ |
4740 |
05 Feb 09 |
nicklas |
69 |
@Override |
4740 |
05 Feb 09 |
nicklas |
70 |
public boolean preDeniedItem(DbControl dc, OverviewContext context, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
71 |
{ |
5500 |
18 Nov 10 |
nicklas |
72 |
return acceptDenied; |
4740 |
05 Feb 09 |
nicklas |
73 |
} |
4740 |
05 Feb 09 |
nicklas |
74 |
|
4740 |
05 Feb 09 |
nicklas |
75 |
/** |
5500 |
18 Nov 10 |
nicklas |
@return TRUE / FALSE depening on the acceptMissing setting (default = false). |
4740 |
05 Feb 09 |
nicklas |
77 |
*/ |
4740 |
05 Feb 09 |
nicklas |
78 |
@Override |
4740 |
05 Feb 09 |
nicklas |
79 |
public boolean preMissingItem(DbControl dc, OverviewContext context, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
80 |
{ |
6047 |
18 Apr 12 |
nicklas |
81 |
return acceptMissing; |
4740 |
05 Feb 09 |
nicklas |
82 |
} |
4740 |
05 Feb 09 |
nicklas |
83 |
|
4740 |
05 Feb 09 |
nicklas |
84 |
/** |
4740 |
05 Feb 09 |
nicklas |
@return Always true |
4740 |
05 Feb 09 |
nicklas |
86 |
*/ |
4740 |
05 Feb 09 |
nicklas |
87 |
@Override |
4740 |
05 Feb 09 |
nicklas |
88 |
public boolean preValidate(DbControl dc, OverviewContext context, I item, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
89 |
{ |
4740 |
05 Feb 09 |
nicklas |
90 |
return true; |
4740 |
05 Feb 09 |
nicklas |
91 |
} |
4740 |
05 Feb 09 |
nicklas |
92 |
|
4740 |
05 Feb 09 |
nicklas |
93 |
/** |
4740 |
05 Feb 09 |
nicklas |
Do nothing. |
4740 |
05 Feb 09 |
nicklas |
95 |
*/ |
4740 |
05 Feb 09 |
nicklas |
96 |
@Override |
4740 |
05 Feb 09 |
nicklas |
97 |
public void postMissingItem(DbControl dc, OverviewContext context, Node node, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
98 |
{} |
4740 |
05 Feb 09 |
nicklas |
99 |
|
4740 |
05 Feb 09 |
nicklas |
100 |
/** |
4740 |
05 Feb 09 |
nicklas |
Do nothing. |
4740 |
05 Feb 09 |
nicklas |
102 |
*/ |
4740 |
05 Feb 09 |
nicklas |
103 |
@Override |
4740 |
05 Feb 09 |
nicklas |
104 |
public void postDeniedItem(DbControl dc, OverviewContext context, Node node, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
105 |
{} |
4740 |
05 Feb 09 |
nicklas |
106 |
|
4740 |
05 Feb 09 |
nicklas |
107 |
/** |
4740 |
05 Feb 09 |
nicklas |
Do nothing. |
4740 |
05 Feb 09 |
nicklas |
109 |
*/ |
4740 |
05 Feb 09 |
nicklas |
110 |
@Override |
4740 |
05 Feb 09 |
nicklas |
111 |
public void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
112 |
{} |
4740 |
05 Feb 09 |
nicklas |
113 |
|
4740 |
05 Feb 09 |
nicklas |
114 |
/** |
4740 |
05 Feb 09 |
nicklas |
Do nothing. |
4740 |
05 Feb 09 |
nicklas |
116 |
*/ |
4740 |
05 Feb 09 |
nicklas |
117 |
@Override |
4740 |
05 Feb 09 |
nicklas |
118 |
public void postValidateFolder(DbControl dc, OverviewContext context, Node folderNode, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
119 |
{} |
4740 |
05 Feb 09 |
nicklas |
120 |
// ------------------------------------- |
4740 |
05 Feb 09 |
nicklas |
121 |
|
4740 |
05 Feb 09 |
nicklas |
122 |
} |