EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.iapi.services.property]

COVERAGE SUMMARY FOR SOURCE FILE [PropertyValidation.java]

nameclass, %method, %block, %line, %
PropertyValidation.java100% (1/1)50%  (3/6)47%  (85/182)47%  (20/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PropertyValidation100% (1/1)50%  (3/6)47%  (85/182)47%  (20/43)
PropertyValidation (): void 100% (1/1)100% (3/3)100% (2/2)
addPropertySetNotification (PropertySetCallback): void 100% (1/1)100% (15/15)100% (4/4)
doMap (String, Serializable, Dictionary): Serializable 0%   (0/1)0%   (0/34)0%   (0/8)
doValidateApplyAndMap (TransactionController, String, Serializable, Dictionar... 100% (1/1)93%  (67/72)88%  (14/16)
validateSingleProperty (String, Serializable, Dictionary): void 0%   (0/1)0%   (0/32)0%   (0/7)
verifyPropertySet (Properties, Properties): void 0%   (0/1)0%   (0/26)0%   (0/6)

1/*
2 
3   Derby - Class org.apache.derby.iapi.services.property.PropertyValidation
4 
5   Copyright 2000, 2004 The Apache Software Foundation or its licensors, as applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 */
20 
21package org.apache.derby.iapi.services.property;
22 
23import org.apache.derby.iapi.reference.Attribute;
24import org.apache.derby.iapi.reference.Property;
25import org.apache.derby.iapi.reference.SQLState;
26 
27import org.apache.derby.iapi.services.property.PropertyUtil;
28import org.apache.derby.iapi.error.StandardException;
29import org.apache.derby.iapi.services.daemon.Serviceable;
30import org.apache.derby.iapi.services.property.PropertySetCallback;
31import org.apache.derby.iapi.store.access.TransactionController;
32import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
33import java.io.Serializable;
34import java.util.Dictionary;
35import java.util.Enumeration;
36import java.util.Properties;
37import java.util.Vector;
38 
39public class PropertyValidation implements PropertyFactory
40{
41        private Vector  notifyOnSet;
42 
43    /* Constructors for This class: */
44        public PropertyValidation()
45        {
46 
47        }
48 
49        public Serializable doValidateApplyAndMap(TransactionController tc,
50                                                                                         String key, Serializable value,
51                                                                                         Dictionary d, boolean dbOnlyProperty)
52                 throws StandardException
53        {
54                Serializable mappedValue = null;
55                 if (notifyOnSet != null) {
56                        synchronized (this) {
57 
58                                for (int i = 0; i < notifyOnSet.size() ; i++) {
59                                        PropertySetCallback psc = (PropertySetCallback) notifyOnSet.elementAt(i);
60                                        if (!psc.validate(key, value, d))
61                                                continue;
62 
63                                        // if this property should not be used then
64                                        // don't call apply. This depends on where
65                                        // the old value comes from
66                                        // SET_IN_JVM - property will not be used
67                                        // SET_IN_DATABASE - propery will be used
68                                        // SET_IN_APPLICATION - will become SET_IN_DATABASE
69                                        // NOT_SET - will become SET_IN_DATABASE
70 
71                                        if (!dbOnlyProperty && key.startsWith("derby.")) {
72                                                if (PropertyUtil.whereSet(key, d) == PropertyUtil.SET_IN_JVM)
73                                                        continue;
74                                        }
75 
76                                        Serviceable s;
77                                        if ((s = psc.apply(key,value,d)) != null)
78                                                ((TransactionManager) tc).addPostCommitWork(s);
79                                        if (mappedValue == null)
80                                                 mappedValue = psc.map(key, value, d);
81                                }
82                        }
83                }
84                return mappedValue;
85        }
86        /**
87          Call the property set callbacks to map a proposed property value
88          to a value to save.
89          <P>
90          The caller must run this in a block synchronized on this
91          to serialize validations with changes to the set of
92          property callbacks
93          */
94        public Serializable doMap(String key,
95                                                         Serializable value,
96                                                         Dictionary set)
97                 throws StandardException
98        {
99                Serializable mappedValue = null;
100                 if (notifyOnSet != null) {
101                        for (int i = 0; i < notifyOnSet.size() && mappedValue == null; i++) {
102                                PropertySetCallback psc = (PropertySetCallback) notifyOnSet.elementAt(i);
103                                mappedValue = psc.map(key, value, set);
104                        }
105                }
106 
107                if (mappedValue == null)
108                        return value;
109                else
110                        return mappedValue;
111        }
112 
113        public void validateSingleProperty(String key,
114                                                  Serializable value,
115                                                  Dictionary set)
116                 throws StandardException
117        {
118                // RESOLVE: log device cannot be changed on the fly right now
119                if (key.equals(Attribute.LOG_DEVICE))
120        {
121                        throw StandardException.newException(
122                    SQLState.RAWSTORE_CANNOT_CHANGE_LOGDEVICE);
123        }
124 
125                 if (notifyOnSet != null) {
126                        for (int i = 0; i < notifyOnSet.size(); i++) {
127                                PropertySetCallback psc = (PropertySetCallback) notifyOnSet.elementAt(i);
128                                psc.validate(key, value, set);
129                        }
130                }
131        }
132 
133        public synchronized void addPropertySetNotification(PropertySetCallback who){
134 
135                if (notifyOnSet == null)
136                        notifyOnSet = new Vector(1,1);
137                notifyOnSet.addElement(who);
138 
139        }
140 
141        public synchronized void verifyPropertySet(Properties p,Properties ignore)
142                 throws StandardException
143        {
144                for (Enumeration e = p.propertyNames(); e.hasMoreElements();)
145                {
146                        String pn = (String)e.nextElement();
147                        //
148                        //Ignore the ones we are told to ignore.
149                        if (ignore.getProperty(pn) != null) continue;
150                        Serializable pv = p.getProperty(pn);
151                        validateSingleProperty(pn,pv,p);
152                }
153        }
154}
155 
156 
157 

[all classes][org.apache.derby.iapi.services.property]
EMMA 2.0.5312 (C) Vladimir Roubtsov