01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Mikhail A. Markov
21: * @version $Revision: 1.1.2.3 $
22: */package org.apache.harmony.rmi.common;
23:
24: import java.security.PrivilegedAction;
25:
26: /**
27: * Action for obtaining properties holding long values.
28: *
29: * @author Mikhail A. Markov
30: * @version $Revision: 1.1.2.3 $
31: */
32: public class GetLongPropAction implements PrivilegedAction {
33:
34: // the name of the property to be obtained
35: private String propName;
36:
37: // default value for the property
38: private long defaultVal;
39:
40: /**
41: * Constructs GetLongPropAction to read property with the given name.
42: *
43: * @param propName the name of the property to be read
44: */
45: public GetLongPropAction(String propName) {
46: this (propName, 0);
47: }
48:
49: /**
50: * Constructs GetLongPropAction to read property with the given name.
51: * and specified default value.
52: *
53: * @param propName the name of the property to be read
54: * @param defaultVal default value for the property
55: */
56: public GetLongPropAction(String propName, long defaultVal) {
57: this .propName = propName;
58: this .defaultVal = defaultVal;
59: }
60:
61: /**
62: * Reads the property with the name specified in constructor and returns it
63: * as a result; if value read is null, then default value will be returned.
64: *
65: * @return property read or defaultValue if read property is null
66: */
67: public Object run() {
68: return Long.getLong(propName, defaultVal);
69: }
70: }
|