本文整理了Java中org.springframework.core.Constants.toCode()
方法的一些代码示例,展示了Constants.toCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constants.toCode()
方法的具体详情如下:
包路径:org.springframework.core.Constants
类名称:Constants
方法名:toCode
[英]Look up the given value within the given group of constants.
Will return the first match.
[中]在给定的常数组中查找给定值。
将返回第一场比赛。
代码示例来源:origin: spring-projects/spring-framework
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: spring-projects/spring-framework
Constants c = new Constants(A.class);
assertEquals("DOG", c.toCode(Integer.valueOf(0), ""));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "D"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "DO"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "DoG"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), null));
assertEquals("CAT", c.toCode(Integer.valueOf(66), ""));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "C"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "ca"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "cAt"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), null));
assertEquals("S1", c.toCode("", ""));
assertEquals("S1", c.toCode("", "s"));
assertEquals("S1", c.toCode("", "s1"));
assertEquals("S1", c.toCode("", null));
try {
c.toCode("bogus", "bogus");
fail("Should have thrown ConstantException");
c.toCode("bogus", null);
fail("Should have thrown ConstantException");
代码示例来源:origin: spring-projects/spring-framework
/**
* Return an identifying description for this transaction definition.
* <p>Available to subclasses, for inclusion in their {@code toString()} result.
*/
protected final StringBuilder getDefinitionDescription() {
StringBuilder result = new StringBuilder();
result.append(constants.toCode(this.propagationBehavior, PREFIX_PROPAGATION));
result.append(',');
result.append(constants.toCode(this.isolationLevel, PREFIX_ISOLATION));
if (this.timeout != TIMEOUT_DEFAULT) {
result.append(',');
result.append(PREFIX_TIMEOUT).append(this.timeout);
}
if (this.readOnly) {
result.append(',');
result.append(READ_ONLY_MARKER);
}
return result;
}
代码示例来源:origin: org.springframework/spring-core
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: org.springframework/spring-tx
/**
* Return an identifying description for this transaction definition.
* <p>Available to subclasses, for inclusion in their {@code toString()} result.
*/
protected final StringBuilder getDefinitionDescription() {
StringBuilder result = new StringBuilder();
result.append(constants.toCode(this.propagationBehavior, PREFIX_PROPAGATION));
result.append(',');
result.append(constants.toCode(this.isolationLevel, PREFIX_ISOLATION));
if (this.timeout != TIMEOUT_DEFAULT) {
result.append(',');
result.append(PREFIX_TIMEOUT).append(this.timeout);
}
if (this.readOnly) {
result.append(',');
result.append(READ_ONLY_MARKER);
}
return result;
}
代码示例来源:origin: spring-projects/spring-framework
definition + "] specifies isolation level which is incompatible with existing transaction: " +
(currentIsolationLevel != null ?
isoConstants.toCode(currentIsolationLevel, DefaultTransactionDefinition.PREFIX_ISOLATION) :
"(unknown)"));
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: org.springframework/spring-tx
definition + "] specifies isolation level which is incompatible with existing transaction: " +
(currentIsolationLevel != null ?
isoConstants.toCode(currentIsolationLevel, DefaultTransactionDefinition.PREFIX_ISOLATION) :
"(unknown)"));
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Returns a String representation for the given bundle event.
*
* @param eventType OSGi <code>BundleEvent</code> given as an int
* @return String representation for the bundle event
*/
public static String nullSafeBundleEventToString(int eventType) {
try {
return BUNDLE_EVENTS.toCode(Integer.valueOf(eventType), "");
} catch (ConstantException cex) {
return UNKNOWN_EVENT_TYPE;
}
}
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Returns a String representation for the given bundle event.
*
* @param event OSGi <code>BundleEvent</code> (can be <code>null</code>)
* @return String representation for the given bundle event
*/
public static String nullSafeToString(BundleEvent event) {
if (event == null)
return NULL_STRING;
try {
return BUNDLE_EVENTS.toCode(Integer.valueOf(event.getType()), EMPTY_STRING);
} catch (ConstantException cex) {
return UNKNOWN_EVENT_TYPE;
}
}
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Returns a String representation of the <code>Bundle</code> state.
*
* @param bundle OSGi bundle (can be <code>null</code>)
* @return bundle state as a string
*/
public static String bundleStateAsString(Bundle bundle) {
Assert.notNull(bundle, "bundle is required");
int state = bundle.getState();
try {
return BUNDLE_STATES.toCode(Integer.valueOf(state), "");
} catch (ConstantException cex) {
return "UNKNOWN STATE";
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: springframework/spring-core
/**
* Look up the given value within the group of constants for
* the given bean property name. Will return the first match.
* @param value constant value to look up
* @param propertyName the name of the bean property
* @return the name of the constant field
* @throws ConstantException if the value wasn't found
* @see #propertyToConstantNamePrefix
*/
public String toCodeForProperty(Object value, String propertyName) throws ConstantException {
return toCode(value, propertyToConstantNamePrefix(propertyName));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-tx
/**
* Return an identifying description for this transaction definition.
* <p>Available to subclasses, for inclusion in their {@code toString()} result.
*/
protected final StringBuilder getDefinitionDescription() {
StringBuilder result = new StringBuilder();
result.append(constants.toCode(this.propagationBehavior, PREFIX_PROPAGATION));
result.append(',');
result.append(constants.toCode(this.isolationLevel, PREFIX_ISOLATION));
if (this.timeout != TIMEOUT_DEFAULT) {
result.append(',');
result.append(PREFIX_TIMEOUT).append(this.timeout);
}
if (this.readOnly) {
result.append(',');
result.append(READ_ONLY_MARKER);
}
return result;
}
代码示例来源:origin: springframework/spring-dao
/**
* Return an identifying description of this transaction definition.
* Available for subclasses.
*/
protected final StringBuffer getDefinitionDescription() {
StringBuffer desc = new StringBuffer();
desc.append(constants.toCode(new Integer(this.propagationBehavior), PROPAGATION_CONSTANT_PREFIX));
desc.append(',');
desc.append(constants.toCode(new Integer(this.isolationLevel), ISOLATION_CONSTANT_PREFIX));
if (this.timeout != TIMEOUT_DEFAULT) {
desc.append(',');
desc.append(TIMEOUT_PREFIX + this.timeout);
}
if (this.readOnly) {
desc.append(',');
desc.append(READ_ONLY_MARKER);
}
return desc;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Return an identifying description for this transaction definition.
* <p>Available to subclasses, for inclusion in their {@code toString()} result.
*/
protected final StringBuilder getDefinitionDescription() {
StringBuilder result = new StringBuilder();
result.append(constants.toCode(this.propagationBehavior, PREFIX_PROPAGATION));
result.append(',');
result.append(constants.toCode(this.isolationLevel, PREFIX_ISOLATION));
if (this.timeout != TIMEOUT_DEFAULT) {
result.append(',');
result.append(PREFIX_TIMEOUT).append(this.timeout);
}
if (this.readOnly) {
result.append(',');
result.append(READ_ONLY_MARKER);
}
return result;
}
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Returns a String representation for the given <code>ServiceEvent</code>.
*
* @param event OSGi <code>ServiceEvent</code> (can be <code>null</code>)
* @return String representation for the given event
*/
public static String nullSafeToString(ServiceEvent event) {
if (event == null)
return NULL_STRING;
try {
return SERVICE_EVENTS.toCode(Integer.valueOf(event.getType()), EMPTY_STRING);
} catch (ConstantException cex) {
return UNKNOWN_EVENT_TYPE;
}
}
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Returns a String representation for the given <code>FrameworkEvent</code> .
*
* @param event OSGi <code>FrameworkEvent</code> (can be <code>null</code>)
* @return String representation of the given event
*/
public static String nullSafeToString(FrameworkEvent event) {
if (event == null)
return NULL_STRING;
try {
return FRAMEWORK_EVENTS.toCode(Integer.valueOf(event.getType()), EMPTY_STRING);
} catch (ConstantException cex) {
return UNKNOWN_EVENT_TYPE;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-tx
definition + "] specifies isolation level which is incompatible with existing transaction: " +
(currentIsolationLevel != null ?
isoConstants.toCode(currentIsolationLevel, DefaultTransactionDefinition.PREFIX_ISOLATION) :
"(unknown)"));
内容来源于网络,如有侵权,请联系作者删除!