src/share/classes/com/sun/tools/javac/api/Formattable.java

Sun, 17 Feb 2013 16:44:55 -0500

author
dholmes
date
Sun, 17 Feb 2013 16:44:55 -0500
changeset 1571
af8417e590f4
parent 581
f2fdd52e4e87
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Merge

mcimadamore@80 1 /*
ohair@554 2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
mcimadamore@80 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@80 4 *
mcimadamore@80 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@80 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
mcimadamore@80 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
mcimadamore@80 10 *
mcimadamore@80 11 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@80 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@80 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@80 14 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@80 15 * accompanied this code).
mcimadamore@80 16 *
mcimadamore@80 17 * You should have received a copy of the GNU General Public License version
mcimadamore@80 18 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@80 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@80 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
mcimadamore@80 24 */
mcimadamore@80 25
mcimadamore@80 26 package com.sun.tools.javac.api;
mcimadamore@80 27
mcimadamore@136 28 import java.util.Locale;
mcimadamore@80 29
mcimadamore@80 30 /**
mcimadamore@80 31 * This interface must be implemented by any javac class that has non-trivial
mcimadamore@80 32 * formatting needs (e.g. where toString() does not apply because of localization).
mcimadamore@80 33 *
jjg@581 34 * <p><b>This is NOT part of any supported API.
jjg@333 35 * If you write code that depends on this, you do so at your own risk.
jjg@333 36 * This code and its internal interfaces are subject to change or
jjg@333 37 * deletion without notice.</b>
jjg@333 38 *
mcimadamore@80 39 * @author Maurizio Cimadamore
mcimadamore@80 40 */
mcimadamore@80 41 public interface Formattable {
mcimadamore@80 42
mcimadamore@80 43 /**
mcimadamore@80 44 * Used to obtain a localized String representing the object accordingly
mcimadamore@80 45 * to a given locale
mcimadamore@80 46 *
mcimadamore@136 47 * @param locale locale in which the object's representation is to be rendered
mcimadamore@136 48 * @param messages messages object used for localization
mcimadamore@80 49 * @return a locale-dependent string representing the object
mcimadamore@80 50 */
mcimadamore@136 51 public String toString(Locale locale, Messages messages);
mcimadamore@80 52 /**
mcimadamore@80 53 * Retrieve a pretty name of this object's kind
mcimadamore@80 54 * @return a string representing the object's kind
mcimadamore@80 55 */
mcimadamore@80 56 String getKind();
mcimadamore@161 57
mcimadamore@161 58 static class LocalizedString implements Formattable {
mcimadamore@161 59 String key;
mcimadamore@161 60
mcimadamore@161 61 public LocalizedString(String key) {
mcimadamore@161 62 this.key = key;
mcimadamore@161 63 }
mcimadamore@161 64
mcimadamore@161 65 public String toString(java.util.Locale l, Messages messages) {
mcimadamore@161 66 return messages.getLocalizedString(l, key);
mcimadamore@161 67 }
mcimadamore@161 68 public String getKind() {
mcimadamore@161 69 return "LocalizedString";
mcimadamore@161 70 }
mcimadamore@161 71
mcimadamore@161 72 public String toString() {
mcimadamore@161 73 return key;
mcimadamore@161 74 }
mcimadamore@161 75 }
mcimadamore@80 76 }

mercurial