接口 Converter
-
- 所有已知实现类:
CommandSessionImpl
public interface Converter
A converter is a service that can help create specific object types from a string, and vice versa. The shell is capable of coercing arguments to the their proper type. However, sometimes commands require extra help to do this conversion. This service can implement a converter for a number of types. The command shell will rank these services in order of service.ranking and will then call them until one of the converters succeeds.
-
-
字段概要
字段 修饰符和类型 字段 说明 static java.lang.String
CONVERTER_CLASSES
This property is a string, or array of strings, and defines the classes or interfaces that this converter recognizes.static int
INSPECT
Print the object in detail.static int
LINE
Print the object as a row in a table.static int
PART
Print the value in a small format so that it is identifiable.
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 java.lang.Object
convert(java.lang.Class<?> desiredType, java.lang.Object in)
Convert an object to the desired type.java.lang.CharSequence
format(java.lang.Object target, int level, Converter escape)
Convert an objet to a CharSequence object in the requested format.
-
-
-
字段详细资料
-
CONVERTER_CLASSES
static final java.lang.String CONVERTER_CLASSES
This property is a string, or array of strings, and defines the classes or interfaces that this converter recognizes. Recognized classes can be converted from a string to a class and they can be printed in 3 different modes.- 另请参阅:
- 常量字段值
-
INSPECT
static final int INSPECT
Print the object in detail. This can contain multiple lines.- 另请参阅:
- 常量字段值
-
LINE
static final int LINE
Print the object as a row in a table. The columns should align for multiple objects printed beneath each other. The print may run over multiple lines but must not end in a CR.- 另请参阅:
- 常量字段值
-
PART
static final int PART
Print the value in a small format so that it is identifiable. This printed format must be recognizable by the conversion method.- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
convert
java.lang.Object convert(java.lang.Class<?> desiredType, java.lang.Object in) throws java.lang.Exception
Convert an object to the desired type. Return null if the conversion can not be done. Otherwise return and object that extends the desired type or implements it.- 参数:
desiredType
- The type that the returned object can be assigned toin
- The object that must be converted- 返回:
- An object that can be assigned to the desired type or null.
- 抛出:
java.lang.Exception
-
format
java.lang.CharSequence format(java.lang.Object target, int level, Converter escape) throws java.lang.Exception
Convert an objet to a CharSequence object in the requested format. The format can be INSPECT, LINE, or PART. Other values must throw IllegalArgumentException.- 参数:
target
- The object to be converted to a Stringlevel
- One of INSPECT, LINE, or PART.escape
- Use this object to format sub ordinate objects.- 返回:
- A printed object of potentially multiple lines
- 抛出:
java.lang.Exception
-
-