| 패키지 | com.adobe.gravity.utility.message |
| 클래스 | public class FormatMessage |
| 상속 | FormatMessage Object |
| 언어 버전: | ActionScript 3.0 |
| 제품 버전: | Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10 |
| 런타임 버전: | AIR 1.1, Flash Player 9 |
Error {errorId}: The file {filename} could not be read.
When the error occurs, the message could be prepared for display with the following code:
var template:String = "Error {errorId}: The file {filename} could not be read.";
var params:Object = new Object();
params.errorId = 42;
params.filename = "/Users/alice/vacation.jpg";
var message:String = FormatMessage.formatString(template, params);
// message="Error 42: The file /Users/alice/vacation.jpg could not be read."
The ActionScript object literal syntax is a convenient way to construct the parameter object. The following is functionally equivalent to the code above:
var template:String = "Error {errorId}: The file {filename} could not be read.";
var params:Object =
{
errorId: 42,
filename: "/Users/alice/vacation.jpg"
};
var message:String = FormatMessage.formatString(template, params);
// message="Error 42: The file /Users/alice/vacation.jpg could not be read."
Note that traditional numeric parameters are supported by simply using an Array as the parameter object:
var template:String = "Error {0}: The file {1} could not be read.";
var params:Array =
[
42,
"/Users/alice/vacation.jpg"
];
var message:String = FormatMessage.formatString(template, params);
// message="Error 42: The file /Users/alice/vacation.jpg could not be read."
Note that for missing parameters, the empty string will be used:
var template:String = "Error {errorId}: The file {filename} could not be read.";
var params:Object =
{
errorId: 42,
};
var message:String = FormatMessage.formatString(template, params);
// message="Error 42: The file could not be read."
Note that parameters are substituted verbatim, no parameter replacement or brace processing is performed on the parameters themselves:
var template:String = "{one}{two}{three}{four}{five}";
var params:Object =
{
one: "{five}",
two: "{four}",
three: "{three}",
four: "{two}",
five: "{one}"
};
var message:String = FormatMessage.formatString(template, params);
// message="{five}{four}{three}{two}{one}"
To escape an opening brace, double the initial brace:
var template:String = "The {{filename} parameter is {filename}.";
var message:String = FormatMessage.formatString(template, {filename: "/Users/alice/vacation.jpg"});
// message="The {filename} parameter is /Users/alice/vacation.jpg."
Best practice: It can be useful to use formatString on all strings, parameterized or not, to ensure that escaping rules are consistent between parameterized and non-parameterized strings (since strings that were unparameterized may become parameterized and vice-versa).
| 메서드 | 정의 주체 | ||
|---|---|---|---|
[정적]
Given a message string, perform parameter substitution on it. | FormatMessage | ||
![]() |
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다. | Object | |
![]() |
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다. | Object | |
![]() |
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다. | Object | |
![]() |
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다. | Object | |
![]() |
로캘별 규칙에 따라 서식이 지정된 이 객체의 문자열 표현을 반환합니다. | Object | |
![]() |
지정된 객체의 문자열 표현을 반환합니다. | Object | |
![]() |
지정된 객체의 프리미티브 값을 반환합니다. | Object | |
formatString | () | 메서드 |
public static function formatString(message:String, parameters:Object):String| 언어 버전: | ActionScript 3.0 |
| 제품 버전: | Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10 |
| 런타임 버전: | AIR 1.1, Flash Player 9 |
Given a message string, perform parameter substitution on it.
매개 변수
message:String — The parameterized message string. Must not be null.
| |
parameters:Object — An object with a property for each parameter that is to be substituted into the message. May be null (which means there are no parameters to be substituted).
|
String — The message string with any parameter substitution performed.
|
Tue Jun 12 2018, 03:17 PM Z
상속되는 공용 속성 숨기기
상속되는 공용 속성 표시