forked from DeBortoliWines/openerp-java-api
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathContext.java
More file actions
112 lines (96 loc) · 3.06 KB
/
Copy pathContext.java
File metadata and controls
112 lines (96 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright 2011, 2013-2014 De Bortoli Wines Pty Limited (Australia)
*
* This file is part of OpenERPJavaAPI.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.odoojava.api;
import java.util.HashMap;
import java.util.Map;
/**
* Provides the session context object that is used in calls to the server.
*
* @author Pieter van der Merwe
*/
public class Context extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
final static String ActiveTestTag = "active_test";
final static String LangTag = "lang";
final static String TimezoneTag = "tz";
@Override
public void putAll(Map<? extends String, ? extends Object> m) {
// TODO Auto-generated method stub
super.putAll(m);
}
/**
* Gets the active_test context property.
*
* @return The active_test value or null if the property doesn't exist.
*/
public Boolean getActiveTest() {
if (!this.containsKey(ActiveTestTag))
return null;
return Boolean.parseBoolean(this.get(ActiveTestTag).toString());
}
/**
* Sets the active_test context value. If true, only active items are returned by default when calling the ReadObject item.
*
* @param active_test
*/
public void setActiveTest(boolean active_test) {
this.remove(ActiveTestTag);
this.put(ActiveTestTag, active_test);
}
/**
* Gets the 'lang' context value.
*
* @return Language or null if the property doesn't exist.
*/
public String getLanguage() {
if (!this.containsKey(LangTag))
return null;
return this.get(LangTag).toString();
}
/**
* Sets the 'lang' context value.
*
* @param lang Examples "en_US", "nl_NL"
*/
public void setLanguage(String lang) {
this.remove(LangTag);
this.put(LangTag, lang);
}
/**
* Gets the 'tz' context value.
*
* @return Time zone string or null if the property doesn't exist
*/
public String getTimeZone() {
if (!this.containsKey(TimezoneTag))
return null;
if (this.get(TimezoneTag) instanceof Boolean && Boolean.getBoolean(this.get(TimezoneTag).toString()) == false)
return null;
return this.get(TimezoneTag).toString();
}
/**
* Sets the 'tz' context flag.
*
* @param tz Examples "Australia/Sydney", "Europe/Brussels"
*/
public void setTimeZone(String tz) {
this.remove(TimezoneTag);
this.put(TimezoneTag, tz);
}
}