public class SessionContext extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static String |
CURRENCY |
static String |
CURRENTDATE |
static String |
CURRENTDATE_VALID_TO |
static String |
LANGUAGE |
static String |
LOCALE |
static String |
PRICEFACTORY |
static String |
TIMEOFFSET
The name of the attribute which stores the time offset in milliseconds.
|
static String |
TIMEZONE |
static String |
TRANSACTION_4_ALLATTRIBUTES |
static String |
TRANSACTION_IN_CREATE_DISABLED
Setting this attribute to 'TRUE' will DISABLE the execution of Item#newInstance( SessionContext, JaloSession,
ComposedType, Map ) inside a transaction.
|
static String |
USER |
static Long |
ZERO_TIME_OFFSET |
| Modifier | Constructor and Description |
|---|---|
|
SessionContext() |
|
SessionContext(SessionContext context) |
protected |
SessionContext(SessionContext context,
boolean asLocal) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAllAttributes(Map<String,? extends Object> attributes) |
boolean |
equals(Object object) |
protected void |
fixStaleItemsInContext() |
protected <T> T |
fixStaleItemsInValue(String name,
T currentValue) |
Date |
getAdjustedCurrentDate()
Returns the current time ( see
getAdjustedCurrentTime() ) with hours, minutes, seconds and milliseconds
normalized to zero. |
protected long |
getAdjustedCurrentDateMillis() |
Date |
getAdjustedCurrentTime()
Returns the adjusted current time relative to time set by calling
setCurrentTime(Date) early. |
protected long |
getAdjustedCurrentTimeMillis() |
Collection<String> |
getAllAttributeNames() |
<T> T |
getAttribute(String name)
Returns the attribute mapped to key 'name'
|
Enumeration |
getAttributeNames()
Deprecated.
|
Map<String,Object> |
getAttributes()
Returns a unmodifiable copy of the session attributes
|
Currency |
getCurrency()
Method getCurrency
|
protected long |
getCurrentTimeMillis()
Override for testing only !
|
Language |
getLanguage()
Returns the language currently associated with this session context.
|
Locale |
getLocale()
Returns the
Locale which matches the current language settings best. |
PriceFactory |
getPriceFactory()
Method getPriceFactory
|
long |
getTimeOffset()
Returns the time offset in milliseconds.
|
TimeZone |
getTimeZone()
Returns the
TimeZone which is currently associated with this session context. |
User |
getUser()
Method getUser
|
int |
hashCode() |
protected void |
initializeOnSessionStartup(User user,
Language language,
Currency currency,
TimeZone timeZone,
PriceFactory injectedPriceFactory) |
Object |
removeAttribute(String name)
Method removeAttribute
|
Object |
setAttribute(String name,
Object value)
Method setAttribute
|
void |
setAttributes(Map<String,? extends Object> attributes)
Method setAttributes
|
void |
setCurrency(Currency currency)
Method setCurrency
|
void |
setCurrentTime(Date timeInstance)
Set the given timeInstance as the current time.
|
void |
setCurrentTimeSystem()
Set the current time back to system time
|
void |
setLanguage(Language language)
Method setLanguage
|
void |
setLocale(Locale loc)
Changes the
Locale which should be associated with this session context. |
void |
setPriceFactory(PriceFactory pricefactory)
Method setPriceFactory
|
protected void |
setSession(JaloSession session) |
void |
setSessionContextValues(SessionContext ctx) |
void |
setTimeZome(TimeZone timezone)
Deprecated.
use
setTimeZone(TimeZone) instead |
void |
setTimeZone(TimeZone timezone)
Changes the time zone which is associated with this session context.
|
void |
setUser(User user)
Method setUser
|
String |
toString() |
public static final String USER
public static final String LANGUAGE
public static final String CURRENCY
public static final String PRICEFACTORY
public static final String LOCALE
public static final String TIMEZONE
public static final Long ZERO_TIME_OFFSET
public static final String TIMEOFFSET
public static final String CURRENTDATE
public static final String CURRENTDATE_VALID_TO
public static final String TRANSACTION_IN_CREATE_DISABLED
Sample:
ctx.setAttribute( SessionContext.TRANSACTION_IN_CREATE_DISABLED, Boolean.TRUE );
public static final String TRANSACTION_4_ALLATTRIBUTES
public SessionContext()
public SessionContext(SessionContext context)
protected SessionContext(SessionContext context, boolean asLocal)
protected void setSession(JaloSession session)
protected void initializeOnSessionStartup(User user, Language language, Currency currency, TimeZone timeZone, PriceFactory injectedPriceFactory)
public void setSessionContextValues(SessionContext ctx)
public void setLanguage(Language language)
language - public Language getLanguage()
public Locale getLocale()
Locale which matches the current language settings best. This affects all data formatting
logic within the hybris platform ( like Currency.formatPrice(double) ). The algorithm works as follows:
setLocale(Locale) : return it directlyLanguage.getLocale() returns a non-null locale: return this
language dependent localeLocale.getDefault().public void setLocale(Locale loc)
Locale which should be associated with this session context. This affects all data formatting
logic within the hybris platform ( like Currency.formatPrice(double) ).public TimeZone getTimeZone()
TimeZone which is currently associated with this session context. If no time zone has been set
via setTimeZome(TimeZone) the default vm time zone is returned (see TimeZone.getDefault(). This
affects all date formatting and parsing logic within the hybris platform.public long getTimeOffset()
setCurrentTime(Date), a value of
zero is returned.@Deprecated public void setTimeZome(TimeZone timezone)
setTimeZone(TimeZone) insteadpublic void setTimeZone(TimeZone timezone)
public void setCurrency(Currency currency)
currency - public Currency getCurrency()
public void setUser(User user)
user - public User getUser()
public void setPriceFactory(PriceFactory pricefactory)
pricefactory - public PriceFactory getPriceFactory()
public void setAttributes(Map<String,? extends Object> attributes)
attributes - public Map<String,Object> getAttributes()
protected void fixStaleItemsInContext()
public <T> T getAttribute(String name)
protected <T> T fixStaleItemsInValue(String name, T currentValue)
@Deprecated public Enumeration getAttributeNames()
getAllAttributeNames() instead.public Collection<String> getAllAttributeNames()
public void setCurrentTime(Date timeInstance)
protected long getCurrentTimeMillis()
public Date getAdjustedCurrentTime()
setCurrentTime(Date) early. If
setCurrentTime(Date) was never called before, then current system time is returned.protected long getAdjustedCurrentTimeMillis()
public void setCurrentTimeSystem()
public Date getAdjustedCurrentDate()
getAdjustedCurrentTime() ) with hours, minutes, seconds and milliseconds
normalized to zero.protected long getAdjustedCurrentDateMillis()
Copyright © 2017 SAP SE. All Rights Reserved.