001    /*
002    // $Id: //open/util/resgen/src/org/eigenbase/resgen/Resource.java#4 $
003    // Package org.eigenbase.resgen is an i18n resource generator.
004    // Copyright (C) 2005-2005 The Eigenbase Project
005    // Copyright (C) 2005-2005 Disruptive Tech
006    // Copyright (C) 2005-2005 LucidEra, Inc.
007    // Portions Copyright (C) 2001-2005 Kana Software, Inc. and others.
008    //
009    // This library is free software; you can redistribute it and/or modify it
010    // under the terms of the GNU Lesser General Public License as published by the
011    // Free Software Foundation; either version 2 of the License, or (at your
012    // option) any later version approved by The Eigenbase Project.
013    //
014    // This library is distributed in the hope that it will be useful, 
015    // but WITHOUT ANY WARRANTY; without even the implied warranty of
016    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017    // GNU Lesser General Public License for more details.
018    // 
019    // You should have received a copy of the GNU Lesser General Public License
020    // along with this library; if not, write to the Free Software
021    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022    */
023    package org.eigenbase.resgen;
024    
025    import java.util.Locale;
026    
027    /**
028     * A <code>Resource</code> is a collection of messages for a particular
029     * software component and locale. It is loaded from an XML file whose root
030     * element is <code>&lt;BaflResourceList&gt;</code>.
031     *
032     * <p>Given such an XML file, {@link ResourceGen} can generate Java a wrapper
033     * class which implements this interface, and also has a method to create an
034     * error for each message.</p>
035     *
036     * @author jhyde
037     * @since 3 December, 2001
038     * @version $Id: //open/util/resgen/src/org/eigenbase/resgen/Resource.java#4 $
039     **/
040    public interface Resource {
041        /**
042         * Populates this <code>Resource</code> from a URL.
043         *
044         * @param url The URL of the XML file containing the error messages
045         * @param locale The ISO locale code (e.g. <code>"en"</code>, or
046         *    <code>"en_US"</code>, or <code>"en_US_WIN"</code>) of the messages
047         * @throws IOException if <code>url</code> cannot be opened, or if the
048         *    format of its contents are invalid
049         **/
050        void init(java.net.URL url, Locale locale) throws java.io.IOException;
051    
052        /**
053         * Populates this <code>Resource</code> from an XML document.
054         *
055         * @param resourceList The URL of the XML file containing the error messages
056         * @param locale The ISO locale code (e.g. <code>"en"</code>, or
057         *    <code>"en_US"</code>, or <code>"en_US_WIN"</code>) of the messages
058         **/
059        void init(ResourceDef.ResourceBundle resourceList, Locale locale);
060    
061        /**
062         * Returns the locale of the messages.
063         **/
064        Locale getLocale();
065    
066        /**
067         * Formats the message corresponding to <code>code</code> with the given
068         * arguments. If an argument is not supplied, the tokens remain in the
069         * returned message string.
070         **/
071        String formatError(int code, Object[] args);
072    
073        /**
074         * Returns the severity of this message.
075         **/
076        int getSeverity(int code);
077        int SEVERITY_INFO = 0;
078        int SEVERITY_ERR  = 1;
079        int SEVERITY_WARN = 2;
080        int SEVERITY_NON_FATAL_ERR = 3;
081    }
082    
083    // End Resource.java