本文整理了Java中org.springframework.core.Constants.asNumber()
方法的一些代码示例,展示了Constants.asNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constants.asNumber()
方法的具体详情如下:
包路径:org.springframework.core.Constants
类名称:Constants
方法名:asNumber
[英]Return a constant value cast to a Number.
[中]将常量值转换为数字。
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the system property mode by the name of the corresponding constant,
* e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
* @param constantName name of the constant
* @see #setSystemPropertiesMode
*/
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
this.systemPropertiesMode = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the misfire instruction via the name of the corresponding
* constant in the {@link org.quartz.CronTrigger} class.
* Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}.
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING
* @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY
*/
public void setMisfireInstructionName(String constantName) {
this.misfireInstruction = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the misfire instruction via the name of the corresponding
* constant in the {@link org.quartz.SimpleTrigger} class.
* Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}.
* @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_FIRE_NOW
* @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT
* @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT
* @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT
* @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
* @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY
*/
public void setMisfireInstructionName(String constantName) {
this.misfireInstruction = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the autodetection mode to use by name.
* @throws IllegalArgumentException if the supplied value is not resolvable
* to one of the {@code AUTODETECT_} constants or is {@code null}
* @see #setAutodetectMode(int)
* @see #AUTODETECT_ALL
* @see #AUTODETECT_ASSEMBLER
* @see #AUTODETECT_MBEAN
* @see #AUTODETECT_NONE
*/
public void setAutodetectModeName(String constantName) {
if (!constantName.startsWith(CONSTANT_PREFIX_AUTODETECT)) {
throw new IllegalArgumentException("Only autodetect constants allowed");
}
this.autodetectMode = (Integer) constants.asNumber(constantName);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the transaction synchronization by the name of the corresponding constant
* in this class, e.g. "SYNCHRONIZATION_ALWAYS".
* @param constantName name of the constant
* @see #SYNCHRONIZATION_ALWAYS
*/
public final void setTransactionSynchronizationName(String constantName) {
setTransactionSynchronization(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the validation mode to use by name. Defaults to {@link #VALIDATION_AUTO}.
* @see #setValidationMode
*/
public void setValidationModeName(String validationModeName) {
setValidationMode(constants.asNumber(validationModeName).intValue());
}
代码示例来源:origin: org.springframework/spring-beans
/**
* Set the system property mode by the name of the corresponding constant,
* e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
* @param constantName name of the constant
* @see #setSystemPropertiesMode
*/
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
this.systemPropertiesMode = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Specify the level of caching that this listener container is allowed to apply,
* in the form of the name of the corresponding constant: e.g. "CACHE_CONNECTION".
* @see #setCacheLevel
*/
public void setCacheLevelName(String constantName) throws IllegalArgumentException {
if (!constantName.startsWith("CACHE_")) {
throw new IllegalArgumentException("Only cache constants allowed");
}
setCacheLevel(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Supports Integer values for the isolation level constants
* as well as isolation level names as defined on the
* {@link org.springframework.transaction.TransactionDefinition TransactionDefinition interface}.
*/
@Override
protected Object resolveSpecifiedLookupKey(Object lookupKey) {
if (lookupKey instanceof Integer) {
return lookupKey;
}
else if (lookupKey instanceof String) {
String constantName = (String) lookupKey;
if (!constantName.startsWith(DefaultTransactionDefinition.PREFIX_ISOLATION)) {
throw new IllegalArgumentException("Only isolation constants allowed");
}
return constants.asNumber(constantName);
}
else {
throw new IllegalArgumentException(
"Invalid lookup key - needs to be isolation level Integer or isolation level name String: " + lookupKey);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the default transaction isolation level by the name of the corresponding
* constant in {@link java.sql.Connection}, e.g. "TRANSACTION_SERIALIZABLE".
* @param constantName name of the constant
* @see #setDefaultTransactionIsolation
* @see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED
* @see java.sql.Connection#TRANSACTION_READ_COMMITTED
* @see java.sql.Connection#TRANSACTION_REPEATABLE_READ
* @see java.sql.Connection#TRANSACTION_SERIALIZABLE
*/
public void setDefaultTransactionIsolationName(String constantName) {
setDefaultTransactionIsolation(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the JMS acknowledgement mode by the name of the corresponding constant
* in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE".
* <p>If you want to use vendor-specific extensions to the acknowledgment mode,
* use {@link #setSessionAcknowledgeMode(int)} instead.
* @param constantName the name of the {@link Session} acknowledge mode constant
* @see javax.jms.Session#AUTO_ACKNOWLEDGE
* @see javax.jms.Session#CLIENT_ACKNOWLEDGE
* @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE
* @see javax.jms.Connection#createSession(boolean, int)
*/
public void setSessionAcknowledgeModeName(String constantName) {
setSessionAcknowledgeMode(sessionConstants.asNumber(constantName).intValue());
}
代码示例来源:origin: org.springframework/spring-context-support
/**
* Set the misfire instruction via the name of the corresponding
* constant in the {@link org.quartz.CronTrigger} class.
* Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}.
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING
* @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY
*/
public void setMisfireInstructionName(String constantName) {
this.misfireInstruction = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the propagation behavior by the name of the corresponding constant in
* TransactionDefinition, e.g. "PROPAGATION_REQUIRED".
* @param constantName name of the constant
* @throws IllegalArgumentException if the supplied value is not resolvable
* to one of the {@code PROPAGATION_} constants or is {@code null}
* @see #setPropagationBehavior
* @see #PROPAGATION_REQUIRED
*/
public final void setPropagationBehaviorName(String constantName) throws IllegalArgumentException {
if (!constantName.startsWith(PREFIX_PROPAGATION)) {
throw new IllegalArgumentException("Only propagation constants allowed");
}
setPropagationBehavior(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the isolation level by the name of the corresponding constant in
* TransactionDefinition, e.g. "ISOLATION_DEFAULT".
* @param constantName name of the constant
* @throws IllegalArgumentException if the supplied value is not resolvable
* to one of the {@code ISOLATION_} constants or is {@code null}
* @see #setIsolationLevel
* @see #ISOLATION_DEFAULT
*/
public final void setIsolationLevelName(String constantName) throws IllegalArgumentException {
if (!constantName.startsWith(PREFIX_ISOLATION)) {
throw new IllegalArgumentException("Only isolation constants allowed");
}
setIsolationLevel(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: org.springframework/spring-context
/**
* Set the autodetection mode to use by name.
* @throws IllegalArgumentException if the supplied value is not resolvable
* to one of the {@code AUTODETECT_} constants or is {@code null}
* @see #setAutodetectMode(int)
* @see #AUTODETECT_ALL
* @see #AUTODETECT_ASSEMBLER
* @see #AUTODETECT_MBEAN
* @see #AUTODETECT_NONE
*/
public void setAutodetectModeName(String constantName) {
if (!constantName.startsWith(CONSTANT_PREFIX_AUTODETECT)) {
throw new IllegalArgumentException("Only autodetect constants allowed");
}
this.autodetectMode = (Integer) constants.asNumber(constantName);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the JMS acknowledgement mode by the name of the corresponding constant
* in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE".
* <p>Note that JCA resource adapters generally only support auto and dups-ok
* (see Spring's {@link StandardJmsActivationSpecFactory}). ActiveMQ also
* supports "SESSION_TRANSACTED" in the form of RA-managed transactions
* (automatically translated by Spring's {@link DefaultJmsActivationSpecFactory}.
* @param constantName the name of the {@link Session} acknowledge mode constant
* @see javax.jms.Session#AUTO_ACKNOWLEDGE
* @see javax.jms.Session#CLIENT_ACKNOWLEDGE
* @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE
* @see javax.jms.Session#SESSION_TRANSACTED
* @see StandardJmsActivationSpecFactory
* @see DefaultJmsActivationSpecFactory
*/
public void setAcknowledgeModeName(String constantName) {
setAcknowledgeMode(sessionConstants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the default isolation level by the name of the corresponding constant
* in {@link org.springframework.transaction.TransactionDefinition}, e.g.
* "ISOLATION_SERIALIZABLE".
* <p>If not specified, the target DataSource's default will be used.
* Note that a transaction-specific isolation value will always override
* any isolation setting specified at the DataSource level.
* @param constantName name of the constant
* @see org.springframework.transaction.TransactionDefinition#ISOLATION_READ_UNCOMMITTED
* @see org.springframework.transaction.TransactionDefinition#ISOLATION_READ_COMMITTED
* @see org.springframework.transaction.TransactionDefinition#ISOLATION_REPEATABLE_READ
* @see org.springframework.transaction.TransactionDefinition#ISOLATION_SERIALIZABLE
* @see #setIsolationLevel
*/
public final void setIsolationLevelName(String constantName) throws IllegalArgumentException {
if (!constantName.startsWith(DefaultTransactionDefinition.PREFIX_ISOLATION)) {
throw new IllegalArgumentException("Only isolation constants allowed");
}
setIsolationLevel(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: org.springframework/spring-beans
/**
* Set the validation mode to use by name. Defaults to {@link #VALIDATION_AUTO}.
* @see #setValidationMode
*/
public void setValidationModeName(String validationModeName) {
setValidationMode(constants.asNumber(validationModeName).intValue());
}
代码示例来源:origin: org.springframework/spring-tx
/**
* Set the transaction synchronization by the name of the corresponding constant
* in this class, e.g. "SYNCHRONIZATION_ALWAYS".
* @param constantName name of the constant
* @see #SYNCHRONIZATION_ALWAYS
*/
public final void setTransactionSynchronizationName(String constantName) {
setTransactionSynchronization(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void constants() {
Constants c = new Constants(A.class);
assertEquals(A.class.getName(), c.getClassName());
assertEquals(9, c.getSize());
assertEquals(A.DOG, c.asNumber("DOG").intValue());
assertEquals(A.DOG, c.asNumber("dog").intValue());
assertEquals(A.CAT, c.asNumber("cat").intValue());
try {
c.asNumber("bogus");
fail("Can't get bogus field");
}
catch (Constants.ConstantException expected) {
}
assertTrue(c.asString("S1").equals(A.S1));
try {
c.asNumber("S1");
fail("Wrong type");
}
catch (Constants.ConstantException expected) {
}
}
内容来源于网络,如有侵权,请联系作者删除!